tags:

views:

440

answers:

2

Hi,

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

A: 

Hi there...i got this myself. Here is what I did.

First,I made mistake on counting in the above. By default Magento lets SKU# be 64 max long. This is because the shortest of the SKU attributes( in table catalog_product_entity) in the DB is set to varchar(64).

  1. Change SKU attribute in catalog_product_entity table to varchar(255) or any length you want. If this length is less than 255 you are fine otherwise you have to change other SKU attributes such as Order SKU, Quote SKu and other in the DB

  2. By setting the SKU length too large it breaks the grid in the Catalog->Product Manage. One solutions is to insert following code in /design/adminhtml/default/default/template/widget/grid.phtml line 157 (after this line: getCollection() as $_index=>$_item): ?>)

getData('sku'); if(strlen($sku)>60){ $sku = substr($sku,0,60); } $_item->setData('sku',$sku); ?>

Now even though you will not be able to see the full SKU number in Catalog->Product Manage, you will see full SKU when double click/edit the product individually.

I hope it was useful.

Best

latvian
+1  A: 

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

Elzo Valugi
Thank You Elzo...that is good solution, however, not too practical... if company has over 80k parts and other modules relay on sku particular then switching to custom_sku you would have to rewrite the other modules and add custom_sku for each product. ...a lot of work. My solution may be vulnerable to the upgrade but what is the possibility that the upgrade will alter DB field such as SKU(atleast i cannot think of why). The other change can be overwriten in layout xml file and now worries then.
latvian
In short, I don't disagree with you. Your solution is better but not too practical in our case...we may have to regret later and then i will come find you:)
latvian