安装程序sql在禁用编译器时不运行?

时间:2015-06-07 22:55:22

标签: mysql sql magento collections magento-collection

我的问题是指CMS magento。我创建了一个脚本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并且有一条评论说要编译以在我的自定义模块magento中执行安装程序sql。我需要知道为什么要这样做...在这个链接中我无法找到更多信息。

1 个答案:

答案 0 :(得分:0)

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

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

[你的模块]

config.xml  [configuraton-file] - The version number resides in this.

sql (folder) > *.php [upgrade php scripts]

现在,Magento在您的模块中运行升级脚本if(BOTH ARE TRUE):

  1. config.xml中模块的版本号大于&#34; core_resource&#34;中模块的版本号。模块。

  2. config.xml文件中陈述的新版本脚本位于模块的sql文件夹中。 Magento非常特别符合文件规范。

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