Send me a message

Do you want me to build websites and software applications for you?

Your Name (required)

Your Email (required)

Subject

Your Message

Enter this code below captcha

Eat These Code Snippets Blog

Joomla, Magento, Wordpress, VB.NET, VC++ and other code snippets to share.

How To Create A Simple Color thumbnail/Swatch/Selector In Magento?

49

Here is a step-by-step tutorial that will guide you on how to create a color swatcher, color thumbnail or color selector or whatever you call it on magento using a configurable attribute and some label trick on the images. When you finished these 10 easy steps, you should have a running color swatcher on your magento store as shown on the screenshot below. You may need to click on the images to get a closer view at the screenshots.

Click to enlarge image

Well, its relatively easy and free because you don’t need to purchase some of those expensive commercial magento color swatcher extensions, you just have to create a configurable product and assigned them with simple products in the magento admin. If you want, you can also download the files that I had modified here by clicking this link

1.) first we need to add a new attribute, go to catalog->attributes-> manage attributes in the magento admin, then click on Add New Attribute button on the top right side and name the attribute code as ref_color

set its attribute properties:

Scope: Global

Catalog Input Type for Store Owner: Dropdown

Unique Value: No

Values Required: No

Apply To: Selected Product Types and then select Simple Product and Configurable Product

Use To Create Configurable Product: Yes

set its frontend properties to:

Use in Quick Search: Yes

Use in Advanced Search: Yes

Comparable on Front-end: No

Use In Layered Navigation: No

Use In Search Results Layered Navigation: No

Use for Promo Rule Conditions: No

Position: 0

Visible on Product View Page on Front-end: Yes

Used in Product Listing: Yes

Used for Sorting in Product Listing: No

Screenshot:

Click image to enlarge

2.) then set the Manage label/options of this attribute by following the screenshot below and don’t forget to hit the Save attribute button

As seen on the screenshot below, you supply the titles to this attribute in the admin and store view, in the admin, i named it as Refer Color and in the store view, Color ,then you supply the color values to it by hitting the Add option button in the manage options section, in my case, i add the blue and orange colors and set blue as the default color.

Click image to enlarge

3.) Now that we had created an attribute, let’s create an attribute set and assign the attribute to it. Go to Catalog->Attributes-> Manage attribute sets and then click on the Add New Set button. You name the attribute set as T-shirts Set and in my case i based it on the Default attribute set as seen on the screenshot below

Click image to enlarge

and then hit the Save Attribute Set button and it will navigate you to the Edit Attribute Set page. In the Groups section, click the Add New button to create a new group and named it as T-shirts properties as seen on the screenshot below.

Click image to enlarge

When the T-shirts properties group is created you assigned the refer_color attribute by dragging the refer_color attribute from the Unassigned Attributes section to the T-shirts properties group. You will see the + icon when you correctly dragged the attribute to the T-shirts properties group as shown below.

Click image to enlarge

4.) Now that we had finished creating the attribute set and assigned the attribute that we created to it, lets proceed in adding a configurable product by going to Catalog -> Manage Products and then click on the Add Product button on the top right of the Manage Products page. In the Create Product Settings, select the attribute set that we created earlier which is T-shirts Set and then choose Configurable Product as the Product Type. Click the Continue button.

Click image to enlarge

In the Configurable Product Settings, select Refer Color by checking the checkbox assigned to it and click on the Continue button.

Click to enlarge image

Then supply product information by filling up the name, description, price and etc. of the product. Don’t forget to assign a Category to it or it won’t appear on the frontend.

When you get to the Images section, you upload the images and label them like this:

Click to enlarge image

Click to enlarge image

as you can see, I labeled the t-shirt images with their corresponding color appended with a “-” and the word “base”, these labels are our basis for determining what product main product image show if a color is selected. The color representing those thumbnails are also uploaded here and we will label them with their corresponding color also appended with a “-” and with the word, “color”, which also serves as our flag in determining that these images represent the color thumbnails/selectors/swatches. You notice also that there is an image that doesn’t have a label, we will code this in the frontend and detect those images without labels as one of the “More Views” or image gallery section of the product page. Don’t forget to hit Save button. What’s nice with this is that we use images to represent the colors which means it can also be applied to what kind of texture or textile design if your store is selling textiles or products that have different textures that needs an image representation to make the potential customers see how the actual color or texture of the product before buying.

