문제

Where is a problem ?

    $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();
도움이 되었습니까?

해결책

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

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top