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