尝试更新选项价格时出现JS错误选择Magento中的捆绑产品

时间:2014-09-05 10:05:24

标签: javascript jquery json magento magento-1.9.1

由于将Magento网站从1.8升级到1.9并将其切换到RWD主题,因此在为捆绑产品选择产品选项时价格不会更新。

选择选项时,控制台会返回以下错误: -

  

未捕获的TypeError:无法读取null

的属性'update'

这发生在bundle.js的第83行tierPriceElement.update(tierPriceHtml);

这是changeSelection方法的一部分,其中包含以下内容: -

changeSelection: function(selection){
    var parts = selection.id.split('-');
    if (this.config['options'][parts[2]].isMulti) {
        selected = new Array();
        if (selection.tagName == 'SELECT') {
            for (var i = 0; i < selection.options.length; i++) {
                if (selection.options[i].selected && selection.options[i].value != '') {
                    selected.push(selection.options[i].value);
                }
            }
        } else if (selection.tagName == 'INPUT') {
            selector = parts[0]+'-'+parts[1]+'-'+parts[2];
            selections = $$('.'+selector);
            for (var i = 0; i < selections.length; i++) {
                if (selections[i].checked && selections[i].value != '') {
                    selected.push(selections[i].value);
                }
            }
        }
        this.config.selected[parts[2]] = selected;
    } else {
        if (selection.value != '') {
            this.config.selected[parts[2]] = new Array(selection.value);
        } else {
            this.config.selected[parts[2]] = new Array();
        }
        this.populateQty(parts[2], selection.value);
        var tierPriceElement = $('bundle-option-' + parts[2] + '-tier-prices'),
            tierPriceHtml = '';
        if (selection.value != '' && this.config.options[parts[2]].selections[selection.value].customQty == 1) {
            tierPriceHtml = this.config.options[parts[2]].selections[selection.value].tierPriceHtml;
        }
        tierPriceElement.update(tierPriceHtml);
    }
    this.reloadPrice();
},

我可以在此处看到完全相同的问题used to exist,但此后它已被删除。

鉴于这是与Magento 1.9一起打包的代码,奇怪的是这没有按预期工作......我确实强制主题回退到base主题的模板文件和相同的尝试更改捆绑产品上的选项时触发错误。

JavaScript当然不是我的专长(也不是调试它),上面的代码片段有什么不对吗?或者有关如何找到原因的任何建议?

修改

看来它毕竟是主题中的东西,因为我恢复到默认的RWD主题并且价格正在更新 - 可能是在布局XML中调用的扩展或其他内容。

3 个答案:

答案 0 :(得分:0)

最后,通过大量的反复试验,我确定了问题,确实是由第三方扩展造成的。

这个罪魁祸首是Magento Product Options Lightbox by Iceberg Commerce,可能会让其他人受益。

此扩展程序会使用自己的版本覆盖catalog/product/view/type/bundle/option/radio.phtml。它是使用日期代码的自己的版本(即使扩展声称与Magento 1.9兼容,它实际上使用了早期版本的捆绑选项代码。

要修复(对于那些希望使用此扩展名的人): -

替换此文件的全部内容(iceberg/bundledoptiondetails/catalog/product/view/type/bundle/option/radio.phtml): -

使用this version from my pastebin

答案 1 :(得分:0)

迁移到Enterprise Edition后我遇到了同样的问题。在我的情况下,解决方案与您的解决方案类似:重命名或删除app/design/frontend/MYPACKAGE/MYTHEME/template/bundle/catalog/product/view/type/bundle/option文件夹中的文件,以便系统回退到base/default/文件。

答案 2 :(得分:0)

我遇到类似的问题,包默认主题覆盖并从Magento 1.8升级到1.9升级:

应用程序/设计/前端/ {包} /默认/模板/束/目录/产品/视图/类型/束/选项/

Trick只是删除它,或者我可以复制rwd / default /../选项并保留可能需要的基本主题的类或HTML。