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

What is the word for reserving something for yourself before others do?

Does detail obscure or enhance action?

Did Shadowfax go to Valinor?

Doing something right before you need it - expression for this?

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

Is it legal for company to use my work email to pretend I still work there?

What is a clear way to write a bar that has an extra beat?

What typically incentivizes a professor to change jobs to a lower ranking university?

Can I make popcorn with any corn?

Today is the Center

What does "Puller Prush Person" mean?

Languages that we cannot (dis)prove to be Context-Free

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

How can bays and straits be determined in a procedurally generated map?

Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Rock identification in KY

Maximum likelihood parameters deviate from posterior distributions

LWC SFDX source push error TypeError: LWC1009: decl.moveTo is not a function

High voltage LED indicator 40-1000 VDC without additional power supply

Client team has low performances and low technical skills: we always fix their work and now they stop collaborate with us. How to solve?

Add text to same line using sed

Java Casting: Java 11 throws LambdaConversionException while 1.8 does not

Is it possible to do 50 km distance without any previous training?



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 yesterday









                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

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?