Simonas Invertus Posted May 9, 2016 Share Posted May 9, 2016 Could somebody please me explain what is happening? classes/SpecificPrice.php protected static function filterOutField($field_name, $field_value, $threshold = 1000) { $query_extra = 'AND `'.$field_name.'` = 0 '; if ($field_value == 0 || array_key_exists($field_name, self::$_no_specific_values)) { return $query_extra; } $key_cache = __FUNCTION__.'-'.$field_name.'-'.$threshold; $specific_list = array(); if (!array_key_exists($key_cache, SpecificPrice::$_filterOutCache)) { $query_count = 'SELECT COUNT(DISTINCT `'.$field_name.'`) FROM `'._DB_PREFIX_.'specific_price` WHERE `'.$field_name.'` != 0'; $specific_count = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query_count); if ($specific_count == 0) { self::$_no_specific_values[$field_name] = true; return $query_extra; } if ($specific_count < $threshold) { $query = 'SELECT DISTINCT `'.$field_name.'` FROM `'._DB_PREFIX_.'specific_price` WHERE `'.$field_name.'` != 0'; $tmp_specific_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); foreach ($tmp_specific_list as $key => $value) { $specific_list[] = $value[$field_name]; } } SpecificPrice::$_filterOutCache[$key_cache] = $specific_list; } else { $specific_list = SpecificPrice::$_filterOutCache[$key_cache]; } // $specific_list is empty if the threshold is reached if (empty($specific_list) || in_array($field_value, $specific_list)) { $query_extra = 'AND `'.$field_name.'` '.self::formatIntInQuery(0, $field_value).' '; } return $query_extra; } Why $threshold = 1000? If you have 999 discounted products discounts are shown. If you have 1001 discounted products discounts are not shown. What is the logic? Why I can not have a lot of discounted products? Link to comment Share on other sites More sharing options...
musicmaster Posted May 10, 2016 Share Posted May 10, 2016 (edited) I haven't studied this extensively. But it seems to me not more than logical to have a limit. If there would be a million discount records your function would likely timeout and give you a white screen - not really what you want. Besides that, this 1000 is only a default value. It can be overruled when you call the function. Edited May 10, 2016 by musicmaster (see edit history) Link to comment Share on other sites More sharing options...
Simonas Invertus Posted May 10, 2016 Author Share Posted May 10, 2016 Yes, you are write white screen is not what I want but, disappearing discounts are also not what I want. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now