Custom Product Collection not Getting Filtered by Layered NavigationSearch current store products onlyMagento 2 - Custom Product Collection not Getting Filtered by Layered NavigationHow to add attribute filter in product listing page in magento 1.9?Layered navigation filters for grouped products onlyLayered Navigation for Admin ReportLayered Navigation for Custom Product Collection filtered via Custom AttributeHow to apply a custom filter logic for selected filter layered navigation product countCustomize Layered Navigation and Catalog List BehaviourMagento 2 - Layered Navigation for Custom Product CollectionLayered navigation missing attributesMagento2 how to apply layered navigation filters at REST API Level?Filter on custom product collectionIncorrect product count in layered navigation after overriding list product collection

Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?

Is there a SQL/English like language that lets you define formulations given some data?

Can renaming a method preserve encapsulation?

Can the IPA represent all languages' tones?

What is a "soap"?

Does EU compensation apply to flights where the departure airport closes check-in counters during protests?

Telephone number in spoken words

How would you translate this? バタコチーズライス

How to Check all AD userers for "blank" password?

How would timezones work on a planet 100 times the size of our Earth

Installing Windows to flash BIOS, then reinstalling Ubuntu

Do beef farmed pastures net remove carbon emissions?

Heating Margarine in Pan = loss of calories?

Who invented Monoid?

Why is Python 2.7 still the default Python version in Ubuntu?

My cat is a houdini

Symbol: Put a smile symbol under a plus

Why is the result of ('b'+'a'+ + 'a' + 'a').toLowerCase() 'banana'?

Case Condition for two lines

Why is the Lucas test not recommended to differentiate higher alcohols?

Boss wants me to ignore a software API license prohibiting mass download

Are there any other rule mechanics that could grant Thieves' Cant?

What is the farthest a camera can see?

What are those bumps on top of the Antonov-225?



Custom Product Collection not Getting Filtered by Layered Navigation


Search current store products onlyMagento 2 - Custom Product Collection not Getting Filtered by Layered NavigationHow to add attribute filter in product listing page in magento 1.9?Layered navigation filters for grouped products onlyLayered Navigation for Admin ReportLayered Navigation for Custom Product Collection filtered via Custom AttributeHow to apply a custom filter logic for selected filter layered navigation product countCustomize Layered Navigation and Catalog List BehaviourMagento 2 - Layered Navigation for Custom Product CollectionLayered navigation missing attributesMagento2 how to apply layered navigation filters at REST API Level?Filter on custom product collectionIncorrect product count in layered navigation after overriding list product collection






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I had Overridden the product List.php Class & here is the code



protected function _getProductCollection()

if (is_null($this->_productCollection))

$result = array_unique($productIds);

$collection = Mage::getResourceModel('catalog/product_collection');
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$collection->addAttributeToSelect($attributes);
$collection->addIdFilter($result);
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);

$this->_productCollection = $collection;


return $this->_productCollection;



working fine, I also had added Layered Navigation as mentioned here and layered navigation appeared as expected.



The only problem is, when I click on any filter in layered navigation, navigation gets updated and filter also get added to url, but product list won't get filtered by the selected filter. Please guide me how can I apply the filters on product collection










