Configurable Product Dropdown Image SwitchConfigurable products: product image not updating after selecting attribute in dropdownFatal Error Mediafallback.php on line 61How to correctly create a configurable product with multiple attributes and imagesHow to display Configurable/Color Swatches in Homepage Magento 1.9.1Magento - Fatal Error in Mediafallback.php - 1.9.2.4Configurable product image resolution issueIssue while Configuring color swatches in Magento 1.9.3.10How to show dropdown configurable attribute in Product Category View in Magento 2?Fatal error: Uncaught Error: Call to a member function getId() on null inProductimg.php errorlog in system.logMagento 1 EE 1.14.3.10 - Mage::getSingleton('core/resource')->getConnection('core_read') is returning null sometimes

How long does it take to type this?

If Manufacturer spice model and Datasheet give different values which should I use?

Pronouncing Dictionary.com's W.O.D "vade mecum" in English

What Brexit solution does the DUP want?

declaring a variable twice in IIFE

A Journey Through Space and Time

What defenses are there against being summoned by the Gate spell?

Is there really no realistic way for a skeleton monster to move around without magic?

How to make payment on the internet without leaving a money trail?

New order #4: World

I probably found a bug with the sudo apt install function

A function which translates a sentence to title-case

Motorized valve interfering with button?

Download, install and reboot computer at night if needed

What makes Graph invariants so useful/important?

How do you conduct xenoanthropology after first contact?

Draw simple lines in Inkscape

What do you call a Matrix-like slowdown and camera movement effect?

Validation accuracy vs Testing accuracy

What is the command to reset a PC without deleting any files

The use of multiple foreign keys on same column in SQL Server

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

Circuitry of TV splitters

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?



Configurable Product Dropdown Image Switch


Configurable products: product image not updating after selecting attribute in dropdownFatal Error Mediafallback.php on line 61How to correctly create a configurable product with multiple attributes and imagesHow to display Configurable/Color Swatches in Homepage Magento 1.9.1Magento - Fatal Error in Mediafallback.php - 1.9.2.4Configurable product image resolution issueIssue while Configuring color swatches in Magento 1.9.3.10How to show dropdown configurable attribute in Product Category View in Magento 2?Fatal error: Uncaught Error: Call to a member function getId() on null inProductimg.php errorlog in system.logMagento 1 EE 1.14.3.10 - Mage::getSingleton('core/resource')->getConnection('core_read') is returning null sometimes






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I upgraded my site from EE 1.14.1.0 to 1.14.3.10 and now when I navigate to a configurable product that uses a drop down (not swatches) to change the image, the image does not change.



I have looked at the solutions in these exchanges, but none of them solved my issue:



Configurable products: product image not updating after selecting attribute in dropdown



^ This solution while it technically solves my problem, it doesn't keep the options in a dropdown, but switches them to swatches. We want the options to remain in a dropdown.



https://stackoverflow.com/questions/41845427/typeerror-product-configurableswatches-is-not-a-constructor-in-magento-1-9-3



^ This solution solves a JS error I also got, but doesn't fix the images switching part.



--



As soon as I navigate to the page, these errors are generated in system.log:



ERR (3): Warning: array_merge_recursive() expects at least 1 parameter, 0 given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 336
ERR (3): Warning: array_unique() expects parameter 1 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 337
ERR (3): Warning: array_map(): Argument #2 should be an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
ERR (3): Warning: array_merge(): Argument #1 is not an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
ERR (3): Warning: in_array() expects parameter 2 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 345


Could this be what is causing the issue? If so, what might a solution be?



This was not an issue prior to updating. I have a support ticket out with Magento, but they are taking their sweet time (since November), so I thought I would see if anyone has any solutions.



--



Update 3/12



Magento sent me a patch that resolved the errors in system.log, but I am still unable to swap images based on the option selected in the dropdown.



In app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php update the filterImageInGallery function as follows:



public function filterImageInGallery($product, $image)

if (!Mage::helper('configurableswatches')->isEnabled())
return true;


if (!isset($this->_productImageFilters[$product->getId()])
&& $childAttributeLabelMapping = $product->getChildAttributeLabelMapping()
)
$mapping = call_user_func_array("array_merge_recursive", $childAttributeLabelMapping);
$filters = array_unique($mapping['labels']);
$filters = array_merge($filters, array_map(function ($label)
return $label . Mage_ConfigurableSwatches_Helper_Productimg::SWATCH_LABEL_SUFFIX;
, $filters));
$this->_productImageFilters[$product->getId()] = $filters;

