2013-02-13 79 views
1

我嘗試升級我的自定義Magento模塊,但由於某種原因它不起作用。Magento自定義模塊SQL升級不起作用

我的模塊配置:

<?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安裝-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升級-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(); 
?> 
+0

嘗試重命名文件'mysql4數據升級,0.1.0-0.1.1.php'的標籤名稱和嘗試 – Kalpesh 2013-02-13 11:47:27

+0

放一些法師日誌檢查文件是否被被稱爲或不 – Kalpesh 2013-02-13 11:47:46

回答

6

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

2

試試這個:

<?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(); 
1

確保3個條件:

  1. 你的模塊版本號。不存在於core_resource表中。
  2. 您有版本號。在您的模塊的etc/config.xml文件中定義。
  3. 您已經定義了全球的資源爲你的模塊的安裝/升級使用yourmodule_setup
+0

' ----- ----- YourCompany_YourModule core_setup ----- ----- ' – 2013-10-02 09:45:30