cernicektomas Posted September 15, 2016 Share Posted September 15, 2016 Hi, please I have one simple beginner question. In which file I can change max lenght of some customer values - eg. name, surname, company etc. - in PrestaShop 1.6.1.5. Thank you very much in advance. Tomas Link to comment Share on other sites More sharing options...
rocky Posted September 17, 2016 Share Posted September 17, 2016 The sizes are all in the $definition variable in classes/Customer.php. Let's say you have customers with really long surnames and you want to increase the maximum length to 64. You can override the maximum size by creating override/classes/Customer.php like this: <?php class Customer extends CustomerCore { public function __construct($id = null) { CustomerCore::$definition['fields']['lastname']['size'] = 64; parent::__construct(); } } This will increase the maximum size of the last name from 32 to 64. Note that you'll need to also edit the ps_customer table in your database using phpMyAdmin and change the size of lastname from varchar(32) to varchar(64). You can add more lines like above if you need to increase the maximum size of more customer variables. You can find the names of the variables in classes/Customer.php. After making these changes, go to the Advanced Parameters > Performance tab and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override. Link to comment Share on other sites More sharing options...
cernicektomas Posted September 17, 2016 Author Share Posted September 17, 2016 The sizes are all in the $definition variable in classes/Customer.php. Let's say you have customers with really long surnames and you want to increase the maximum length to 64. You can override the maximum size by creating override/classes/Customer.php like this: <?php class Customer extends CustomerCore { public function __construct($id = null) { CustomerCore::$definition['fields']['lastname']['size'] = 64; parent::__construct(); } } This will increase the maximum size of the last name from 32 to 64. Note that you'll need to also edit the ps_customer table in your database using phpMyAdmin and change the size of lastname from varchar(32) to varchar(64). You can add more lines like above if you need to increase the maximum size of more customer variables. You can find the names of the variables in classes/Customer.php. After making these changes, go to the Advanced Parameters > Performance tab and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override. Thank you very much for the solution. Link to comment Share on other sites More sharing options...
Alsernet2000 Posted September 12, 2017 Share Posted September 12, 2017 (edited) It is missing one thing: You have to pass the $id to the parent construct: <?php class Customer extends CustomerCore { public function __construct($id = null) { CustomerCore::$definition['fields']['lastname']['size'] = 64; parent::__construct($id); } } But thanks for this code, It was really helpful. Edited September 12, 2017 by Alsernet2000 (see edit history) 2 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