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!

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

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