Magento – How to increase character limit of text field in Magento 2

magento-2.1.9product-attribute

I have one attribute named "Features". Values for this attribute are coming from Lightspeed pos and input type for this attribute is a text field. Light speed doesn't provide a text area for this attribute.

I want to increase the character limit for this field in the admin. Right now the limit is 255 chars. So, how can I increase this limit?

Best Answer

Unfortunately your attribute seams to be of type varchar and here you have a database restriction to 255 characters in for the value field of type varchar in the corresponding eav table catalog_product_entity_varchar.

You need an attribute of type text in order to store more data since then you will have a value field of type text with a restriction of 65,535 bytes in the corresponding eav table catalog_product_entity_text.

Now that's theory. Unfortunately Magento does not support the change of attribute type for good reason. Although there is a way doing that by database changes for varchar to text, I don't recommend that here - although for good reason :-)

I would suggest the following:

  1. Create a new attribute "features2" of type text
  2. Export the features for all existing products
  3. Import the data for all existing products into the new created attribute
  4. Rename the attributes so that the new created attribute will be named "features" (you may also delete the old attribute after that)

Of course you should test that approach in a test / stage environment before applying the changes in production.