How can I include the simple product sku to display for configurable products which have more than two or more drop down options ( two or more attributes)? I would like the SKU to display after all the selections have been made for the configurable drop downs. Any help with this would be greatly appreciated.

Thanks for looking.

  • Was the answer I gave of any use to you? Commented Sep 24, 2013 at 13:53

2 Answers 2


Mapping the attribute options in the dropdowns to actual products can be done by using the spConfig javascript variable printed on the product view page of every configurable product.

var spConfig = new Product.Config({
      "label":"Shoe Size",

Notice the products keys that have an array of product ids. Using some javascript that observes the onchange event of your option dropdowns you should be able to work your way through the array ending up with the product the user has chosen.

Now for mapping that to the product SKU, you're probably best of retrieving them from a custom javascript array which you can create by using the code from this article. So now for some untested code

$simple_collection = Mage::getModel('catalog/product_type_configurable')->setProduct(Mage::registry('current_product'))

$id_to_sku = array();                           
foreach ($simple_collection  as $_item)
    $id_to_sku['p'+$_item->getId()] = $_item->getSku();

echo '<script type="text/javascript">
var confIdToSku = '.json_encode($id_to_sku).';

Which would output an array like

var confIdToSku = {"p32":"pr-sku-1", "p35":"pr-sku-2"}

That would enable you to map the product ID to the SKU you need.

I'd suggest creating a new PHTML file for this in your template directory, using block type core/template and calling that in the template/catalog/product/view.phtml.

I'm no hero with Javascript so I didn't include any javascript code examples in my answer, I hope you can figure that part out for yourself.

  • This is fantastic, is there a way to ensure that it grabs a product simple sku that is IN STOCK? @Sander mangel
    – thismethod
    Commented Nov 14, 2016 at 21:06
  • 1
    I don't have the rep to edit this answer, but there is a typo in the example. It should read $id_to_sku['p'.$_item->getId()] = $_item->getSku();. Otherwise great answer Commented May 22, 2017 at 16:12

You can try this post to get all details of selected simple product of configurable product. You can get Id, sku, name etc... using this post.

Get Simple product details of configurable products like ID,SKU,Product Name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.