Sorry I'm still quite new to this. I am having trouble getting the data from this array in my ajax success. I am trying to iterate through productVariantImages
to get the two imagePath
but I am only able to get one which is from id 496. Below is the sample of the array.
Also if possible I would like to use objects instead of array
[1] => Array
(
[id] => 194
[sku] => Apple SKU2
[variantName] => Pear 2
[productVariantImages] => Array
(
[0] => Array
(
[id] => 496
[imageName] => Apples in season.png
[imagePath] => http://tos-staging-web-server-s3.s3.amazonaws.com/9/catalogue/apples_in_season.png
[visible] => 1
[featured] =>
[modifiedDate] => 1448293975
[createDate] => 1448293975
)
[1] => Array
(
[id] => 266
[imageName] => Apples in season.png
[imagePath] => http://tos-staging-web-server-s3.s3.amazonaws.com/9/catalogue/apples_in_season.png
[visible] => 1
[featured] =>
[modifiedDate] => 1448293975
[createDate] => 1448293975
)
)
)
My ajax
success: function(data){
...
var thumbnails = {};
$.each(data.productVariantImages,function(i, productVariantImages){
thumbnails[data.sku] = this.imagePath;
});
...
}
Current output
{Apple SKU2: "http://tos-staging-web-server-s3.s3.amazonaws.com/9/catalogue/apples_in_season.png"}
Desired output: Trying to iterate through and get key/value values as shown
{Apple SKU2: "http://tos-staging-web-server-s3.s3.amazonaws.com/9/catalogue/apples_in_season.png",
Apple SKU2: "http://tos-staging-web-server-s3.s3.amazonaws.com/9/catalogue/apples_in_season.png"}