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.
1 Answer 1
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.
-
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, Kieronkieron– kieron2013年11月29日 14:11:00 +00:00Commented Nov 29, 2013 at 14:11
-
no problem. glad to help!Nikitas– Nikitas2013年11月29日 17:02:48 +00:00Commented Nov 29, 2013 at 17:02
-
Now
upgrade-0.2.0-0.2.1.phpworks as per magento 2.0 standardPratik Joshi– Pratik Joshi2015年09月03日 09:36:53 +00:00Commented Sep 3, 2015 at 9:36