Don’t forget also to set the Stock Availability to In Stock in the Inventory section

Click to enlarge image

Click on the Save And Continue Edit button and then go to the Associated Products Section, we have to create and associate a simple product to this configurable product. The simple product is identical to the configurable product, the only difference is that the simple product contains the T-shirt properties on its left side tab/menu. This contains the option to select what color to assigned to a particular simple product.

To create a simple product, click on the Copy From Configurable button.

Click to enlarge image

A pop-up window will appear and you will see that some fields are already filled up because what we did is we copy some attributes of the simple product that we are about to create from the configurable product. I distinguished a simple product by appending the color to its product name. In my case I put (Blue) to its Name

Click to enlarge image

Don’t forget to put a Qty and set Stock Availability to In Stock to this associated simple product!

Click to enlarge image

Now click on the T-Shirt Properties tab and assign color to it, in my case I assigned the color blue to this simple product

Click to enlarge image

Note: You should not set a Category for this simple product in the Categories tab, leave all categories uncheck because we don’t want this associated simple products to appear on the category list in the frontend as independent simple product!

Save the simple product by clicking on the Save button. You do the same step to create the other colors, in this tutorial, we use only the colors, blue and orange, so you create the orange t-shirt simple product like what we did with the blue t-shirt.

When you save the simple product, you would see a message in bold red that says “Links with associated products will retain only after saving current product.” Simply Click the Save and Continue Edit button and you should see the associated products showing up

Click to enlarge image

Click to enlarge image

5.) Alright, we are done tweaking the backend. We had created a configurable product and also created simple products associated to it. We are going to code now the frontend, but first let’s have a preview of what it looks like at the frontend. You should have the same product view that i had as shown below:

Well it looks nothing special actually, I had put some marks/hints to let you understand what we are trying to achieve. I hope this representation helps your understanding.

So we will start to modify now the frontend template. first let us copy the configurable.phtml (if it doesn’t exists in your template) from

app\design\frontend\base\default\template\catalog\product\view\type\options

to your app\design\frontend\<your default package>\<your default theme>\template\catalog\product\view\type\options

You may have to create the folders if they don’t exist. Notice that i put <your default package> and <your default theme>, this pertains to what default theme you are using for your magento store, in my case i use the modern theme which is included in the magento installation. So I copy and paste configurable.phtml to my

app\design\frontend\default\modern\template\catalog\product\view\type\options folder. I had to create the type and options folder since they don’t exist in my template.

Before we modify configurable.phtml let’s modify first media.phtml which is located in app\design\frontend\<your default package>\<your default theme>\template\catalog\product\view folder if it doesn’t exists, you copy it from the base just like what we did with configurable.phtml.

In media.phtml, find this code:


<?php foreach ($this->getGalleryImages() as $_image): ?>
<li> <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(66); ?>" width="66" height="66" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li> <?php endforeach; ?>

and replace it with this code:

<?php foreach ($this->getGalleryImages() as $_image):

 //this part gets modified
 if(trim($_image['label'])=="")//if empty image label then this is not a color image, display
 {

 ?>
 <li>
 <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(66); ?>" width="66" height="66" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
 </li>
 <?php

 }
 //end of modified part
 endforeach; ?>

what we did is we added a condition to display only the images in the More Views section that have no label

6.) Let’s modify now the configurable.phtml

Find this code in the configurable.phtml, it can be found on the first part of the source code. Anything beyond this code, you may clear them out because we are going to replace any code beyond this code

$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());

put this code just after the code above:

