Size SKU in Magento


How can I allow SKU be longer than 34 characters (for simple products) for all products?

When i add new product(simple) and enter more than 34 characters, Magento cuts it to 34 after saving.

In the database the 'sku' attributes ( for quete item,order item,invoice item, shipment item) from eav_attribute table hold varchar(255). For Catalog_Product_Entity the attributed is VarChar(64). In either case, it is more than 34characters. Thus, I could change SKU to 64 characters without making any change in database, correct?

How do i do that? I have good understanding of the user side magento code, but not Admin side. Can you suggest me good tutorial on making changes in Admin side that could help me figure this question myself.

Thank you, Margots

3/23/2010 9:38:06 AM

Accepted Answer

@latvian The kind of modification that you propose as a solution is not a very good idea as it breaks compatibility with the core installation and it may create unpredicted behaviour in the future when upgrading the core. This quick and dirty way of solving problems will only create problems in the future.

What I recommend is adding a custom attribute to the product object called custom_sku that can be a string and you can make it as long as you want. Here is a link on how to add a custom attribute to your installation.

3/23/2010 9:37:21 AM

There's more to it than this even....

Change SKU field in: catalog_product_entity to varchar(255) Change SKU field in: catalog_product_flat_some_number to varchar(255)

And then you will have to edit the Sku.php so the validation wont trigger in the admin.

Change: const SKU_MAX_LENGTH = 64;

to: const SKU_MAX_LENGTH = 255;

That will allow the max_length to be 255 instead of 64.. make it whatever you'd like.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow