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
module-sales-rule
Model
ResourceModel
SaveHandler.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\SalesRule\Model\ResourceModel
;
7
8
use
Magento\SalesRule\Model\ResourceModel\Rule
;
9
use
Magento\Framework\EntityManager\MetadataPool
;
10
use
Magento\Framework\EntityManager\Operation\AttributeInterface
;
11
15
class
SaveHandler
implements
AttributeInterface
16
{
20
protected
$ruleResource
;
21
25
protected
$metadataPool
;
26
31
public
function
__construct
(
32
Rule
$ruleResource
,
33
MetadataPool
$metadataPool
34
) {
35
$this->ruleResource =
$ruleResource
;
36
$this->metadataPool =
$metadataPool
;
37
}
38
46
public
function
execute
(
$entityType
, $entityData,
$arguments
= [])
47
{
48
$linkField = $this->metadataPool->getMetadata(
$entityType
)->getLinkField();
49
if
(isset($entityData[
'website_ids'
])) {
50
$websiteIds
= $entityData[
'website_ids'
];
51
if
(!is_array(
$websiteIds
)) {
52
$websiteIds
= explode(
','
, (
string
)
$websiteIds
);
53
}
54
$this->ruleResource->bindRuleToEntity($entityData[$linkField],
$websiteIds
,
'website'
);
55
}
56
57
if
(isset($entityData[
'customer_group_ids'
])) {
58
$customerGroupIds = $entityData[
'customer_group_ids'
];
59
if
(!is_array($customerGroupIds)) {
60
$customerGroupIds = explode(
','
, (
string
)$customerGroupIds);
61
}
62
$this->ruleResource->bindRuleToEntity($entityData[$linkField], $customerGroupIds,
'customer_group'
);
63
}
64
return
$entityData;
65
}
66
}
Magento\SalesRule\Model\ResourceModel\SaveHandler\execute
execute($entityType, $entityData, $arguments=[])
Definition:
SaveHandler.php:46
Magento\SalesRule\Model\ResourceModel\SaveHandler\$ruleResource
$ruleResource
Definition:
SaveHandler.php:20
Magento\Framework\EntityManager\Operation\AttributeInterface
Definition:
AttributeInterface.php:12
$websiteIds
$websiteIds
Definition:
assign_products_to_websites.php:17
$entityType
$entityType
Definition:
attribute_set_with_image_attribute.php:13
Magento\SalesRule\Model\ResourceModel\SaveHandler\$metadataPool
$metadataPool
Definition:
SaveHandler.php:25
Magento\Framework\EntityManager\MetadataPool
Definition:
MetadataPool.php:18
Magento\SalesRule\Model\ResourceModel\SaveHandler
Definition:
SaveHandler.php:15
Magento\SalesRule\Model\ResourceModel\SaveHandler\__construct
__construct(Rule $ruleResource, MetadataPool $metadataPool)
Definition:
SaveHandler.php:31
Magento\SalesRule\Model\ResourceModel\Rule
Definition:
CollectionTest.php:6
Magento\SalesRule\Model\ResourceModel
Magento\SalesRule\Model\ResourceModel\Rule
Definition:
Rule.php:20
$arguments
$arguments
Definition:
final_price.phtml:24