--
You received this message because you are subscribed to the Google Groups "Magento Development List" group.
To post to this group, send email to magent...@googlegroups.com.
To unsubscribe from this group, send email to magento-deve...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/magento-devel?hl=en.
foreach ($collectionProduct2 as $item)
{
$collectionProduct1->addItem($item);
}
return $collectionProduct1;
Although, a handy merge function to wrap this would be pretty cool... as would a fromArray function in the collection abstract class, so that we could simply use...
$collection = $collection->fromArray(array_merge($collection1->toArray(), $collection2->toArray());
> And when I am trying merge two collection through fromArray it gives me the error as in:
> "Call to undefined method Mage_Catalog_Model_Resource_Eav_Mysql4_Product::fromArray()"
>
Yes, $collection->fromArray doesn't currently exist, it was a suggestion for an improvement
You'll need to use my first example, using the $collection->additem() function
Another possible improvement would be an addItems function...
$collection1->addItems($collection2->toArray())
then, extend the Varien_Data_Collection, adding :
function addItems(array $items)
{
foreach ($items as $item)
{
$this->addItem($item);