Namor Esther Posted February 11, 2020 Share Posted February 11, 2020 Hello, My Prestashop version is 1.7.2. I'll try to be as clear as I can. I have created many reductions for many client groups on my Prestashop. Those reductions are connected with product categories. But, when I change the category of a product, its reduction doesn't change, I have to go on client groups page and save each group. I have checked database and I found that was because ps_product_group_cache table was not updated on category change. I think about a solution, but I don't know if it could work : I've found that the update of this table was made in "classes/GroupReduction.php", in update() method, maybe I could call it with a button to update all reductions in one click. Here is the method update() and _updateCache() in "classes/GroupReduction.php" : public function update($null_values = false) { return (parent::update($null_values) && $this->_updateCache()); } protected function _updateCache() { $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_product` cp WHERE cp.`id_category` = '.(int)$this->id_category, false); $ids = array(); foreach ($products as $product) { $ids[] = $product['id_product']; } $result = true; if ($ids) { $result &= Db::getInstance()->update('product_group_reduction_cache', array( 'reduction' => (float)$this->reduction, ), 'id_product IN('.implode(', ', $ids).') AND id_group = '.(int)$this->id_group); } return $result; } Thanks for answers, Namor. 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