Tuesday, 1 July 2014

Magento Get a product collection by specific ids

This tutorial describe How can get product collection using specific product id.
Here is the code to fetch AND filter with custom option using specific product id also you can use to get simple products associated with a configurable product.

$productIds= Mage::getModel('catalog/product_type_configurable')
->getChildrenIds($_product->getId());

$productCollection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToSelect('sceneseven_thumbnail_image')
                ->addAttributeToFilter('entity_id', array('in' => $productIds))
                ->addAttributeToFilter('color_group',$colorFilter)
                ->addAttributeToSort('color', 'ASC');


Best of luck

No comments:

Post a Comment