return !in_array(Mage_ConfigurableSwatches_Helper_Data::normalizeKey($image->getLabel()),
$this->_productImageFilters[$product->getId()]);


return true;










share|improve this question






























    1















    I upgraded my site from EE 1.14.1.0 to 1.14.3.10 and now when I navigate to a configurable product that uses a drop down (not swatches) to change the image, the image does not change.



    I have looked at the solutions in these exchanges, but none of them solved my issue:



    Configurable products: product image not updating after selecting attribute in dropdown



    ^ This solution while it technically solves my problem, it doesn't keep the options in a dropdown, but switches them to swatches. We want the options to remain in a dropdown.



    https://stackoverflow.com/questions/41845427/typeerror-product-configurableswatches-is-not-a-constructor-in-magento-1-9-3



    ^ This solution solves a JS error I also got, but doesn't fix the images switching part.



    --



    As soon as I navigate to the page, these errors are generated in system.log:



    ERR (3): Warning: array_merge_recursive() expects at least 1 parameter, 0 given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 336
    ERR (3): Warning: array_unique() expects parameter 1 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 337
    ERR (3): Warning: array_map(): Argument #2 should be an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
    ERR (3): Warning: array_merge(): Argument #1 is not an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
    ERR (3): Warning: in_array() expects parameter 2 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 345


    Could this be what is causing the issue? If so, what might a solution be?



    This was not an issue prior to updating. I have a support ticket out with Magento, but they are taking their sweet time (since November), so I thought I would see if anyone has any solutions.



    --



    Update 3/12



    Magento sent me a patch that resolved the errors in system.log, but I am still unable to swap images based on the option selected in the dropdown.



    In app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php update the filterImageInGallery function as follows:



    public function filterImageInGallery($product, $image)

    if (!Mage::helper('configurableswatches')->isEnabled())
    return true;


    if (!isset($this->_productImageFilters[$product->getId()])
    && $childAttributeLabelMapping = $product->getChildAttributeLabelMapping()
    )
    $mapping = call_user_func_array("array_merge_recursive", $childAttributeLabelMapping);
    $filters = array_unique($mapping['labels']);
    $filters = array_merge($filters, array_map(function ($label)
    return $label . Mage_ConfigurableSwatches_Helper_Productimg::SWATCH_LABEL_SUFFIX;
    , $filters));
    $this->_productImageFilters[$product->getId()] = $filters;

    return !in_array(Mage_ConfigurableSwatches_Helper_Data::normalizeKey($image->getLabel()),
    $this->_productImageFilters[$product->getId()]);


    return true;










    share|improve this question


























      1












      1








      1








      I upgraded my site from EE 1.14.1.0 to 1.14.3.10 and now when I navigate to a configurable product that uses a drop down (not swatches) to change the image, the image does not change.



      I have looked at the solutions in these exchanges, but none of them solved my issue:



      Configurable products: product image not updating after selecting attribute in dropdown



      ^ This solution while it technically solves my problem, it doesn't keep the options in a dropdown, but switches them to swatches. We want the options to remain in a dropdown.



      https://stackoverflow.com/questions/41845427/typeerror-product-configurableswatches-is-not-a-constructor-in-magento-1-9-3



      ^ This solution solves a JS error I also got, but doesn't fix the images switching part.



      --



      As soon as I navigate to the page, these errors are generated in system.log:



      ERR (3): Warning: array_merge_recursive() expects at least 1 parameter, 0 given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 336
      ERR (3): Warning: array_unique() expects parameter 1 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 337
      ERR (3): Warning: array_map(): Argument #2 should be an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
      ERR (3): Warning: array_merge(): Argument #1 is not an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
      ERR (3): Warning: in_array() expects parameter 2 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 345


      Could this be what is causing the issue? If so, what might a solution be?



      This was not an issue prior to updating. I have a support ticket out with Magento, but they are taking their sweet time (since November), so I thought I would see if anyone has any solutions.



      --



      Update 3/12



      Magento sent me a patch that resolved the errors in system.log, but I am still unable to swap images based on the option selected in the dropdown.



      In app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php update the filterImageInGallery function as follows:



      public function filterImageInGallery($product, $image)

      if (!Mage::helper('configurableswatches')->isEnabled())
      return true;


      if (!isset($this->_productImageFilters[$product->getId()])
      && $childAttributeLabelMapping = $product->getChildAttributeLabelMapping()
      )
      $mapping = call_user_func_array("array_merge_recursive", $childAttributeLabelMapping);
      $filters = array_unique($mapping['labels']);
      $filters = array_merge($filters, array_map(function ($label)
      return $label . Mage_ConfigurableSwatches_Helper_Productimg::SWATCH_LABEL_SUFFIX;
      , $filters));
      $this->_productImageFilters[$product->getId()] = $filters;

      return !in_array(Mage_ConfigurableSwatches_Helper_Data::normalizeKey($image->getLabel()),
      $this->_productImageFilters[$product->getId()]);


      return true;










      share|improve this question
















      I upgraded my site from EE 1.14.1.0 to 1.14.3.10 and now when I navigate to a configurable product that uses a drop down (not swatches) to change the image, the image does not change.



      I have looked at the solutions in these exchanges, but none of them solved my issue:



      Configurable products: product image not updating after selecting attribute in dropdown



      ^ This solution while it technically solves my problem, it doesn't keep the options in a dropdown, but switches them to swatches. We want the options to remain in a dropdown.



      https://stackoverflow.com/questions/41845427/typeerror-product-configurableswatches-is-not-a-constructor-in-magento-1-9-3



      ^ This solution solves a JS error I also got, but doesn't fix the images switching part.



      --



      As soon as I navigate to the page, these errors are generated in system.log:



      ERR (3): Warning: array_merge_recursive() expects at least 1 parameter, 0 given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 336
      ERR (3): Warning: array_unique() expects parameter 1 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 337
      ERR (3): Warning: array_map(): Argument #2 should be an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
      ERR (3): Warning: array_merge(): Argument #1 is not an array in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 340
      ERR (3): Warning: in_array() expects parameter 2 to be array, null given in /app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php on line 345


      Could this be what is causing the issue? If so, what might a solution be?



      This was not an issue prior to updating. I have a support ticket out with Magento, but they are taking their sweet time (since November), so I thought I would see if anyone has any solutions.



      --



      Update 3/12



      Magento sent me a patch that resolved the errors in system.log, but I am still unable to swap images based on the option selected in the dropdown.



      In app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php update the filterImageInGallery function as follows:



      public function filterImageInGallery($product, $image)

      if (!Mage::helper('configurableswatches')->isEnabled())
      return true;


      if (!isset($this->_productImageFilters[$product->getId()])
      && $childAttributeLabelMapping = $product->getChildAttributeLabelMapping()
      )
      $mapping = call_user_func_array("array_merge_recursive", $childAttributeLabelMapping);
      $filters = array_unique($mapping['labels']);
      $filters = array_merge($filters, array_map(function ($label)
      return $label . Mage_ConfigurableSwatches_Helper_Productimg::SWATCH_LABEL_SUFFIX;
      , $filters));
      $this->_productImageFilters[$product->getId()] = $filters;

      return !in_array(Mage_ConfigurableSwatches_Helper_Data::normalizeKey($image->getLabel()),
      $this->_productImageFilters[$product->getId()]);


      return true;







      configurable-product configurable-swatches magento-1.14.3.10






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 13 at 18:43







      cbartell

















      asked Mar 6 at 18:55









      cbartellcbartell

      115




      115




















          1 Answer
          1






          active

          oldest

          votes


















          0














          After getting a response from Magento that was "this is not part of native functionality" and thus it was "likely customized", I poked around some more on my own. What I've discovered is that for EE 1.14.3.10 this is a true statement, but for EE 1.14.1.0 it is not. I tested with a vanilla install of 1.14.1.0 and was able to switch the images using a dropdown without any customizations/extensions.



          I ended up creating a new extension to override some of the configurable swatches functionality.



          The files I copied from the vanilla 1.14.1.0 install into my new extension in 1.14.3.10 were:



          /app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php
          /app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
          /app/code/core/Mage/ConfigurableSwatches/Model/Observer.php


          In my theme there were a couple of JS files that also had to be addressed:



          /skin/frontend/[theme]/default/js/app.js



          var ProductMediaManager = 
          IMAGE_ZOOM_THRESHOLD: 20,
          imageWrapper: null,

          destroyZoom: function()
          $j('.zoomContainer').remove();
          $j('.ds-product-image-gallery .gallery-image').removeData('elevateZoom');
          ,

          createZoom: function(image) [no changes] ,

          swapImage: function(targetImage)
          ProductMediaManager.destroyZoom();

          var imageGallery = $j('.ds-product-image-gallery');

          imageGallery.slick('slickGoTo', targetImage);
          ,

          wireThumbnails: function()
          //trigger image change event on thumbnail click
          $j('.ds-product-image-thumbs .thumb-link').click( function(e)
          e.preventDefault();
          var target = $j(this).data('imageIndex');
          ProductMediaManager.swapImage(target);
          $j("li.selected").removeClass("selected");
          $j(this).parent("li").addClass("selected");
          )

          $j('.ds-product-image-gallery').on( 'afterChange', function(e, slick, currentSlide)
          var slide = $j(this).find('.gallery-image').eq(currentSlide);
          ProductMediaManager.createZoom(slide);
          );
          ,

          initZoom: function()
          [no changes]
          ,

          init: function() [no changes]

          ;


          /skin/frontend/dayspring/default/js/configurableswatches/product-media.js



          getCompatibleProductImages: function(productFallback, selectedLabels) 
          //find compatible products
          var compatibleProducts = [];
          var compatibleProductSets = [];
          selectedLabels.each(function(selectedLabel)
          if(typeof(productFallback['option_labels']) != 'undefined')
          if (!productFallback['option_labels'][selectedLabel])
          return;


          var optionProducts = productFallback['option_labels'][selectedLabel]['products'];
          compatibleProductSets.push(optionProducts);

          //optimistically push all products
          optionProducts.each(function (productId)
          compatibleProducts.push(productId);
          );

          );

          //intersect compatible products
          compatibleProductSets.each(function(productSet)
          compatibleProducts = ConfigurableMediaImages.arrayIntersect(compatibleProducts, productSet);
          );

          return compatibleProducts;
          ,


          getSwatchImage: function(productId, optionLabel, selectedLabels)
          var fallback = ConfigurableMediaImages.productImages[productId];
          if(!fallback)
          return null;


          //first, try to get label-matching image on config product for this option's label
          if(typeof(fallback['option_labels']) != 'undefined')
          var currentLabelImage = fallback['option_labels'][optionLabel];
          if (currentLabelImage && fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType])
          //found label image on configurable product
          return fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType];



          var compatibleProducts = ConfigurableMediaImages.getCompatibleProductImages(fallback, selectedLabels);

          if(compatibleProducts.length == 0) //no compatible products
          return null; //bail


          //second, get any product which is compatible with currently selected option(s)
          $j.each(fallback['option_labels'], function(key, value)
          var image = value['configurable_product'][ConfigurableMediaImages.imageType];
          var products = value['products'];

          if(image) //configurable product has image in the first place
          //if intersection between compatible products and this label's products, we found a match
          var isCompatibleProduct = ConfigurableMediaImages.arrayIntersect(products, compatibleProducts).length > 0;
          if(isCompatibleProduct)
          return image;


          );

          //third, get image off of child product which is compatible
          var childSwatchImage = null;
          var childProductImages = fallback[ConfigurableMediaImages.imageType];
          compatibleProducts.each(function(productId)
          if(childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
          childSwatchImage = childProductImages[productId];
          return false; //break "loop"

          );
          if (childSwatchImage)
          return childSwatchImage;


          //fourth, get base image off parent product
          if (childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
          return childProductImages[productId];


          //no fallback image found
          return null;
          ,


          After creating this extension, I am now able to switch images by selecting an option from a dropdown.






          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264761%2fconfigurable-product-dropdown-image-switch%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            After getting a response from Magento that was "this is not part of native functionality" and thus it was "likely customized", I poked around some more on my own. What I've discovered is that for EE 1.14.3.10 this is a true statement, but for EE 1.14.1.0 it is not. I tested with a vanilla install of 1.14.1.0 and was able to switch the images using a dropdown without any customizations/extensions.



            I ended up creating a new extension to override some of the configurable swatches functionality.



            The files I copied from the vanilla 1.14.1.0 install into my new extension in 1.14.3.10 were:



            /app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php
            /app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
            /app/code/core/Mage/ConfigurableSwatches/Model/Observer.php


            In my theme there were a couple of JS files that also had to be addressed:



            /skin/frontend/[theme]/default/js/app.js



            var ProductMediaManager = 
            IMAGE_ZOOM_THRESHOLD: 20,
            imageWrapper: null,

            destroyZoom: function()
            $j('.zoomContainer').remove();
            $j('.ds-product-image-gallery .gallery-image').removeData('elevateZoom');
            ,

            createZoom: function(image) [no changes] ,

            swapImage: function(targetImage)
            ProductMediaManager.destroyZoom();

            var imageGallery = $j('.ds-product-image-gallery');

            imageGallery.slick('slickGoTo', targetImage);
            ,

            wireThumbnails: function()
            //trigger image change event on thumbnail click
            $j('.ds-product-image-thumbs .thumb-link').click( function(e)
            e.preventDefault();
            var target = $j(this).data('imageIndex');
            ProductMediaManager.swapImage(target);
            $j("li.selected").removeClass("selected");
            $j(this).parent("li").addClass("selected");
            )

            $j('.ds-product-image-gallery').on( 'afterChange', function(e, slick, currentSlide)
            var slide = $j(this).find('.gallery-image').eq(currentSlide);
            ProductMediaManager.createZoom(slide);
            );
            ,

            initZoom: function()
            [no changes]
            ,

            init: function() [no changes]

            ;


            /skin/frontend/dayspring/default/js/configurableswatches/product-media.js



            getCompatibleProductImages: function(productFallback, selectedLabels) 
            //find compatible products
            var compatibleProducts = [];
            var compatibleProductSets = [];
            selectedLabels.each(function(selectedLabel)
            if(typeof(productFallback['option_labels']) != 'undefined')
            if (!productFallback['option_labels'][selectedLabel])
            return;


            var optionProducts = productFallback['option_labels'][selectedLabel]['products'];
            compatibleProductSets.push(optionProducts);

            //optimistically push all products
            optionProducts.each(function (productId)
            compatibleProducts.push(productId);
            );

            );

            //intersect compatible products
            compatibleProductSets.each(function(productSet)
            compatibleProducts = ConfigurableMediaImages.arrayIntersect(compatibleProducts, productSet);
            );

            return compatibleProducts;
            ,


            getSwatchImage: function(productId, optionLabel, selectedLabels)
            var fallback = ConfigurableMediaImages.productImages[productId];
            if(!fallback)
            return null;


            //first, try to get label-matching image on config product for this option's label
            if(typeof(fallback['option_labels']) != 'undefined')
            var currentLabelImage = fallback['option_labels'][optionLabel];
            if (currentLabelImage && fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType])
            //found label image on configurable product
            return fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType];



            var compatibleProducts = ConfigurableMediaImages.getCompatibleProductImages(fallback, selectedLabels);

            if(compatibleProducts.length == 0) //no compatible products
            return null; //bail


            //second, get any product which is compatible with currently selected option(s)
            $j.each(fallback['option_labels'], function(key, value)
            var image = value['configurable_product'][ConfigurableMediaImages.imageType];
            var products = value['products'];

            if(image) //configurable product has image in the first place
            //if intersection between compatible products and this label's products, we found a match
            var isCompatibleProduct = ConfigurableMediaImages.arrayIntersect(products, compatibleProducts).length > 0;
            if(isCompatibleProduct)
            return image;


            );

            //third, get image off of child product which is compatible
            var childSwatchImage = null;
            var childProductImages = fallback[ConfigurableMediaImages.imageType];
            compatibleProducts.each(function(productId)
            if(childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
            childSwatchImage = childProductImages[productId];
            return false; //break "loop"

            );
            if (childSwatchImage)
            return childSwatchImage;


            //fourth, get base image off parent product
            if (childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
            return childProductImages[productId];


            //no fallback image found
            return null;
            ,


            After creating this extension, I am now able to switch images by selecting an option from a dropdown.






            share|improve this answer



























              0














              After getting a response from Magento that was "this is not part of native functionality" and thus it was "likely customized", I poked around some more on my own. What I've discovered is that for EE 1.14.3.10 this is a true statement, but for EE 1.14.1.0 it is not. I tested with a vanilla install of 1.14.1.0 and was able to switch the images using a dropdown without any customizations/extensions.



              I ended up creating a new extension to override some of the configurable swatches functionality.



              The files I copied from the vanilla 1.14.1.0 install into my new extension in 1.14.3.10 were:



              /app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php
              /app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
              /app/code/core/Mage/ConfigurableSwatches/Model/Observer.php


              In my theme there were a couple of JS files that also had to be addressed:



              /skin/frontend/[theme]/default/js/app.js



              var ProductMediaManager = 
              IMAGE_ZOOM_THRESHOLD: 20,
              imageWrapper: null,

              destroyZoom: function()
              $j('.zoomContainer').remove();
              $j('.ds-product-image-gallery .gallery-image').removeData('elevateZoom');
              ,

              createZoom: function(image) [no changes] ,

              swapImage: function(targetImage)
              ProductMediaManager.destroyZoom();

              var imageGallery = $j('.ds-product-image-gallery');

              imageGallery.slick('slickGoTo', targetImage);
              ,

              wireThumbnails: function()
              //trigger image change event on thumbnail click
              $j('.ds-product-image-thumbs .thumb-link').click( function(e)
              e.preventDefault();
              var target = $j(this).data('imageIndex');
              ProductMediaManager.swapImage(target);
              $j("li.selected").removeClass("selected");
              $j(this).parent("li").addClass("selected");
              )

              $j('.ds-product-image-gallery').on( 'afterChange', function(e, slick, currentSlide)
              var slide = $j(this).find('.gallery-image').eq(currentSlide);
              ProductMediaManager.createZoom(slide);
              );
              ,

              initZoom: function()
              [no changes]
              ,

              init: function() [no changes]

              ;


              /skin/frontend/dayspring/default/js/configurableswatches/product-media.js



              getCompatibleProductImages: function(productFallback, selectedLabels) 
              //find compatible products
              var compatibleProducts = [];
              var compatibleProductSets = [];
              selectedLabels.each(function(selectedLabel)
              if(typeof(productFallback['option_labels']) != 'undefined')
              if (!productFallback['option_labels'][selectedLabel])
              return;


              var optionProducts = productFallback['option_labels'][selectedLabel]['products'];
              compatibleProductSets.push(optionProducts);

              //optimistically push all products
              optionProducts.each(function (productId)
              compatibleProducts.push(productId);
              );

              );

              //intersect compatible products
              compatibleProductSets.each(function(productSet)
              compatibleProducts = ConfigurableMediaImages.arrayIntersect(compatibleProducts, productSet);
              );

              return compatibleProducts;
              ,


              getSwatchImage: function(productId, optionLabel, selectedLabels)
              var fallback = ConfigurableMediaImages.productImages[productId];
              if(!fallback)
              return null;


              //first, try to get label-matching image on config product for this option's label
              if(typeof(fallback['option_labels']) != 'undefined')
              var currentLabelImage = fallback['option_labels'][optionLabel];
              if (currentLabelImage && fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType])
              //found label image on configurable product
              return fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType];



              var compatibleProducts = ConfigurableMediaImages.getCompatibleProductImages(fallback, selectedLabels);

              if(compatibleProducts.length == 0) //no compatible products
              return null; //bail


              //second, get any product which is compatible with currently selected option(s)
              $j.each(fallback['option_labels'], function(key, value)
              var image = value['configurable_product'][ConfigurableMediaImages.imageType];
              var products = value['products'];

              if(image) //configurable product has image in the first place
              //if intersection between compatible products and this label's products, we found a match
              var isCompatibleProduct = ConfigurableMediaImages.arrayIntersect(products, compatibleProducts).length > 0;
              if(isCompatibleProduct)
              return image;


              );

              //third, get image off of child product which is compatible
              var childSwatchImage = null;
              var childProductImages = fallback[ConfigurableMediaImages.imageType];
              compatibleProducts.each(function(productId)
              if(childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
              childSwatchImage = childProductImages[productId];
              return false; //break "loop"

              );
              if (childSwatchImage)
              return childSwatchImage;


              //fourth, get base image off parent product
              if (childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
              return childProductImages[productId];


              //no fallback image found
              return null;
              ,


              After creating this extension, I am now able to switch images by selecting an option from a dropdown.






              share|improve this answer

























                0












                0








                0







                After getting a response from Magento that was "this is not part of native functionality" and thus it was "likely customized", I poked around some more on my own. What I've discovered is that for EE 1.14.3.10 this is a true statement, but for EE 1.14.1.0 it is not. I tested with a vanilla install of 1.14.1.0 and was able to switch the images using a dropdown without any customizations/extensions.



                I ended up creating a new extension to override some of the configurable swatches functionality.



                The files I copied from the vanilla 1.14.1.0 install into my new extension in 1.14.3.10 were:



                /app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php
                /app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
                /app/code/core/Mage/ConfigurableSwatches/Model/Observer.php


                In my theme there were a couple of JS files that also had to be addressed:



                /skin/frontend/[theme]/default/js/app.js



                var ProductMediaManager = 
                IMAGE_ZOOM_THRESHOLD: 20,
                imageWrapper: null,

                destroyZoom: function()
                $j('.zoomContainer').remove();
                $j('.ds-product-image-gallery .gallery-image').removeData('elevateZoom');
                ,

                createZoom: function(image) [no changes] ,

                swapImage: function(targetImage)
                ProductMediaManager.destroyZoom();

                var imageGallery = $j('.ds-product-image-gallery');

                imageGallery.slick('slickGoTo', targetImage);
                ,

                wireThumbnails: function()
                //trigger image change event on thumbnail click
                $j('.ds-product-image-thumbs .thumb-link').click( function(e)
                e.preventDefault();
                var target = $j(this).data('imageIndex');
                ProductMediaManager.swapImage(target);
                $j("li.selected").removeClass("selected");
                $j(this).parent("li").addClass("selected");
                )

                $j('.ds-product-image-gallery').on( 'afterChange', function(e, slick, currentSlide)
                var slide = $j(this).find('.gallery-image').eq(currentSlide);
                ProductMediaManager.createZoom(slide);
                );
                ,

                initZoom: function()
                [no changes]
                ,

                init: function() [no changes]

                ;


                /skin/frontend/dayspring/default/js/configurableswatches/product-media.js



                getCompatibleProductImages: function(productFallback, selectedLabels) 
                //find compatible products
                var compatibleProducts = [];
                var compatibleProductSets = [];
                selectedLabels.each(function(selectedLabel)
                if(typeof(productFallback['option_labels']) != 'undefined')
                if (!productFallback['option_labels'][selectedLabel])
                return;


                var optionProducts = productFallback['option_labels'][selectedLabel]['products'];
                compatibleProductSets.push(optionProducts);

                //optimistically push all products
                optionProducts.each(function (productId)
                compatibleProducts.push(productId);
                );

                );

                //intersect compatible products
                compatibleProductSets.each(function(productSet)
                compatibleProducts = ConfigurableMediaImages.arrayIntersect(compatibleProducts, productSet);
                );

                return compatibleProducts;
                ,


                getSwatchImage: function(productId, optionLabel, selectedLabels)
                var fallback = ConfigurableMediaImages.productImages[productId];
                if(!fallback)
                return null;


                //first, try to get label-matching image on config product for this option's label
                if(typeof(fallback['option_labels']) != 'undefined')
                var currentLabelImage = fallback['option_labels'][optionLabel];
                if (currentLabelImage && fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType])
                //found label image on configurable product
                return fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType];



                var compatibleProducts = ConfigurableMediaImages.getCompatibleProductImages(fallback, selectedLabels);

                if(compatibleProducts.length == 0) //no compatible products
                return null; //bail


                //second, get any product which is compatible with currently selected option(s)
                $j.each(fallback['option_labels'], function(key, value)
                var image = value['configurable_product'][ConfigurableMediaImages.imageType];
                var products = value['products'];

                if(image) //configurable product has image in the first place
                //if intersection between compatible products and this label's products, we found a match
                var isCompatibleProduct = ConfigurableMediaImages.arrayIntersect(products, compatibleProducts).length > 0;
                if(isCompatibleProduct)
                return image;


                );

                //third, get image off of child product which is compatible
                var childSwatchImage = null;
                var childProductImages = fallback[ConfigurableMediaImages.imageType];
                compatibleProducts.each(function(productId)
                if(childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
                childSwatchImage = childProductImages[productId];
                return false; //break "loop"

                );
                if (childSwatchImage)
                return childSwatchImage;


                //fourth, get base image off parent product
                if (childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
                return childProductImages[productId];


                //no fallback image found
                return null;
                ,


                After creating this extension, I am now able to switch images by selecting an option from a dropdown.






                share|improve this answer













                After getting a response from Magento that was "this is not part of native functionality" and thus it was "likely customized", I poked around some more on my own. What I've discovered is that for EE 1.14.3.10 this is a true statement, but for EE 1.14.1.0 it is not. I tested with a vanilla install of 1.14.1.0 and was able to switch the images using a dropdown without any customizations/extensions.



                I ended up creating a new extension to override some of the configurable swatches functionality.



                The files I copied from the vanilla 1.14.1.0 install into my new extension in 1.14.3.10 were:



                /app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php
                /app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
                /app/code/core/Mage/ConfigurableSwatches/Model/Observer.php


                In my theme there were a couple of JS files that also had to be addressed:



                /skin/frontend/[theme]/default/js/app.js



                var ProductMediaManager = 
                IMAGE_ZOOM_THRESHOLD: 20,
                imageWrapper: null,

                destroyZoom: function()
                $j('.zoomContainer').remove();
                $j('.ds-product-image-gallery .gallery-image').removeData('elevateZoom');
                ,

                createZoom: function(image) [no changes] ,

                swapImage: function(targetImage)
                ProductMediaManager.destroyZoom();

                var imageGallery = $j('.ds-product-image-gallery');

                imageGallery.slick('slickGoTo', targetImage);
                ,

                wireThumbnails: function()
                //trigger image change event on thumbnail click
                $j('.ds-product-image-thumbs .thumb-link').click( function(e)
                e.preventDefault();
                var target = $j(this).data('imageIndex');
                ProductMediaManager.swapImage(target);
                $j("li.selected").removeClass("selected");
                $j(this).parent("li").addClass("selected");
                )

                $j('.ds-product-image-gallery').on( 'afterChange', function(e, slick, currentSlide)
                var slide = $j(this).find('.gallery-image').eq(currentSlide);
                ProductMediaManager.createZoom(slide);
                );
                ,

                initZoom: function()
                [no changes]
                ,

                init: function() [no changes]

                ;


                /skin/frontend/dayspring/default/js/configurableswatches/product-media.js



                getCompatibleProductImages: function(productFallback, selectedLabels) 
                //find compatible products
                var compatibleProducts = [];
                var compatibleProductSets = [];
                selectedLabels.each(function(selectedLabel)
                if(typeof(productFallback['option_labels']) != 'undefined')
                if (!productFallback['option_labels'][selectedLabel])
                return;


                var optionProducts = productFallback['option_labels'][selectedLabel]['products'];
                compatibleProductSets.push(optionProducts);

                //optimistically push all products
                optionProducts.each(function (productId)
                compatibleProducts.push(productId);
                );

                );

                //intersect compatible products
                compatibleProductSets.each(function(productSet)
                compatibleProducts = ConfigurableMediaImages.arrayIntersect(compatibleProducts, productSet);
                );

                return compatibleProducts;
                ,


                getSwatchImage: function(productId, optionLabel, selectedLabels)
                var fallback = ConfigurableMediaImages.productImages[productId];
                if(!fallback)
                return null;


                //first, try to get label-matching image on config product for this option's label
                if(typeof(fallback['option_labels']) != 'undefined')
                var currentLabelImage = fallback['option_labels'][optionLabel];
                if (currentLabelImage && fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType])
                //found label image on configurable product
                return fallback['option_labels'][optionLabel]['configurable_product'][ConfigurableMediaImages.imageType];



                var compatibleProducts = ConfigurableMediaImages.getCompatibleProductImages(fallback, selectedLabels);

                if(compatibleProducts.length == 0) //no compatible products
                return null; //bail


                //second, get any product which is compatible with currently selected option(s)
                $j.each(fallback['option_labels'], function(key, value)
                var image = value['configurable_product'][ConfigurableMediaImages.imageType];
                var products = value['products'];

                if(image) //configurable product has image in the first place
                //if intersection between compatible products and this label's products, we found a match
                var isCompatibleProduct = ConfigurableMediaImages.arrayIntersect(products, compatibleProducts).length > 0;
                if(isCompatibleProduct)
                return image;


                );

                //third, get image off of child product which is compatible
                var childSwatchImage = null;
                var childProductImages = fallback[ConfigurableMediaImages.imageType];
                compatibleProducts.each(function(productId)
                if(childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
                childSwatchImage = childProductImages[productId];
                return false; //break "loop"

                );
                if (childSwatchImage)
                return childSwatchImage;


                //fourth, get base image off parent product
                if (childProductImages[productId] && ConfigurableMediaImages.isValidImage(childProductImages[productId]))
                return childProductImages[productId];


                //no fallback image found
                return null;
                ,


                After creating this extension, I am now able to switch images by selecting an option from a dropdown.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 4 at 14:24









                cbartellcbartell

                115




                115



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264761%2fconfigurable-product-dropdown-image-switch%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Sum ergo cogito? 1 nng

                    三茅街道4182Guuntc Dn precexpngmageondP