magento assign which size chart to which product

Show which size chart you want to assign to which product?

For example:
- Size chart for Gloves
- Size chart for jackets ....
and you want to make the minimum code change possible to your magento core files.

Here is the solution.

Method 1:

Create new attribut called "size_chart_template":

Go to Admin->Attributes->Manage Attributes

Add new attribute with the following properties:

  • Attribute Code : size_chart_template
  • Scope&: Global
  • Catalog Input type  for Store Owner   : Dropdown
  • Unique Value : No
  • Required value : No
  • Input Validation for store owner: No
  • Apply to * : All Product Types
  • Use to create Configurable Product : No

For Frontend Properties: No everywhere and Position to 0

In Manage Label/Options:

Admin : Size Chart Template

add your options for example:

Helmets
Gloves
Jackets ...

Save your attribute.

Now go to Catalog->Attributes->Manage Attribute Sets

Select your set and add the attribut you have just created. (drag and drop)

 

Now we are going to assign for the product  Red Helmet the size chart Helmets.

Go to Red Helmet and select Helmets from your dropdown list (You should add this attribut before use it).

 


paste this code snippet to app/design/frontend/default/yourtemplate/template/catalog/product/view.phtml
  <?php
       if($_product->getAttributeText('size_chart_template') != ""){ 
               $sizeChartURL=   $this->getSkinUrl('sizecharts/'.$_product->getAttributeText('size_chart_template').'.php');
               $sizeChartIcon= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."/size-charts/size-chart-icon.png";
               echo 'size chart';       
                   }
?> 

Now create skin/frontend/default/yourtemplate/sizecharts/Helmets.php

 


<?php
 chdir ('../../../../../');
 require_once getcwd().'/app/Mage.php';
 umask(0);
 Mage::app();
 $mediaURL=  Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
?>
Your HTML code here. 
If you have any question do not hesitate to ask.

Method 2: Create Magento Size Charts Using Static Blocks and Javascript

Comments

Very nice

This is very nice, i almost got it to work. But something goes wrong in the last bit. The size chart image doesn't get loaded (because the path is wrong) , and the url goes to $sizeChartURL. Could you help me out here? Regards, Jasper

size chart

This looks like the solution i was looking for, however it doesn't seem to work in 1.4.2. I've ad the code in view.phtml but nothing happens except the code is visible. It's probably something small but i've put a lot of hours in this issue but my knowledge on php is just not good enough to get this thing working. I would really appreciate it if you can help me out. John