I want to use the URL http://mydomain.test/category-name.html?cat=9,10,40 I need to get all products from category "category-name" and categories with ids 9, 10 and 40.

How can I do this. Maybe there is such an extension?

1 Answer 1


If you want all the products for category 9 you can do this:

$category_id = 9;
$category = Mage::getModel('catalog/category')->load($category_id);
$products = Mage::getResourceModel('catalog/product_collection')

You can do this for the other categories.

to print the products you can do something like this:

foreach ($products as $_product) { ?>
    <a href="<?php echo $_product->getProductUrl() ?>">
        <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(200); ?>" width="200" height="200" alt="" />
    <a href="<?php echo $_product->getProductUrl(); ?>">
        <?php echo $_product->getName(); ?>
<?php } ?>

If you want a list try something like this:

$collection = Mage::getModel('catalog/product')
    ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
    ->addAttributeToFilter('category_id', array(
        array('finset' => '9'),
        array('finset' => '10'),
        array('finset' => '40')
    ->addAttributeToSort('created_at', 'desc');
  • Thanks But I know this. I need get producs-list by cat=9,10,20, and show on catalog list page
    – omelandr
    Commented Apr 7, 2015 at 20:22
  • I've added something more, hope this works for you
    – Xus
    Commented Apr 7, 2015 at 20:36

Your Answer

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

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