In my magento store (ce-1.9.0) I have setup a custom product attribute:
custom_depth_check
And the attribute has the setting of
Used in Product Listing : Yes
Used for Sorting in Product Listing : Yes
I now need to filter any getLoadedProductCollection()
with this attribute. The attribute will either be set at:
null
0
1
I need to filter all instances of getLoadedProductCollection()
so that it will EXLCUDE any products with
custom_depth_check : 1
I have tried to clear and reload like so:
$_productCollection=$this->getLoadedProductCollection()
->clear()
->addAttributeToFilter('custom_depth_check', array('neq' => 1));
But that results in an empty collection. I also tried adding ->load()
at the end but again nothing comes up.
I have to stored this collection into an array for specific field such as name, price, description, images etc.
how can i achieve this.
getLoadedProductCollection
probably returns a collection which has beenloaded
. All filters etc have already been applied and it is now immutable. Are you usingMage_Catalog_Block_Product_List:getLoadedProductCollection
?protected function _getProductCollection()
List.php
copy down the functionality fromMage_Catalog_Model_Layer::prepareProductCollection
You'll want to add your new filter right below theaddAttributeToSelect
line. I think one of theaddMinimalPrice
,addUrlRewrite
etc are loading the collection ahead of what you want.Layer.php
and adding my filter in there? (line 120?) or copying that function and using it in my local copy ofList.php
?