File tree Expand file tree Collapse file tree 3 files changed +24
-12
lines changed
Catalog/Block/Product/View Expand file tree Collapse file tree 3 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -219,8 +219,16 @@ public function getJsonConfig()
219
219
$ config [$ option ->getId ()] = $ priceValue ;
220
220
}
221
221
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 ();
224
232
225
233
return $ this ->_jsonEncoder ->encode ($ config );
226
234
}
Original file line number Diff line number Diff line change @@ -204,7 +204,8 @@ public function updateElementTypes(\Magento\Framework\Event\Observer $observer)
204
204
public function getPriceConfiguration (\Magento \Framework \Event \Observer $ observer )
205
205
{
206
206
if ($ this ->_weeeData ->isEnabled ()) {
207
- $ priceConfig =$ observer ->getData ('config ' );
207
+ $ priceConfigObj =$ observer ->getData ('configObj ' );
208
+ $ priceConfig =$ priceConfigObj ->getConfig ();
208
209
if (is_array ($ priceConfig )) {
209
210
foreach ($ priceConfig as $ keyConfigs => $ configs ) {
210
211
if (is_array ($ configs )) {
@@ -217,8 +218,7 @@ public function getPriceConfiguration(\Magento\Framework\Event\Observer $observe
217
218
}
218
219
}
219
220
}
220
-
221
- $ observer ->setData ('config ' , $ priceConfig );
221
+ $ priceConfigObj ->setConfig ($ priceConfig );
222
222
}
223
223
return $ this ;
224
224
}
Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ public function testGetPriceConfiguration()
40
40
],
41
41
];
42
42
43
+ $ configObj = new \Magento \Framework \Object (
44
+ [
45
+ 'config ' => $ testArray ,
46
+ ]
47
+ );
48
+
43
49
$ testArrayWithWeee =$ testArray ;
44
50
$ testArrayWithWeee [0 ][0 ]['prices ' ]['weeePrice ' ]= [
45
51
'amount ' => $ testArray [0 ][0 ]['prices ' ]['finalPrice ' ]['amount ' ],
@@ -57,12 +63,8 @@ public function testGetPriceConfiguration()
57
63
58
64
$ observerObject ->expects ($ this ->any ())
59
65
->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 ));
66
68
67
69
$ objectManager = new ObjectManager ($ this );
68
70
$ weeeObserverObject = $ objectManager ->getObject (
@@ -71,6 +73,8 @@ public function testGetPriceConfiguration()
71
73
'weeeData ' => $ weeHelper ,
72
74
]
73
75
);
74
- $ weeeObserverObject ->getPriceConfiguration ($ observerObject );
76
+ $ weeeObserverObject ->getPriceConfiguration ($ observerObject );
77
+
78
+ $ this ->assertEquals ($ testArrayWithWeee , $ configObj ->getData ('config ' ));
75
79
}
76
80
}
You can’t perform that action at this time.
0 commit comments