I am trying to filter the products of a category, I talk about the catalog search, I'm working in a multi-store and I need to filter only the products in the catalog of a store. I filter this in the model.

  • You want to filter product according to store view?? – aravind Mar 8 '18 at 5:52
  • exactly friend, look for the products of the categories that belong to a store, in a multi-store environment – Jaime Suarez Mar 8 '18 at 12:43
$_rootcatID = Mage::app()->getStore()->getRootCategoryId();

$_testproductCollection = 
 ->addAttributeToFilter('category_id', array('in' => $_rootcatID))

foreach($_testproductCollection as $_testproduct){ 
echo $this->htmlEscape($_testproduct->getName())."<br/>"; 


$storeId = 1; 
$rootId = Mage::app()->getStore($storeId)->getRootCategoryId();
$categories = Mage::getModel('catalog/category')->getCollection()
          ->addFieldToFilter('path', array('like'=> "1/$rootId/%"));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.