//start of modification

 //get all the media gallery images associated with this product that has a label
 $_gallery = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();
 $imgcount = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages()->count();
 if($imgcount >1)
 {
 $label_color = array();
 $product_base = array();
 foreach ($_gallery as $_image )
 {
 if(trim($_image['label'])!="")//if image has a label
 {
 $label = ucwords($_image['label']);//get the label text of the image

 $arr_color = explode('-', $label);//broke the label into an array
 $color = ucwords(trim($arr_color[0]));//get the color value, blue or orange
 $indentifier = ucwords(trim($arr_color[1]));//get image identifier, base or color

 if($indentifier=='Color')//if these are the color swatches/thumbnails
 {
 $label_color['color'][] = strval($color);//let's store them to an array
 $label_color['image'][] = strval($this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(35, 35));//small images
 }
 else if($indentifier=='Base')//else this is the product base image
 {
 $product_base['color'][] = strval($color);
 $product_base['image'][] = strval($this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(304, 273));
 }

 }
 }
 }

function findColorImage($value, $arr, $key)
{
 $found = '';
 $total = count($arr[$key]);
 if($total>0)
 {
 for($i=0; $i<$total;$i++)
 {
 if($value == $arr[$key][$i])//if it matches the color listed in the attribute
 {
 $found = $arr['image'][$i];//return the image src

 }
 }
 }
 return $found;

}

?>

<?php if ($_product->isSaleable() && count($_attributes)):?>
 <dl>
<?php
foreach($_attributes as $_attribute)
{
 if($_attribute->getLabel()== 'Color')//if this is the ref_color attribute
 {
 $attribute = $_product->getResource()->getAttribute('refer_color');//load the configurable attribute here which is the refer_color
 $frontend = $attribute->getFrontend();
 $selectOptions = $frontend->getSelectOptions();    //get the frontend labels and values of this attribute
 ?>
 <div><br/><div><h4>Color</h4></div>
 <input name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" type="hidden" value="" /><!-- We set a hidden field here to store the value of the color being selected-->
 <?php
 foreach($selectOptions as $refer_color_properties)
 {
 if($refer_color_properties['value']!='')
 {
 $color_image = findColorImage(ucwords(strval($refer_color_properties['label'])),$label_color,'color');
 if($color_image != '')//if there was an color image being returned
 {
 $product_image = findColorImage(ucwords(strval($refer_color_properties['label'])),$product_base,'color');//get find the product base image for this color
 ?>
 <div id="<?php echo $refer_color_properties['label']; ?>"  onmouseout="style.borderColor='transparent'" onclick="colorSelected('attribute<?php echo $_attribute->getAttributeId() ?>','<?php echo $refer_color_properties['value'];?>','<?php echo $product_image; ?>','<?php echo $refer_color_properties['label'];?>')">
 <?php //display color image
 echo "<img src='".$color_image."' alt='".$refer_color_properties['label']."'/>";
 ?>
 </div>
 <?php
 }
 }
 }
 ?>
 </div>
 <?php
 }
 else//display other attributes
 {?>
 <dt><label><?php echo $_attribute->getLabel();?><span>&nbsp;*</span></label></dt>
 <dd<?php if ($_attribute->decoratedIsLast){?><?php }?>>
 <select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>">
 <option><?php echo $this->__('Choose an Option...') ?></option>
 </select>
 </dd>
 <?php
 }
}

?>
 </dl>
 <script type="text/javascript">
 var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
 </script>
<?php endif;

//end of modification

Now the code above will check if there is a configurable attribute called color and display their images instead of the default display of magento which is select box or combo box, otherwise it will display the other configurables in default display of magento

Let’s recap, your configurable.phtml should look like this:

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>

<?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());

//start of modification

 //get all the media gallery images associated with this product that has a label
 $_gallery = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();
 $imgcount = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages()->count();
 if($imgcount >1)
 {
 $label_color = array();
 $product_base = array();
 foreach ($_gallery as $_image )
 {
 if(trim($_image['label'])!="")//if image has a label
 {
 $label = ucwords($_image['label']);//get the label text of the image

 $arr_color = explode('-', $label);//broke the label into an array
 $color = ucwords(trim($arr_color[0]));//get the color value, blue or orange
 $indentifier = ucwords(trim($arr_color[1]));//get image identifier, base or color

 if($indentifier=='Color')//if these are the color swatches/thumbnails
 {
 $label_color['color'][] = strval($color);//let's store them to an array
 $label_color['image'][] = strval($this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(35, 35));//small images
 }
 else if($indentifier=='Base')//else this is the product base image
 {
 $product_base['color'][] = strval($color);
 $product_base['image'][] = strval($this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(304, 273));
 }

 }
 }
 }

