How do I filter out products from certain categories from Magento search? -
i tried adding following on mage/catalog/block/product/list.php, _getproductcollection()
$this->_productcollection ->addattributetofilter('category_id', array('nin' => array('36,37'),));
but came with:
fatal error: call member function getbackend() on non-object in c:\app\code\core\mage\eav\model\entity\abstract.php on line 816
i suspected because looking attribute product doesn't have "category_id" , tried adding:
$this->_productcollection ->joinfield('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left') ->addattributetofilter('category_id', array('nin' => array('36,37'),));
but brings error:
joined field alias declared"
what doing wrong?
mage/catalog/block/product/list.php correct file apply overwrite?
want apply search results i.e catalogsearch/result/
try using ** ->addcategoriesfilter($category);** instead of ->addattributetofilter(
it works me :)
Comments
Post a Comment