【问题标题】:Specifying actions for programmatically created coupon code为以编程方式创建的优惠券代码指定操作
【发布时间】:2012-12-13 20:18:27
【问题描述】:

根据网上几篇帖子(http://www.magentocommerce.com/boards/viewthread/178767/http://marius-strajeru.blogspot.co.uk/2010/04/create-bulk-discount-rules.html)中的信息,我将一些代码放在一起生成一些优惠券代码。

我坚持的一点是如何编写代码来指定优惠券使用的“动作”特定条件。这将在 Magento 管理系统中“操作”选项卡的“仅将规则应用于符合以下条件的购物车项目”部分中指定。

在 Magento 管理系统中,我将构建以下行:

类别不是 10,20,30 之一

我需要知道的是如何在代码中复制它。 我目前有以下内容,但似乎无法正常工作 - 至少,当我检查生成的优惠券代码时,我需要的操作值丢失了。

    $actions = array();
    $actions[1] = array(
    'type' => 'salesrule/rule_condition_category',
    'aggregator' => 'all',
    'value' => 1,
    'new_child' => ''
    );
    $actions['1--1'] = array(
        'type' => 'salesrule/rule_condition_category',
        'attribute' => 'category_ids',
        'operator' => '!()',
        'value' => '932,341,800',
        'is_value_processed' => 0,
    );
    $model->setData('actions',$actions);

我假设代码完全是错误的,尽管不会导致系统崩溃。 我如何才能达到我的需要?

【问题讨论】:

    标签: magento


    【解决方案1】:

    这是我最终得到的,效果很好!

            $conditions = array(
                "1" => array(
                    'type' => 'salesrule/rule_condition_combine',
                    'aggregator' => 'all',
                    'value' => 1,
                    'new_child' => false
                    ),
                "1--1" => array(
                    'type' => 'salesrule/rule_condition_product_found',
                    'value' => 1,
                    'aggregator' => 'all',
                    'new_child' => false
                ),
                "1--1--1" => array(
                    'type' => 'salesrule/rule_condition_product',
                    'attribute' => 'category_ids',
                    'operator' => '!()',
                    'value' => '10,20,30'
                )
            );
            $actions = array(
                "1" => array(
                        "type"          => "salesrule/rule_condition_product",
                        "aggregator"    => "all",
                        "value"         => "1",
                        "new_child"     => false
                ),
                "1--1" => array(
                        "type"          => "salesrule/rule_condition_product",
                        "attribute"     => "category_ids",
                        'operator' => '!()',
                        'value' => '10,20,30'
                )
            );
    
            $rule->setData('conditions',$conditions);
            $rule->setData("actions",$actions);
    

    【讨论】:

    • 先生,我们可以在 $actions 中再添加一个条件吗?像“1--1--1”???我在这两个条件之后添加了“1--1--1”,但它对我不起作用
    猜你喜欢
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    • 2014-05-31
    相关资源
    最近更新 更多