cancel
Showing results for 
Search instead for 
Did you mean: 

SKU length issue

SKU length issue

Hi,

  I wanted to change sku length from 64 to 255.
i changed the number in sku.php and in database i changed the sku length in tables eav_attribute and catalog_product_entity.
when i am saving a configurable product, sku length issue is still showing on configurations. Could you please help me on it? 

 

I'm using Magento 2. There is no issue with simple products too

1 REPLY 1

Re: SKU length issue

Hello @magento789 

 

To change the SKU length from 64 to 255 characters in Magento 2, you need to perform the following steps:

  • Backup your database: Before making any changes, it's crucial to create a backup of your Magento database.
  • Locate the SKU attribute: The SKU attribute is stored in the eav_attribute table in the database. Use a database management tool (e.g., phpMyAdmin, MySQL command line) to execute the following SQL query:
    • SELECT * FROM eav_attribute WHERE attribute_code = 'sku';
  • This query will retrieve the record corresponding to the SKU attribute.
  • Modify the SKU attribute length: Update the backend_type and frontend_class fields of the SKU attribute record to reflect the desired length. Execute the following SQL query, replacing [your_new_length] with the desired length (e.g., 255):
    • UPDATE eav_attribute SET backend_type = 'varchar', frontend_class = NULL WHERE attribute_code = 'sku';
  • Modify the SKU column length in the database: The SKU attribute change will not take effect until you modify the corresponding SKU column in the appropriate tables. Execute the following SQL queries to update the SKU column length in the required tables:
    • ALTER TABLE catalog_product_entity MODIFY sku VARCHAR(255);
    • ALTER TABLE catalog_product_entity_decimal MODIFY sku VARCHAR(255);
    • ALTER TABLE catalog_product_entity_int MODIFY sku VARCHAR(255);
    • ALTER TABLE catalog_product_entity_text MODIFY sku VARCHAR(255);
    • ALTER TABLE catalog_product_entity_varchar MODIFY sku VARCHAR(255);
  • These queries update the SKU column length in various product-related tables.
  • Clear cache and reindex: Clear the Magento cache and reindex the data by running the following commands from your Magento root directory:
    • php bin/magento cache:clean
    • php bin/magento cache:flush
    • php bin/magento indexer:reindex
  • This step ensures that the changes take effect and that the SKU attribute is updated across the system.

If you find our reply helpful, please give us kudos.

 

A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.

 

WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9