Reputation: 33
I have searched everywhere and cannot find an answer for some reason. I have had my first attribute save and work in my database, but my second attribute will not work. I believe that my installer script is not being executed, which is incredibly frustrating. Here is what I have:
app/local/Name/Module/sql/name_module_setup/mysql4-upgrade-0.1.0-0.1.1.php
(please note that I have had this same script in .../mysql4-install-0.1.0.php
and .../mysql4-install-0.1.1.php
in order to try different things)
<?php
require_once('app/Mage.php');
$installer = $this;
$installer->startSetup();
//$installer = new Mage_Sales_Model_Mysql4_Setup; //this line has been both commented and non-commented
$attribute = array(
'type' => 'text',
'backend_type' => 'text',
'frontend_input' => 'text',
'is_user_defined' => false,
'label' => 'Custom ID',
'visible' => true,
'required' => false,
'user_defined' => false,
'searchable' => true,
'filterable' => true,
'comparable' => true,
'default' => 'Test'
);
$installer->addAttribute('order', 'custom_id', $attribute);
$attribute = array(
'type' => 'int',
'backend_type' => 'int',
'frontend_input' => 'int',
'is_user_defined' => false,
'label' => 'Custom Number',
'visible' => true,
'required' => false,
'user_defined' => false,
'searchable' => true,
'filterable' => true,
'comparable' => true,
'default' => '0'
);
$installer->addAttribute('order', 'custom_number', $attribute);
error_log("The new custom number attribute is being made",0); //Never sent to error_log
$installer->endSetup();
...app/local/Name/Module/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Name_Module>
<version>0.1.1</version><!--Tried 0.1.0 and 0.1.1-->
</Name_Module>
</modules>
<global>
<models>
<name_module>
<class>Name_Module_Model</class>
</name_module>
</models>
...
<resources>
<name_module_setup>
<setup>
<module>Name_Module</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</name_module_setup>
<module_write>
<connection>
<use>core_write</use>
</connection>
</module_write>
<module_read>
<connection>
<use>core_read</use>
</connection>
</module_read>
</resources>
<fieldsets>
<sales_convert_quote>
<custom_id>
<to_order>*</to_order>
</custom_id>
<custom_number>
<to_order>*</to_order>
</custom_number>
</sales_convert_quote>
</fieldsets>
</global>
...
</config>
I feel like I have tried everything... Any help would be fantastic! Thanks in advance!
Upvotes: 2
Views: 957
Reputation: 33
So I figured it out finally... for some reason, I had to go into phpmyadmin and go to core/resource
and delete the rows that contain your module, refresh cache, and try again. After that, the installer script ran! Hope this helps somebody out!
Upvotes: 1
Reputation: 688
You can try the following code
<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('order', 'custom_id', array(
'type' => 'text',
'backend_type' => 'text',
'frontend_input' => 'text',
'is_user_defined' => false,
'label' => 'Custom ID',
'visible' => true,
'required' => false,
'user_defined' => false,
'searchable' => true,
'filterable' => true,
'comparable' => true,
'default' => 'Test'
));
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('order', 'custom_number', array(
'type' => 'int',
'backend_type' => 'int',
'frontend_input' => 'int',
'is_user_defined' => false,
'label' => 'Custom Number',
'visible' => true,
'required' => false,
'user_defined' => false,
'searchable' => true,
'filterable' => true,
'comparable' => true,
'default' => '0'
));
$installer->endSetup();
Try to clear magento cache and check.
Upvotes: 0