alextn Posted April 20, 2019 Share Posted April 20, 2019 (edited) Hi everyone, Prestashop 1.7. I need to modify for reasons I am not explaining the isEan13 function so that in the EAN 13 field letters and numbers can be entered without any control. I opened the classes / validate / validate.php file and modified the isEan13 function like this: public static function isEan13 ($ ean13) { return is_string ($ ean13); } Entering numbers all ok, entering text letters, I always get the error This value is not valid. Any help please? PS cash emptied Edited May 7, 2019 by selectshop.at mass capital letters on title removed (see edit history) Link to comment Share on other sites More sharing options...
alextn Posted April 21, 2019 Author Share Posted April 21, 2019 I was wrong! I meant I emptied the cache. Can you help me? Link to comment Share on other sites More sharing options...
musicmaster Posted May 7, 2019 Share Posted May 7, 2019 From the top of my head: - this function is called from a table in the Validate.php Class file. - That table also contains a field that this is numeric Link to comment Share on other sites More sharing options...
alextn Posted May 7, 2019 Author Share Posted May 7, 2019 (edited) Yess. Tnks... Edited May 7, 2019 by alextn (see edit history) Link to comment Share on other sites More sharing options...
Birnex Posted May 19, 2019 Share Posted May 19, 2019 Hello, can you explain what you do to solve the Problem? Link to comment Share on other sites More sharing options...
alextn Posted May 19, 2019 Author Share Posted May 19, 2019 (edited) Members 0 21 messaggi Segnala messaggio Inviato 24 Aprile Solution: ////////////////////////////////////////////////////////////////////// make the following changes FILE: classes/Validate.php public static function isEan13($ean13) { return !$ean13 || preg_match('/^[0-9]{0,13}$/', $ean13); } it becomes public static function isEan13($ean13) { return !$ean13 || preg_match('/^[a-zA-Z0-9]{0,13}$/', $ean13); } ////////////////////////////////////////////////////////////////////// FILE: src\PrestaShopBundle\Form\Admin\Product/ProductOptions.php ->add('ean13', FormType\TextType::class, [ 'required' => false, 'error_bubbling' => true, 'label' => $this->translator->trans('EAN-13 or JAN barcode', [], 'Admin.Catalog.Feature'), 'constraints' => [ new Assert\Regex('/^[0-9]{0,13}$/'), ], 'empty_data' => '', ]) it becomes ->add('ean13', FormType\TextType::class, [ 'required' => false, 'error_bubbling' => true, 'label' => $this->translator->trans('EAN-13 or JAN barcode', [], 'Admin.Catalog.Feature'), 'constraints' => [ new Assert\Regex('/^[a-zA-Z0-9]{0,13}$/'), ], 'empty_data' => '', ]) ////////////////////////////////////////////////////////////////////// Edited May 19, 2019 by alextn (see edit history) Link to comment Share on other sites More sharing options...
Birnex Posted May 19, 2019 Share Posted May 19, 2019 Hello, my problem is, i need 14 numbers. If i change the Value 13 to 14, dont work. Link to comment Share on other sites More sharing options...
alextn Posted May 19, 2019 Author Share Posted May 19, 2019 Where are you doing the tests? on the product or on one of the product combinations? Link to comment Share on other sites More sharing options...
Birnex Posted May 19, 2019 Share Posted May 19, 2019 What for a test? I change the part: Assert\Regex('/^[a-zA-Z0-9]{0,13}$/'), NEW Assert\Regex('/^[a-zA-Z0-9]{0,14}$/'), the Page works. But i cant open the Admin page. Link to comment Share on other sites More sharing options...
alextn Posted May 19, 2019 Author Share Posted May 19, 2019 src\PrestaShopBundle\Form\Admin\Product/ProductOptions.php src\PrestaShopBundle\Form\Admin\Product/ProductCombination.php FILE: classes/Validate.php replace the attached files with the original ones in the respective prestashop positions - version 1.7 only. Clear the cache, and try again. ProductCombination.php ProductOptions.php Validate.php Link to comment Share on other sites More sharing options...
Birnex Posted May 19, 2019 Share Posted May 19, 2019 I do the change only in ProductOptions and Validate.php. ok i try it Link to comment Share on other sites More sharing options...
Birnex Posted May 19, 2019 Share Posted May 19, 2019 I do the change only in ProductOptions and Validate.php. ok i try it Link to comment Share on other sites More sharing options...
Birnex Posted May 19, 2019 Share Posted May 19, 2019 I check the files. There is no change in the EAN 13. i need 14 numbers. Link to comment Share on other sites More sharing options...
alextn Posted May 19, 2019 Author Share Posted May 19, 2019 change the number 13 with 14 on the function, on all 3 files I have attached to it. Clear the cache, and try again. must work. be very careful the cache Link to comment Share on other sites More sharing options...
musicmaster Posted May 19, 2019 Share Posted May 19, 2019 Don't forget to adapt the fieldsize in the database Link to comment Share on other sites More sharing options...
Birnex Posted May 19, 2019 Share Posted May 19, 2019 Where ist the cache file? And wich structure in the database i must change? Link to comment Share on other sites More sharing options...
boon802 Posted March 19, 2020 Share Posted March 19, 2020 Hello, I am on 1.6 prestashop. I change Validate.php but i don't find the other files Do you know the name of files i need to change for Letter in EAN 13 ? Thanks a lot Link to comment Share on other sites More sharing options...
Sviz Posted July 2, 2021 Share Posted July 2, 2021 Hi, I'm on ps 1.7.7.5, I need to use a 14 numbers EAN code 1) I made changes on files src\PrestaShopBundle\Form\Admin\Product/ProductOptions.php src\PrestaShopBundle\Form\Admin\Product/ProductCombination.php FILE: classes/Validate.php 2) I've adapted the fieldsize in the database 3) I Cleared the cache but doesn't work do i have to do something else? Thanks 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