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

Revoked SSL certificate

Can you really stack all of this on an Opportunity Attack?

Codimension of non-flat locus

Cross compiling for RPi - error while loading shared libraries

Why do I get two different answers for this counting problem?

Is it inappropriate for a student to attend their mentor's dissertation defense?

NMaximize is not converging to a solution

How is it possible to have an ability score that is less than 3?

Did Shadowfax go to Valinor?

Can I ask the recruiters in my resume to put the reason why I am rejected?

Approximately how much travel time was saved by the opening of the Suez Canal in 1869?

How much RAM could one put in a typical 80386 setup?

Is it possible to run Internet Explorer on OS X El Capitan?

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

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

How to determine what difficulty is right for the game?

How old can references or sources in a thesis be?

How does quantile regression compare to logistic regression with the variable split at the quantile?

LaTeX: Why are digits allowed in environments, but forbidden in commands?

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

I'm flying to France today and my passport expires in less than 2 months

Today is the Center

Convert two switches to a dual stack, and add outlet - possible here?

Maximum likelihood parameters deviate from posterior distributions



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
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • 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

                      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?