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
Checkout
_files
discount_10percent.php
Go to the documentation of this file.
1
<?php
9
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
11
$salesRuleFactory
=
$objectManager
->get(\
Magento
\SalesRule\Model\RuleFactory::class);
12
14
$salesRule
=
$salesRuleFactory
->create();
15
16
$data
= [
17
'name'
=>
'Test Coupon'
,
18
'is_active'
=>
true
,
19
'website_ids'
=> [
20
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->get(
21
\
Magento
\Store\Model\StoreManagerInterface::class
22
)->getStore()->getWebsiteId()
23
],
24
'customer_group_ids'
=> [
\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID
],
25
'coupon_type'
=>
\Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC
,
26
'coupon_code'
=> uniqid(),
27
'simple_action'
=>
\Magento\SalesRule\Model\Rule::BY_PERCENT_ACTION
,
28
'discount_amount'
=> 10,
29
'discount_step'
=> 1
30
];
31
32
$salesRule
->loadPost(
$data
)->setUseAutoGeneration(
false
)->save();
33
$objectManager
->get(\
Magento
\Framework\Registry::class)->unregister(
'Magento/Checkout/_file/discount_10percent'
);
34
$objectManager
->get(\
Magento
\Framework\Registry::class)
35
->register(
'Magento/Checkout/_file/discount_10percent'
,
$salesRule
->getRuleId());
$data
$data
Definition:
discount_10percent.php:16
Magento\SalesRule\Model\Rule\COUPON_TYPE_SPECIFIC
const COUPON_TYPE_SPECIFIC
Definition:
Rule.php:75
$salesRule
$salesRule
Definition:
discount_10percent.php:14
Magento\SalesRule\Model\Rule\BY_PERCENT_ACTION
const BY_PERCENT_ACTION
Definition:
Rule.php:84
Magento
$salesRuleFactory
$salesRuleFactory
Definition:
discount_10percent.php:11
$objectManager
$objectManager
Definition:
discount_10percent.php:9
Magento\Customer\Model\GroupManagement\NOT_LOGGED_IN_ID
const NOT_LOGGED_IN_ID
Definition:
GroupManagement.php:27
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125