How to add note for attribute in magento?

I created a new product attribute in Magento using the admin panel. But I canโ€™t find where to put a note for this attribute (that is, the text that should appear under the input field as additional information about this.)

Am I missing something, or is it impossible to implement in the admin panel?

This is an example of what an attribute note will look like:
enter image description here

I am using Magento 1.7 CE.

+4
source share
2 answers

This is not possible through the admin panel.

By the way, you really have to add your attributes programmatically. (if you came across a database, then you did it).

You need to change the โ€œnoteโ€ column of the eav_attribute table.

You can change it with the updateAttribute() command in the update script. Example:

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

Hmm, it might be a little late, but anyway, I had a similar problem today and it was solved in the following intuitive way:

My problem first: how do I get attributes on a custom search page in custom order?

for this i found something here: http://www.magentocommerce.com/boards/viewthread/11782/ - they say: U can use the custom field'note 'from the mysql table:' eav_attribute 'so you can change the Application \ code \ core \ Mage \ CatalogSearch \ Model \ Advanced.php order i.e.

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

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

But then you still have a problem on how to edit things correctly without editing anything directly in the mysql client; from now on I had your problem, my solution:

Model : get / set

  • in the application /code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php
  • grep: class Mage_Eav_Model_Entity_Attribute_Abstract ex
  • add: best after search: "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); }

Controller : install

  • in app / code / core / Mage / Adminhtml / controllers / Catalog / Product / AttributeController.php
  • (ok this is a shortcut, I think you can add some attributes to the "note_text" somewhere, but I don't have a plan from magento)
  • search: "default" and extension:
  • from:

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

  • in

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

View :

  • in./app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php
  • after

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

  • add:

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

Finally, I initialized the note field in the mysql table:

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

where attributes with identifiers 84 and 100 already have some notes.

0
source

Source: https://habr.com/ru/post/1445556/


All Articles