I need to get a collection in magento by multiple categories but I am not getting any product when I add more categories.

$products = Mage::getModel('catalog/category')->load(7,8)
                ->addAttributeToSelect('*') // add all attributes - optional
                ->addAttributeToFilter('status', 1) // enabled
                ->addAttributeToFilter('visibility', 4) //visibility in catalog,search
                ->setOrder('price', 'ASC'); //sets the order by price
        return $products;

Please try the following to retrieve products from multiple categories:

$_testproductCollection = Mage::getResourceModel('catalog/product_collection')
    ->addAttributeToFilter('category_id', array('in' => array('your_cat1','your_cat2',....)))

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.