0

我已经设置了一个可配置的产品并将相对简单的产品与它相关联。我已经多次阅读 Magento 的指南。

Magento 正在产品页面上输出选项菜单,但唯一的选项是“选择一个选项...”。

在我看到的 HTML 中

<script type="text/javascript">
    var spConfig = new Product.Config({"attributes":{"144":{"id":"144","code":"size_mens_necklace","label":"Size","options":[{"id":"45","label":"18 in | 46 cm","price":"0","oldPrice":"0","products":["820","821","822","823"]},{"id":"44","label":"20 in | 51 cm","price":"0","oldPrice":"0","products":["824","825","826","827"]},{"id":"43","label":"24 in | 61 cm","price":"0","oldPrice":"0","products":["828","829","830","831"]}]},"92":{"id":"92","code":"color","label":"Color","options":[{"id":"18","label":"Gold Tone","price":"0","oldPrice":"0","products":["820","821"]},{"id":"17","label":"Rose-Gold Tone","price":"0","oldPrice":"0","products":["822","823"]},{"id":"16","label":"Silver Tone","price":"0","oldPrice":"0","products":["824","826"]},{"id":"15","label":"Two Tone","price":"0","oldPrice":"0","products":["825","827"]},{"id":"14","label":"Black","price":"0","oldPrice":"0","products":["828","829"]},{"id":"13","label":"Blue","price":"0","oldPrice":"0","products":["830","831"]}]},"141":{"id":"141","code":"material","label":"Materials","options":[{"id":"28","label":"ENAMEL","price":"0","oldPrice":"0","products":["820","822"]},{"id":"27","label":"METAL","price":"0","oldPrice":"0","products":["821","823"]},{"id":"26","label":"STERLING SILVER","price":"0","oldPrice":"0","products":["824","825"]},{"id":"25","label":"STAINLESS STEEL","price":"0","oldPrice":"0","products":["831"]},{"id":"24","label":"TITANIUM","price":"0","oldPrice":"0","products":["827","830"]},{"id":"23","label":"RODIUM","price":"0","oldPrice":"0","products":["826"]},{"id":"22","label":"COPPER","price":"0","oldPrice":"0","products":["828"]},{"id":"19","label":"ACRYLIC","price":"0","oldPrice":"0","products":["829"]}]}},"template":"$#{price}","basePrice":"18","oldPrice":"25","productId":"809","chooseText":"Please Select Size","taxConfig":{"includeTax":false,"showIncludeTax":true,"showBothPrices":false,"defaultTax":0,"currentTax":0,"inclTaxTitle":"Incl. Tax"}});
</script>

在浏览器控制台中,我看到:

The value "160dpi" for key "target-densitydpi" was truncated to its numeric prefix. mens-necklace-with-configurable-options.html:13
The key "target-densitydpi" is not supported. mens-necklace-with-configurable-options.html:13
Uncaught TypeError: Cannot read property 'msie' of undefined jquery.uniform.min.js:1
Uncaught TypeError: Cannot read property 'msie' of undefined jquery.colorbox-min.js:4
Uncaught TypeError: Cannot call method 'carousel' of null mens-necklace-with-configurable-options.html:292
Uncaught TypeError: Cannot call method 'click' of null mens-necklace-with-configurable-options.html:307
Uncaught TypeError: Object #<Object> has no method 'attachEvent' 6856a05de8509fa18d4dff9124c059b4.js:983
Uncaught TypeError: Cannot read property 'length' of undefined 6856a05de8509fa18d4dff9124c059b4.js:2459
Uncaught TypeError: Cannot call method 'carousel' of null mens-necklace-with-configurable-options.html:2911
Uncaught TypeError: Cannot call method 'click' of null mens-necklace-with-configurable-options.html:2926
Uncaught TypeError: Object [object Object] has no method 'uniform' mens-necklace-with-configurable-options.html:234
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/media/catalog/category/198-women-jewelry_1.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/media/catalog/category/fashion-jewelry7_2.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/media/catalog/category/100313_mens_cross_jewelry_1.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/media/catalog/category/jewelry-for-men_3.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/media/catalog/category/fashion-jewelry7_3.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/media/catalog/category/198-women-jewelry_2.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/media/catalog/category/jewelry-for-men_4.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/index.php/necklaces/men/all-men-s-necklaces/0
Failed to load resource: the server responded with a status of 404 (Not Found) http://domain.com/bonpo/index.php/necklaces/men/all-men-s-necklaces/
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

