Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
CatalogRule
_files
rule_by_category_ids.php
Go to the documentation of this file.
1
<?php
7
use
Magento\CatalogRule\Api\CatalogRuleRepositoryInterface
;
8
use
Magento\CatalogRule\Model\Rule\Condition\Combine
;
9
use
Magento\CatalogRule\Model\Rule\Condition\Product
;
10
use
Magento\TestFramework\Helper\Bootstrap
;
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);
45
$catalogRuleRepository
->save(
$rule
);
$rule
$rule
Definition:
rule_by_category_ids.php:13
Magento\TestFramework\Helper\Bootstrap
Definition:
Bootstrap.php:12
$catalogRuleRepository
$catalogRuleRepository
Definition:
rule_by_category_ids.php:44
Magento\CatalogRule\Model\Rule\Condition\Product
Definition:
Product.php:15
Magento\CatalogRule\Model\Rule\Condition\Combine
Definition:
Combine.php:12
Magento
Magento\CatalogRule\Api\CatalogRuleRepositoryInterface
Definition:
CatalogRuleRepositoryInterface.php:13