4

I have a custom product attribute with input type "Text Field" .So generally magento is allowing to enter maximum 255 characters into this.

Now my query is,I don't want to limit characters into text fields. Admin can enter more then 255 characters in this custom attribute.

2 Answers 2

1

This might help you: here first name is the custom option. so change the max length value.

$productData = Mage::getSingleton('core/session')->getProductData();
$product_id = $productData['id'];
$product = Mage::getModel('catalog/product')->load($product_id);


 <?php foreach ($product->getOptions() as $_option): ?>
                    <?php if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD): ?>
                        <?php if (stristr($_option->getTitle(), "first name")): ?>
                            <div class="form-group row">
                                <label class="col-sm-4 control-label line" for="options_<?php echo $_option->getId() ?>_text"><?php echo $_option->getTitle(); ?></label>
                                <div class="col-sm-8">
                                    <input  title="Enter <?php echo $_option->getTitle(); ?>" <?php if($_option->getMaxCharacters()): ?>maxlength="<?php echo $_option->getMaxCharacters() ?>"<?php endif; ?> type="text" value="<?php if (isset($options[$_option->getId()]))
                    echo $options[$_option->getId()]; ?>"  placeholder="" autocomplete="off" id="firstname" class="form-control <?php echo $_option->getIsRequire() ? ' required-entry required' : '' ?> <?php echo $_option->getMaxCharacters() ? ' validate-length maximum-length-' . $_option->getMaxCharacters() : '' ?> product-custom-option" name="options[<?php echo $_option->getId() ?>]"/>
                                </div>
                            </div> 
                        <?php endif ?>
1

Attributes of type varchar have a database restriction to 255 characters because of the value field of type varchar(255) in the corresponding eav table catalog_product_entity_varchar. The input type for this kind of attributes is usually an "Text Field".

You need an attribute of type text in order to store more than 255 characters since then you will have a value field of type text with a restriction of 65,535 bytes in the corresponding eav table catalog_product_entity_text. Usually this fields have a input type "Text Area". A common example of such a product attribute is description.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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