【问题标题】:Please specify the product's option(s). configurable product magento请指定产品的选项。可配置的产品 magento
【发布时间】:2014-04-21 14:11:19
【问题描述】:

我正在使用可配置产品,我创建了用于显示可配置产品的自定义视图。在将可配置产品添加到购物车时出现错误(请指定产品的选项)。 此错误仅发生在可配置产品中。

我正在使用此代码添加到购物车

 $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',
                          )

数组包含我为产品选择的属性值。 我不知道为什么会这样。

【问题讨论】:

    标签: magento configurable-product


    【解决方案1】:

    经过大量尝试,我发现了错误,我在$params 数组中缺少两个参数uencform_key。应该是这样的

    $params = array(
              'product' => $product->getId(),
              'form_key'=>$form_key,
              'uenc' =>Mage::app()->getRequest()->getParam('uenc', 1),
              'super_attribute' => $super_attribute,
              'qty' => $qty,
          );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      相关资源
      最近更新 更多