Jump to content
alextn

Disable the EAN control function

Recommended Posts

Posted (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 by selectshop.at
mass capital letters on title removed

Share this post


Link to post
Share on other sites
I was wrong! I meant I emptied the cache. Can you help me?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Posted (edited)

Yess. Tnks...

Edited by alextn

Share this post


Link to post
Share on other sites
  • Members
  •  0
  • 21 messaggi

 

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 by alextn

Share this post


Link to post
Share on other sites

Hello, 

my problem is, i need 14 numbers. If i change the Value 13 to 14, dont work. 

Share this post


Link to post
Share on other sites

 

Where are you doing the tests? on the product or on one of the product combinations?

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

Where ist the cache file? And wich structure in the database i must change? 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More