ibrahimovich87 Posted May 3, 2018 Share Posted May 3, 2018 (edited) Hello everyone. I would like to know how to make the 'Reference code' field as required, and that the value must be unique, cannot be repeated? And if possible (optional but preferable), warning will be shown if repeated Reference code is detected. I did tried to search for the solution but I couldn't find any. Appreciate everyone's feedbacks. Many thanks! I am using PrestaShop version: 1.7.2.5 Edited May 5, 2018 by selectshop.at title editted by moderator (see edit history) Link to comment Share on other sites More sharing options...
ibrahimovich87 Posted May 4, 2018 Author Share Posted May 4, 2018 I've finded this solution, but on my PS 1.7.2.5 non function " To make Product Reference unique open AdminProductsController.php ( /controllers/admin/AdminProductsController.php ) Find function checkProduct() , it should be like this public function checkProduct() and add this line in starting of checkProduct() function if( Tools::getValue('id_product') == 0) $this->checkUniqueRef(); and at the end of file ( before last curly brace ) add following function public function checkUniqueRef() { $reference = Tools::getValue('reference'); $sql = 'SELECT id_product FROM `'._DB_PREFIX_.'product` WHERE reference="'.$reference.'" '; $res = Db::getInstance()->getValue($sql); if($res) { $this->errors[] = sprintf(Tools::displayError('Product with reference %s is already exists.'), $reference); } } CAn anyone 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