function findColorImage($value, $arr, $key)
{
 $found = '';
 $total = count($arr[$key]);
 if($total>0)
 {
 for($i=0; $i<$total;$i++)
 {
 if($value == $arr[$key][$i])//if it matches the color listed in the attribute
 {
 $found = $arr['image'][$i];//return the image src

 }
 }
 }
 return $found;

}

?>

<?php if ($_product->isSaleable() && count($_attributes)):?>
 <dl>
<?php
foreach($_attributes as $_attribute)
{
 if($_attribute->getLabel()== 'Color')//if this is the ref_color attribute
 {
 $attribute = $_product->getResource()->getAttribute('refer_color');//load the configurable attribute here which is the refer_color
 $frontend = $attribute->getFrontend();
 $selectOptions = $frontend->getSelectOptions();    //get the frontend labels and values of this attribute
 ?>
 <div><br/><div><h4>Color</h4></div>
 <input name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" type="hidden" value="" /><!-- We set a hidden field here to store the value of the color being selected-->
 <?php
 foreach($selectOptions as $refer_color_properties)
 {
 if($refer_color_properties['value']!='')
 {
 $color_image = findColorImage(ucwords(strval($refer_color_properties['label'])),$label_color,'color');
 if($color_image != '')//if there was an color image being returned
 {
 $product_image = findColorImage(ucwords(strval($refer_color_properties['label'])),$product_base,'color');//get find the product base image for this color
 ?>
 <div id="<?php echo $refer_color_properties['label']; ?>"  onmouseout="style.borderColor='transparent'" onclick="colorSelected('attribute<?php echo $_attribute->getAttributeId() ?>','<?php echo $refer_color_properties['value'];?>','<?php echo $product_image; ?>','<?php echo $refer_color_properties['label'];?>')">
 <?php //display color image
 echo "<img src='".$color_image."' alt='".$refer_color_properties['label']."'/>";
 ?>
 </div>
 <?php
 }
 }
 }
 ?>
 </div>
 <?php
 }
 else//display other attributes
 {?>
 <dt><label><?php echo $_attribute->getLabel();?><span>&nbsp;*</span></label></dt>
 <dd<?php if ($_attribute->decoratedIsLast){?><?php }?>>
 <select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>">
 <option><?php echo $this->__('Choose an Option...') ?></option>
 </select>
 </dd>
 <?php
 }
}

?>
 </dl>
 <script type="text/javascript">
 var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
 </script>
<?php endif;

//end of modification

?>

7.) Next let’s modify view.phtml which can be found on your app\design\frontend\<your default package>\<your default theme>\template\catalog\product folder, I am using magento’s modern theme so i can find the view.phtml in

app\design\frontend\default\modern\template\catalog\product folder

find this code which can be found as the first lines of the phtml

$_helper = $this->helper('catalog/output');
 $_product = $this->getProduct();

and put this javascript code right after the code above:

<!-- code added for color thumbnails -->
<script type="text/javascript">
 function colorSelected(id, value, product_image_src, color_div_id)
 {
 var base_image = document.getElementById("image");
 base_image.setAttribute("src", product_image_src);//display product base image of this color
 document.getElementById(id).value = value;//set the value of the hidden field
 setBorder(color_div_id,'2px solid #666');
 }

 function setBorder(id, value)
 {
 document.getElementById(id).style.border=value;
 }

</script>
<!--- end -->

8.) We are almost through, one last css code to place on your style.css which can be found on your skin\frontend\<your default package>\<your default theme>\css folder, I am using the modern theme of magento so my style.css can be found in

skin\frontend\default\modern\css

put this on the bottom of your css:


/*Color thumbnails CSS*/
.inlinebox {
display: -moz-inline-stack;
border:2px solid transparent;
display: inline-block;
vertical-align: top;
zoom: 1;
*display: inline;
min-height: 35px;
_height: 35px;
cursor:pointer;
}

