Every configurable product has own product id as you know.

on frontend options on admin

When I select medium (in this example) I want to get 26, when I select large I want to get 28 etc.

I think the only way to do that using attribute id, right? How can I get product id using option's attribute id? Or another way?

1 Answer 1


if you take a look to source code for product page you will notice something like this:

var spConfig = new Product.Config({"attributes":{"1162":{"id":"1162","code":"colour","label":"Colour","options":[{"id":"2197","label":"Blue","price":"0","oldPrice":"0","products":["18577"],"image":"http:\/\/magento.localhost\/media\/amconf\/images\/2197.jpg"}],"use_image":1}},"template":"\u00a3#{price}","basePrice":"106.99","oldPrice":"106.99","productId":"18576","chooseText":"Choose an Option...","taxConfig":{"includeTax":true,"showIncludeTax":true,"showBothPrices":false,"defaultTax":20,"currentTax":20,"inclTaxTitle":"Incl. VAT"}});

this is simple product id:


call for spConfig you can find at the bottom of app/design/frontend/[your theme]/default/template/catalog/product/view/type/options/configurable.phtml

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

Hope this helps.

  • more than one product can have the same attribute value, you need to calculate the intersection of all selected options and compare against spConfig
    – doc_id
    Sep 20, 2017 at 1:37

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.