Prestashop > 1.7.8 change UPC , name, meta and seo max lenght

P

With prestashop 1.7.8 update lot of thing change regarding field validation, so previous modification that work on prestashop version does not work.

This guide can help you to change lenght but also field content validation, this usually is used for change UPC lenght, name lenght, meta title , description lenght ecc.

1) Change every field lenght value in database, for example ps_product.upc and ps_product_lang.name and ps_product_attribute.upc according to the new value you need.

2) Change in Classes\Validate.php

Classes\Validate.php change isUpc validation to something like this:
return !$upc || preg_match(‘/^[^<>={}]*$/’, $upc);
or
#return !$upc || preg_match(‘/^[0-9]{0,255}$/’, $upc);

3) In src\PrestaShopBundle\Form\Admin\Product\ProductCombination.php change ‘attrivute_upc’ regex 0,12 to 0,255
new Assert\Regex(‘/^[0-9]{0,255}$/’), or to allow extra character:

new Assert\Regex([
‘pattern’ => ‘/^[^<>={}]*$/’
]),

4) Same in ProductOptions.php

5) in ProductSeo.php change meta_description and meta_title ‘counter’ => 128, to what do you have se in point 1.

6) in src\Core\Domain\Product\ProductSettings.php change constant value:
public const MAX_NAME_LENGTH = 192;

7) in \src\PrestaShopBundle\Form\Admin\Product\ProductInformation.php
chang new Assert\Length([‘min’ => 3, ‘max’ => 128]),

8) in src/Core/Domain/Product/ValueObject/Upc.php:
public const VALID_PATTERN = ‘/^[0-9]{0,12}$/’;
and
public const MAX_LENGTH = 255;

About the author

Avatar photo
Matteo Lavaggi