@@ -158,28 +158,50 @@ protected function setFinalGroupPrices($field, $currencyCode, $min, $max, $dashe
158
158
{
159
159
if (count ($ subproducts ) > 0 ) {
160
160
$ groupPriceList = [];
161
+ $ subProductsMin = -1 ;
162
+ $ subProductsMax = 0 ;
161
163
/** @var Group $group */
162
164
foreach ($ this ->groups as $ group ) {
163
165
$ groupId = (int ) $ group ->getData ('customer_group_id ' );
164
166
$ minPrice = $ min ;
167
+
165
168
foreach ($ subproducts as $ subProduct ) {
166
169
$ subProduct ->setData ('customer_group_id ' , $ groupId );
167
170
$ subProduct ->setData ('website_id ' , $ subProduct ->getStore ()->getWebsiteId ());
168
171
$ specialPrice = $ this ->getSpecialPrice ($ subProduct , $ currencyCode , $ withTax , []);
169
172
$ tierPrice = $ this ->getTierPrice ($ subProduct , $ currencyCode , $ withTax );
170
173
$ price = $ this ->getTaxPrice ($ product , $ subProduct ->getPriceModel ()->getFinalPrice (1 , $ subProduct ), $ withTax );
174
+
171
175
if (!empty ($ tierPrice [$ groupId ]) && $ specialPrice [$ groupId ] > $ tierPrice [$ groupId ]){
172
176
$ minPrice = $ tierPrice [$ groupId ];
173
177
}
174
- $ groupPriceList [$ groupId ]['min ' ] = min ($ minPrice , $ price );
175
- $ groupPriceList [$ groupId ]['max ' ] = max ($ max , $ price );
178
+
179
+ if (isset ($ tierPrice [$ groupId ]) && $ tierPrice [$ groupId ] !== false ) {
180
+ $ minPrice = $ tierPrice [$ groupId ];
181
+ }
182
+
183
+ if ($ subProductsMin == -1 || $ price < $ subProductsMin ) {
184
+ $ subProductsMin = $ price ;
185
+ }
186
+
187
+ if ($ price > $ subProductsMax ) {
188
+ $ subProductsMax = $ price ;
189
+ }
190
+
191
+ $ groupPriceList [$ groupId ]['min ' ] = min ($ minPrice , $ subProductsMin );
192
+ $ groupPriceList [$ groupId ]['max ' ] = $ subProductsMax ;
176
193
$ subProduct ->setData ('customer_group_id ' , null );
194
+
177
195
}
196
+
197
+ $ subProductsMin = -1 ;
198
+ $ subProductsMax = 0 ;
178
199
}
179
200
180
201
$ minArray = [];
181
202
foreach ($ groupPriceList as $ key => $ value ) {
182
203
$ minArray [$ key ]['price ' ] = $ value ['min ' ];
204
+ $ minArray [$ key ]['price_max ' ] = $ value ['max ' ];
183
205
$ minArray [$ key ]['formatted ' ] = $ this ->formattedConfigPrice ($ value ['min ' ], $ value ['max ' ], $ currencyCode );
184
206
if ($ currencyCode !== $ this ->baseCurrencyCode ) {
185
207
$ minArray [$ key ]['formatted ' ] = $ this ->formattedConfigPrice ($ value ['min ' ], $ value ['max ' ], $ currencyCode );
@@ -190,6 +212,7 @@ protected function setFinalGroupPrices($field, $currencyCode, $min, $max, $dashe
190
212
$ groupId = (int ) $ group ->getData ('customer_group_id ' );
191
213
$ this ->customData [$ field ][$ currencyCode ]['group_ ' . $ groupId ] = $ minArray [$ groupId ]['price ' ];
192
214
$ this ->customData [$ field ][$ currencyCode ]['group_ ' . $ groupId . '_formated ' ] = $ minArray [$ groupId ]['formatted ' ];
215
+ $ this ->customData [$ field ][$ currencyCode ]['group_ ' . $ groupId . '_max ' ] = $ minArray [$ groupId ]['price_max ' ];
193
216
}
194
217
} else {
195
218
/** @var Group $group */
0 commit comments