¿Cómo se obtiene el valor de assocIMG
por la clave coincide con la clave por ejemplojQuery valor del objeto get por la clave
si tengo una var 11786
lo quiero volver media/catalog/product/8795139_633.jpg
var spConfig = {
"attributes": {
"125": {
"id": "125",
"code": "pos_colours",
"label": "Colour",
"options": [{
"id": "236",
"label": "Dazzling Blue",
"price": "0",
"oldPrice": "0",
"products": ["11148"]
}, {
"id": "305",
"label": "Vintage Brown",
"price": "0",
"oldPrice": "0",
"products": ["11786", "11787", "11788", "11789", "11790", "11791", "11792", "11793"]
}]
}
}
};
var assocIMG = // Added - Removed { here, causes issues with other scripts when not working with a configurable product.
{
11786: 'media/catalog/product/8795139_633.jpg',
11787: 'media/catalog/product/8795139_633.jpg',
}
Por encima son los objetos Estoy trabajando con y debajo está mi jQuery actual. La ayuda sería muy apreciada.
$('#attribute125').change(function() {
var image = $(this).val();
$.each(spConfig.attributes, function() {
prods = $(this.options).filter(function() { return this.id == image; })[0].products[0];
alert(prods);
});
});
¿Puedes explicarlo mejor? Estoy confundido: ¿tienes muchos identificadores de productos en ese conjunto de productos, pero solo 2 imágenes? –