Skip to content

Instantly share code, notes, and snippets.

@Stasevi4
Last active June 22, 2018 05:58
Show Gist options
  • Save Stasevi4/d991f541e117301e070cd7eb0d4ffffc to your computer and use it in GitHub Desktop.
Save Stasevi4/d991f541e117301e070cd7eb0d4ffffc to your computer and use it in GitHub Desktop.
Magento Fix Undefined index - app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 145
diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php
index 13e8659..f7000df 100755
--- a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php
+++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php
@@ -141,12 +141,12 @@ class Mage_ConfigurableSwatches_Helper_Productimg extends Mage_Core_Helper_Abstr
$swatchLabel = $label . self::SWATCH_LABEL_SUFFIX;
$imageKeys[$label] = array_search($label, $imageHaystack);
- if ($imageKeys[$label] === false) {
+ if ($imageKeys[$label] === false && array_keys($mapping, $label)) {
$imageKeys[$label] = array_search($mapping[$label]['default_label'], $imageHaystack);
}
$imageKeys[$swatchLabel] = array_search($swatchLabel, $imageHaystack);
- if ($imageKeys[$swatchLabel] === false) {
+ if ($imageKeys[$swatchLabel] === false && array_keys($mapping, $label)) {
$imageKeys[$swatchLabel] = array_search(
$mapping[$label]['default_label'] . self::SWATCH_LABEL_SUFFIX, $imageHaystack
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment