Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I would really like to limit the title length on products in Magento.

What I've tried is adding 'maxlength' => 65 somewhere in \app\code\core\Mage\Adminhtml\Block\, without success.

Does someone know how to add this feature? In HTML it will just be adding length="65" maxlength="65".

share|improve this question
Slightly off-topic: Better off truncating the title to 12 words, rather than 65 Chars... –  Mike Hudson Jun 28 '12 at 1:29
Use the developer block hinting to ensure THAT block is actually making the output you see on front end... or the block that dictates the title's input. –  Chris K Jun 28 '12 at 7:25
@MikeHudson True, but HTML doesn't support maxlenght="so many words". –  cobra91 Jun 28 '12 at 14:20
@ChrisK In the front-end I'd like to show the same as in the back-end. Truncating isn't an option for me. –  cobra91 Jun 28 '12 at 14:21

2 Answers 2

After almost 10 hours of searching I gave the up the "best" way, and choose for the roundabout.

Simply add

document.getElementById("name").setAttribute("maxlength", "65");
document.getElementById("name").setAttribute("length", "65");

to app/design/adminhtml/default/default/template/catalog/wysiwyg/js.phtml

share|improve this answer
Original question should be more like "where do forms come from". The code around the form for new products is in app/design/adminhtml/default/default/template/catalog/product/edit.phtml on line 52: <?php echo $this->getBlockHtml('formkey')?>. Trying to find what actually makes this form's HTML is quite a mystery to me. –  Chris K Jun 28 '12 at 16:59
Stumped, I asked this question on Stack Overflow: stackoverflow.com/questions/11249858/… –  Chris K Jun 28 '12 at 17:27

As a result from that SO question. One repeating pattern in form creation is $fieldset->addField, so that presented itself as a key way to grep in files.

user@magento:~/www/app$ grep -rin "addField.*text" * | grep -i product
code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php:140:        $fieldset->addField('simple_product_inventory_qty', 'text', array(

There were about a dozen results which were quickly narrowed down (we're not caring about giftcard or Attribute sets). I'm not 100% sure THIS file is the answer but it seems that some logic could be added to catch whether or not the input's name=="Name" and then a maxlength could then be added in.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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