[英]Creating Category Attribute in Magento 1.9.2 via setup script
我想創建三個不同的類別屬性,自定義輸入文本,所見即所得文本區域和另一個類別圖像上傳。
我首先開始使用自定義輸入文本,因為我覺得最簡單,但它不起作用。 我檢查了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的/ etc
<?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>
應用程序/代碼/本地/賽第一輪/ 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/
我錯過了缺失或步驟嗎?
如果我是對的,這個擴展程序將在頁面刷新后運行?
請嘗試以下更改:
<?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_setup到customheader_setup並重新命名dircetory到應用程序/代碼/本地/賽第一輪/ Customheader / SQL / customheader_setup
還要確保安裝腳本名稱應為mysql4-install-0.1.0.php ,此處0.1.0是您的模塊版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.