Magento模块数据库安装脚本未运行 [英] Magento Module DB Setup Script not running

查看:63
本文介绍了Magento模块数据库安装脚本未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行Magento 1.9.0.2,我试图通过模块将2个新的复选框字段添加到地址"表单中.

Running Magento 1.9.0.2, I'm trying to add 2 new checkbox fields into the Address form via Module.

问题:未执行数据库脚本(请注意第一行的 die()函数)

Problem: The database script is NOT executed (note the die() function on the first line)

症状:

  • 我的模块在 core_resources 表中不存在
  • 数据库未更新
  • 模块已列出&在系统>配置>高级
  • 中启用
  • 已启用日志,文件夹 {base_dir}/var/log/为777,未生成日志
  • 我正在安装模块;正在将文件上传到文件夹&刷新缓存前端一旦触发安装?
  • 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?

问题:我想念什么?

这是 {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>

和SQL更新文件 {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();
?>

最后,它是模块定义文件 Tdg_Check.xml :

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>

推荐答案

在Magento模块条目中,如下所示存储在代码字段中:yourmodulename_setup

In Magento module entry stored in code field like below: yourmodulename_setup

在core_resource表的代码字段中检查诸如check_setup之类的记录.

Check for record like check_setup in code field of core_resource table.

所以要再次运行安装脚本,您必须在模块中找到模块记录并删除该记录.它将自动再次运行脚本.

So for run install script again you have to find module record in module and remove that record. It will automatically run the script again.

这篇关于Magento模块数据库安装脚本未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