0

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

asked Apr 1, 2021 at 15:53

2 Answers 2

1

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.

answered Apr 1, 2021 at 19:21
3
  • Is there anyway to do so without database? Commented 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. Commented Apr 1, 2021 at 20:13
  • great approach !!! Thanks Shmal Commented Dec 28, 2022 at 5:38
0

There are 2 Way to handle this product name

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

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

answered Apr 1, 2021 at 16:58
1
  • 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. Commented Apr 1, 2021 at 17:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.