我的问题是指一个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。我想知道为什么要这么做。在此链接中,我找不到更多信息。
发布于 2015-06-08 14:07:48
你不需要编译就能运行升级脚本。事实上,我认为您可能需要暂时关闭编译才能运行升级脚本(但我对此不太确定)。
这取决于模块版本的值,该值存储在Magento数据库的core_resource表中。
你的模块
config.xml [configuraton-file] - The version number resides in this.
sql (folder) > *.php [upgrade php scripts]现在,Magento在以下情况下在模块中运行升级脚本(两者均为真):
我认为你的模块在core_resource表中的版本号已经是最新的版本了,所以它不会搜索任何升级脚本。所以,我建议你在Magento db的core_resource表中删除你的模块条目或者减少版本号。然后按照Mageto标准维护文件,您的升级脚本就会运行。
https://stackoverflow.com/questions/30699307
复制相似问题