簡體   English   中英

Magento自定義模塊SQL升級不起作用

[英]Magento custom module SQL upgrade not working

我嘗試升級自定義的Magento模塊,但由於某種原因,它無法正常工作。

我的模塊配置:

<?xml version="1.0"?>
<config>
    <modules>
        <MVE_CategoryAttribute>
            <version>0.1.1</version>
        </MVE_CategoryAttribute>
    </modules>
    <global>
            <resources>
                <categoryattribute_setup>
                  <setup>
                    <module>MVE_CategoryAttribute</module>
                    <class>Mage_Eav_Model_Entity_Setup</class>
                  </setup>
                  <connection>
                    <use>default_setup</use>
                  </connection>
                </categoryattribute_setup>
            </resources>
    </global>
</config>

安裝腳本(mysql4-install-0.1.0.php):

<?php

$this->startSetup();

$this->addAttribute('catalog_category', 'imagetext', array(
    'group'         => 'General Information',
    'input'         => 'textarea',
    'type'          => 'varchar',
    'label'         => 'Tekst op afbeelding',
    'backend'       => '',
    'visible'       => 1,
    'required'      => 0,
    'user_defined' => 1,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

$this->endSetup();

?>

升級腳本(mysql4-upgrade-0.1.0-0.1.1.php):

<?php   
$this->startSetup();     
$this->updateAttribute('catalog_category', 'imagetext', 'global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);  
$this->endSetup();  
?>

檢查模塊的core_resource中的版本號。 如果仍為0.1.0,則清除您的xml緩存並重新啟動頁面,它應該運行。 如果已經是0.1.1,並且您知道尚未應用數據庫更改,則將值更改回0.1.0,清除xml緩存並刷新頁面。

嘗試這個:

<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->updateAttribute('catalog_category', 'imagetext', 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);
$installer->endSetup();

確保滿足3個條件:

  1. 您的模塊版本號 在core_resource表中不存在。
  2. 您有一個版本號。 在模塊的etc / config.xml文件中定義。
  3. 您已使用標簽名稱yourmodule_setup為模塊的設置/升級定義了全局資源。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM