0

I have this error: Wrong attribute set ID , where is a problem

I tried this:

$installer = $this;
$installer->startSetup();
Mage::log("other_setup_addAttribute UPGRADE 0.0.1 -> 0.0.2 START");

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$data=array(
    'type'=>'varchar',
    'input'=>'text',
    'sort_order'=> 7, //under visibility field
    'label'=>'Promotion %',
    'global'=>Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'required'=>'0',
    'comparable'=>'0',
    'searchable'=>'0',
    'is_configurable'=>'1',
    'user_defined'=>'1',
    'visible_on_front' => 1,
    'visible_in_advanced_search' => 0,
    'is_html_allowed_on_front' => 0,
    'unique'=> false
);

$setup->addAttribute('catalog_product','sd_promotion_label',$data);

$attributeId= $setup->getAttribute('catalog_product','sd_promotion_label');


$setup->addAttributeToSet(
                          'catalog_product', 'Default', 'General', $attributeId
);

Mage::log("other_setup_addAttribute 0.0.1 -> 0.0.2 END");
$installer->endSetup();

EDIT

$installer = $this;
$installer->startSetup();
Mage::log("other_setup_addAttribute UPGRADE 0.0.2 -> 0.0.3 START");

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$data=array(
    'type'=>'varchar',
    'input'=>'text',
    'sort_order'=> 7, //under visibility field
    'label'=>'Promotion %',
    'global'=>Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'required'=>'0',
    'comparable'=>'0',
    'searchable'=>'0',
    'is_configurable'=>'1',
    'user_defined'=>'1',
    'visible_on_front' => 1,
    'visible_in_advanced_search' => 0,
    'is_html_allowed_on_front' => 0,
    'unique'=> false
);

$setup->addAttribute('catalog_product','sd_promotion_label',$data);

$attributeId= $setup->getAttribute('catalog_product','sd_promotion_label');

$_attributeSetId = $setup->getAttributeSetId('catalog_product','Default');//default
$_attributeGroupId = $setup->getAttributeGroup('catalog_product',$_attributeSetId,'General'); //General

$setup->addAttributeToSet(
    'catalog_product', $_attributeSetId, $_attributeGroupId, $attributeId
);

Mage::log("other_setup_addAttribute 0.0.2 -> 0.0.3 END");
$installer->endSetup();
1

You are trying to pass the name of the attribute set ID and attribute group ID instead of the ID itself. Look up the ID first before trying to add it like this:

$_attributeSetId = $setup->getAttributeSetId('catalog_product','Default');
$_attributeGroupId = $setup->getAttributeGroup('catalog_product',$_attributeSetId,'General');

Replace your addAttributeToSet with this:

$setup->addAttributeToSet(
                          'catalog_product', $_attributeSetId, $_attributeGroupId, $attributeId
);
2
  • I have the same error: Wrong attribute set ID – PЯINCƏ Jan 20 '17 at 9:00
  • This is not a really solution but +1 for your effort seanbreeden – PЯINCƏ Jan 20 '17 at 17:55
0

I found the solution of the error, magento tries to get the id of the "Default" attribute while it does not exist !

$_attributeSetId = $setup->getAttributeSetId('catalog_product','Default'); <- this one.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.