I am trying to add an attribute like product_id for products that will have auto_increment.

What I did so far and is not working:


<?xml version="1.0"?>

The model:

class Mymodule_Model_Myitem extends Mage_Core_Model_Abstract {
 //this method simply adds one to the increment id an returns the new one
    public function getIncrementId(){
        return Mage::getSingleton('eav/config')

protected function _beforeSave()


    if (!$this->getIncrementId()) {
        $incrementId = Mage::getSingleton('eav/config')



and the installer script:

$install = $this;

$install->addEntityType('mymodule', array(
    'entity_model'          => 'mymodule',
    'increment_model'       => 'eav/entity_increment_numeric',
    'increment_per_store'   => false,

$entityType = Mage::getModel('eav/entity_type')->loadByCode('custom_sku2');
$entityStoreConfig = Mage::getModel('eav/entity_store')->loadByEntityStore($entityType ->getId(), 12);
$entityStoreConfig->setEntityTypeId($entityType ->getId())


Then I create an attribute the normal way in Magento with the name "custom_sku2" and I add this attribute in products grid. Even after save i cannot see this attribute auto increment, it is blank.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.