How layer navigation counter works in Magento 2Reset layer product collection filter in searchHow to get the categories of the product collection loadedFilter (layered navigation) categoriesMagento 2 : How faceted data works for layered navigation?Layer navigation shows not matching attributes with custom products collectionHow to implement multiple category filter in Magento 2 layered navigationMagento 2 how to filter product collection on category page with custom filtersCategory product count not updating after deleting all productsMagento 1: Custom layer block not showing categoriesLayered navigation not showing some sub-category

Does capillary rise violate hydrostatic paradox?

Is this saw blade faulty?

Would this string work as string?

Offset in split text content

Amorphous proper classes in MK

Why didn't Voldemort know what Grindelwald looked like?

C++ lambda syntax

Do people actually use the word "kaputt" in conversation?

What is the meaning of "You've never met a graph you didn't like?"

Why didn’t Eve recognize the little cockroach as a living organism?

Is there any common country to visit for persons holding UK and Schengen visas?

Not hide and seek

Mortal danger in mid-grade literature

Highest stage count that are used one right after the other?

Why do Radio Buttons not fill the entire outer circle?

Error in master's thesis, I do not know what to do

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Do I have to take mana from my deck or hand when tapping this card?

Pre-Employment Background Check With Consent For Future Checks

How to split IPA spelling into syllables

How do you say "Trust your struggle." in French?

Reason why a kingside attack is not justified

python displays `n` instead of breaking a line

categorizing a variable turns it from insignificant to significant



How layer navigation counter works in Magento 2


Reset layer product collection filter in searchHow to get the categories of the product collection loadedFilter (layered navigation) categoriesMagento 2 : How faceted data works for layered navigation?Layer navigation shows not matching attributes with custom products collectionHow to implement multiple category filter in Magento 2 layered navigationMagento 2 how to filter product collection on category page with custom filtersCategory product count not updating after deleting all productsMagento 1: Custom layer block not showing categoriesLayered navigation not showing some sub-category













1















I want to add some conditions for the layer navigation counter. Basically I want to skip from counting some products.



In vendor/magento/module-catalog-search/Model/Layer/Filter/Category.php in _getItemsData we have a products collection, and then based on the collection, all the counter for the categories comes form this line :



 $optionsFacetedData = $productCollection->getFacetedData('category');


On the getFacetedData function we have:



 $aggregations = $this->searchResult->getAggregations();


This will return all the counters for all categories, attributes, prices etc...



If I add some condition on the product collection nothing happen with the counter, even if i remove all the items from the collection i still have the same numbers for category counter.



Does anyone know how this getAggregations function works, and how the counter works?



I mean where in the code i can find the actual assignment for the category x and the number of products associated with the category.










share|improve this question




























    1















    I want to add some conditions for the layer navigation counter. Basically I want to skip from counting some products.



    In vendor/magento/module-catalog-search/Model/Layer/Filter/Category.php in _getItemsData we have a products collection, and then based on the collection, all the counter for the categories comes form this line :



     $optionsFacetedData = $productCollection->getFacetedData('category');


    On the getFacetedData function we have:



     $aggregations = $this->searchResult->getAggregations();


    This will return all the counters for all categories, attributes, prices etc...



    If I add some condition on the product collection nothing happen with the counter, even if i remove all the items from the collection i still have the same numbers for category counter.



    Does anyone know how this getAggregations function works, and how the counter works?



    I mean where in the code i can find the actual assignment for the category x and the number of products associated with the category.










    share|improve this question


























      1












      1








      1








      I want to add some conditions for the layer navigation counter. Basically I want to skip from counting some products.



      In vendor/magento/module-catalog-search/Model/Layer/Filter/Category.php in _getItemsData we have a products collection, and then based on the collection, all the counter for the categories comes form this line :



       $optionsFacetedData = $productCollection->getFacetedData('category');


      On the getFacetedData function we have:



       $aggregations = $this->searchResult->getAggregations();


      This will return all the counters for all categories, attributes, prices etc...



      If I add some condition on the product collection nothing happen with the counter, even if i remove all the items from the collection i still have the same numbers for category counter.



      Does anyone know how this getAggregations function works, and how the counter works?



      I mean where in the code i can find the actual assignment for the category x and the number of products associated with the category.










      share|improve this question
















      I want to add some conditions for the layer navigation counter. Basically I want to skip from counting some products.



      In vendor/magento/module-catalog-search/Model/Layer/Filter/Category.php in _getItemsData we have a products collection, and then based on the collection, all the counter for the categories comes form this line :



       $optionsFacetedData = $productCollection->getFacetedData('category');


      On the getFacetedData function we have:



       $aggregations = $this->searchResult->getAggregations();


      This will return all the counters for all categories, attributes, prices etc...



      If I add some condition on the product collection nothing happen with the counter, even if i remove all the items from the collection i still have the same numbers for category counter.



      Does anyone know how this getAggregations function works, and how the counter works?



      I mean where in the code i can find the actual assignment for the category x and the number of products associated with the category.







      magento2 category layered-navigation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 17 hours ago







      Alin Lupoiu

















      asked 17 hours ago









      Alin LupoiuAlin Lupoiu

      1,2491549




      1,2491549




















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266475%2fhow-layer-navigation-counter-works-in-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266475%2fhow-layer-navigation-counter-works-in-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Sum ergo cogito? 1 nng

          三茅街道4182Guuntc Dn precexpngmageondP