9.) Refresh your cache by going to the admin section and click on the menu, System -> Cache Management and check all the checkbox in the Cache Storage Management and select Refresh on the combo box and press submit. Click also the Flush Javascript/CSS Cache

10.) It’s finished and go to the frontend and view the product. You now have a simple but effective color selector/swatcher/thumbnail or whatever you call it in your magento store!

If you like this guide and wanted to copy or use it on your blog or website, you are free to distribute and share as you wish and please don’t forget to link to my original article or my website if possible which is Eat These Code Snippets, thanks!

Feel free to share.

    49 Responses

    1. Hi,
      Nice one!
      How ever, in this method, each and every color should be created specifically for each and every product; For 10-20 products its ok, but for hundreds or thousands… How would you approach it then?
      Cheers!

    2. If your talking about adding products manually, yeah it would be too tired to add them but if your e-commerce site is supported with an internal inventory software like CEGID which can export csv files, you can import the products to magento using scripts running in cron job that reads the exported csv files or you could make use of Magento’s import feature on Advanced Profiles. http://www.deepcodeonline.com/blog/magento/update-how-to-import-configurable-and-simple-products-in-magento-1-4-1-with-label-on-the-images-and-super-products-attribute-linking/

    3. Great article! How do you make this work if the product also has another option, like size? It is not working in this case for me..

    4. @Bill

      For the sizes, you don’t need to create images, you just have to hack your frontend template to check if the configurable attribute displayed is your sizes attribute and hide the selection or combo box, for example

      $_attributes = Mage::helper(‘core’)->decorateArray($this->getAllowAttributes());

      foreach($_attributes as $_attribute)
      {

      if($_attribute->getLabel()== ‘Size’)
      {
      $attribute = $_product->getResource()->getAttribute(‘size_attribute’);//load the configurable attribute
      $frontend = $attribute->getFrontend();
      $selectOptions = $frontend->getSelectOptions(); //get the frontend labels and values of this attribute
      ?>

      foreach($selectOptions as $size_properties)
      {
      if($size_properties['value']!=”)
      {
      //do your stuff here, maybe display sizes in a div or span
      }
      }

      }

    5. Great! Is there any way to keep the dropdown box for the color and size?

    6. This looks like a great solution and we were excited to try it out. We are running into a problem though.

      It seems to be dying at:

      $frontend = $attribute->getFrontend();

      in the configurable.phtml. We’re on 1.4.1.1 – going to take a look at it again with fresh eyes. Appreciate any thoughts.

      Thx!

    7. Hello
      this tutorial is very detailled and this functionality very useful. I adapted it for my shop but with some new constraints :
      - I need it’s compatible with Simple Configurable Product Extension,
      - compatible with a lightbox,
      - I have to use it with configurable products with other options than colors and also some custom options.
      I am very near to make it work, colors are switching well, the compatibility with the lightbox is OK but I have a last but main issue: the field in configurable.phtml seems to not be able to trigger the javascript (or may be some thing else) to transmit the attribut color selected and contribute to determine the simple product associated. So, the custom options, which are at the simple product level in case of the SCP extension) don’t appear (because the simple product is not selected).
      If I replace th field by a field, if you use the drop down, it works (javascript triggered), but even if the values are switched on the drop down by clicking on the thumbnails, in this case, clicking on the colors, the javascript (which can make appearing the custom options) is not triggered at all.
      I don’t know how to do to be able to make this clicking on thumbnails triggering this javascript, and I don’t know how the field succeeds to do this.

      If you could have some idea, thanks in advance…

    8. My post is a little bit difficult to understand because some html coded terms desappeared.

      …..the field INPUT in configurable.phtml seems to not be able to trigger…….
      ……If I replace the field INPUT by a SELECT field, if you use the drop down, ……..
      ….. and I don’t know how the SELECT field succeeds to do this……….

      Sorry for this.

    9. It’s not working on Magento 1.4.1.1 ….

    10. Hello Jonas,
      I’m trying to make it working on Magento 1.4.1.0, is it impossible to adapt it for this version and upper ?

    11. So to be able to use this color swatch in my 1.4.1.0 environment, I modified these principal codes:
      - input field has to be a select field because if not it does not work. You have to specify this mandatory class:
      class=”required-entry super-attribute-select”
      and to show only information on it:
      disabled=”disabled” onfocus=”javascript:disabled = true;
      - at the end of the function colorSelected in your activ view.phtml, you have to add:
      spConfig.configureElement(document.getElementById(id));
      It’s the principal changes to do, but you could have to change other things depending on the installed extensions and your choices. For example I prefere to not update the principal image of the product but an other one and it’s possible. You could have to change some little things to be perfectly compatible with a lightbox…
      Anyway, thanks a lot for the first proposal.

    12. Has anyone tried this on 1.4.2?

      Also, is there any way of adapting this technique to work with product custom options?

    13. Hello Liam
      I did’nt tried it in 1.4.2 but for custom options you can try this extension:
      SWMS Option image which works on 1.4.1.0
      http://www.magentocommerce.com/magento-connect/SWMS/extension/2993/swms–option-image#overview

    14. I’ve just follow the paths on magento 1.4.2 and unfortunately all my product pages are in-accessable. Does anybody know why this is happenning. Im pretty sure that the coding has been completed entirely so I’m guessing there should be no problems. Could really do with some help!

    15. Solved the issue. Went back into the code and had a look if the correct coding had been put in the correct places. Couple of errors fixed. However – I’m now finding that for my particular swatch selector it wont recognise many standard colours. Including red!? Blue, orange and even brown seem to be fine though. Suggestions would be helpful. Thanks

    16. My problem is in media.phtml

      dont know what to change:

      ref:

      <?php if (count($this->getGalleryImages()) > 0): ?>
      <div class="more-views">
        <!--  <h4><?php echo $this->__('More view of the Item') ?></h4>-->
          <ul>
           <?php $i=1;  foreach ($this->getGalleryImages() as $_image): ?>
          <?php if($i%3 == 0) { ?>
      	   <li class="last">
      	  <?php }else { ?>
      	  <li>
      	  <?php } ?>	  
       		<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" rel="lightbox[rotation]" title="<?php echo $_product->getName();?>">
      <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(70, 92); ?>" width="70" height="92" alt=""/></a>
               </li>
          <?php $i++; endforeach; ?>
          </ul>
      </div>
      <?php endif; ?>
      
    17. I am having trouble getting this to work in 1.4.1.1 – Is it something I’m doing wrong?

    18. I try it careful. but my website don’t work.(mangento v1.4.2 or v1.5, they are all don’t work)

    19. The Code does not work. There are some codes need to be corrected.
      replace the code:

      if($_attribute->getLabel()== ‘Color’)//if this is the ref_color attribute

      into:
      if($_attribute->getLabel()== ‘Refer Color’)//if this is the ref_color attribute

      replace the code:

      $attribute = $_product->getResource()->getAttribute(‘refer_color’);//load the

      into:
      $attribute = $_product->getResource()->getAttribute(‘ref_color’);//load the

      After doing this,it works. If has anything , contact me!

    20. thanks editor and yanyan
      it works in magento 1.5.1.0

    21. This is all fine, but since I’m not a programmer,I found one for myself here

      http://www.magentocommerce.com/magento-connect/filter/tag/color%20swatch/

    22. The color images show up, but there’s no way to click them to select the option. Any ideas?

    23. … And the thumbnails for the color swatches are still showing up

    24. Thank you for the code, greak work, really useful !
      But when you got attributes that affect prices, it doesn’t do the job, prices don’t change (till they are added to cart) that can be a little strange for end users…
      I solved this problem with additional javascript code in view.phtml.
      It works, but it’s not optimized, to be ‘clean’ I should use the function that calculate the product price relative to selected options.
      Does someone know the way to do that ?
      See ya!

    25. I found good link about color swatch.. very basic and clear explanation. Thanks a lot deepcodeonline team too :)

      http://www.phptechi.com/how-to-create-a-color-swatcher-in-magento.html

    26. Hello,

      VERY, VERY GREAT How To!!! :-)

      i´ve only one problem:
      It was only the standard image show in shppingcart! :-(

      how to show the selectet color image in shoppingcart?

      thanks in advance!

      Best regards
      Marco

      PS: i use Magento 1.6.2

    27. Hi ,
      Thanks
      I want like audiator when select image that image go add in cart ? It is possible ?

      Ruslan

    28. i followed ur steps but i didn’t get color thumbnails in my page. i am using magento-1.6.1 how to solve this solution?

    29. i followed ur steps but i get Call to a member function getFrontend() on a non-object error. i am using magento-1.6.1 how to solve this solution?

    30. Boa tarde galera, sou webdesigner, estou quebrando a cabeça com o Magento, achei extensões que inseri automaticamente cor e tamanho, aplicativo maravilhoso,
      http://www.extensionsmall.com/color-swatch-with-zoom.html
      Magento cobra por esse tipo de extensão. Preço: R $ 79
      seria bom se alguem compartilha-se a extensão kkkkk
      abraços e vamos que vamos!

    31. vamos se ajudar gente, aqui parece estar sendo atualizado sempre,
      http://www.magentocommerce.com/magento-connect/easy-cms-block-free-version.html

      eCMS Fácil / Bloco – Versão grátis
      Você pode colocar um texto, banner, propaganda, imagens, flash, música, vídeo, produto

    32. mais acho que essa extensão é da Trial versão
      xD

    33. is this code is work on magento 1.6.2.0 because i make this code with all your instruction and i got error of getfrontend. it can be used in magento latest stable version reply me as soon as possible

    34. i got “Fatal error: Call to a member function getFrontend() on a non-object ” in configurable.phtml.

    35. thanks for ur article..everything works fine..But it doesn’t bring the selected product image in the cart page..

    36. Hi Vignesh,
      did you put an image to each of the simple products ?

    37. Hi zuiko,
      Thanks for ur reply..Yes. I put image to each of the simple products with same label name i.e., blue-base & orange-base. But still default image in configurable product appears in shopping cart..
      do i have change to change any code in cart page…

    38. Thanks so much for this tutorial! I finally solved a problem with configurable products…

      Tiziana

    39. I’ve got this to work,… fantastic.
      My only problem is that the main product image (base) when selected by the colour thumbnail changes to a low resolution image (I assume magneto is pulling a thumbnail image)

      How can I get magento 1.7 to show the high resolution base image?

      Thanks in advance!

    40. hiii…i have implemented all the steps…but when i go to my frontend…..it doesnot appear anythning when i select my product…please tell me where i have to make changes….

    41. Hi

      Awesome article.

      We create a simple product that gets displayed as new products also like there are two products getting displayed.

      Even for featured products.

      How do i remove the simple product from getting displayed

    42. @Heloise,
      check the visibility of your simples linked to the configurable. They must be set to “not visible individually”.

    43. I’m have problem with out of stock product.
      the options is show whenever product are out of stock. ;-(
      Does anyone have solution with this?

    44. I wonder how could we put this code in Magento go. I will be glad you advise me.

    45. Hey than for the tutorial I wished I had found it before I started working on the swatch, now I read on your other blog that you simulated color dropdown change for product.js, so that sizes are loaded, can you tell me how?

    46. Never mind, just called
      spConfig.configureElement(color’s id);
      Worked like a charm.
      Did you do the same?

    47. hi, i am using magento 1.7.0.2. after implement according to instruction, it’s now showing two ref_color , and only one is color selectable. please advice what was done wrong.

      thanks

    48. hi,
      I can you please upload also zip file with all codes. it will be easy for everyone. Thanks

    49. in configurable.phtml
      <div id="” onmouseout=”style.borderColor=’transparent’” class=”inlinebox ” onclick=”colorSelected(‘attributegetAttributeId() ?>’,”,”,”)”>

      i have doubt in this div, it has onclick funtion , it send arguments of colorSelected funtion but where is the js code in colorSelected funtion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Connect with Facebook

    *
    *