2

I've added a custom attribute to the customer. I've added a note to clarify the attribute.

The installer for the attribute:

<?php
$installer->addAttribute('customer', 'attribute_code', array(
    'type' => 'text',
    'backend' => '',
    'label' => 'Custom Label',
    'input' => 'multiselect',
    'source' => 'module_namespace/eav_entity_attribute_source_customcustomerattr',
    'visible' => true,
    'required' => false,
    'default' => '',
    'frontend' => '',
    'unique' => false,
    'note' => 'Instruction text',
));

I've added a csv to the module which works for the Custom Label but it doesn't work for the Instruction text

Magento prints the note in : app/design/adminhtml/default/default/template/widget/form/renderer/fieldset/element.phtml

<?php $_note = $_element->getNote();
// other
<?php if ($_note): ?>
    <p class="note<?php echo $_class ? " {$_class}-note" : ''?>" id="note_<?php echo $_element->getId()?>">
        <span><?php echo $_note ?></span>
    </p>
<?php endif ?>

What am I missing?

3

You're not missing anything.
The problem is that the note field of the attributes are never translated.
The tabs with attributes are generated via the block Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes.
you will find this $this->_setFieldset($attributes, $fieldset, array('gallery'));.
This line creates the inputs for each attribute.
If you search for the _setFieldset method definition, you will find it in Mage_Adminhtml_Block_Widget_Form and you will see this in it's body.

         $element = $fieldset->addField($attribute->getAttributeCode(), $fieldType,
                array(
                    'name'      => $attribute->getAttributeCode(),
                    'label'     => $attribute->getFrontend()->getLabel(),
                    'class'     => $attribute->getFrontend()->getClass(),
                    'required'  => $attribute->getIsRequired(),
                    'note'      => $attribute->getNote(),
                )
            )

Notice the line 'note' => $attribute->getNote(),. The attribute note does not get translated.
Also in the template you mentioned, the note is used as it is: $_note = $_element->getNote().
You have 2 options here.
one is to rewrite the _setFieldset method and translate the note using Mage::helper('catalog')->__($attribute->getNote()), but this involves a lot of work.
The second option is to create a new admin theme that contains only the template you mentioned and instead of $_note = $_element->getNote(); use

$_note = $this->__($_element->getNote());

Here is a tutorial on how to change the admin theme

1
  • Thanks I know enough. I'll rewrite the _setFieldset as it will keep the files within the module. – janw Jul 23 '15 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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