Magento将可配置产品添加到购物车
问题描述:
我如何将可配置产品添加到购物车在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
)));
如何为配置的产品做到这一点? 感谢
答
你可以尝试这样的事情
$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();
我怎样才能配置产品选项ID?我认为还有其他产品与此类产品相关联。 – mahdi 2014-10-22 06:35:05
你可以去试试这个链接http://magento.stackexchange.com/questions/28881/get-simple-product-id-from-configurable-product-selection – 2014-10-22 06:39:21