2014-10-22 135 views
0

我如何將可配置產品添加到購物車在magento中?我嘗試此代碼,以簡單的產品放入購物車,但它`不是配置產品工作Magento將可配置產品添加到購物車

 $result = $proxy->shoppingCartProductAdd($sessionID, $cartID, array(array(
     'product_id' => $productID, 
     'sku' => $sku, 
     'qty' => $qty, 
     'options' =>array(0 =>array('key' => $option1id ,'value' => $option1value),1 =>array('key'  => $option2id ,'value' => $option2value)), 
     'bundle_option' => null, 
     'bundle_option_qty' => null, 
     'links' => null 
     ))); 

如何爲配置的產品做到這一點? 感謝

回答

2

你可以嘗試這樣的事情

$productId = 'your-product-id'; 
$cart = Mage::getModel('checkout/cart'); 
$cart->init(); 
$productCollection = Mage::getModel('catalog/product')->load($productId); 
$cart->addProduct($productCollection , array('product_id' => $productId, 'qty' => 1,'options' => array($optionId => $optionValue)); 
$cart->save(); 
+0

我怎樣才能配置產品選項ID?我認爲還有其他產品與此類產品相關聯。 – mahdi 2014-10-22 06:35:05

+0

你可以去試試這個鏈接http://magento.stackexchange.com/questions/28881/get-simple-product-id-from-configurable-product-selection – 2014-10-22 06:39:21

相關問題