|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | + |
6 | 7 | namespace Magento\SalesRule\Model\Plugin;
|
7 | 8 |
|
| 9 | +use Magento\Quote\Model\Quote\Config; |
8 | 10 | use Magento\SalesRule\Model\ResourceModel\Rule as RuleResource;
|
9 | 11 |
|
10 |
| -/** |
11 |
| - * Quote Config Product Attributes Class |
12 |
| - */ |
13 | 12 | class QuoteConfigProductAttributes
|
14 | 13 | {
|
15 | 14 | /**
|
16 | 15 | * @var RuleResource
|
17 | 16 | */
|
18 |
| - protected $_ruleResource; |
| 17 | + private $ruleResource; |
| 18 | + |
| 19 | + /** |
| 20 | + * @var array|null |
| 21 | + */ |
| 22 | + private $activeAttributeCodes; |
19 | 23 |
|
20 | 24 | /**
|
21 | 25 | * @param RuleResource $ruleResource
|
22 | 26 | */
|
23 | 27 | public function __construct(RuleResource $ruleResource)
|
24 | 28 | {
|
25 |
| - $this->_ruleResource = $ruleResource; |
| 29 | + $this->ruleResource = $ruleResource; |
26 | 30 | }
|
27 | 31 |
|
28 | 32 | /**
|
29 | 33 | * Append sales rule product attribute keys to select by quote item collection
|
30 | 34 | *
|
31 |
| - * @param \Magento\Quote\Model\Quote\Config $subject |
| 35 | + * @param Config $subject |
32 | 36 | * @param array $attributeKeys
|
33 | 37 | *
|
34 | 38 | * @return array
|
35 | 39 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
36 | 40 | */
|
37 |
| - public function afterGetProductAttributes(\Magento\Quote\Model\Quote\Config $subject, array $attributeKeys) |
| 41 | + public function afterGetProductAttributes(Config $subject, array $attributeKeys): array |
38 | 42 | {
|
39 |
| - $attributes = $this->_ruleResource->getActiveAttributes(); |
40 |
| - foreach ($attributes as $attribute) { |
41 |
| - $attributeKeys[] = $attribute['attribute_code']; |
| 43 | + if ($this->activeAttributeCodes === null) { |
| 44 | + $this->activeAttributeCodes = array_column($this->ruleResource->getActiveAttributes(), 'attribute_code'); |
42 | 45 | }
|
43 |
| - return $attributeKeys; |
| 46 | + |
| 47 | + return array_merge($attributeKeys, $this->activeAttributeCodes); |
44 | 48 | }
|
45 | 49 | }
|
0 commit comments