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, 2018 at 5:52
  • exactly friend, look for the products of the categories that belong to a store, in a multi-store environment Mar 8, 2018 at 12:43

1 Answer 1

$_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/%"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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