@@ -224,35 +224,31 @@ public function setSettings($storeId)
224224
225225 foreach ($ sorting_indices as $ values )
226226 {
227- if ($ this ->config ->isCustomerGroupsEnabled ($ storeId ))
227+ if ($ this ->config ->isCustomerGroupsEnabled ($ storeId ) && strpos ( $ values [ ' attribute ' ], ' price ' ) !== false )
228228 {
229- if ( strpos ( $ values [ ' attribute ' ], ' price ' ) !== false )
229+ foreach ( $ groups = Mage:: getModel ( ' customer/group ' )-> getCollection () as $ group )
230230 {
231- foreach ($ groups = Mage::getModel ('customer/group ' )->getCollection () as $ group )
232- {
233- $ group_id = (int )$ group ->getData ('customer_group_id ' );
231+ $ group_id = (int )$ group ->getData ('customer_group_id ' );
234232
235- $ suffix_index_name = 'group_ ' . $ group_id ;
233+ $ suffix_index_name = 'group_ ' . $ group_id ;
236234
237- $ sort_attribute = strpos ($ values ['attribute ' ], 'price ' ) !== false ? $ values ['attribute ' ]. '. ' . $ currencies [0 ]. '. ' . $ suffix_index_name : $ values ['attribute ' ];
235+ $ sort_attribute = strpos ($ values ['attribute ' ], 'price ' ) !== false ? $ values ['attribute ' ] . '. ' . $ currencies [0 ] . '. ' . $ suffix_index_name : $ values ['attribute ' ];
238236
239- $ mergeSettings ['ranking ' ] = array ($ values ['sort ' ]. '( ' . $ sort_attribute. ') ' , 'typo ' , 'geo ' , 'words ' , 'proximity ' , 'attribute ' , 'exact ' , 'custom ' );
237+ $ mergeSettings ['ranking ' ] = array ($ values ['sort ' ] . '( ' . $ sort_attribute . ') ' , 'typo ' , 'geo ' , 'words ' , 'proximity ' , 'attribute ' , 'exact ' , 'custom ' );
240238
241- $ this ->algolia_helper ->setSettings ($ this ->getIndexName ($ storeId ).'_ ' .$ values ['attribute ' ].'_ ' . $ suffix_index_name .'_ ' .$ values ['sort ' ], $ mergeSettings );
242- }
239+ $ this ->algolia_helper ->setSettings ($ this ->getIndexName ($ storeId ) . '_ ' . $ values ['attribute ' ] . '_ ' . $ suffix_index_name . '_ ' . $ values ['sort ' ], $ mergeSettings );
243240 }
244241 }
245242 else
246243 {
247- $ sort_attribute = strpos ($ values ['attribute ' ], 'price ' ) !== false ? $ values ['attribute ' ]. '. ' . $ currencies [0 ]. '. ' . 'default ' : $ values ['attribute ' ];
244+ $ sort_attribute = strpos ($ values ['attribute ' ], 'price ' ) !== false ? $ values ['attribute ' ] . '. ' . $ currencies [0 ] . '. ' . 'default ' : $ values ['attribute ' ];
248245
249- $ mergeSettings ['ranking ' ] = array ($ values ['sort ' ]. '( ' . $ sort_attribute. ') ' , 'typo ' , 'geo ' , 'words ' , 'proximity ' , 'attribute ' , 'exact ' , 'custom ' );
246+ $ mergeSettings ['ranking ' ] = array ($ values ['sort ' ] . '( ' . $ sort_attribute . ') ' , 'typo ' , 'geo ' , 'words ' , 'proximity ' , 'attribute ' , 'exact ' , 'custom ' );
250247
251248 if ($ values ['attribute ' ] === 'price ' )
252- $ this ->algolia_helper ->setSettings ($ this ->getIndexName ($ storeId ) . '_ ' .$ values ['attribute ' ]. '_default_ ' . $ values ['sort ' ], $ mergeSettings );
249+ $ this ->algolia_helper ->setSettings ($ this ->getIndexName ($ storeId ) . '_ ' . $ values ['attribute ' ] . '_default_ ' . $ values ['sort ' ], $ mergeSettings );
253250 else
254- $ this ->algolia_helper ->setSettings ($ this ->getIndexName ($ storeId ) . '_ ' .$ values ['attribute ' ]. '_ ' . $ values ['sort ' ], $ mergeSettings );
255-
251+ $ this ->algolia_helper ->setSettings ($ this ->getIndexName ($ storeId ) . '_ ' . $ values ['attribute ' ] . '_ ' . $ values ['sort ' ], $ mergeSettings );
256252 }
257253 }
258254 }
@@ -355,6 +351,8 @@ protected function handlePrice(&$product, $sub_products, &$customData)
355351
356352 if ($ special_price && $ special_price < $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id ])
357353 {
354+ $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id . '_original_formated ' ] = $ customData [$ field ][$ currency_code ]['default_formated ' ];
355+
358356 $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id ] = $ special_price ;
359357 $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id . '_formated ' ] = $ this ->formatPrice ($ special_price , false , $ currency_code );
360358 }
@@ -381,6 +379,8 @@ protected function handlePrice(&$product, $sub_products, &$customData)
381379 $ _priceModel = $ product ->getPriceModel ();
382380
383381 list ($ min , $ max ) = $ _priceModel ->getTotalPrices ($ product , null , $ with_tax , true );
382+ $ min = (double ) $ min ;
383+ $ max = (double ) $ max ;
384384 }
385385
386386 if ($ type == 'grouped ' )
@@ -429,13 +429,17 @@ protected function handlePrice(&$product, $sub_products, &$customData)
429429 if ($ min != $ max && $ min <= $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id ])
430430 {
431431 $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id ] = 0 ;
432- $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id . '_formated ' ] = $ dashed_format ;
433432 }
433+ else
434+ {
435+ $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id ] = $ customData [$ field ][$ currency_code ]['default ' ];
436+ }
437+
438+ $ customData [$ field ][$ currency_code ]['group_ ' . $ group_id . '_formated ' ] = $ dashed_format ;
434439 }
435440 }
436441 }
437442
438-
439443 if ($ customData [$ field ][$ currency_code ]['default ' ] == 0 )
440444 {
441445 $ customData [$ field ][$ currency_code ]['default ' ] = $ min ;
0 commit comments