【问题标题】:programmatically add child products of bundle product in Quote以编程方式在 Quote 中添加捆绑产品的子产品
【发布时间】:2012-12-21 05:02:58
【问题描述】:

我正在尝试以编程方式创建订单。它适用于简单的产品,但是当我尝试使用捆绑产品时,它不会添加子产品。

下面是代码

$quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore('default')->getId());

$newProd = Mage::getModel('catalog/product')->load($sku);

$option= array(
        "bundle_option" => array(
        "35" => 66, 
        "36" => 67
        ),
        'qty' => 1
    );

$quote->addProduct($newProd, new Varien_Object($option));

请任何人对此有解决方案,或者我哪里错了?

谢谢

【问题讨论】:

    标签: magento magento-1.7 magento-1.4 magento-1.5 magento-1.6


    【解决方案1】:

    我认为您应该检查 Bundle-options 数组,因为在 Bundled 项目中有各种输入类型,例如单选(接受一个输入)复选框(接受多个产品)同样有下拉和多选。

    [bundle_option] => Array
        (
            [5] => 13
            [6] => Array
                (
                    [0] => 23
                )
    
            [8] => Array
                (
                    [0] => 37
                )
    
            [12] => Array
                (
                    [0] => 56
                )
    
        )
    
    [bundle_option_qty] => Array
        (
            [5] => 1
            [6] => Array
                (
                    [23] => 1
                )
    
            [8] => Array
                (
                    [37] => 1
                )
    
            [12] => Array
                (
                    [56] => 1
                )
    
        )
    

    这是一个捆绑产品选项,其中 [5] 是一个单选按钮,将有一个产品,[6],[8] 是 checkox,其中可以有更多产品,依此类推。

    同样你必须保持如上所示的产品数量。

    希望这会对你有所帮助。

    【讨论】:

    • 感谢您的回复...但它不适用于我..我有捆绑产品和 2 个儿童产品...并且都有单选按钮,两者都是必需的
    猜你喜欢
    • 2012-11-15
    • 2011-09-03
    • 1970-01-01
    • 2012-05-18
    • 1970-01-01
    • 2016-03-14
    • 2018-04-27
    • 1970-01-01
    • 2011-03-07
    相关资源
    最近更新 更多