php - Magento: Limit text field size in product custom attribute to 80 characters -
i have problem using following tip magento forum:
quote: 1 option add backend model attribute. in model write own
beforesave
function process length of given value , trim desired length. class should extendmage_eav_model_entity_attribute_backend_abstract
code:
public function beforesave($object) { $attrcode = $this->getattribute()->getattributecode(); if ($object->hasdata($attrcode)) { $object->setdata($attrcode, substr($object->getdata($attrcode),0,50)); } return $this; }
my question is: how , implement snippet? put in /app/code/core/mage/eav/model/entity/attribute/backend/default.php
had no effect.
first @ all, you'll never should place custom code core files. destroys upgradabillity. create own custom modules under app/code/local. there can create model extends mage_eav_model_entity_attribute_backend_abstract.
may link helps create module:
http://www.smashingmagazine.com/2012/03/01/basics-creating-magento-module/
also can use magerun (an cli tool magento) create module: http://magerun.net/
Comments
Post a Comment