I have a magento store with two websites for Italian and Spanish market. I perform a php page to add items to cart programatically, but it works in Spain but not in Italy.
See sample code that works on ES but not in IT.
umask(0);
Mage::app();
$session = Mage::getSingleton('core/session', array('name' =>> 'frontend'));
$cart = Mage::getSingleton('checkout/cart');
$cart->init();
$cart->addProduct(140616, 3);
$session->setCartWasUpdated(true);
$cart->save();
In var_dump afther $cart->init(); I see that the cart in IT dont load customer data.
Var_Dump in ES
object(Mage_Checkout_Model_Cart)[80] protected '_summaryQty' => null protected '_productIds' => null protected '_data' => array (size=1) 'quote' => object(Mage_Sales_Model_Quote)[82] protected '_eventPrefix' => string 'sales_quote' (length=11) protected '_eventObject' => string 'quote' (length=5) protected '_customer' => object(Mage_Customer_Model_Customer)[136] protected '_eventPrefix' => string 'customer' (length=8) protected '_eventObject' => string 'customer' (length=8) protected '_errors' => array (size=0) empty protected '_attributes' => null protected '_addresses' => null protected '_addressesCollection' => null
Var_Dump in IT
object(Mage_Checkout_Model_Cart)[81] protected '_summaryQty' => null protected '_productIds' => null protected '_data' => array (size=1) 'quote' => object(Mage_Sales_Model_Quote)[83] protected '_eventPrefix' => string 'sales_quote' (length=11) protected '_eventObject' => string 'quote' (length=5) protected '_customer' => null protected '_addresses' => null protected '_items' => object(Mage_Sales_Model_Resource_Quote_Item_Collection)[136] protected '_quote' => &object(Mage_Sales_Model_Quote)[83] protected '_productIds' => array (size=11) 0 => int 139190 1 => int 139167 2 => int 73844
Any sugestion?
Thanks
1 Answer 1
As per as comment. You need to initialize Mage::app() for each store.
SO just need to add store on Mage::app() .
Use: Mage::app("StoreCOde",'Storetype');
instead of Mage::app()
Mage::app("StoreCOde",'Storetype');instead ofMage::app();