-
11-12-2019 - |
题
我已经创建了以下说明的扩展: http://www.marketingdept.com/blog/2014/01/magento-developers-add-a-custom-field-to-the-category-admin -page/ 尝试将字段添加到Catega admin以无济于事。我的字段被称为custom_h1,没有core_resources显示的custom_h1_setup,线路没有显示。
custom_h1.xml在app \ etc \ modules中
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Custom_H1>
<active>true</active>
<codePool>local</codePool>
</Custom_H1>
</modules>
</config>
.
config.xml app / code / local / custom_h1 / etc /
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Custom_H1>
<!-- Make sure that the version number matches the filename on your install script! -->
<version>0.3.0</version>
</Custom_H1>
</modules>
<global>
<resources>
<custom_h1_setup>
<setup>
<module>Custom_H1</module>
<!-- This next line is absolutely critical so that we call the appropriate setup class -->
<class>Mage_Catalog_Model_Resource_Setup</class>
<connection>
<use>core_setup</use>
</connection>
</setup>
</custom_h1_setup>
<custom_h1_setup_write>
<connection>
<use>core_write</use>
</connection>
</custom_h1_setup_write>
<custom_h1_setup_read>
<connection>
<use>core_read</use>
</connection>
</custom_h1_setup_read>
</resources>
</global>
</config>
.
mysql4-install-0.3.0.php在app / code / local / custom_h1 / sql / custom_h1 / setup / 中
<?php
$installer = $this;
$installer->startSetup();
/**
* This is an entity associated with catalog_category
* @var integer
*/
$entityTypeId = $installer->getEntityTypeId('catalog_category');
/**
* Use the default attribute set for catalog_category -- this refers to the table `eav_attribute_set`
* In my case, it's 3, but this function should automatically get that for you.
* @var integer
*/
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
/**
* This determines what group (tab) that the field will be placed. "General Information"
* is the default tab, and I'm okay with this, but see `eav_attribute_group` for other
* groups
* @var integer
*/
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
/**
* Let's set up our attribute, customize the type as needed (e.g. int, varchar, decimal)
* Note where I've used `internal_title` and change to your variable.
*/
$installer->addAttribute('catalog_category', 'custom_h1', array(
'type' => 'varchar', /* Type - see eav_entity_* for the different types */
'label' => 'Custom H1 Text', /* Your label */
'input' => 'text', /* This refers to the type of form field should display*/
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => TRUE,
'required' => FALSE,
'user_defined' => FALSE,
'default' => ''
));
/**
* Now, add the attribute to the proper attribute group - again, replace the variable title
* with yours.
*/
$installer->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'custom_h1',
'2' /* Refers to the sort order of fields - see `eav_entity_attribute` for reference on the location of other fields. I want this right below the active field, so 2 works for me.*/
);
$installer->endSetup();
.
我确保所有用户都拥有这些文件夹的所有权限。如何使用此额外字段获取此模块加载和类别管理员?
注意:我尝试返回并只是按照文章的完全按照文章制作示例扩展,它仍未显示额外的字段。两个扩展都显示在配置菜单中,以便为模块启用/禁用输出。
解决方案
使用app/code/local/Custom/H1
目录而不是app/code/local/Custom_H1