We have a configurable product on the front end

How can I get the final simple product ID on the product list page?

Does anyone have any idea how to get it?

  • Have you given the selection of Size and Colour on category Page? Commented May 3 at 10:00
  • Can you provide me with the code on how can I get the product ID on the product list page for configurable products? @DhirenVasoya as I have got the product id for PDP page from this code so how can I do the same for product list page $(".product-options-wrapper .swatch-opt").click(function() { var selProId = $('[data-role=swatch-options]').data('mage-SwatchRenderer').getProduct(); Commented May 3 at 10:21
  • The code depend on the structure which apply on caetgory page, that why I ask how you given selection on category page? Commented May 3 at 10:55
  • I have configurable products which I have size and color options on the PLP page @Dhiren Vasoya Commented May 3 at 11:18
  • That I know, how you provided those options on Category page, because based on that selection you need to get Simple Product Id. Commented May 3 at 11:53

1 Answer 1


You need to provide swatch/attribute selection on the product cards on the listing page. Once you select any options, you will find the selected product id using the below syntax.

  • var selProId = $('[data-role="swatch-option-"]').data('mage-SwatchRenderer').getProduct(); how we can give product id dynamically as in data-role like this swatch-option-2040 for product list page Commented May 6 at 12:44
  • Hi @UrmiKothari, not exactly getting it. Could you please elaborate? Or reach out to me at [email protected]. Commented May 16 at 11:49
  • 1
    Hello @Magento TridhyaTech The issue is resolved now from this way I get the product id in plp page for configurable product var productId = $(this).attr('id').replace('product-item-info_', ''); var selProId = $('[data-role="swatch-option-' + productId + '"]').data('mage-SwatchRenderer').getProduct(); Commented May 17 at 12:08

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.