Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

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

If you want to get Simple product details of configurable product like simple product Id, sku, product name etc. you can get using my simple module.

Magento Simple product details of configurable products

Before using this module you need to add simple script for getting simple product id from configurable product. Check my previous post Get Simple product of configurable product.

In that script you just need to change following ajax code instead of alert box.
Note: You must need to add jQuery library in your page if library is not already added before using ajax code.

jQuery.ajax({
    type: "POST",
    url: "<?php echo $this->getBaseUrl()?>productdetails/index/optiondetails/",
    data:"id="+currentSimpleProductId,
    success: function(msg)
    {
        alert(msg);
        //var data = JSON.parse(msg);
        //alert(data.id);
    }
});

Download Source

Please support us, Like us on Facebook.

  1. Does not seem to work in 1.8.1 Have tried as the tutorial suggests. Showing the product ID only works but not when I replace the "alert("Selected product is: "+currentSimpleProductId)" for the ajax.

    ReplyDelete
    Replies
    1. This is working in magento 1.8.1 as well. Please like our facebook page for more help. www.facebook.com/developersarea

      Delete
  2. Hi! Thanks for this module! Really helps! But I have some question, how can i display the associated simple product attribute/detail to the product page, instead of showing it into an alert box? Lets say, i want to show "per pack" attribute beside the price.

    ReplyDelete
    Replies
    1. Yes you can do this as, create one blank div and than replace you alert box with...
      jQuery("#DIVID").html(msg);

      Thanks,

      Delete
  3. Hi,

    I am attempting to display a simple products upsell list on a configurable product, your code may just do the job but I am struggling with the implementation, where would I use the code? I guess upsell.php or abstract.php seems pretty complicated :/

    ReplyDelete
  4. Will it work in magento 1.9.0.0 version?

    ReplyDelete
    Replies
    1. Yes it will work in Magento 1.9 as well.

      Delete
    2. Yes its working fine in 1.9. Thanks for your sharing your module.

      Delete
  5. I replaced the alert message with supplied code and added jquery (https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js) but now my drop down boxes are empty. I am using Magento 1.9.1. Please help! Thank you

    ReplyDelete
    Replies
    1. Can you please show me your link?

      Thanks

      Delete
  6. i try to retrieve price and want to replace the magento default price of this associated products with that price

    ReplyDelete
  7. i retrieve product price and want to replace the default associated product price with this price

    ReplyDelete
    Replies
    1. You are getting product price in alert message?

      Delete
  8. yes.But i want to replace this price in the position of default price

    ReplyDelete
    Replies
    1. You can use jQuery to replace default price with new price. That is what you want?

      Delete
  9. Yes.I want to display the corresponding prices when selecting each simple products

    ReplyDelete
    Replies
    1. Use jQuery method to replace default product price with new one in place of alert.

      Delete
    2. jQuery("#defaultpriceID").html(newprice);

      Delete
  10. Hi, the script works with the alert box but not when I substitute the alert box eith the ajax, then the 'alert msg' dialog box gets not displayed at all. I really need to have simple details on view.phtml so I guess using ajax is the first step to achieve this (I'm using magento 1.9.2.4 by the way). Can you help me?

    ReplyDelete
    Replies
    1. Hello,
      If alert box is working for you, then you simply need to replace alert box code with above ajax code nothing else.

      Should you have any questions, please let me know.

      Thanks,

      Delete
  11. Btw i got it working but i have to click twice on the same option to get the values ? How i can correct this ?

    ReplyDelete
    Replies
    1. I precise i have two attributes. Color and Size

      Delete
  12. Which file i can put below code :

    jQuery.ajax({
    type: "POST",
    url: "getBaseUrl()?>productdetails/index/optiondetails/",
    data:"id="+currentSimpleProductId,
    success: function(msg)
    {
    alert(msg);
    //var data = JSON.parse(msg);
    //alert(data.id);
    }
    });

    ReplyDelete
  13. Hi,

    just tried your scripts in Magento 1.9.1 ..

    Fist part worked fine - get the alert with the ID of the selected simple product. Then I replaced thea alert line with the jQuery code ... nothing happened.

    I just want to display the sku of the simple product. How can I get the sku out of the id? ...

    Thank you very much!!!

    ReplyDelete
  14. Hi, i've tried your scritp and the module, the script for the ID works great on Magento 1.9 but when i try to use it with this module i can get the message. The url getBaseUrl()?>productdetails/index/optiondetails/ gets a 404 not found. I've copied with FTP module file in app/code/local and etc/module

    Thank you!

    ReplyDelete
  15. Has anyone got this to work with 1.9.3.3?

    ReplyDelete
  16. Hi there!!
    Simple alert with product id is working but after pasting code it is showing error in ajax request and also when get url copy and pasted in another tab it is showing 404 error. Please help me out as my project is stuck just because of this one thing!!
    Quick reply will be appreciated!!

    ReplyDelete
    Replies
    1. Hello,

      Please show me your code. Better to email me on hkpatel201@gmail.com

      Thanks,

      Delete
  17. Hi,

    i have a problem to get the value of a custom attribute. its code is 'base_price_amount'.
    $product->getBasePriceAmount(); returns 'null'

    how can i access custom attributes?

    thanks for your answer.

    ReplyDelete
  18. hi,

    i have a problem with a custom attribute. its code is 'base_price_amount'.
    $product->getBasePriceAmount(); returns 'NULL'

    how to access a custom attribute?!

    thanks for your answer

    ReplyDelete

 

Copyright @ 2017 HKBlog.