Auto Select colour Swatch when configurable product page loadsAuto select option based on category ?Configurable Swatches on Listing Page: Show Multiple Color AttributesConfigurable product with multiple color variationsChange More product images on color swatch selectConfigurable swatch not working properlyIs there a way to automatically select the first colour swatch on the product page?Is there any way that one swatch is selected by default (magento configurable swatches)How to change image size on category page when click swatchHow to Auto Select The Color as Swatch Option for Products with Only One Color (on Magento 2.1 Product View)?Hide Configurable product images from details page when color swatch is selected

Copenhagen passport control - US citizen

Shell script can be run only with sh command

How does one intimidate enemies without having the capacity for violence?

Are white and non-white police officers equally likely to kill black suspects?

Draw simple lines in Inkscape

whey we use polarized capacitor?

How do I create uniquely male characters?

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

The magic money tree problem

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

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

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

least quadratic residue under GRH: an EXPLICIT bound

What makes Graph invariants so useful/important?

New order #4: World

What are these boxed doors outside store fronts in New York?

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

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

What is the offset in a seaplane's hull?

Why was the small council so happy for Tyrion to become the Master of Coin?

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

Is it possible to make sharp wind that can cut stuff from afar?

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?



Auto Select colour Swatch when configurable product page loads


Auto select option based on category ?Configurable Swatches on Listing Page: Show Multiple Color AttributesConfigurable product with multiple color variationsChange More product images on color swatch selectConfigurable swatch not working properlyIs there a way to automatically select the first colour swatch on the product page?Is there any way that one swatch is selected by default (magento configurable swatches)How to change image size on category page when click swatchHow to Auto Select The Color as Swatch Option for Products with Only One Color (on Magento 2.1 Product View)?Hide Configurable product images from details page when color swatch is selected






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








2















I have a configurable product with one colour and different sizes, both these are set as required fields.



I've set the colour attribute as not required, but then it wont show up when I create a configurable product and wont show on the product page.



How do I get the colour swatch to be automatically selected when the product page loads?










share|improve this question
























  • What is your question?

    – Robbie Averill
    Jun 27 '16 at 12:05











  • How do I get the colour swatch to be automatically selected when the product page loads?

    – user2240778
    Jun 27 '16 at 13:21

















2















I have a configurable product with one colour and different sizes, both these are set as required fields.



I've set the colour attribute as not required, but then it wont show up when I create a configurable product and wont show on the product page.



How do I get the colour swatch to be automatically selected when the product page loads?










share|improve this question
























  • What is your question?

    – Robbie Averill
    Jun 27 '16 at 12:05











  • How do I get the colour swatch to be automatically selected when the product page loads?

    – user2240778
    Jun 27 '16 at 13:21













2












2








2








I have a configurable product with one colour and different sizes, both these are set as required fields.



I've set the colour attribute as not required, but then it wont show up when I create a configurable product and wont show on the product page.



How do I get the colour swatch to be automatically selected when the product page loads?










share|improve this question
















I have a configurable product with one colour and different sizes, both these are set as required fields.



I've set the colour attribute as not required, but then it wont show up when I create a configurable product and wont show on the product page.



How do I get the colour swatch to be automatically selected when the product page loads?







magento-1.9 configurable-product javascript color-swatches






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 27 '16 at 13:21







user2240778

















asked Jun 27 '16 at 12:03









user2240778user2240778

298315




298315












  • What is your question?

    – Robbie Averill
    Jun 27 '16 at 12:05











  • How do I get the colour swatch to be automatically selected when the product page loads?

    – user2240778
    Jun 27 '16 at 13:21

















  • What is your question?

    – Robbie Averill
    Jun 27 '16 at 12:05











  • How do I get the colour swatch to be automatically selected when the product page loads?

    – user2240778
    Jun 27 '16 at 13:21
















What is your question?

– Robbie Averill
Jun 27 '16 at 12:05





What is your question?

– Robbie Averill
Jun 27 '16 at 12:05













How do I get the colour swatch to be automatically selected when the product page loads?

– user2240778
Jun 27 '16 at 13:21





How do I get the colour swatch to be automatically selected when the product page loads?

– user2240778
Jun 27 '16 at 13:21










2 Answers
2






active

oldest

votes


















0














Open this file from appdesignfrontend[your package][your theme]templatecatalogproductviewtypeoptionsconfigurable.phtml



Now add the below javascript code :-



 function fireEvent(element,event)
if (document.createEventObject)
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)

else
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);


Event.observe(window, 'load', function()
spConfig.settings[0].selectedIndex = 1;
obj = spConfig.settings[0]; // this grabs the first select item
Event.observe(obj,'change',function());
fireEvent(obj,'change'); // this simulates selecting the first option, which triggers
spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu
);


after this code :-



var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);


and flush magento cache and check.






