Magento 1.7. I have one configurable product and associated products, also I have some dropdown boxes. After choosing the option from my product, I added it to the cart. I want to now get the product_id or product_sku for the simple product; for configurable products working.


php code :

 public function getProductIdSku(Varien_Event_Observer $observer){
    $product = $observer->getEvent()->getQuoteItem();
    $productSku = $product->getSku();  //for configurable product
    $productQty = $product->getQty();  //for configurable product

    $order = $observer->getEvent();
    $data = $order->getData('sku');  //fr simple product is not working
    $quote = Mage::getSingleton('checkout/session')->getQuote();  //for configurable product

    $sales_quote = Mage::getModel('sales/quote_item_option');...->getId(); getSku();

2 Answers 2


You can get the simple product details on the same event by placing the following code in your observer :

$main_product = $observer->getEvent()->getProduct();
$associated_product = $observer->getEvent()->getQuoteItem();
$productSku = $main_product ->getSku();  //for configurable product
$productQty = $main_product ->getQty();  //for configurable product
if($product->getTypeID() == 'configurable'){
  //to get the id or sku of associated product use the following.
  $simple_product_id = $quoteitem->getProduct()->getId();
  $simple_product_sku = $quoteitem->getProduct()->getSku();

Hope this works for you.


Here the solution is

  $main_product = $observer->getEvent()->getProduct();
    $associated_product = $observer->getEvent()->getQuoteItem();
    if($product->getTypeId() == 'configurable'){
      //to get the id or sku of associated product use the following.
     //  $asoc_id is Configurbale product id 
      $ConfigProductId = $quoteitem->getProduct()->getId(); 
    //$assoc_sku is simple Product id
      $assoc_sku = $quoteitem->getProduct()->getSku();
     // Associated Product id  

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.