miekka Posted January 19, 2012 Share Posted January 19, 2012 Hi, Is there a way to validate reference number when adding a new product? Iam wondering how to make sure that there won't be products with same number by mistake. Anssi Link to comment Share on other sites More sharing options...
phrasespot Posted January 21, 2012 Share Posted January 21, 2012 Is there a way to validate reference number when adding a new product? Iam wondering how to make sure that there won't be products with same number by mistake. Two different things. To ensure the uniqueness of each reference change the column of PREFIX_product table, reference column to be UNIQUE (make a backup first). ALTER TABLE `your_database`.`PREFIX_product` ADD UNIQUE INDEX `unique_reference`(`reference`); Uniqueness will be enforced by the DB and if you try to enter a duplicate reference you will get an error. To answer the validation question I need to know the format of the reference numbers you are using. Link to comment Share on other sites More sharing options...
ayin Posted November 15, 2014 Share Posted November 15, 2014 Hello, I am using Prestashop 1.6 and I wonder if you can explain where i should include the validation for the back-office. Should i change the file "\classes\Product.php", at line 247: public static $definition = array( (...) 'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32), and add ", 'validate' => 'checkUniqueRef' " and insert into the file '\classes\Validade.php' the an validation like: public static function checkUniqueRef($reference) { return <DB..SQL... select ... from product... where referece = $reference>; } Is that the way to get unique reference validation in Prestashop back office? Thanks 1 Link to comment Share on other sites More sharing options...
Divyesh Prajapati Posted March 26, 2015 Share Posted March 26, 2015 Hi All, Seems old post. But if any one wants to have unique reference number for product and do't want to have duplicate entries for reference then I have posted solution here.... https://www.prestashop.com/forums/topic/395050-products-reference-code-field-to-be-required-and-unique/?do=findComment&comment=2016160 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