Change the scope of a attribute
-
16-10-2019 - |
Question
A extension created a extra tab in my category menu. With this code:
$setup->addAttribute('catalog_category', 'menutopdescription1', array(
'group' => 'General',
'input' => 'textarea',
'type' => 'text',
'label' => 'Topmenu description',
'backend' => '',
'visible' => 1,
'required' => 0,
'is_wysiwyg_enabled' => 1,
'visible_on_front' => 1,
'note'=>'Category description for top menu dropdown',
'is_html_allowed_on_front' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
This results in a global scope. Now I would like to change it to "website". So I can easily translate it for my other websites.
This attribute isn't visible in the attribute list of Magento, so I have to make the changes in the database. Which key do I have to change?
Solution
Create an upgrade script with this code:
$setup->updateAttribute('catalog_category', 'menutopdescription1', 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE);
$setup is an instance of Mage_Catalog_Model_Resource_Setup or Mage_Eav_Model_Entity_Setup.
If you want to change the db directly (I don't recommend it) you need to change the field is_global
to 2
from the table catalog_eav_attribute
for the record with the id the same as your attribute has in the eav_attribute
table.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange