Jump to content

Enter letters in UPC field


acpkor

Recommended Posts

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

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

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' => '',
            ])

 

  • Like 1
Link to comment
Share on other sites

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

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
×
×
  • Create New...