cancel
Showing results for 
Search instead for 
Did you mean: 

Saving SKU in Product ID

Saving SKU in Product ID

I want to save sku in Product id, is it possible?

I tried making changes to the Mage/Adminhtml/controllers/Catalog/ProductController.php

but it doesn't help. Please guide if anyone knows about it.

1 REPLY

Re: Saving SKU in Product ID

Extension used before -> https://github.com/schmengler/AutoSKU

Probably this extension already solves your problem but I will explain the important parts:

  • set the SKU attribute to "not required" so that you can leave it empty
  • change the backend model of the SKU attribute to set a value in its _beforeSave() method if the value is not set yet.
  • if you use product import, you cannot leave the SKU blank, otherwise your import data is considered invalid and cannot be parsed. This is at least true for the Magento core import (Mage_ImportExport), any import that is based on this (like AvS_FastSimpleImport) and the Magmi importer. In the AutoSKU extension I solved this with a prefix for temporary SKUs, so you can import products as "tmp1", "tmp2", ... and after import those can be converted automatically.

Disadvantage of your approach, using the product id, is that you will have to use _afterSave() for new products and then save a second time because you don't know the ID beforehand. In the AutoSKU extension, I choose the increment backend model to generate SKUs, so this was not a problem.