4

我使用管理面板在 Magento 中创建了一个新的产品属性。但是我找不到在哪里为该属性添加注释(即应该在输入字段下方显示的文本作为有关它的额外信息。)

我是否遗漏了什么,或者这不可能在管理面板中实现?

这是一个关于属性的注释的示例:
在此处输入图像描述

我正在使用 Magento 1.7 CE。

4

2 回答 2

5

这是不可能通过管理面板。

顺便说一句,你真的应该以编程方式添加你的属性。(如果你的数据库崩溃,你就完了)。

您需要修改 eav_attribute 表的“note”列。

您可以updateAttribute()使用升级脚本中的命令对其进行修改。例子 :

$installer->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'color', 'note','my comment');
于 2012-11-12T16:16:30.240 回答
0

嗯,这可能有点晚了,但无论如何,我今天遇到了类似的问题,并通过以下直观的方式解决了它:

首先我的问题:如何在扩展搜索页面中以自定义顺序获取属性?

为此,我在这里找到了一些东西:http: //www.magentocommerce.com/boards/viewthread/11782/ - 他们告诉:你可能会使用 mysql 表中的自定义未使用字段“note”:“eav_attribute”您可以在 app\code\core\Mage\CatalogSearch\Model\Advanced.php 中更改 order-by 即

从: ->setOrder('main_table.attribute_id', 'asc')

到: ->setOrder('main_table.note', 'asc')

但是,你仍然有问题,如何正确编辑这些东西,而不是直接在 mysql-client 中编辑任何东西;从现在开始,我遇到了你的问题,我的解决方案:

模型:获取/设置

  • 在 app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php
  • grep:类 Mage_Eav_Model_Entity_Attribute_Abstract ex
  • 添加:搜索后最好:“n getName”

/** * Get attribute note * * @return string */ public function getNote() { return $this->_getData('note'); } /** * Set attribute note * * @param string $name * @return Mage_Eav_Model_Entity_Attribute_Abstract */ public function setNote($note) { return $this->setData('note', $note); }

控制器:设置

  • 在 app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
  • (好的,这是一条捷径,我认为您可以在某处向“note_text”添加一些属性,但我没有来自 magento 的计划)
  • 搜索:“默认值”并扩展:
  • 从:

$defaultValueField = $model->getDefaultValueByInput($data['frontend_input']); if ($defaultValueField) { $data['default_value'] = $this->getRequest()->getParam($defaultValueField); }

  • 到:

$defaultValueField = $model->getDefaultValueByInput($data['frontend_input']); if ($defaultValueField) { $data['default_value'] = $this->getRequest()->getParam($defaultValueField); $data['note'] = $this->getRequest()->getParam('note_text'); }

查看

  • 在 ./app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php
  • 后:

    $fieldset->addField('default_value_text', 'text', array(

  • 添加:

    $fieldset->addField('note_text', 'text', array( 'name' => 'note_text', 'label' => Mage::helper('eav')->__('Note Value'), 'title' => Mage::helper('eav')->__('Note Value'), 'value' => $attributeObject->getDefaultValue(), ));

最后,我通过以下方式初始化了 mysql 表中的注释字段:

update eav_attribute set note=lpad(attribute_id,10,'0000000000') where attribute_id not in(84,100);

其中 id 为 84 和 100 的属性已经有了一些注释。

于 2013-10-11T11:52:40.053 回答