@@ -210,29 +210,41 @@ public function updateElementTypes(\Magento\Framework\Event\Observer $observer)
210
210
*
211
211
* @param \Magento\Framework\Event\Observer $observer
212
212
* @return $this
213
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
213
214
*/
214
215
public function getPriceConfiguration (\Magento \Framework \Event \Observer $ observer )
215
216
{
216
217
if ($ this ->_weeeData ->isEnabled ()) {
217
218
$ priceConfigObj =$ observer ->getData ('configObj ' );
218
219
$ priceConfig =$ priceConfigObj ->getConfig ();
219
- if (is_array ($ priceConfig )) {
220
- foreach ($ priceConfig as $ keyConfigs => $ configs ) {
221
- if (is_array ($ configs )) {
222
- foreach ($ configs as $ keyConfig => $ config ) {
223
- $ calcPrice ='finalPrice ' ;
224
- if ($ this ->_taxData ->priceIncludesTax () && $ this ->_taxData ->displayPriceExcludingTax ()) {
225
- $ calcPrice ='basePrice ' ;
220
+ try {
221
+ if (is_array ($ priceConfig )) {
222
+ foreach ($ priceConfig as $ keyConfigs => $ configs ) {
223
+ if (is_array ($ configs )) {
224
+ foreach ($ configs as $ keyConfig => $ config ) {
225
+ $ calcPrice = 'finalPrice ' ;
226
+ if ($ this ->_taxData ->priceIncludesTax () && $ this ->_taxData ->displayPriceExcludingTax ()) {
227
+ $ calcPrice = 'basePrice ' ;
228
+ }
229
+ if (array_key_exists ('prices ' , $ configs )) {
230
+ $ priceConfig [$ keyConfigs ]['prices ' ]['weeePrice ' ] = [
231
+ 'amount ' => $ configs ['prices ' ][$ calcPrice ]['amount ' ],
232
+ ];
233
+ } else {
234
+ foreach ($ configs as $ keyConfig => $ config ) {
235
+ $ priceConfig [$ keyConfigs ][$ keyConfig ]['prices ' ]['weeePrice ' ] = [
236
+ 'amount ' => $ config ['prices ' ][$ calcPrice ]['amount ' ],
237
+ ];
238
+ }
239
+ }
226
240
}
227
- $ priceConfig [$ keyConfigs ][$ keyConfig ]['prices ' ]['weeePrice ' ]= [
228
- 'amount ' => $ config ['prices ' ][$ calcPrice ]['amount ' ],
229
- ];
230
241
}
231
-
232
242
}
233
243
}
244
+ $ priceConfigObj ->setConfig ($ priceConfig );
245
+ } catch (Exception $ e ) {
246
+ return $ this ;
234
247
}
235
- $ priceConfigObj ->setConfig ($ priceConfig );
236
248
}
237
249
return $ this ;
238
250
}
0 commit comments