Skip to content

Instantly share code, notes, and snippets.

@mukundthanki
Last active December 14, 2015 04:28
Show Gist options
  • Save mukundthanki/5028083 to your computer and use it in GitHub Desktop.
Save mukundthanki/5028083 to your computer and use it in GitHub Desktop.
Magento: Load products from selected categories in magento
<?php
$categories = array(8,22);
$collection = mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status',1)
->joinField('category_id',
'catalog/category_product',
'category_id',
'product_id=entity_id',
null,
'left')
->addAttributeToFilter('category_id', array('in' => $categories));
$collection->getSelect()->group('e.entity_id');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment