acpkor Posted November 10, 2022 Share Posted November 10, 2022 Hello, I want to enter letters and numbers in the UPC field in the product file. From "phpadmin" inside the table "pr_prodcuts" I can. But from the back office it won't let me.. What file should I modify to let me enter letters from the back office? Thank you! Link to comment Share on other sites More sharing options...
ventura Posted November 10, 2022 Share Posted November 10, 2022 It would be necessary to modify the validation, with an override in function isUpc class Validate.php Link to comment Share on other sites More sharing options...
acpkor Posted November 10, 2022 Author Share Posted November 10, 2022 Thank you, I have modified this: public static function isUpc($upc) { return !$upc || preg_match('/^[0-9]{0,12}$/', $upc); } For this public static function isUpc($upc) { return true; // return !$upc || preg_match('/^[0-9]{0,12}$/', $upc); } But it's not working It still won't let me put lyrics. should i do it another way? Link to comment Share on other sites More sharing options...
ventura Posted November 10, 2022 Share Posted November 10, 2022 To allow numbers and letters it would have to be something like this public static function isUpc($upc) { return !$upc || preg_match('/^[a-zA-Z0-9]{0,12}$/', $upc); } Or edit de validation field in classes/Product.php Link to comment Share on other sites More sharing options...
acpkor Posted November 10, 2022 Author Share Posted November 10, 2022 Thank you, But I can't. I have modified as you say. The file that I modify is: /classes/Validate.php But it still doesn't let me put lyrics Link to comment Share on other sites More sharing options...
acpkor Posted November 10, 2022 Author Share Posted November 10, 2022 in classes/Product.php what should i edit? Link to comment Share on other sites More sharing options...
ventura Posted November 10, 2022 Share Posted November 10, 2022 The form upc field includes a validation pattern. It´s necessary to modify the constraints /src/PrestaShopBundle/Form/Admin/Product/ProductOptions.php ->add('upc', FormType\TextType::class, [ 'required' => false, 'label' => $this->translator->trans('UPC barcode', [], 'Admin.Catalog.Feature'), 'constraints' => [ new Assert\Regex('/^[a-zA-Z0-9]{0,12}$/'), ], 'empty_data' => '', ]) 1 Link to comment Share on other sites More sharing options...
acpkor Posted November 11, 2022 Author Share Posted November 11, 2022 I have made the change and it doesn't work either. It still won't let me put lyrics. Do I have to modify something in classes/Product.php ? Link to comment Share on other sites More sharing options...
acpkor Posted November 11, 2022 Author Share Posted November 11, 2022 and besides, now it doesn't work with just numbers... Have I changed something wrong...? Link to comment Share on other sites More sharing options...
acpkor Posted November 11, 2022 Author Share Posted November 11, 2022 RESOLVED left over in /classes/Validate.php one {0,12}$ { return !$upc || preg_match('/^[a-zA-Z0-9]{0,12}${0,12}$/', $upc); } Now it works fine. Thank you very much! Link to comment Share on other sites More sharing options...
QuickUpdate.net Posted November 13, 2022 Share Posted November 13, 2022 Are letters in UPC barcode standard? Link to comment Share on other sites More sharing options...
acpkor Posted November 14, 2022 Author Share Posted November 14, 2022 good morning, With the information provided by "ventura", letters can be entered in the UPC field. You have to make the changes indicated in the /classes/Validate.php file public static function isUpc($upc) { return !$upc || preg_match('/^[a-zA-Z0-9]{0,12}$/', $upc); } and /src/PrestaShopBundle/Form/Admin/Product/ProductOptions.php ->add('upc', FormType\TextType::class, [ 'required' => false, 'label' => $this->translator->trans('UPC barcode', [], 'Admin.Catalog.Feature'), 'constraints' => [ new Assert\Regex('/^[a-zA-Z0-9]{0,12}$/'), ], 'empty_data' => '', ]) a greeting 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