dongtun1683 2015-11-03 17:49 采纳率: 0%
浏览 200
已采纳

Magento的。 可配置产品 - 选择2个或更多选项(多个选项)

I am adding configurable product in cart programmatically.

        $parentId = $post['parrent_product'];
        $values = '';
        foreach ($post['simple_product_id'] as $id) {
            $values .= $id . ',';
        }
        $params = array(
            'product' => $parentId,
            'super_attribute' => array(
                132 => $values, //132 - super_attribute_code, $values - its a string with simple products(options) ids
            ),
            'qty' => $post['qty'],
        );
        $cart = Mage::getSingleton('checkout/cart');
        $product = new Mage_Catalog_Model_Product();
        $product->load($parentId);
        $cart->addProduct($product, $params);
        $cart->save();

I need to add configurable product with 2 options in cart. For example conf product is "pizza" and 2 options: cheese and tomato. Currently my code adding what i need but the price of options not calculating in cart.

  • 写回答

1条回答 默认 最新

  • dongqiang5541 2015-11-03 19:39
    关注

    This is not currently working because the product is a configurable product that is configured by a single attribute. This attribute can only have one value, it can not have multiple.

    In order to get what you want out of this, you should create a product with Custom Options instead of having the user select configurable attributes. This will allow the user to select any of the options, adjusting the price along the way.

    If you wanted to keep it as a configurable with attributes you'd need a new attribute for every topping and they would have to select (Full, left Half, Right Half, or None as the options) for their topping amount. This would then allow you to select more than one topping.

    This should work on the product page before you try to make it work with a custom UI.

    Cheers!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?