我正在使用可配置产品,我创建了用于显示可配置产品的自定义视图。在将可配置产品添加到购物车时出现错误(请指定产品的选项)。此错误仅发生在可配置产品中。
我正在使用此代码添加到购物车
$params = array(
'product' => $product->getId(),
'super_attribute' => array (
133 => '3',
143 => '19',
142 => '18',
141 => '16',
140 => '14',
139 => '12',
138 => '10',
137 => '22',
136 => '9',
135 => '6',
144 => '21',
),
'qty' => 2,
);
$cart = Mage::getSingleton('checkout/cart');
$cart->addProduct($product, $params);
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
在上面的代码中
'super_attribute' => array (
133 => '3',
143 => '19',
142 => '18',
141 => '16',
140 => '14',
139 => '12',
138 => '10',
137 => '22',
136 => '9',
135 => '6',
144 => '21',
)
数组包含我为产品选择的属性值。我不知道为什么会这样。