Jump to content

[SOLVED] Change Back-office products field type


Arpels

Recommended Posts

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 by Arpels (see edit history)
Link to comment
Share on other sites

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

  • 2 weeks later...

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

  • 2 years later...

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...