8

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?

17

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.

| improve this answer | |
  • You can replace 'catalog_category' with Mage_Catalog_Model_Category::ENTITY – Dan Apr 8 '14 at 9:51
  • @Dan. I would If I could but I don't want to. :D. now seriously...that will work also. thanks – Marius Apr 8 '14 at 9:54
  • The snippet above did not work for me. Instead what I had to do was: $installer->updateAttribute('Mage_Catalog_Model_Category::ENTITY', 'menutopdescription1', 'is_global', '0'); – Louis B. May 19 '15 at 13:49
  • 2
    @LouisBataillard I've edited the answer (waiting on approval). 'global' is used during attribute creation, which is passed through a _prepareValues() method. And modified to 'is_global'. Why the developers do this I don't know (i find it confusing to change how we reference the same thing). 'is_global' is the actual attribute's "attribute". And this is the key we want to reference during updates to attributes. – Darren Felton Aug 19 '15 at 15:44
  • What if i have to change scope to Globle instaed website in DB? – Ketan Borada Feb 14 '19 at 6:45

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.