Running Magento 1.9.0.2, I'm trying to add 2 new checkbox fields into the Address form via Module.
Problem: The database script is NOT executed (note the die()
function on the first line)
Symptoms:
- My module does not exist in
core_resources
table - database does not get updated
- module is listed & enabled in System > Configuration > Advanced
- log enabled, folder
{base_dir}/var/log/
is 777, no log produced - I'm installing the module; is uploading the files to the folder & refresh the cache & frontend once triggers the install?
Question: What did I miss?
Here is the {base_dir}/app/code/local/Tdg/Check/etc/config.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Tdg_Check>
<version>1.0.1</version>
</Tdg_Check>
</modules>
<admin>
<fieldsets>
<customer_dataflow>
<chk_commercial><billing>1</billing><shipping>1</shipping></chk_commercial>
<chk_residential><billing>1</billing><shipping>1</shipping></chk_residential>
</customer_dataflow>
</fieldsets>
</admin>
<global>
<models>
<check>
<class>Tdg_Check_Model</class>
</check>
</models>
<resources>
<check_setup>
<setup>
<module>Tdg_Check</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</check_setup>
<check_write>
<connection>
<use>core_write</use>
</connection>
</check_write>
<check_read>
<connection>
<use>core_read</use>
</connection>
</check_read>
</resources>
<fieldsets>
<sales_copy_order_billing_address>
<chk_commercial><to_order>*</to_order></chk_commercial>
<chk_residential><to_order>*</to_order></chk_residential>
</sales_copy_order_billing_address>
<sales_copy_order_shipping_address>
<chk_commercial><to_order>*</to_order></chk_commercial>
<chk_residential><to_order>*</to_order></chk_residential>
</sales_copy_order_shipping_address>
<sales_convert_quote_address>
<chk_commercial><to_order_address>*</to_order_address><to_customer_address>*</to_customer_address></chk_commercial>
<chk_residential><to_order_address>*</to_order_address><to_customer_address>*</to_customer_address></chk_residential>
</sales_convert_quote_address>
<sales_convert_order_address>
<chk_commercial><to_quote_address>*</to_quote_address></chk_commercial>
<chk_residential><to_quote_address>*</to_quote_address></chk_residential>
</sales_convert_order_address>
<customer_address>
<chk_commercial><to_quote_address>*</to_quote_address></chk_commercial>
<chk_residential><to_quote_address>*</to_quote_address></chk_residential>
</customer_address>
<checkout_onepage_billing>
<chk_commercial><to_customer>*</to_customer></chk_commercial>
<chk_residential><to_customer>*</to_customer></chk_residential>
</checkout_onepage_billing>
</fieldsets>
</global>
</config>
And the SQL Update file {base_dir}/app/code/Tdg/Check/sql/check_setup/mysql4-install-1.0.1.php
:
<?php
die('Installing Module');
/* @var $installer Mage_Customer_Model_Entity_Setup */
$installer = $this;
$installer->startSetup();
/* @var $addressHelper Mage_Customer_Helper_Address */
$addressHelper = Mage::helper('customer/address');
$store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);
/* @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
// update customer address user defined attributes data
$attributes = array(
'chk_commercial' => array(
'label' => 'Chk Commercial',
'type' => 'int',
'input' => 'checkbox',
'default' => 0,
'is_user_defined' => 1,
'is_system' => 0,
'is_visible' => 1,
'sort_order' => 140,
'is_required' => 1,
'multiline_count' => 0,
'validate_rules' => array(
'max_text_length' => 1,
'min_text_length' => 1
),
),
'chk_residential' => array(
'label' => 'Chk Residential',
'type' => 'int',
'input' => 'checkbox',
'default' => 0,
'is_user_defined' => 1,
'is_system' => 0,
'is_visible' => 1,
'sort_order' => 141,
'is_required' => 1,
'multiline_count' => 0,
'validate_rules' => array(
'max_text_length' => 1,
'min_text_length' => 1
),
),
);
foreach ($attributes as $attributeCode => $data) {
$attribute = $eavConfig->getAttribute('customer_address', $attributeCode);
$attribute->setWebsite($store->getWebsite());
$attribute->addData($data);
$usedInForms = array(
'adminhtml_customer_address',
'customer_address_edit',
'customer_register_address'
);
$attribute->setData('used_in_forms', $usedInForms);
$attribute->save();
}
$installer->run("
ALTER TABLE {$this->getTable('sales_flat_quote_address')} ADD COLUMN `chk_commercial` VARCHAR(1) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`;
ALTER TABLE {$this->getTable('sales_flat_order_address')} ADD COLUMN `chk_commercial` VARCHAR(1) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`;
ALTER TABLE {$this->getTable('sales_flat_quote_address')} ADD COLUMN `chk_residential` VARCHAR(1) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`;
ALTER TABLE {$this->getTable('sales_flat_order_address')} ADD COLUMN `chk_residential` VARCHAR(1) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`;
");
$installer->endSetup();
?>
Last, it's the Module definition file Tdg_Check.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Tdg_Check>
<active>true</active>
<codePool>local</codePool>
</Tdg_Check>
</modules>
</config>
core_resources
does not have my module name on it ? (p.s. actually which value will appear incore_resources
table? Is itTdg_Check
?) – Raptorcheck_setup
! I removed it from thecore_resources
table and the install script runs ! Thanks ! Please put it as answer ! – Raptor