2012-05-02 171 views
3

我试图从预订选项的upsell区域添加一个捆绑项目到购物车 - 所以它会带你直接到购物车,而不是项目页和现在用的是以下网址:magento直接添加捆绑项目从upsell购物车 - 预定义选项

Mage::$this->helper('checkout/cart')->getAddUrl($_link)

级联用,例如:

?bundle_option[14][]=16&bundle_option[15][]=17&bundle_option[16][]=19&

此网址然后添加项目到购物车,但警告:

以下某些产品没有全部所需的选项。请编辑它们并配置所有必需的选项。

而且不会让我继续结帐。它还包含通常添加到购物车成功消息。

如果我从它自己的页面添加项目(使用所有默认选项),它可以正常工作。

我根据Add bundle product to cart without having to specify the options设置了它,并选择了所需的单选按钮和默认值。

另外,将options_bundle_qty[...选项添加到网址中并没有帮助。

更新:我有完全相同的设置在1.4和1.6安装,它是在1.4的工作,而不是1.6

回答

4

你可能想尝试创建一个单一的测试。 php文件类似于:

$params = array(
    'product' => 164, 
    'related_product' => null, 
    'bundle_option' => array(
     21 => 58, 
     20 => 55, 
     11 => 28, 
     12 => array(
      0 => 31, 
     ), 
     13 => array(
      0 => 32, 
      1 => 35, 
     ), 
    ), 
    'options' => array(
     3 => 'olaaaaaaaa', 
    ), 
    'qty' => 2, 
); 

$cart = Mage::getSingleton('checkout/cart'); 

$product = new Mage_Catalog_Model_Product(); 
$product->load(164); 

$cart->addProduct($product, $params); 
$cart->save(); 

Mage::getSingleton('checkout/session')->setCartWasUpdated(true); 

$message = $this->__('Custom message: %s was successfully added to your shopping cart.', $product->getName()); 
Mage::getSingleton('checkout/session')->addSuccess($message); 

要测试和调试添加产品包,以便更容易查明任何问题。显然,您需要编辑产品ID和选项以与您需要的数据相关联。

希望这有助于。

相关问题