Magento – Increase maximum chars for meta description

magento-1.9meta-descriptionseo

The Google's limit for the meta description, from some months to today, is around 300 characters.

So, I'd like to increase the limit of 255 chars in Magento 1.9

How can I do it in a clean way? 🙂

p.s.
My question is different from this 'cause I want to know if there is a way to maintain the meta description field on the DB as a numeric field, but only with an increased limit.

Best Answer

Update meta description maximum length via upgrade script

Use below code for update maximum length

/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
$installer = $this;

$entityTypeId = $installer->getEntityTypeId('catalog_product');
$installer->updateAttribute($entityTypeId, 'meta_description', 'frontend_class', 'validate-length maximum-length-300');

OR

$installer  = Mage::getResourceModel('catalog/setup', 'catalog_setup');
$installer->startSetup();

$entityTypeId = $installer->getEntityTypeId('catalog_product');
$installer->updateAttribute($entityTypeId, 'meta_description', 'frontend_class', 'validate-length maximum-length-300');

$installer->endSetup();

By Default magento1 set maximum length: 255

Please see here defualt code app\code\core\Mage\Catalog\sql\catalog_setup\mysql4-upgrade-1.4.0.0.39-1.4.0.0.40.php

Related Topic