Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save splendidinternet/0db39b406264024d5c06 to your computer and use it in GitHub Desktop.
Save splendidinternet/0db39b406264024d5c06 to your computer and use it in GitHub Desktop.
Patch for Magento 1.9.1.0 swatches image swap
diff --git a/skin/frontend/rwd/default/js/configurableswatches/product-media.js b/skin/frontend/rwd/default/js/configurableswatches/product-media.js
index 17fd81f..5726200 100644
--- a/skin/frontend/rwd/default/js/configurableswatches/product-media.js
+++ b/skin/frontend/rwd/default/js/configurableswatches/product-media.js
@@ -65,8 +65,11 @@ var ConfigurableMediaImages = {
});
});
+ compatibleProducts.sort();
+
//intersect compatible products
compatibleProductSets.each(function(productSet) {
+ productSet.sort();
compatibleProducts = ConfigurableMediaImages.arrayIntersect(compatibleProducts, productSet);
});
@@ -107,6 +110,7 @@ var ConfigurableMediaImages = {
if(image) { //configurable product has image in the first place
//if intersection between compatible products and this label's products, we found a match
+ products.sort();
var isCompatibleProduct = ConfigurableMediaImages.arrayIntersect(products, compatibleProducts).length > 0;
if(isCompatibleProduct) {
return image;
@@ -120,7 +124,7 @@ var ConfigurableMediaImages = {
compatibleProducts.each(function(productId) {
if(childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId])) {
childSwatchImage = childProductImages[productId];
- return false; //break "loop"
+ throw $break; //break "loop"
}
});
if (childSwatchImage) {
@namrodbui
Copy link

I LOVE YOU.

@gmcn
Copy link

gmcn commented Apr 5, 2017

me too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment