i have written a small functionality, where i need to get data from XML or CSV and populate the data in the cart.
I am able to read the data from the file and create an array of the items
foreach ($products as $productId => $singleQty)
{
$_product$product = $this->_productModel>productModel->load($productId);
if ($_product$product)
{
echo $_product$product->getId() .'<br/>';
$this->_cart>cart->addProduct($_product, array('qty' => $singleQty));
$this->_cart>cart->save();
}
}
the echo result is completely fine,, it displays the product Ids correctly
But only one item gets added into the cart, with the total number of items.
Suppose i have product IDs
2 and 4 with quantities 200 and 400 respectively,
the above snippet only adds product with ID 2, but the quantity added is 600
Any idea what i am doing wrong?