2

I have a product Collection:

$_productCollection = Mage::getResourceModel('catalog/product_collection')->getCollection()->setPageSize(10);

I want to add a product to that collection by using addItem() method:

$product = Mage::getModel('catalog/product')->load(66);
$_productCollection->addItem($product);

I tried to dump my $_productCollection before and after using addItem() method but I get the same result.

What's wrong with that ? Thanks in advance

2

1 Answer 1

2

You should load the collection before adding items, but this will invalidate any filter you want to apply later

Try...

$_productCollection->load();
$product = Mage::getModel('catalog/product')->load(66);
$_productCollection->addItem($product);

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.