TypeError: Product.ConfigurableSwatches is not a constructor in Magento 1.9.3
TypeError: Product.ConfigurableSwatches is not a constructor in Magento 1.9.3
我正在使用 Magento 1.9.3.1 并在可配置的产品详细信息页面上遇到以下错误
TypeError: Product.ConfigurableSwatches is not a constructor
为什么会出现此错误,我该如何解决?
这似乎是 Magento 中的一个错误,因为当满足以下两个条件时,我能够在全新安装中重现它:
- 配置属性不是颜色的可配置产品。
- 已为该属性禁用可配置样本。
你可以通过在调用它之前检查Product.ConfigurableSwatches
是否存在来解决它:
1) 打开此文件:app/design/frontend/rwd/default/template/configurableswatches/catalog/product/view/type/configurable/swatch-js.phtml
2) 改变这个:
<script type="text/javascript">
document.observe('dom:loaded', function() {
var swatchesConfig = new Product.ConfigurableSwatches(spConfig);
});
</script>
为此:
<script type="text/javascript">
document.observe('dom:loaded', function() {
if (Product.ConfigurableSwatches) {
var swatchesConfig = new Product.ConfigurableSwatches(spConfig);
}
});
</script>
我正在使用 Magento 1.9.3.1 并在可配置的产品详细信息页面上遇到以下错误
TypeError: Product.ConfigurableSwatches is not a constructor
为什么会出现此错误,我该如何解决?
这似乎是 Magento 中的一个错误,因为当满足以下两个条件时,我能够在全新安装中重现它:
- 配置属性不是颜色的可配置产品。
- 已为该属性禁用可配置样本。
你可以通过在调用它之前检查Product.ConfigurableSwatches
是否存在来解决它:
1) 打开此文件:app/design/frontend/rwd/default/template/configurableswatches/catalog/product/view/type/configurable/swatch-js.phtml
2) 改变这个:
<script type="text/javascript">
document.observe('dom:loaded', function() {
var swatchesConfig = new Product.ConfigurableSwatches(spConfig);
});
</script>
为此:
<script type="text/javascript">
document.observe('dom:loaded', function() {
if (Product.ConfigurableSwatches) {
var swatchesConfig = new Product.ConfigurableSwatches(spConfig);
}
});
</script>