2016-09-22 68 views
1

我想創建三個不同的分類屬性,一個自定義輸入文本,一個wysiwyg文本區域和另一個分類圖像上傳。通過安裝腳本在Magento 1.9.2中創建分類屬性

我首先開始使用自定義輸入文本,因爲我覺得最簡單但不起作用。我檢查了core_resource,看看版本是否已經註冊,但是沒有,屬性也沒有出現在類別上。

這是我的代碼

應用程序的/ etc /模塊/ Rnd_Customheader.xml

<?xml version="1.0"?> 
<config> 
<modules> 
    <Rnd_Customheader> 
     <active>true</active> 
     <codePool>community</codePool> 
    </Rnd_Customheader> 
</modules> 
</config> 

應用程序/代碼/本地/賽第一輪/ Customheader /等

<?xml version="1.0"?> 
<config> 
<modules> 
    <Rnd_Customheader> 
     <version>0.1.0</version> 
    </Rnd_Customheader> 
</modules> 
<global> 
    <resources> 
     <Rnd_Customheader_setup> 
      <setup> 
       <module>Rnd_Customheader</module> 
       <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class> 
      </setup> 
      <connection> 
      <use>default_setup</use> 
      </connection> 
     </Rnd_Customheader_setup> 
    </resources> 
</global> 
</config> 

應用程序/代碼/本地/ Rnd/Customheader/sql/rnd_customheader_setup

<?php 
    $installer = $this; 
    $installer->startSetup(); 
    $attribute = array(
     'type'   => 'text', 
     'label'   => 'Custom Header (If you want different page header)', 
     'input'   => 'text', 
     'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
     'visible'  => true, 
     'required'  => false, 
     'user_defined' => true, 
     'default'  => "", 
     'group'   => "General Information" 
    ); 
    $installer->addAttribute('catalog_category', 'custom_header', $attribute); 
    $installer->endSetup(); 
?> 

這是我引用

https://magento.stackexchange.com/questions/94833/add-custom-attribute-for-category

http://gauss-development.com/blog/tutorials/adding-custom-category-attributes-magento/

是否有遺漏或步驟我錯過了什麼?

如果我是對的,這個擴展將在頁面刷新後運行?

+0

http://stackoverflow.com/questions/33447763/creating-new-attribute-field-in-catalog-manage-categories-display-settings/33472607#33472607 –

+0

@rodge可以請提一下安裝腳本名稱嗎? – ROBIN

+0

這是安裝腳本的名稱mysql4-install-0.1.0.php – rodge

回答

0

請嘗試以下變化:

<?xml version="1.0"?> 
    <config> 
     <modules> 
     <Rnd_Customheader> 
      <version>0.1.0</version> 
     </Rnd_Customheader> 
     </modules> 
     <global> 
     <resources> 
    <customheader_setup> 
     <setup> 
      <module>Rnd_Customheader</module> 
      <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class> 
     </setup> 
     <connection> 
     <use>default_setup</use> 
     </connection> 
    </customheader_setup> 
</resources> 

變化Rnd_Customheader_setupcustomheader_setup和dircetory重命名爲應用程序/代碼/本地/賽第一輪/ Customheader/SQL/customheader_setup

還要確保安裝腳本名稱應該是mysql4-install-0.1.0.php,這裏的0.1.0是你的模塊版本。

+0

我試過這個改動但沒有運氣 – rodge