share|improve this question
































    2















    I had Overridden the product List.php Class & here is the code



    protected function _getProductCollection()

    if (is_null($this->_productCollection))

    $result = array_unique($productIds);

    $collection = Mage::getResourceModel('catalog/product_collection');
    $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
    $collection->addAttributeToSelect($attributes);
    $collection->addIdFilter($result);
    Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);

    $this->_productCollection = $collection;


    return $this->_productCollection;



    working fine, I also had added Layered Navigation as mentioned here and layered navigation appeared as expected.



    The only problem is, when I click on any filter in layered navigation, navigation gets updated and filter also get added to url, but product list won't get filtered by the selected filter. Please guide me how can I apply the filters on product collection










    share|improve this question




























      2












      2








      2








      I had Overridden the product List.php Class & here is the code



      protected function _getProductCollection()

      if (is_null($this->_productCollection))

      $result = array_unique($productIds);

      $collection = Mage::getResourceModel('catalog/product_collection');
      $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
      $collection->addAttributeToSelect($attributes);
      $collection->addIdFilter($result);
      Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);

      $this->_productCollection = $collection;


      return $this->_productCollection;



      working fine, I also had added Layered Navigation as mentioned here and layered navigation appeared as expected.



      The only problem is, when I click on any filter in layered navigation, navigation gets updated and filter also get added to url, but product list won't get filtered by the selected filter. Please guide me how can I apply the filters on product collection










      share|improve this question
















      I had Overridden the product List.php Class & here is the code



      protected function _getProductCollection()

      if (is_null($this->_productCollection))

      $result = array_unique($productIds);

      $collection = Mage::getResourceModel('catalog/product_collection');
      $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
      $collection->addAttributeToSelect($attributes);
      $collection->addIdFilter($result);
      Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);

      $this->_productCollection = $collection;


      return $this->_productCollection;



      working fine, I also had added Layered Navigation as mentioned here and layered navigation appeared as expected.



      The only problem is, when I click on any filter in layered navigation, navigation gets updated and filter also get added to url, but product list won't get filtered by the selected filter. Please guide me how can I apply the filters on product collection







      magento-1.8 layered-navigation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 26 '14 at 4:40









      Keyul Shah

      6,6697 gold badges32 silver badges59 bronze badges




      6,6697 gold badges32 silver badges59 bronze badges










      asked Sep 26 '14 at 4:29









      AhmedAhmed

      5681 gold badge8 silver badges28 bronze badges




      5681 gold badge8 silver badges28 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          5














          For layered Navigation you have to:



          Extend




          app/code/core/Mage/CatalogSearch/Model/Layer.php




          to your custom module.



          And over ride prepare collection function:



          public function prepareProductCollection($collection)
          if(Mage::helper('catalogsearch')->getQuery()->getQueryText())
          return parent::prepareProductCollection($collection);
          else
          $collection
          ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
          $collection->setStore(Mage::app()->getStore())
          ->addMinimalPrice()
          ->addFinalPrice()
          ->addTaxPercents()
          ->addStoreFilter()
          ->addUrlRewrite();

          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);


          return $this;



          Check this Reference URL






          share|improve this answer



























          • Let's say I have a widget with a custom product colleciton -- how can I use the above function?

            – easymoden00b
            Feb 26 '15 at 15:23






          • 1





            Hi TBI Infotech, im facing exactly the same issue in magento 2.0... i have overridden LayeredNavigation (MagentoLayeredNavigationBlockNavigation) class, but as above problem, filters come in URL, but they are not getting applied....I have also overridden Magentos Catalog's Block Product ListProduct's _getProductCollection().

            – Sushivam
            Sep 28 '16 at 11:41











          • I have updated the issue with code in Magento 2 here magento.stackexchange.com/questions/138474/…

            – Sushivam
            Sep 28 '16 at 13:44











          • What is the equivalent class in Magento2 for app/code/core/Mage/CatalogSearch/Model/Layer...?

            – Sushivam
            Sep 29 '16 at 10:17


















          0














          You are using wrong method



          protected function _getProductCollection()

          if (is_null($this->_productCollection))
          $result = array_unique($productIds);
          $collection = Mage::getResourceModel('catalog/product_collection');
          $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
          $collection->addAttributeToSelect($attributes);
          $collection->addAttributeToFilter('entity_id', array('in' => $result));
          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          $this->_productCollection = $collection;

          return $this->_productCollection;



          So try the above code let me know if any comments.






          share|improve this answer

























          • $collection->addAttributeToFilter('entity_id', array('in' => $result)); made no difference, same result

            – Ahmed
            Sep 26 '14 at 4:46











          • Collection is filtering just fine, but the selected filter of layered navigation is not getting applied on him

            – Ahmed
            Sep 26 '14 at 4:48












          • then you have to check filter file i think layer.php

            – Keyul Shah
            Sep 26 '14 at 4:55











          • please correct me if I am wrong, but I think Layer.php is not responsible for filtering the product collection but it creates a layered navigation based on the product collection which it gets from the current category

            – Ahmed
            Sep 26 '14 at 5:15











          • public function getProductCollection() if(isset($this->_productCollections[$this->getCurrentCategory()->getId()])) $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; else $collection = $this->getCurrentCategory()->getProductCollection(); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; return $collection;

            – Ahmed
            Sep 26 '14 at 5:16














          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%2f37148%2fcustom-product-collection-not-getting-filtered-by-layered-navigation%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5














          For layered Navigation you have to:



          Extend




          app/code/core/Mage/CatalogSearch/Model/Layer.php




          to your custom module.



          And over ride prepare collection function:



          public function prepareProductCollection($collection)
          if(Mage::helper('catalogsearch')->getQuery()->getQueryText())
          return parent::prepareProductCollection($collection);
          else
          $collection
          ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
          $collection->setStore(Mage::app()->getStore())
          ->addMinimalPrice()
          ->addFinalPrice()
          ->addTaxPercents()
          ->addStoreFilter()
          ->addUrlRewrite();

          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);


          return $this;



          Check this Reference URL






          share|improve this answer



























          • Let's say I have a widget with a custom product colleciton -- how can I use the above function?

            – easymoden00b
            Feb 26 '15 at 15:23






          • 1





            Hi TBI Infotech, im facing exactly the same issue in magento 2.0... i have overridden LayeredNavigation (MagentoLayeredNavigationBlockNavigation) class, but as above problem, filters come in URL, but they are not getting applied....I have also overridden Magentos Catalog's Block Product ListProduct's _getProductCollection().

            – Sushivam
            Sep 28 '16 at 11:41











          • I have updated the issue with code in Magento 2 here magento.stackexchange.com/questions/138474/…

            – Sushivam
            Sep 28 '16 at 13:44











          • What is the equivalent class in Magento2 for app/code/core/Mage/CatalogSearch/Model/Layer...?

            – Sushivam
            Sep 29 '16 at 10:17















          5














          For layered Navigation you have to:



          Extend




          app/code/core/Mage/CatalogSearch/Model/Layer.php




          to your custom module.



          And over ride prepare collection function:



          public function prepareProductCollection($collection)
          if(Mage::helper('catalogsearch')->getQuery()->getQueryText())
          return parent::prepareProductCollection($collection);
          else
          $collection
          ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
          $collection->setStore(Mage::app()->getStore())
          ->addMinimalPrice()
          ->addFinalPrice()
          ->addTaxPercents()
          ->addStoreFilter()
          ->addUrlRewrite();

          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);


          return $this;



          Check this Reference URL






          share|improve this answer



























          • Let's say I have a widget with a custom product colleciton -- how can I use the above function?

            – easymoden00b
            Feb 26 '15 at 15:23






          • 1





            Hi TBI Infotech, im facing exactly the same issue in magento 2.0... i have overridden LayeredNavigation (MagentoLayeredNavigationBlockNavigation) class, but as above problem, filters come in URL, but they are not getting applied....I have also overridden Magentos Catalog's Block Product ListProduct's _getProductCollection().

            – Sushivam
            Sep 28 '16 at 11:41











          • I have updated the issue with code in Magento 2 here magento.stackexchange.com/questions/138474/…

            – Sushivam
            Sep 28 '16 at 13:44











          • What is the equivalent class in Magento2 for app/code/core/Mage/CatalogSearch/Model/Layer...?

            – Sushivam
            Sep 29 '16 at 10:17













          5












          5








          5







          For layered Navigation you have to:



          Extend




          app/code/core/Mage/CatalogSearch/Model/Layer.php




          to your custom module.



          And over ride prepare collection function:



          public function prepareProductCollection($collection)
          if(Mage::helper('catalogsearch')->getQuery()->getQueryText())
          return parent::prepareProductCollection($collection);
          else
          $collection
          ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
          $collection->setStore(Mage::app()->getStore())
          ->addMinimalPrice()
          ->addFinalPrice()
          ->addTaxPercents()
          ->addStoreFilter()
          ->addUrlRewrite();

          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);


          return $this;



          Check this Reference URL






          share|improve this answer















          For layered Navigation you have to:



          Extend




          app/code/core/Mage/CatalogSearch/Model/Layer.php




          to your custom module.



          And over ride prepare collection function:



          public function prepareProductCollection($collection)
          if(Mage::helper('catalogsearch')->getQuery()->getQueryText())
          return parent::prepareProductCollection($collection);
          else
          $collection
          ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
          $collection->setStore(Mage::app()->getStore())
          ->addMinimalPrice()
          ->addFinalPrice()
          ->addTaxPercents()
          ->addStoreFilter()
          ->addUrlRewrite();

          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);


          return $this;



          Check this Reference URL







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 2 at 7:23









          Rakesh Donga

          3,0456 silver badges25 bronze badges




          3,0456 silver badges25 bronze badges










          answered Sep 26 '14 at 7:39









          TBI InfotechTBI Infotech

          4,6171 gold badge9 silver badges30 bronze badges




          4,6171 gold badge9 silver badges30 bronze badges















          • Let's say I have a widget with a custom product colleciton -- how can I use the above function?

            – easymoden00b
            Feb 26 '15 at 15:23






          • 1





            Hi TBI Infotech, im facing exactly the same issue in magento 2.0... i have overridden LayeredNavigation (MagentoLayeredNavigationBlockNavigation) class, but as above problem, filters come in URL, but they are not getting applied....I have also overridden Magentos Catalog's Block Product ListProduct's _getProductCollection().

            – Sushivam
            Sep 28 '16 at 11:41











          • I have updated the issue with code in Magento 2 here magento.stackexchange.com/questions/138474/…

            – Sushivam
            Sep 28 '16 at 13:44











          • What is the equivalent class in Magento2 for app/code/core/Mage/CatalogSearch/Model/Layer...?

            – Sushivam
            Sep 29 '16 at 10:17

















          • Let's say I have a widget with a custom product colleciton -- how can I use the above function?

            – easymoden00b
            Feb 26 '15 at 15:23






          • 1





            Hi TBI Infotech, im facing exactly the same issue in magento 2.0... i have overridden LayeredNavigation (MagentoLayeredNavigationBlockNavigation) class, but as above problem, filters come in URL, but they are not getting applied....I have also overridden Magentos Catalog's Block Product ListProduct's _getProductCollection().

            – Sushivam
            Sep 28 '16 at 11:41











          • I have updated the issue with code in Magento 2 here magento.stackexchange.com/questions/138474/…

            – Sushivam
            Sep 28 '16 at 13:44











          • What is the equivalent class in Magento2 for app/code/core/Mage/CatalogSearch/Model/Layer...?

            – Sushivam
            Sep 29 '16 at 10:17
















          Let's say I have a widget with a custom product colleciton -- how can I use the above function?

          – easymoden00b
          Feb 26 '15 at 15:23





          Let's say I have a widget with a custom product colleciton -- how can I use the above function?

          – easymoden00b
          Feb 26 '15 at 15:23




          1




          1





          Hi TBI Infotech, im facing exactly the same issue in magento 2.0... i have overridden LayeredNavigation (MagentoLayeredNavigationBlockNavigation) class, but as above problem, filters come in URL, but they are not getting applied....I have also overridden Magentos Catalog's Block Product ListProduct's _getProductCollection().

          – Sushivam
          Sep 28 '16 at 11:41





          Hi TBI Infotech, im facing exactly the same issue in magento 2.0... i have overridden LayeredNavigation (MagentoLayeredNavigationBlockNavigation) class, but as above problem, filters come in URL, but they are not getting applied....I have also overridden Magentos Catalog's Block Product ListProduct's _getProductCollection().

          – Sushivam
          Sep 28 '16 at 11:41













          I have updated the issue with code in Magento 2 here magento.stackexchange.com/questions/138474/…

          – Sushivam
          Sep 28 '16 at 13:44





          I have updated the issue with code in Magento 2 here magento.stackexchange.com/questions/138474/…

          – Sushivam
          Sep 28 '16 at 13:44













          What is the equivalent class in Magento2 for app/code/core/Mage/CatalogSearch/Model/Layer...?

          – Sushivam
          Sep 29 '16 at 10:17





          What is the equivalent class in Magento2 for app/code/core/Mage/CatalogSearch/Model/Layer...?

          – Sushivam
          Sep 29 '16 at 10:17













          0














          You are using wrong method



          protected function _getProductCollection()

          if (is_null($this->_productCollection))
          $result = array_unique($productIds);
          $collection = Mage::getResourceModel('catalog/product_collection');
          $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
          $collection->addAttributeToSelect($attributes);
          $collection->addAttributeToFilter('entity_id', array('in' => $result));
          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          $this->_productCollection = $collection;

          return $this->_productCollection;



          So try the above code let me know if any comments.






          share|improve this answer

























          • $collection->addAttributeToFilter('entity_id', array('in' => $result)); made no difference, same result

            – Ahmed
            Sep 26 '14 at 4:46











          • Collection is filtering just fine, but the selected filter of layered navigation is not getting applied on him

            – Ahmed
            Sep 26 '14 at 4:48












          • then you have to check filter file i think layer.php

            – Keyul Shah
            Sep 26 '14 at 4:55











          • please correct me if I am wrong, but I think Layer.php is not responsible for filtering the product collection but it creates a layered navigation based on the product collection which it gets from the current category

            – Ahmed
            Sep 26 '14 at 5:15











          • public function getProductCollection() if(isset($this->_productCollections[$this->getCurrentCategory()->getId()])) $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; else $collection = $this->getCurrentCategory()->getProductCollection(); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; return $collection;

            – Ahmed
            Sep 26 '14 at 5:16
















          0














          You are using wrong method



          protected function _getProductCollection()

          if (is_null($this->_productCollection))
          $result = array_unique($productIds);
          $collection = Mage::getResourceModel('catalog/product_collection');
          $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
          $collection->addAttributeToSelect($attributes);
          $collection->addAttributeToFilter('entity_id', array('in' => $result));
          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          $this->_productCollection = $collection;

          return $this->_productCollection;



          So try the above code let me know if any comments.






          share|improve this answer

























          • $collection->addAttributeToFilter('entity_id', array('in' => $result)); made no difference, same result

            – Ahmed
            Sep 26 '14 at 4:46











          • Collection is filtering just fine, but the selected filter of layered navigation is not getting applied on him

            – Ahmed
            Sep 26 '14 at 4:48












          • then you have to check filter file i think layer.php

            – Keyul Shah
            Sep 26 '14 at 4:55











          • please correct me if I am wrong, but I think Layer.php is not responsible for filtering the product collection but it creates a layered navigation based on the product collection which it gets from the current category

            – Ahmed
            Sep 26 '14 at 5:15











          • public function getProductCollection() if(isset($this->_productCollections[$this->getCurrentCategory()->getId()])) $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; else $collection = $this->getCurrentCategory()->getProductCollection(); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; return $collection;

            – Ahmed
            Sep 26 '14 at 5:16














          0












          0








          0







          You are using wrong method



          protected function _getProductCollection()

          if (is_null($this->_productCollection))
          $result = array_unique($productIds);
          $collection = Mage::getResourceModel('catalog/product_collection');
          $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
          $collection->addAttributeToSelect($attributes);
          $collection->addAttributeToFilter('entity_id', array('in' => $result));
          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          $this->_productCollection = $collection;

          return $this->_productCollection;



          So try the above code let me know if any comments.






          share|improve this answer













          You are using wrong method



          protected function _getProductCollection()

          if (is_null($this->_productCollection))
          $result = array_unique($productIds);
          $collection = Mage::getResourceModel('catalog/product_collection');
          $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
          $collection->addAttributeToSelect($attributes);
          $collection->addAttributeToFilter('entity_id', array('in' => $result));
          Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
          $this->_productCollection = $collection;

          return $this->_productCollection;



          So try the above code let me know if any comments.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 26 '14 at 4:39









          Keyul ShahKeyul Shah

          6,6697 gold badges32 silver badges59 bronze badges




          6,6697 gold badges32 silver badges59 bronze badges















          • $collection->addAttributeToFilter('entity_id', array('in' => $result)); made no difference, same result

            – Ahmed
            Sep 26 '14 at 4:46











          • Collection is filtering just fine, but the selected filter of layered navigation is not getting applied on him

            – Ahmed
            Sep 26 '14 at 4:48












          • then you have to check filter file i think layer.php

            – Keyul Shah
            Sep 26 '14 at 4:55











          • please correct me if I am wrong, but I think Layer.php is not responsible for filtering the product collection but it creates a layered navigation based on the product collection which it gets from the current category

            – Ahmed
            Sep 26 '14 at 5:15











          • public function getProductCollection() if(isset($this->_productCollections[$this->getCurrentCategory()->getId()])) $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; else $collection = $this->getCurrentCategory()->getProductCollection(); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; return $collection;

            – Ahmed
            Sep 26 '14 at 5:16


















          • $collection->addAttributeToFilter('entity_id', array('in' => $result)); made no difference, same result

            – Ahmed
            Sep 26 '14 at 4:46











          • Collection is filtering just fine, but the selected filter of layered navigation is not getting applied on him

            – Ahmed
            Sep 26 '14 at 4:48












          • then you have to check filter file i think layer.php

            – Keyul Shah
            Sep 26 '14 at 4:55











          • please correct me if I am wrong, but I think Layer.php is not responsible for filtering the product collection but it creates a layered navigation based on the product collection which it gets from the current category

            – Ahmed
            Sep 26 '14 at 5:15











          • public function getProductCollection() if(isset($this->_productCollections[$this->getCurrentCategory()->getId()])) $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; else $collection = $this->getCurrentCategory()->getProductCollection(); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; return $collection;

            – Ahmed
            Sep 26 '14 at 5:16

















          $collection->addAttributeToFilter('entity_id', array('in' => $result)); made no difference, same result

          – Ahmed
          Sep 26 '14 at 4:46





          $collection->addAttributeToFilter('entity_id', array('in' => $result)); made no difference, same result

          – Ahmed
          Sep 26 '14 at 4:46













          Collection is filtering just fine, but the selected filter of layered navigation is not getting applied on him

          – Ahmed
          Sep 26 '14 at 4:48






          Collection is filtering just fine, but the selected filter of layered navigation is not getting applied on him

          – Ahmed
          Sep 26 '14 at 4:48














          then you have to check filter file i think layer.php

          – Keyul Shah
          Sep 26 '14 at 4:55





          then you have to check filter file i think layer.php

          – Keyul Shah
          Sep 26 '14 at 4:55













          please correct me if I am wrong, but I think Layer.php is not responsible for filtering the product collection but it creates a layered navigation based on the product collection which it gets from the current category

          – Ahmed
          Sep 26 '14 at 5:15





          please correct me if I am wrong, but I think Layer.php is not responsible for filtering the product collection but it creates a layered navigation based on the product collection which it gets from the current category

          – Ahmed
          Sep 26 '14 at 5:15













          public function getProductCollection() if(isset($this->_productCollections[$this->getCurrentCategory()->getId()])) $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; else $collection = $this->getCurrentCategory()->getProductCollection(); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; return $collection;

          – Ahmed
          Sep 26 '14 at 5:16






          public function getProductCollection() if(isset($this->_productCollections[$this->getCurrentCategory()->getId()])) $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; else $collection = $this->getCurrentCategory()->getProductCollection(); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; return $collection;

          – Ahmed
          Sep 26 '14 at 5:16


















          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%2f37148%2fcustom-product-collection-not-getting-filtered-by-layered-navigation%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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form