@@ -55,12 +55,12 @@ public function execute(\Magento\Framework\Event\Observer $observer)
55
55
try {
56
56
/** @var \Magento\Catalog\Model\Product $product */
57
57
$ product = $ this ->registry ->registry ('current_product ' );
58
- $ weeeAttributes = $ this ->weeeData ->getWeeeAttributesForBundle ($ product );
58
+ $ weeeAttributesForBundle = $ this ->weeeData ->getWeeeAttributesForBundle ($ product );
59
59
$ priceConfig = $ this ->recurConfigAndInsertWeeePrice (
60
60
$ priceConfigObj ->getConfig (),
61
61
'prices ' ,
62
- $ this ->getWhichCalcPriceToUse ($ product ->getStoreId (), $ weeeAttributes ),
63
- $ weeeAttributes
62
+ $ this ->getWhichCalcPriceToUse ($ product ->getStoreId (), $ weeeAttributesForBundle ),
63
+ $ weeeAttributesForBundle
64
64
);
65
65
$ priceConfigObj ->setConfig ($ priceConfig );
66
66
} catch (\Exception $ e ) {
@@ -76,25 +76,26 @@ public function execute(\Magento\Framework\Event\Observer $observer)
76
76
* @param array $input
77
77
* @param string $searchKey
78
78
* @param string $calcPrice
79
- * @param array $weeeAttributes
79
+ * @param array $weeeAttributesForBundle
80
80
* @return array
81
81
*/
82
- private function recurConfigAndInsertWeeePrice ($ input , $ searchKey , $ calcPrice , $ weeeAttributes = null )
82
+ private function recurConfigAndInsertWeeePrice ($ input , $ searchKey , $ calcPrice , $ weeeAttributesForBundle = null )
83
83
{
84
84
$ holder = [];
85
85
if (is_array ($ input )) {
86
86
foreach ($ input as $ key => $ el ) {
87
87
if (is_array ($ el )) {
88
- $ holder [$ key ] = $ this ->recurConfigAndInsertWeeePrice ($ el , $ searchKey , $ calcPrice , $ weeeAttributes );
88
+ $ holder [$ key ] =
89
+ $ this ->recurConfigAndInsertWeeePrice ($ el , $ searchKey , $ calcPrice , $ weeeAttributesForBundle );
89
90
if ($ key === $ searchKey ) {
90
91
if ((!array_key_exists ('weeePrice ' , $ holder [$ key ])) &&
91
92
(array_key_exists ($ calcPrice , $ holder [$ key ]))
92
93
) {
93
94
//this is required for product options && bundle
94
95
$ holder [$ key ]['weeePrice ' ] = $ holder [$ key ][$ calcPrice ];
95
96
// 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 );
98
99
}
99
100
}
100
101
}
@@ -111,15 +112,17 @@ private function recurConfigAndInsertWeeePrice($input, $searchKey, $calcPrice, $
111
112
*
112
113
* @param array $holder
113
114
* @param int|string $key
114
- * @param array $weeeAttributes
115
+ * @param array $weeeAttributesForBundle
115
116
* @return array
116
117
*/
117
- private function insertWeeePrice ($ holder , $ key , $ weeeAttributes )
118
+ private function insertWeeePrice ($ holder , $ key , $ weeeAttributesForBundle )
118
119
{
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
+ ) {
121
124
$ weeeSum = 0 ;
122
- foreach ($ weeeAttributes [$ holder ['optionId ' ]] as $ weeeAttribute ) {
125
+ foreach ($ weeeAttributesForBundle [$ holder ['optionId ' ]] as $ weeeAttribute ) {
123
126
$ holder [$ key ]['weeePrice ' . $ weeeAttribute ->getCode ()] =
124
127
['amount ' => (float )$ weeeAttribute ->getAmount ()];
125
128
$ weeeSum += (float )$ weeeAttribute ->getAmount ();
@@ -137,13 +140,13 @@ private function insertWeeePrice($holder, $key, $weeeAttributes)
137
140
* Returns which product price to use as a basis for the Weee's final price
138
141
*
139
142
* @param int|null $storeId
140
- * @param array|null $weeeAttributes
143
+ * @param array|null $weeeAttributesForBundle
141
144
* @return string
142
145
*/
143
- protected function getWhichCalcPriceToUse ($ storeId = null , $ weeeAttributes = null )
146
+ protected function getWhichCalcPriceToUse ($ storeId = null , $ weeeAttributesForBundle = null )
144
147
{
145
148
$ calcPrice = 'finalPrice ' ;
146
- if (!empty ($ weeeAttributes )) {
149
+ if (!empty ($ weeeAttributesForBundle )) {
147
150
if ($ this ->weeeData ->geDisplayExcl ($ storeId ) ||
148
151
$ this ->weeeData ->geDisplayExlDescIncl ($ storeId ) ||
149
152
($ this ->taxData ->priceIncludesTax () && $ this ->taxData ->displayPriceExcludingTax ())
0 commit comments