share|improve this answer






























    0














    If you want to go with jQuery in magento
    so you can trigger with click on color swatches on document ready



    jQuery("document").ready(function() 
    setTimeout(function()
    jQuery("#configurable_swatch li:last-child a span").trigger('click');
    ,100);
    );





    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%2f122954%2fauto-select-colour-swatch-when-configurable-product-page-loads%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Open this file from appdesignfrontend[your package][your theme]templatecatalogproductviewtypeoptionsconfigurable.phtml



      Now add the below javascript code :-



       function fireEvent(element,event)
      if (document.createEventObject)
      // dispatch for IE
      var evt = document.createEventObject();
      return element.fireEvent('on'+event,evt)

      else
      // dispatch for firefox + others
      var evt = document.createEvent("HTMLEvents");
      evt.initEvent(event, true, true ); // event type,bubbling,cancelable
      return !element.dispatchEvent(evt);


      Event.observe(window, 'load', function()
      spConfig.settings[0].selectedIndex = 1;
      obj = spConfig.settings[0]; // this grabs the first select item
      Event.observe(obj,'change',function());
      fireEvent(obj,'change'); // this simulates selecting the first option, which triggers
      spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu
      );


      after this code :-



      var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);


      and flush magento cache and check.






      share|improve this answer



























        0














        Open this file from appdesignfrontend[your package][your theme]templatecatalogproductviewtypeoptionsconfigurable.phtml



        Now add the below javascript code :-



         function fireEvent(element,event)
        if (document.createEventObject)
        // dispatch for IE
        var evt = document.createEventObject();
        return element.fireEvent('on'+event,evt)

        else
        // dispatch for firefox + others
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
        return !element.dispatchEvent(evt);


        Event.observe(window, 'load', function()
        spConfig.settings[0].selectedIndex = 1;
        obj = spConfig.settings[0]; // this grabs the first select item
        Event.observe(obj,'change',function());
        fireEvent(obj,'change'); // this simulates selecting the first option, which triggers
        spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu
        );


        after this code :-



        var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);


        and flush magento cache and check.






        share|improve this answer

























          0












          0








          0







          Open this file from appdesignfrontend[your package][your theme]templatecatalogproductviewtypeoptionsconfigurable.phtml



          Now add the below javascript code :-



           function fireEvent(element,event)
          if (document.createEventObject)
          // dispatch for IE
          var evt = document.createEventObject();
          return element.fireEvent('on'+event,evt)

          else
          // dispatch for firefox + others
          var evt = document.createEvent("HTMLEvents");
          evt.initEvent(event, true, true ); // event type,bubbling,cancelable
          return !element.dispatchEvent(evt);


          Event.observe(window, 'load', function()
          spConfig.settings[0].selectedIndex = 1;
          obj = spConfig.settings[0]; // this grabs the first select item
          Event.observe(obj,'change',function());
          fireEvent(obj,'change'); // this simulates selecting the first option, which triggers
          spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu
          );


          after this code :-



          var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);


          and flush magento cache and check.






          share|improve this answer













          Open this file from appdesignfrontend[your package][your theme]templatecatalogproductviewtypeoptionsconfigurable.phtml



          Now add the below javascript code :-



           function fireEvent(element,event)
          if (document.createEventObject)
          // dispatch for IE
          var evt = document.createEventObject();
          return element.fireEvent('on'+event,evt)

          else
          // dispatch for firefox + others
          var evt = document.createEvent("HTMLEvents");
          evt.initEvent(event, true, true ); // event type,bubbling,cancelable
          return !element.dispatchEvent(evt);


          Event.observe(window, 'load', function()
          spConfig.settings[0].selectedIndex = 1;
          obj = spConfig.settings[0]; // this grabs the first select item
          Event.observe(obj,'change',function());
          fireEvent(obj,'change'); // this simulates selecting the first option, which triggers
          spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu
          );


          after this code :-



          var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);


          and flush magento cache and check.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 10 '17 at 13:28









          Jaimin PatelJaimin Patel

          255




          255























              0














              If you want to go with jQuery in magento
              so you can trigger with click on color swatches on document ready



              jQuery("document").ready(function() 
              setTimeout(function()
              jQuery("#configurable_swatch li:last-child a span").trigger('click');
              ,100);
              );





              share|improve this answer



























                0














                If you want to go with jQuery in magento
                so you can trigger with click on color swatches on document ready



                jQuery("document").ready(function() 
                setTimeout(function()
                jQuery("#configurable_swatch li:last-child a span").trigger('click');
                ,100);
                );





                share|improve this answer

























                  0












                  0








                  0







                  If you want to go with jQuery in magento
                  so you can trigger with click on color swatches on document ready



                  jQuery("document").ready(function() 
                  setTimeout(function()
                  jQuery("#configurable_swatch li:last-child a span").trigger('click');
                  ,100);
                  );





                  share|improve this answer













                  If you want to go with jQuery in magento
                  so you can trigger with click on color swatches on document ready



                  jQuery("document").ready(function() 
                  setTimeout(function()
                  jQuery("#configurable_swatch li:last-child a span").trigger('click');
                  ,100);
                  );






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 1 '18 at 13:02









                  Pradip GarcharPradip Garchar

                  12114




                  12114



























                      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%2f122954%2fauto-select-colour-swatch-when-configurable-product-page-loads%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