Wednesday, 4 July 2012

How To Show Size Chart in Magento Detail Page

Create Magento Size Charts Using Static Blocks and Javascript

In my Old post I showed you how to create a size chart using a
link that pop-ups an external php page.
In this tutorial, I will show you how to use static blocks and JavaScript to create size charts . Demo Here
Suppose you want to create a size chart for the product type Jackets.
Here are steps you have to follow:
  • STEP 1: Create a new static block called "Jackets Size Chart" identified by "jackets-size-chart"
  • STEP 2: Create a new attribut called size_chart_template

STEP 1


STEP 2

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:
jackets-size-chart (remember this is the identifier of your static block)
...
Save your attribute.
Now go to Catalog->Attributes->Manage Attribute Sets
Select your set and add the attribute you have just created. (drag and drop)
Now we are going to assign to the product  Icon Retro Motorcycle Jacket, the size chart identified by "jackets-size-chart".
Go to Icon Retro Motorcycle Jacket Item and select "jackets-size-chart" from your dropdown list (You should add this attribut before use it).
Open app/design/frontend/default/yourtemplate/template/catalog/product/view.phtml and paste the following code. (where you like to see your size chart info)
1  <!-- BOF SIZE CHART --><!-- BOF SIZE CHART -->
2<?php
3  $sizeChartIcon= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."size-charts/size-chart.gif"; ?>
4            <a onclick="$('size-chart').show();"><?php echo '<img src="%27.$sizeChartIcon.%27" alt="size chart">' ; ?>  </a>
5            <div id="size-chart" style="display:none;"> <?php echo  Mage::app() ->getLayout() ->createBlock('cms/block') ->setBlockId($_product->getAttributeText('size_chart_template')) ->toHtml(); ?></div>
6<!-- EOF SIZE CHART --><!-- EOF SIZE CHART -->

11 comments:

  1. hello i can not understand this line.Now we are going to assign to the product Icon Retro Motorcycle Jacket, the size chart identified by "jackets-size-chart".. plese sugeset me in brief

    ReplyDelete
  2. Hi,

    I am not able to work this thing out for my store.

    Could you help me to show the size chart on my product page.

    email : kumbhar.sandip.b@gmail.com

    ReplyDelete
  3. Why not just use this extension https://store.plumrocket.com/magento-extensions/size-chart-magento-extension.html?

    ReplyDelete
  4. Great yrr i got the full idea... this is cool stuff!!!

    ReplyDelete

  5. I am not able to work this thing out for my store.

    Could you help me to show the size chart on my product page.

    ReplyDelete
  6. Hello,

    This is really a great post. Thank you for taking time to provide us some of the useful and exclusive information with us. Keep on blogging!!

    ReplyDelete
  7. ... or you can just use plumrocket size chart extension https://store.plumrocket.com/size-chart-magento-extension.html

    ReplyDelete
  8. MageAnts provide magento 2 size char extension you can view here https://www.mageants.com/size-chart-extension-for-magento-2.html they provide 100% bug free because created by certified developer

    ReplyDelete
  9. hello magentoabid,
    can you tell me how can I make this as POPUP????

    ReplyDelete
  10. Good article. Thanks for sharing. If you do not want to write any code you can use exists extension. I recommend use Size Chart extension from Averun - https://averun.com/magento-size-chart.html . It is simple and very useful solution. You will receive preinstalled international chart sizes and assistant to determinate size for customers.

    ReplyDelete

Note: only a member of this blog may post a comment.