Skip to content

Commit fa8493b

Browse files
author
Mike Weis
committed
MAGETWO-43961: Final price does not include tax on custom option for simple product with FPT
- updated variable name
1 parent 4ceb3cf commit fa8493b

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

app/code/Magento/Weee/Observer/GetPriceConfigurationObserver.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public function execute(\Magento\Framework\Event\Observer $observer)
5555
try {
5656
/** @var \Magento\Catalog\Model\Product $product */
5757
$product = $this->registry->registry('current_product');
58-
$weeeAttributes = $this->weeeData->getWeeeAttributesForBundle($product);
58+
$weeeAttributesForBundle = $this->weeeData->getWeeeAttributesForBundle($product);
5959
$priceConfig = $this->recurConfigAndInsertWeeePrice(
6060
$priceConfigObj->getConfig(),
6161
'prices',
62-
$this->getWhichCalcPriceToUse($product->getStoreId(), $weeeAttributes),
63-
$weeeAttributes
62+
$this->getWhichCalcPriceToUse($product->getStoreId(), $weeeAttributesForBundle),
63+
$weeeAttributesForBundle
6464
);
6565
$priceConfigObj->setConfig($priceConfig);
6666
} catch (\Exception $e) {
@@ -76,25 +76,26 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7676
* @param array $input
7777
* @param string $searchKey
7878
* @param string $calcPrice
79-
* @param array $weeeAttributes
79+
* @param array $weeeAttributesForBundle
8080
* @return array
8181
*/
82-
private function recurConfigAndInsertWeeePrice($input, $searchKey, $calcPrice, $weeeAttributes = null)
82+
private function recurConfigAndInsertWeeePrice($input, $searchKey, $calcPrice, $weeeAttributesForBundle = null)
8383
{
8484
$holder = [];
8585
if (is_array($input)) {
8686
foreach ($input as $key => $el) {
8787
if (is_array($el)) {
88-
$holder[$key] = $this->recurConfigAndInsertWeeePrice($el, $searchKey, $calcPrice, $weeeAttributes);
88+
$holder[$key] =
89+
$this->recurConfigAndInsertWeeePrice($el, $searchKey, $calcPrice, $weeeAttributesForBundle);
8990
if ($key === $searchKey) {
9091
if ((!array_key_exists('weeePrice', $holder[$key])) &&
9192
(array_key_exists($calcPrice, $holder[$key]))
9293
) {
9394
//this is required for product options && bundle
9495
$holder[$key]['weeePrice'] = $holder[$key][$calcPrice];
9596
// only do processing on product options
96-
if (array_key_exists('optionId', $input) && $weeeAttributes) {
97-
$holder = $this->insertWeeePrice($holder, $key, $weeeAttributes);
97+
if (array_key_exists('optionId', $input) && $weeeAttributesForBundle) {
98+
$holder = $this->insertWeeePrice($holder, $key, $weeeAttributesForBundle);
9899
}
99100
}
100101
}
@@ -111,15 +112,17 @@ private function recurConfigAndInsertWeeePrice($input, $searchKey, $calcPrice, $
111112
*
112113
* @param array $holder
113114
* @param int|string $key
114-
* @param array $weeeAttributes
115+
* @param array $weeeAttributesForBundle
115116
* @return array
116117
*/
117-
private function insertWeeePrice($holder, $key, $weeeAttributes)
118+
private function insertWeeePrice($holder, $key, $weeeAttributesForBundle)
118119
{
119-
if (array_key_exists($holder['optionId'], $weeeAttributes)) {
120-
if (count($weeeAttributes[$holder['optionId']]) > 0 && is_array($weeeAttributes[$holder['optionId']])) {
120+
if (array_key_exists($holder['optionId'], $weeeAttributesForBundle)) {
121+
if (count($weeeAttributesForBundle[$holder['optionId']]) > 0 &&
122+
is_array($weeeAttributesForBundle[$holder['optionId']])
123+
) {
121124
$weeeSum = 0;
122-
foreach ($weeeAttributes[$holder['optionId']] as $weeeAttribute) {
125+
foreach ($weeeAttributesForBundle[$holder['optionId']] as $weeeAttribute) {
123126
$holder[$key]['weeePrice' . $weeeAttribute->getCode()] =
124127
['amount' => (float)$weeeAttribute->getAmount()];
125128
$weeeSum += (float)$weeeAttribute->getAmount();
@@ -137,13 +140,13 @@ private function insertWeeePrice($holder, $key, $weeeAttributes)
137140
* Returns which product price to use as a basis for the Weee's final price
138141
*
139142
* @param int|null $storeId
140-
* @param array|null $weeeAttributes
143+
* @param array|null $weeeAttributesForBundle
141144
* @return string
142145
*/
143-
protected function getWhichCalcPriceToUse($storeId = null, $weeeAttributes = null)
146+
protected function getWhichCalcPriceToUse($storeId = null, $weeeAttributesForBundle = null)
144147
{
145148
$calcPrice = 'finalPrice';
146-
if (!empty($weeeAttributes)) {
149+
if (!empty($weeeAttributesForBundle)) {
147150
if ($this->weeeData->geDisplayExcl($storeId) ||
148151
$this->weeeData->geDisplayExlDescIncl($storeId) ||
149152
($this->taxData->priceIncludesTax() && $this->taxData->displayPriceExcludingTax())

0 commit comments

Comments
 (0)