I'm manually adding some products to the cart:
$product = Mage::getModel('catalog/product')->load(113);
$params = array(
'product' => 113,
'qty' => 1
);
$request = new Varien_Object();
$request->setData($params);
$cartHelper->getCart()->addProduct($product, $request);
But the price is always empty (or null).
I've been debugging the execution through
Mage_Checkout_Model_Cart->addProduct(...)
Mage_Sales_Model_Quote->addProduct(...)
Mage_Sales_Model_Quote->addProductAdvanced(...)
and finally:
protected function _addCatalogProduct(Mage_Catalog_Model_Product $product, $qty = 1)
{
$newItem = false;
$item = $this->getItemByProduct($product);
if (!$item) {
$item = Mage::getModel('sales/quote_item');
$item->setQuote($this);
if (Mage::app()->getStore()->isAdmin()) {
$item->setStoreId($this->getStore()->getId());
}
else {
$item->setStoreId(Mage::app()->getStore()->getId());
}
$newItem = true;
}
/**
* We can't modify existing child items
*/
if ($item->getId() && $product->getParentProductId()) {
return $item;
}
$item->setOptions($product->getCustomOptions())
->setProduct($product);
// Add only item that is not in quote already (there can be other new or already saved item
if ($newItem) {
$this->addItem($item);
}
return $item;
}
But the price is not there, in that $item :(
Any help would be much appreciated.