如何在magento中为属性添加注释?

时间:2012-11-12 15:59:28

标签: magento attributes

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

我是否遗漏了某些内容,或者是否无法在管理面板中实施?

这是关于属性的注释如何显示的示例:
enter image description here

我正在使用Magento 1.7 CE。

2 个答案:

答案 0 :(得分:5)

通过管理面板无法实现。

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

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

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

$installer->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'color', 'note','my comment');

答案 1 :(得分:0)

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

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

为此,我在这里找到了一些东西: http://www.magentocommerce.com/boards/viewthread/11782/ - 他们告诉: 你可以使用mysql表中的自定义未使用字段'note':'eav_attribute' 因此你可以改变 应用程序\代码\核心\法师\ CatalogSearch \型号\ Advanced.php 订单 即

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

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

然而,你仍然有问题,如何正确编辑事物,而不是直接在mysql客户端编辑任何东西;从现在开始,我遇到了你的问题,我的解决方案:

模型:获取/设置

  • in app / code / core / Mage / Eav / Model / Entity / Attribute / Abstract.php
  • grep:class 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
  • (o.k。这是一个捷径,我想你可以在某个地方为“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'); }

查看

  • in ./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表中的note-field:

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

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

相关问题