Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
rule_by_category_ids.php
Go to the documentation of this file.
1 <?php
11 
13 $rule = Bootstrap::getObjectManager()->get(\Magento\CatalogRule\Model\RuleFactory::class)->create();
14 $rule->loadPost([
15  'name' => 'test_category_rule',
16  'is_active' => '1',
17  'stop_rules_processing' => 0,
18  'website_ids' => [1],
19  'customer_group_ids' => [0, 1],
20  'discount_amount' => 50,
21  'simple_action' => 'by_percent',
22  'from_date' => '',
23  'to_date' => '',
24  'sort_order' => 0,
25  'sub_is_enable' => 0,
26  'sub_discount_amount' => 0,
27  'conditions' => [
28  '1' => [
29  'type' => Combine::class,
30  'aggregator' => 'all',
31  'value' => '1',
32  'new_child' => '',
33  ],
34  '1--1' => [
35  'type' => Product::class,
36  'attribute' => 'category_ids',
37  'operator' => '==',
38  'value' => '10',
39  ],
40  ],
41 ]);
42 
44 $catalogRuleRepository = Bootstrap::getObjectManager()->get(CatalogRuleRepositoryInterface::class);
$catalogRuleRepository