【问题标题】:Why doesn't my installer SQL run when compiler is disabled?为什么禁用编译器时我的安装程序 SQL 不运行?
【发布时间】:2015-06-07 22:55:21
【问题描述】:

我创建了一个脚本化的 SQL 安装程序,当我在我的服务器中访问 MySQL 并进行搜索时,我找不到使用脚本创建的新列。我的代码是:

<?php 

$installer = new Mage_Sales_Model_Resource_Setup('core_setup');

//entities for options in table Sales Flat Order Item
$entities = array(
    'order_item'
);

//entity for desactivate_count in table Sales Flat Order
$entitydes = array(
    'order'
);

//for type text
$optionstxt = array(
    'type'     => 'text',
    'grid' => false
);

//for type int
$optionsint = array(
    'type' => 'int',
    'grid' => false,
    'default' => '0'
    );

//just for column incomm_desactivate_count
$optionsdesc = array(
    'type' => 'int',
    'grid' => true,
    'default' => '0'
    );

foreach ($entities as $entity) {
    $installer->addAttribute($entity, 'incomm_request_active_code', $options);
    $installer->addAttribute($entity, 'incomm_cancel', $options);
    $installer->addAttribute($entity, 'incomm_exception_count', $optionsint); //value int(2)
    $installer->addAttribute($entity, 'incomm_return_active_code', $options);
    $installer->addAttribute($entity, 'incomm_activated', $optionsint); //value int(1)
}

foreach ($entitydes as $entity) {
    $installer->addAttribute($entity, 'incomm_desactivate_count', $optionsdesc); //value int(2)
}

$installer->endSetup();

我发现Magento Module SQL does not run 有一条评论说要编译以在我的自定义模块中执行安装程序 SQL。我需要知道为什么我必须这样做...在此链接中我找不到更多相关信息。

【问题讨论】:

    标签: mysql sql magento collections


    【解决方案1】:

    您无需编译即可运行升级脚本。事实上,我认为您可能需要暂时关闭编译以运行升级脚本(不过我不太确定)。

    这取决于模块版本的值,该值存储在 Magento 数据库的 core_resource 表中。

    [你的模块]

    config.xml  [configuraton-file] - The version number resides in this.
    
    sql (folder) > *.php [upgrade php scripts]
    

    现在,如果(两者都为真),Magento 会在您的模块中运行升级脚本:

    1. config.xml 中模块的版本号大于“core_resource”模块中模块的版本号。

    2. config.xml 文件中所述的新版本脚本位于模块的sql 文件夹中。 Magento 的文件命名约定非常奇特。

    我认为 core_resource 表中模块的版本号已经是最新版本,因此它不会搜索任何升级脚本。 因此,我建议您删除模块的条目或减少 Magento db 的 core_resource 表中的版本号。然后按照 Mageto 标准维护文件,你的升级脚本就会运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-16
      • 2019-04-03
      • 1970-01-01
      • 1970-01-01
      • 2014-10-26
      • 1970-01-01
      • 2012-07-13
      • 1970-01-01
      相关资源
      最近更新 更多