Skip to content
Snippets Groups Projects
Commit 85ce9a2c authored by Cristian Partica's avatar Cristian Partica
Browse files

FearlessKiwis-MAGETWO-35688-FPT-Final-price-of-Simple-Product-isn-t-recalculat...

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
parent f26c75c1
Branches
No related merge requests found
...@@ -219,8 +219,16 @@ class Options extends \Magento\Framework\View\Element\Template ...@@ -219,8 +219,16 @@ class Options extends \Magento\Framework\View\Element\Template
$config[$option->getId()] = $priceValue; $config[$option->getId()] = $priceValue;
} }
//alter the return array from the other modules eg: weee $configObj = new \Magento\Framework\Object(
$this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['config' => &$config]); [
'config' => $config,
]
);
//pass the return array encapsulated in an object for the other modules to be able to alter it eg: weee
$this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['configObj' => $configObj]);
$config=$configObj->getConfig();
return $this->_jsonEncoder->encode($config); return $this->_jsonEncoder->encode($config);
} }
......
...@@ -204,7 +204,8 @@ class Observer extends \Magento\Framework\Model\AbstractModel ...@@ -204,7 +204,8 @@ class Observer extends \Magento\Framework\Model\AbstractModel
public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer) public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer)
{ {
if ($this->_weeeData->isEnabled()) { if ($this->_weeeData->isEnabled()) {
$priceConfig=$observer->getData('config'); $priceConfigObj=$observer->getData('configObj');
$priceConfig=$priceConfigObj->getConfig();
if (is_array($priceConfig)) { if (is_array($priceConfig)) {
foreach ($priceConfig as $keyConfigs => $configs) { foreach ($priceConfig as $keyConfigs => $configs) {
if (is_array($configs)) { if (is_array($configs)) {
...@@ -217,8 +218,7 @@ class Observer extends \Magento\Framework\Model\AbstractModel ...@@ -217,8 +218,7 @@ class Observer extends \Magento\Framework\Model\AbstractModel
} }
} }
} }
$priceConfigObj->setConfig($priceConfig);
$observer->setData('config', $priceConfig);
} }
return $this; return $this;
} }
......
...@@ -40,6 +40,12 @@ class ObserverTest extends \PHPUnit_Framework_TestCase ...@@ -40,6 +40,12 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
], ],
]; ];
$configObj = new \Magento\Framework\Object(
[
'config' => $testArray,
]
);
$testArrayWithWeee=$testArray; $testArrayWithWeee=$testArray;
$testArrayWithWeee[0][0]['prices']['weeePrice']= [ $testArrayWithWeee[0][0]['prices']['weeePrice']= [
'amount' => $testArray[0][0]['prices']['finalPrice']['amount'], 'amount' => $testArray[0][0]['prices']['finalPrice']['amount'],
...@@ -57,12 +63,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase ...@@ -57,12 +63,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
$observerObject->expects($this->any()) $observerObject->expects($this->any())
->method('getData') ->method('getData')
->with('config') ->with('configObj')
->will($this->returnValue($testArray)); ->will($this->returnValue($configObj));
$observerObject->expects($this->once())
->method('setData')
->with('config', $testArrayWithWeee);
$objectManager = new ObjectManager($this); $objectManager = new ObjectManager($this);
$weeeObserverObject = $objectManager->getObject( $weeeObserverObject = $objectManager->getObject(
...@@ -71,6 +73,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase ...@@ -71,6 +73,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
'weeeData' => $weeHelper, 'weeeData' => $weeHelper,
] ]
); );
$weeeObserverObject->getPriceConfiguration($observerObject); $weeeObserverObject->getPriceConfiguration($observerObject);
$this->assertEquals($testArrayWithWeee, $configObj->getData('config'));
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment