Skip to content

Commit

Permalink
Revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Kilo committed May 7, 2020
1 parent b60504e commit 65c7153
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions app/code/Magento/SalesRule/Model/Quote/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Magento\Framework\App\ObjectManager;
use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
use Magento\SalesRule\Api\Data\DiscountDataInterfaceFactory;
use Magento\Quote\Api\Data\AddressExtensionFactory;

/**
* Discount totals calculation model.
Expand Down Expand Up @@ -51,28 +50,21 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
*/
private $discountDataInterfaceFactory;

/**
* @var AddressExtensionFactory
*/
private $addressExtensionFactory;

/**
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\SalesRule\Model\Validator $validator
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
* @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory
* @param AddressExtensionFactory|null $addressExtensionFactory
*/
public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\SalesRule\Model\Validator $validator,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
RuleDiscountInterfaceFactory $discountInterfaceFactory = null,
DiscountDataInterfaceFactory $discountDataInterfaceFactory = null,
AddressExtensionFactory $addressExtensionFactory = null
DiscountDataInterfaceFactory $discountDataInterfaceFactory = null
) {
$this->setCode(self::COLLECTOR_TYPE_CODE);
$this->eventManager = $eventManager;
Expand All @@ -83,8 +75,6 @@ public function __construct(
?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class);
$this->discountDataInterfaceFactory = $discountDataInterfaceFactory
?: ObjectManager::getInstance()->get(DiscountDataInterfaceFactory::class);
$this->addressExtensionFactory = $addressExtensionFactory
?: ObjectManager::getInstance()->get(AddressExtensionFactory::class);
}

/**
Expand All @@ -94,7 +84,6 @@ public function __construct(
* @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
* @param \Magento\Quote\Model\Quote\Address\Total $total
* @return $this
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
Expand Down Expand Up @@ -130,20 +119,7 @@ public function collect(

$address->setDiscountDescription([]);
$items = $this->calculator->sortItemsByPriority($items, $address);

if (!is_object($address->getExtensionAttributes())) {
$addressExtensionAttributes = $address->getExtensionAttributes();
$addressExtension = $this->addressExtensionFactory->create();

foreach ($addressExtensionAttributes as $key => $value) {
$addressExtension->setData($key, $value);
}
$addressExtension->setDiscounts([]);
$address->setExtensionAttributes($addressExtension);
} else {
$address->getExtensionAttributes()->setDiscounts([]);
}

$address->getExtensionAttributes()->setDiscounts([]);
$addressDiscountAggregator = [];

/** @var \Magento\Quote\Model\Quote\Item $item */
Expand Down Expand Up @@ -324,7 +300,6 @@ private function aggregateDiscountPerRule(
}
}
}

$address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator));
}
}

0 comments on commit 65c7153

Please sign in to comment.