2015-12-21 71 views
0

我需要將產品從其他網站添加到magento購物車。我讓Ajax請求Magento的函數代碼Magento:通過外部網站的ajax請求將產品添加到購物車

$product_id = $this->getRequest()->getParam('id'); 
    $cart = Mage::getSingleton('checkout/cart'); 
    $cart->init(); 
    $product = Mage::getModel('catalog/product')->load($product_id);  
    $cart->addProduct($product, array('qty' => 1)); 
    $cart->save(); 
    Mage::getSingleton('checkout/session')->setCartWasUpdated(true); 

新行出現在表sales_flat_quote,但是當我打開的Magento網站 - 車是空的。這是爲什麼?我應該更改代碼以使其工作?

回答

相關問題