Skip to content

Commit 65c7153

Browse files
committed
Revert changes
1 parent b60504e commit 65c7153

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

app/code/Magento/SalesRule/Model/Quote/Discount.php

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Framework\App\ObjectManager;
99
use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
1010
use Magento\SalesRule\Api\Data\DiscountDataInterfaceFactory;
11-
use Magento\Quote\Api\Data\AddressExtensionFactory;
1211

1312
/**
1413
* Discount totals calculation model.
@@ -51,28 +50,21 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
5150
*/
5251
private $discountDataInterfaceFactory;
5352

54-
/**
55-
* @var AddressExtensionFactory
56-
*/
57-
private $addressExtensionFactory;
58-
5953
/**
6054
* @param \Magento\Framework\Event\ManagerInterface $eventManager
6155
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
6256
* @param \Magento\SalesRule\Model\Validator $validator
6357
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
6458
* @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
6559
* @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory
66-
* @param AddressExtensionFactory|null $addressExtensionFactory
6760
*/
6861
public function __construct(
6962
\Magento\Framework\Event\ManagerInterface $eventManager,
7063
\Magento\Store\Model\StoreManagerInterface $storeManager,
7164
\Magento\SalesRule\Model\Validator $validator,
7265
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
7366
RuleDiscountInterfaceFactory $discountInterfaceFactory = null,
74-
DiscountDataInterfaceFactory $discountDataInterfaceFactory = null,
75-
AddressExtensionFactory $addressExtensionFactory = null
67+
DiscountDataInterfaceFactory $discountDataInterfaceFactory = null
7668
) {
7769
$this->setCode(self::COLLECTOR_TYPE_CODE);
7870
$this->eventManager = $eventManager;
@@ -83,8 +75,6 @@ public function __construct(
8375
?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class);
8476
$this->discountDataInterfaceFactory = $discountDataInterfaceFactory
8577
?: ObjectManager::getInstance()->get(DiscountDataInterfaceFactory::class);
86-
$this->addressExtensionFactory = $addressExtensionFactory
87-
?: ObjectManager::getInstance()->get(AddressExtensionFactory::class);
8878
}
8979

9080
/**
@@ -94,7 +84,6 @@ public function __construct(
9484
* @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
9585
* @param \Magento\Quote\Model\Quote\Address\Total $total
9686
* @return $this
97-
* @throws \Magento\Framework\Exception\NoSuchEntityException
9887
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9988
* @SuppressWarnings(PHPMD.NPathComplexity)
10089
*/
@@ -130,20 +119,7 @@ public function collect(
130119

131120
$address->setDiscountDescription([]);
132121
$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([]);
147123
$addressDiscountAggregator = [];
148124

149125
/** @var \Magento\Quote\Model\Quote\Item $item */
@@ -324,7 +300,6 @@ private function aggregateDiscountPerRule(
324300
}
325301
}
326302
}
327-
328303
$address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator));
329304
}
330305
}

0 commit comments

Comments
 (0)