获取左列中Magento自定义类别属性的值

获取左列中Magento自定义类别属性的值,magento,magento-1.7,Magento,Magento 1.7,好的,我正在尝试在我的商店页面的左栏顶部显示自定义Magento类别属性的内容 我正在编辑2columns-left.phtm,并插入以下内容: $_category = Mage::getModel('catalog/category')->load($category->getId()); echo $_helper->categoryAttribute($_category, $_category->getName(), 'name'); 这是在紧接着之前插入的

好的,我正在尝试在我的商店页面的左栏顶部显示自定义Magento类别属性的内容

我正在编辑2columns-left.phtm,并插入以下内容:

$_category = Mage::getModel('catalog/category')->load($category->getId());
echo $_helper->categoryAttribute($_category, $_category->getName(), 'name');
这是在紧接着之前插入的

<?php echo $this->getChildHtml('left') ?>

现在,在任何人指出显而易见的问题之前,是的,我知道这段代码使用了预先存在的属性'name',但是我太累了,太迷糊了,我已经求助于简单的例子来尝试让它工作。我的属性是category_desc-这是通过我编写的一个简单模块创建并成功存储的。通过在后端向其添加值、保存类别然后刷新来确认-输入的值已成功保存

即使上面的例子也不起作用——它只是呈现一个完全空白的左列。我还尝试了无数的变化,在这个和其他代码,我发现(包括一些帖子等),这是应该允许我访问我的尼斯新的自定义属性的类别,但我只是无法让它工作。必须有一种方法可以简单地访问此值。。。当然

我使用Magento 1.7。模块中用于创建自定义属性的代码如下所示:

config.xml:

<?xml version="1.0"?>
<config>
<modules>
    <SS_CustomCategoryAttribute>
        <version>0.0.1</version>
    </SS_CustomCategoryAttribute>
</modules>

<global>
    <resources>
        <add_category_attribute>
            <setup>
                <module>SS_CustomCategoryAttribute</module>
                <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </add_category_attribute>
        <add_category_attribute_write>
            <connection>
                <use>core_write</use>
            </connection>
        </add_category_attribute_write>
        <add_category_attribute_read>
            <connection>
                <use>core_read</use>
            </connection>
        </add_category_attribute_read>
    </resources>
</global>

0.0.1
SS_客户分类属性
Mage\u目录\u模型\u资源\u Eav\u Mysql4\u设置
核心单元设置
核心写入
核心读取

mysql4-install-0.0.1.php:

<?php
$this->startSetup();
$this->addAttribute('catalog_category', 'category_desc', array(
'group'         => 'General',
'input'         => 'textarea',
'type'          => 'text',
'label'         => 'Category Description',
'backend'       => '',
'visible'       => true,
'required'      => false,
'wysiwyg_enabled' => true,
'visible_on_front' => true,
'is_html_allowed_on_front' => true,
'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

$this->endSetup();

真的
社区
如果不明显的话,我对Magento的这一级别的定制还比较陌生,我必须承认我已经从另一个来源改编了模块代码,但它似乎工作得很好


有什么想法吗?

在左侧布局左侧添加功能\u col.phtml

 function addAttribute($code)

{
    $this->_getProductCollection()->addAttributeToSelect($code);

return $this;

}
echo $_product->getResource()->getAttribute('author_name')->getFrontend()->getValue($_product) 
用于在左布局left_col.phtml中显示自定义属性的值

 function addAttribute($code)

{
    $this->_getProductCollection()->addAttributeToSelect($code);

return $this;

}
echo $_product->getResource()->getAttribute('author_name')->getFrontend()->getValue($_product)