根据在线帖子( 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);
我假设代码根本就是错误的,尽管并没有导致系统崩溃。 我如何才能实现我所需要的?
最佳答案
这就是我的最终结果,效果很好!
$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);
关于magento - 指定以编程方式创建的优惠券代码的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13867777/