Since couple of weeks I'm trying to understand Magento, it's structure, mechanisms and I'm stuck on scripts creating for example additional columns in tables.
In my config.xml
script I have:
<?xml version="1.0"?>
<config >
< modules >
< Inchoo_Orders >
<version>0.0.0.3< /version>
< /Inchoo_Orders>
< /modules>
<global>
<models>
<inchoo_orders>
<class>Inchoo_Orders_Model</class>
enter preformatted text here
<resourceModel>inchoo_orders_resource</resourceModel>
</inchoo_orders>
</models>
<resources>
<inchoo_orders_setup>
<setup>
<module>Inchoo_Orders</module>
<class>Inchoo_Orders_Model_Mysql4_Setup</class>
</setup>
</inchoo_orders_setup>
</resources>
......
My Sql script name is: mysql4-upgrade-0.0.0.2-0.0.0.3.php
But it won't update table. What I'm doing wrong ?
Getting error:
Fatal error: Class 'Inchoo_Orders_Model_Mysql4_Setup' not found in
/home/…/app/code/core/Mage/Core/Model/Resource/Setup.php
on line 234
If I change class to Mage_Core_Model_Resource_Setup
not giving me any errors but also I can't see it work.
Best Answer
Mysql4 is actually deprecated. However, if your Mysql4_Setup file lives within the resource directory, you will need to change the class name to
Inchoo_Orders_Model_Resource_Mysql4_Setup
.If you are just trying to update a table and not much else, you should be able to just change
to
If you need some sort of custom functionality that will live in your own Setup class, create this file.
And remember to add this to your config.xml file:
If you need instruction on how to actually update the table itself, let me know.
Based on our continued discussion in the comments, it has been determined that all you really want to do here is add an attribute programatically.
First things first, you do not need your install script should be an instance of
Mage_Catalog_Model_Resource_Setup
Then you need to create a source model for your attribute.