I want that the maximum of character of product name attribute is 50 character per example in the back office.
I can not find that on default input validation on product name attribute managing.
Help plz
2 Answers 2
In the table eav_attribute there is column frontend_class where right now, the value for the name attribute is validate-length maximum-length-255 you can change the value of the maximum-length-255 number to the one you want. e.g. maximum-length-50.
This will change the js validation of the field in the admin area.
- 
 Is there anyway to do so without database?Toranto mina– Toranto mina2021年04月01日 19:25:51 +00:00Commented Apr 1, 2021 at 19:25
- 
 Its a lot more complicated to do it with code, the admin product form is getting created with the UI Components and the attributes created in Magento are getting added automaticaly to some LayoutProcessor. Usually in UI component you can change the xml where the UI component is getting created but for the EAV attributes they are being added automatically. If I will find some free time I will look it up, but I think I lead you to the right direction.Vyacheslav Shmal– Vyacheslav Shmal2021年04月01日 20:13:59 +00:00Commented Apr 1, 2021 at 20:13
- 
 great approach !!! Thanks ShmalGiga Todadze– Giga Todadze2022年12月28日 05:38:07 +00:00Commented Dec 28, 2022 at 5:38
There are 2 Way to handle this product name
- Open Your database , go to catalog_product_entity_varchar,Change The structure of value column.
(But Their is some little problem -: For Other Attributes, That are store in this table also are affected)
(OR)
- That code you used for showing product name. - <?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
you need to change here:-
<?php /* @escapeNotVerified */ $name = $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
<?php echo $name = strlen($name ) > 50 ? substr($name ,0,50)."..." : $name ;?>
This is only for list.phtml .Similarly You Can also do it for other pages.
- 
 Thank you for your answer but my question is about admin, when we try to save a product on manage product, i want that name wont be more than 50 character.Toranto mina– Toranto mina2021年04月01日 17:08:53 +00:00Commented Apr 1, 2021 at 17:08