2

I would like to do something as simple as create an upgrade script for an existing module to add custom category attributes. Unfortunately this has been anything but simple as no upgrade script is ever run. I've read about a dozen tutorials and stackoverflow questions to find an answer to no avail.

Below is my config.xml with version 0.2.1 at the top:

 <resources>
 <mymodule_services_setup>
 <setup>
 <module>MyModule_Services</module>
 <class>MyModule_Services_Model_Resource_Eav_Mysql4_Setup</class>
 </setup>
 <connection>
 <use>core_setup</use>
 </connection>
 </mymodule_services_setup>
 <mymodule_services_write>
 <connection>
 <use>core_write</use>
 </connection>
 </mymodule_services_write>
 <mymodule_services_read>
 <connection>
 <use>core_read</use>
 </connection>
 </mymodule_services_read>
 </resources>

The install script at MyModule/Services/sql/mymodule_services_setup/mysql4-upgrade-0.2.1.php:

 $installer = $this;
 //$installer->installEntities();
 Mage::log('running script', null, 'services_upgrade.log');
 $installer->startSetup();
 $installer->addAttribute('catalog_category', 'hide_page_title', array(
 'type' => 'int',
 'label' => 'Hide Page Title',
 'input' => 'select',
 'source' => 'eav/entity_attribute_source_boolean',
 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
 'required' => false,
 'default' => 0
 ));
 Mage::log('in the middle', null, 'services_upgrade.log');
 $installer->addAttribute('catalog_category', 'show_percentage_off', array(
 'type' => 'int',
 'label' => 'Show Percentage Off',
 'input' => 'select',
 'source' => 'eav/entity_attribute_source_boolean',
 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
 'required' => false,
 'default' => 0
 ));
 Mage::log('finished', null, 'services_upgrade.log');
 $installer->endSetup();

The Setup class (MyModule/Services/Model/Resource/Eav/Mysql/Setup.php) specified in the config.xml is there but empty as follows for now:

class MyModule_Services_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
{
}

Resource_core shows the module version being bumped up but the upgrade script is never run.

If anyone can give any help I would be eternally grateful as this simple task is taking hours.

Marius
199k55 gold badges431 silver badges837 bronze badges
asked Nov 29, 2013 at 13:38

1 Answer 1

7

i think you must enter:

MyModule/Services/sql/mymodule_services_setup/mysql4-upgrade-0.2.0-0.2.1.php:

to upgrade from 0.2.0 to 0.2.1 and then type 0.2.1 into config.xml <version> tag.

answered Nov 29, 2013 at 14:04
3
  • Nikitas you're my saviour! 4 hours of banging my head against a wall is finally over and I can now go to A&E. I'd vote you up but I have no reputation. Cheers, Kieron Commented Nov 29, 2013 at 14:11
  • no problem. glad to help! Commented Nov 29, 2013 at 17:02
  • Now upgrade-0.2.0-0.2.1.php works as per magento 2.0 standard Commented Sep 3, 2015 at 9:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.