1

Hi I am trying to create attributes. I need to create an attribute which accepts any value between 1 to 9999. The code is as follows,

 $installer->addAttribute('catalog_product', 'number_of_codes', array(
'type'              => 'text',
'backend'           => '',
'frontend'          => '',
'label'             => 'Number of Codes to Generate',
'input'             => 'select',
'class'             => '',
'source'            => 'catalog/product_attribute_source_layout',
'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible'           => false,
'required'          => false,
'user_defined'      => true,
'default'           => '1',
'searchable'        => false,
'filterable'        => false,
'comparable'        => false,
'visible_on_front'  => false,
'unique'            => false,
'group'             => 'Code_Generation'
));
3

The easiest might be to add a frontend validator where you attribute data is added. Include validation.js on your page and add these class-attributes to your input field:

<input .... class="required-entry validate-digits-range digits-range-1-9999" />

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.