/** * Set Group reduction if needed */ public function setGroupReduction() { $row = GroupReduction::getGroupByCategoryId((int) $this->id_category_default); if (!$row) { if (!GroupReduction::deleteProductReduction((int) $this->id)) { return false; } } else { if (!GroupReduction::setProductReduction((int) $this->id, $row['id_group'], (int) $this->id_category_default, (double) $row['reduction'])) { return false; } } return true; }