我读过 javascript 冲突会导致这个问题。我正在使用 jQuery,但包含了 noConflict()。

4

1 回答 1

4

Magento 以编程方式生成该列表的方式是

  1. 生成一个空的选择列表

  2. 使用 in 的值spConfig来填充带有选项的选择列表。这发生在您的浏览器执行时var spConfig = new Product.Config(...)

如果我们格式化 javascript 对象字符串,我们可以看到 Magento 知道您配置的产品

{
    "attributes": {
        "144": {
            "id": "144",
            "code": "size_mens_necklace",
            "label": "Size",
            "options": [{
                "id": "45",
                "label": "18 in | 46 cm",
                "price": "0",
                "oldPrice": "0",
                "products": ["820", "821", "822", "823"]
            }, {
                "id": "44",
                "label": "20 in | 51 cm",
                "price": "0",
                "oldPrice": "0",
                "products": ["824", "825", "826", "827"]
            }, {
                "id": "43",
                "label": "24 in | 61 cm",
                "price": "0",
                "oldPrice": "0",
                "products": ["828", "829", "830", "831"]
            }]
        },
        "92": {
            "id": "92",
            "code": "color",
            "label": "Color",
            "options": [{
                "id": "18",
                "label": "Gold Tone",
                "price": "0",
                "oldPrice": "0",
                "products": ["820", "821"]
            }, {
                "id": "17",
                "label": "Rose-Gold Tone",
                "price": "0",
                "oldPrice": "0",
                "products": ["822", "823"]
            }, {
                "id": "16",
                "label": "Silver Tone",
                "price": "0",
                "oldPrice": "0",
                "products": ["824", "826"]
            }, {
                "id": "15",
                "label": "Two Tone",
                "price": "0",
                "oldPrice": "0",
                "products": ["825", "827"]
            }, {
                "id": "14",
                "label": "Black",
                "price": "0",
                "oldPrice": "0",
                "products": ["828", "829"]
            }, {
                "id": "13",
                "label": "Blue",
                "price": "0",
                "oldPrice": "0",
                "products": ["830", "831"]
            }]
        },
        "141": {
            "id": "141",
            "code": "material",
            "label": "Materials",
            "options": [{
                "id": "28",
                "label": "ENAMEL",
                "price": "0",
                "oldPrice": "0",
                "products": ["820", "822"]
            }, {
                "id": "27",
                "label": "METAL",
                "price": "0",
                "oldPrice": "0",
                "products": ["821", "823"]
            }, {
                "id": "26",
                "label": "STERLING SILVER",
                "price": "0",
                "oldPrice": "0",
                "products": ["824", "825"]
            }, {
                "id": "25",
                "label": "STAINLESS STEEL",
                "price": "0",
                "oldPrice": "0",
                "products": ["831"]
            }, {
                "id": "24",
                "label": "TITANIUM",
                "price": "0",
                "oldPrice": "0",
                "products": ["827", "830"]
            }, {
                "id": "23",
                "label": "RODIUM",
                "price": "0",
                "oldPrice": "0",
                "products": ["826"]
            }, {
                "id": "22",
                "label": "COPPER",
                "price": "0",
                "oldPrice": "0",
                "products": ["828"]
            }, {
                "id": "19",
                "label": "ACRYLIC",
                "price": "0",
                "oldPrice": "0",
                "products": ["829"]
            }]
        }
    },
    "template": "$#{price}",
    "basePrice": "18",
    "oldPrice": "25",
    "productId": "809",
    "chooseText": "Please Select Size",
    "taxConfig": {
        "includeTax": false,
        "showIncludeTax": true,
        "showBothPrices": false,
        "defaultTax": 0,
        "currentTax": 0,
        "inclTaxTitle": "Incl. Tax"
    }
}

这指出了您的选项列表未生成为的原因

  1. 控制台中列出的无数 javascript 错误,虽然与产品选项无关,但已停止在页面上执行 Javascript,Magento 永远不会定义spConfig

  2. 有人添加了js/varien/configurable.js阻止选项标签加载的自定义项(reloadOptionLabels以及fillSelect您在此处感兴趣的方法)

于 2013-12-28T23:28:34.700 回答