8
8
use Magento \Framework \App \ObjectManager ;
9
9
use Magento \SalesRule \Api \Data \RuleDiscountInterfaceFactory ;
10
10
use Magento \SalesRule \Api \Data \DiscountDataInterfaceFactory ;
11
- use Magento \Quote \Api \Data \AddressExtensionFactory ;
12
11
13
12
/**
14
13
* Discount totals calculation model.
@@ -51,28 +50,21 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
51
50
*/
52
51
private $ discountDataInterfaceFactory ;
53
52
54
- /**
55
- * @var AddressExtensionFactory
56
- */
57
- private $ addressExtensionFactory ;
58
-
59
53
/**
60
54
* @param \Magento\Framework\Event\ManagerInterface $eventManager
61
55
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
62
56
* @param \Magento\SalesRule\Model\Validator $validator
63
57
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
64
58
* @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
65
59
* @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory
66
- * @param AddressExtensionFactory|null $addressExtensionFactory
67
60
*/
68
61
public function __construct (
69
62
\Magento \Framework \Event \ManagerInterface $ eventManager ,
70
63
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
71
64
\Magento \SalesRule \Model \Validator $ validator ,
72
65
\Magento \Framework \Pricing \PriceCurrencyInterface $ priceCurrency ,
73
66
RuleDiscountInterfaceFactory $ discountInterfaceFactory = null ,
74
- DiscountDataInterfaceFactory $ discountDataInterfaceFactory = null ,
75
- AddressExtensionFactory $ addressExtensionFactory = null
67
+ DiscountDataInterfaceFactory $ discountDataInterfaceFactory = null
76
68
) {
77
69
$ this ->setCode (self ::COLLECTOR_TYPE_CODE );
78
70
$ this ->eventManager = $ eventManager ;
@@ -83,8 +75,6 @@ public function __construct(
83
75
?: ObjectManager::getInstance ()->get (RuleDiscountInterfaceFactory::class);
84
76
$ this ->discountDataInterfaceFactory = $ discountDataInterfaceFactory
85
77
?: ObjectManager::getInstance ()->get (DiscountDataInterfaceFactory::class);
86
- $ this ->addressExtensionFactory = $ addressExtensionFactory
87
- ?: ObjectManager::getInstance ()->get (AddressExtensionFactory::class);
88
78
}
89
79
90
80
/**
@@ -94,7 +84,6 @@ public function __construct(
94
84
* @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
95
85
* @param \Magento\Quote\Model\Quote\Address\Total $total
96
86
* @return $this
97
- * @throws \Magento\Framework\Exception\NoSuchEntityException
98
87
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
99
88
* @SuppressWarnings(PHPMD.NPathComplexity)
100
89
*/
@@ -130,20 +119,7 @@ public function collect(
130
119
131
120
$ address ->setDiscountDescription ([]);
132
121
$ items = $ this ->calculator ->sortItemsByPriority ($ items , $ address );
133
-
134
- if (!is_object ($ address ->getExtensionAttributes ())) {
135
- $ addressExtensionAttributes = $ address ->getExtensionAttributes ();
136
- $ addressExtension = $ this ->addressExtensionFactory ->create ();
137
-
138
- foreach ($ addressExtensionAttributes as $ key => $ value ) {
139
- $ addressExtension ->setData ($ key , $ value );
140
- }
141
- $ addressExtension ->setDiscounts ([]);
142
- $ address ->setExtensionAttributes ($ addressExtension );
143
- } else {
144
- $ address ->getExtensionAttributes ()->setDiscounts ([]);
145
- }
146
-
122
+ $ address ->getExtensionAttributes ()->setDiscounts ([]);
147
123
$ addressDiscountAggregator = [];
148
124
149
125
/** @var \Magento\Quote\Model\Quote\Item $item */
@@ -324,7 +300,6 @@ private function aggregateDiscountPerRule(
324
300
}
325
301
}
326
302
}
327
-
328
303
$ address ->getExtensionAttributes ()->setDiscounts (array_values ($ addressDiscountAggregator ));
329
304
}
330
305
}
0 commit comments