gpt4 book ai didi

magento - 更改 Magento 产品页面上的文本 "Choose an option..."

转载 作者:行者123 更新时间:2023-12-04 00:42:47 24 4
gpt4 key购买 nike

我创建了一个可配置的产品,它有三个选项:颜色 , 尺寸 款式 .
现在在产品页面中,每个选项都有默认文本“ 选择一个选项... ”在下拉菜单中,但我希望文本应该是“ 选择颜色”、“”选择尺寸 和“ 选择样式 ”。
我在 app\code\core\Mage\Catalog\Block\View\Type\Configurable.php 中编辑了函数 getJsonConfig()

来自:

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

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

并编辑文件 frontend/base/default/template/catalog/product/view/type/options/configurable.phtml 的第 39 行到:
<option><?php echo $this->__('Select ') ?><?php echo $_attribute->getLabel() ?></option>

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

最佳答案

我的版本也是一样的问题。您只需要更改模板
目录/产品/ View /类型/选项/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;?>

注意(摘自评论)
如果所选的默认值恰好不是“Select %s”,请替换
$(element).options[0] = new Option(chooseDefaultText, '');


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

关于magento - 更改 Magento 产品页面上的文本 "Choose an option...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8113283/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com