5

I'm wondering if there's an easy way to create comment help text for custom product attributes (or really for any product attributes - even some core attributes could use some helper text to make it a bit more clear what they do).

What I mean by comment help text is for example what you get when you use <comment> in system.xml. system.xml comment help text

So, for example, let's say you wanted to add a comment under Meta Title in the Meta Information tab of a product edit page to say "This is what will show up in the browser title bar".

I just noticed that Meta Description as an example already has some comment help text ("Maximum 255 chars") underneath it, but from a quick glance I'm not seeing where that would be defined under the Attribute details under Catalog > Manage Attributes > meta_description

I haven't done much digging yet into the core code to hunt for this yet, so my apologies if this is a really stupid question!

1
  • I'd look pretty hard at the setup script / default entities definition which creates that attribute in the first place. I'd check myself but I'm installing osx. Again.
    – benmarks
    Mar 13, 2014 at 15:41

1 Answer 1

8

Ha...this is a good one.
The field in the db that determines the text under the attribute field is note from the eav_attribute table.
I never noticed that you can't change that from the UI.
I've created a lot of attributes that have a 'comment' below the fields but never change one.

To add that you need to specify this in the install script:

$this->addAttribtue('catalog_product', 'attribute_code_here', array(
   ....
   'note' => 'This will be displayed below the field',
   ....
));

To change it for one attribute you can add this in an install/upgrade script.

$this->updateAttribute('catalog_product', 'attribute_code_here', 'note', 'This will be displayed below the field'); 

I can't believe that I've missed this in all the million versions I've used so far.

[EDIT]
See the definition of the meta_description attribute in Mage_Catalog_Model_Resource_Setup::installEntities().

'meta_description'   => array(
                        'type'                       => 'varchar',
                        'label'                      => 'Meta Description',
                        'input'                      => 'textarea',
                        'required'                   => false,
                        'note'                       => 'Maximum 255 chars',
                        'class'                      => 'validate-length maximum-length-255',
                        'sort_order'                 => 3,
                        'global'                     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
                        'group'                      => 'Meta Information',
                    ),
3
  • I see what's going on here. This goes back to what Vinai said about never creating these things manually - it's better to create them all with setup scripts. I still do them manually b/c I'm not managing a lot of them at a time, so I can get away with it. This is another good reason to move to always creating attribs programatically. Mar 13, 2014 at 16:17
  • My proposal on Twitter was to add an UI to view / update the note field. I've already implemented this and ready to send a PR against at least Magento 1.x
    – Zifius
    Mar 13, 2014 at 16:57
  • it also works in magento2 with the 'note' field.
    – artgrohe
    Jun 18, 2020 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.