Skip to content

Commit 85ce9a2

Browse files
author
Cristian Partica
committed
FearlessKiwis-MAGETWO-35688-FPT-Final-price-of-Simple-Product-isn-t-recalculated-after-selecting-options-on-product-page
- bamboo pass by reference problem static - Wee Observer integrity test fix
1 parent f26c75c commit 85ce9a2

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

app/code/Magento/Catalog/Block/Product/View/Options.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,16 @@ public function getJsonConfig()
219219
$config[$option->getId()] = $priceValue;
220220
}
221221

222-
//alter the return array from the other modules eg: weee
223-
$this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['config' => &$config]);
222+
$configObj = new \Magento\Framework\Object(
223+
[
224+
'config' => $config,
225+
]
226+
);
227+
228+
//pass the return array encapsulated in an object for the other modules to be able to alter it eg: weee
229+
$this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['configObj' => $configObj]);
230+
231+
$config=$configObj->getConfig();
224232

225233
return $this->_jsonEncoder->encode($config);
226234
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ public function updateElementTypes(\Magento\Framework\Event\Observer $observer)
204204
public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer)
205205
{
206206
if ($this->_weeeData->isEnabled()) {
207-
$priceConfig=$observer->getData('config');
207+
$priceConfigObj=$observer->getData('configObj');
208+
$priceConfig=$priceConfigObj->getConfig();
208209
if (is_array($priceConfig)) {
209210
foreach ($priceConfig as $keyConfigs => $configs) {
210211
if (is_array($configs)) {
@@ -217,8 +218,7 @@ public function getPriceConfiguration(\Magento\Framework\Event\Observer $observe
217218
}
218219
}
219220
}
220-
221-
$observer->setData('config', $priceConfig);
221+
$priceConfigObj->setConfig($priceConfig);
222222
}
223223
return $this;
224224
}

app/code/Magento/Weee/Test/Unit/Model/Observer.php renamed to app/code/Magento/Weee/Test/Unit/Model/ObserverTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public function testGetPriceConfiguration()
4040
],
4141
];
4242

43+
$configObj = new \Magento\Framework\Object(
44+
[
45+
'config' => $testArray,
46+
]
47+
);
48+
4349
$testArrayWithWeee=$testArray;
4450
$testArrayWithWeee[0][0]['prices']['weeePrice']= [
4551
'amount' => $testArray[0][0]['prices']['finalPrice']['amount'],
@@ -57,12 +63,8 @@ public function testGetPriceConfiguration()
5763

5864
$observerObject->expects($this->any())
5965
->method('getData')
60-
->with('config')
61-
->will($this->returnValue($testArray));
62-
63-
$observerObject->expects($this->once())
64-
->method('setData')
65-
->with('config', $testArrayWithWeee);
66+
->with('configObj')
67+
->will($this->returnValue($configObj));
6668

6769
$objectManager = new ObjectManager($this);
6870
$weeeObserverObject = $objectManager->getObject(
@@ -71,6 +73,8 @@ public function testGetPriceConfiguration()
7173
'weeeData' => $weeHelper,
7274
]
7375
);
74-
$weeeObserverObject->getPriceConfiguration($observerObject);
76+
$weeeObserverObject->getPriceConfiguration($observerObject);
77+
78+
$this->assertEquals($testArrayWithWeee, $configObj->getData('config'));
7579
}
7680
}

0 commit comments

Comments
 (0)