更改文本“选择选项...”在Magento产品页面上 [英] Change the text "Choose an option..." on Magento product page

查看:121
本文介绍了更改文本“选择选项...”在Magento产品页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个可配置产品,它有三个选项:颜色大小样式


在产品页面中,每个选项在下拉菜单中都有默认文本选择选项... ,但我希望文本应该是选择颜色选择大小选择样式


我在应用程序中编辑了函数getJsonConfig \code\core\Mage\Catalog\Block\View\Type\Configurable.php

I created a configurable product, it has three option: color, size and style.

Now in product page, each option has the default text "Choose an Option..." in dropdown, but I want the text should be "Select color", "Select size" and "Select style".

I edited function getJsonConfig() in app\code\core\Mage\Catalog\Block\View\Type\Configurable.php

From:

    'chooseText'        => Mage::helper('catalog')->__('Choose an Option...'),

至:

    'chooseText'        => ('Select ').$attribute->getLabel(),

并编辑第39行文件 frontend / base / default / template / catalog / product / view / type / options / configurable.phtml to:

And edit line 39 of the file frontend/base/default/template/catalog/product/view/type/options/configurable.phtml to:

<option><?php echo $this->__('Select ') ?><?php echo $_attribute->getLabel() ?></option>

但结果不好,它在三个选项中显示文本选择样式。
请给我一个这个问题的提示,非常感谢!

But the result is not good, it alway show the text "Choose style" in three options. Please give me a hint for this issue, thank you very much!

推荐答案

我的版本同样的问题。您只需要更改模板
catalog / product / view / type / options / configurable.phtml:

My version of the same problem. You need to change only template catalog/product/view/type/options/configurable.phtml:

<?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;?>

注意(从评论中提取)
如果所选的默认值不是选择%s,替换

Note (extracted from comments) If the selected default value happens not to be "Select %s", replace

$(element).options[0] = new Option(chooseDefaultText, '');

$(element).options[0].innerHTML = chooseDefaultText;

这篇关于更改文本“选择选项...”在Magento产品页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