Arpels Posted March 23, 2017 Share Posted March 23, 2017 (edited) Hello, I want to change the type of ean13 field to alloxw chars in it. I've updated the table structure, the field itself to allow more than 13 INT but when I put chars in it, it says it's not valid. How do I change/remove the control on the datatype of the field at save event AND in the import function for CSV upload ? Thanks ! Edited April 8, 2017 by Arpels (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted March 27, 2017 Share Posted March 27, 2017 This cannot be done only by changing Table Structure. You have to change the Validation criterial of "EAN-13" input field. By default, Prestashop validates all mandatory field before saving them into database through "Validate" class which can be found at the path given below - ROOT_DIRECTORY/classes/Validate.php To allow characters or any other required string, you have make changes in the function definition given below - public static function isEan13($ean13) { return !$ean13 || preg_match('/^[0-9]{0,13}$/', $ean13); } As of now, it only allows digits of length 0 to 13. You can simply remove this condition of regular expression to allow characters. Link to comment Share on other sites More sharing options...
Arpels Posted April 8, 2017 Author Share Posted April 8, 2017 Hello, I've manage to change the control that has prestashop over the field to enable chars input : For the ean13, as exemple, in /classes/order/OrderDetail.php I've changed isEan13 with isGenericName in the definition array. Link to comment Share on other sites More sharing options...
alextn Posted April 21, 2019 Share Posted April 21, 2019 (edited) Hi, I have the same problem as you. I changed the class this way but it still doesn't work. Can you tell me how you did it? return !$ean13 || preg_match('/^[0-9A-Z]{0,13}$/', $ean13); Edited April 21, 2019 by alextn (see edit history) 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