Lets say I have an empty collection and a list of productIDs. I want to populate the collection with products specified by the IDs in the list. How would I do this?

2 Answers 2


If you want to prepare a "Collection" if you have product ID's then this should be fine.

->addFieldToFilter('entity_id', array('in' => array(OF_YOUR_PRODUCTIDS)));

In this way you can get the "collection" object, just query it using those IDs.


This is what I did:

// Get array of IDs from cookie
$productIds = explode(';', Mage::helper('customcompare/cookieAccess')->readCookie());

// Add products to collection
foreach ($productIds as $productId) {
    $newProduct = Mage::getModel('catalog/product')->load($productId);
    $collection[$count] = $newProduct;
    $count = $count + 1;

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.