2

enter image description here

I want to change "Choose an Option..." text. I think it's related to app/design/frontend/base/default/template/catalog/product/view/type/options/configurable.phtml file.

Everyone know this code but I want to put in here anyway.

<?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
    <dl>
    <?php foreach($_attributes as $_attribute): ?>
        <dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
        <dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
            <div class="input-box">
                <select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
                    <option><?php echo $this->__('Choose an Option...') ?></option>
                  </select>
              </div>
        </dd>
    <?php endforeach; ?>
    </dl>
    <script type="text/javascript">
        var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
    </script>
<?php endif;?>

I changed <option><?php echo $this->__('Choose an Option...') ?></option> line to <option>Test</option> for testing, but nothing has changed.

3 Answers 3

2

When the page loads and when you select one option the rest of the selects are rebuilt and the first option comes from the config array generated in Mage_Catalog_Block_Product_View_Type_Configurable::getJsonConfig().

Look for this line:

'chooseText'        => Mage::helper('catalog')->__('Choose an Option...'), 
3
  • So, can I change Choose an Option to $_attribute->getLabel()? In this example: Size. And how can I do that? Commented Apr 3, 2014 at 20:38
  • 1
    You cannot use a dynamic text. The text is used for all the dropdowns. Unless you modify the js that refills the selects (js/varien/configurable.js)
    – Marius
    Commented Apr 3, 2014 at 20:42
  • So, I have to use jQuery or something like that to do that. Thank you so much Marius. Commented Apr 3, 2014 at 20:46
2

I found the answer on stackoverflow. Worked perfectly for me. via

Just change catalog/product/view/type/options/configurable.phtml file:

<?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
    <dl>
    <?php foreach($_attributes as $_attribute): ?>
        <dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
        <dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
            <div class="input-box">
                <?php $chooseText = $this->__('Select %s', $_attribute->getLabel()); ?>
                <select data-choose-text="<?php echo $chooseText; ?>" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
                    <option><?php echo $chooseText; ?></option>
                </select>
              </div>
        </dd>
    <?php endforeach; ?>
    </dl>
    <script type="text/javascript">
        Product.ConfigDefaultText = new Class.create(Product.Config, {
            fillSelect: function($super, element) {
                $super(element);
                var chooseDefaultText = element.getAttribute('data-choose-text');
                $(element).options[0] = new Option(chooseDefaultText, '');
            }
        });
        var spConfig = new Product.ConfigDefaultText(<?php echo $this->getJsonConfig() ?>);
    </script>
<?php endif;?>
0

the easiest way is to activate Inline translation (System-Configuration-Advanced-Developer-Translate Inline-Enabled for Frontend) (be aware to select the store view on which you want to edit) then go to your page and press over the little blue icon over the drop-down and edit.

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.