diego Posted August 21, 2018 Share Posted August 21, 2018 Hi everyone, I'm modifying the controller AdminProductController.php to do some controls on the BO side on SKU. However, I have the problem of showing an error message to the user when a condition occurs on the update of the product, but this is not displayed. What I do now is this: I modified the file controller-> admin-> AdminProductController.php adding this function public function checkUniqueRef() { $reference = Tools::getValue('reference'); $idproduct = Tools::getValue('id_product'); if ($reference!=""){ $sql = 'SELECT id_product FROM `'._DB_PREFIX_.'product` WHERE reference="'.$reference.'" AND id_product<>'.$idproduct; $res = Db::getInstance()->getValue($sql); if($res) { $this->errors[] = $this->trans('Product with this reference is already exists.', array(), 'Admin.Notifications.Error'); //alternative //$this->errors[] = sprintf(Tools::displayError('Product with reference %s is already exists.'), $reference); } } } and i call here: public function checkProduct() { $this->checkUniqueRef(); if (!empty($this->errors)) { $this->display = 'update'; return false; } however, if the error is found, the error message is not displayed, but the success message for the update is displayed. If I insert an echo ("hello") statement inside the condition if ($ res) {....} a generic error is displayed that is not for me. Do you have any suggestions? thanks in advance to those who want to help me! 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