Configurable product shows out of stock whether child product still in stock. Can't figure out what to do to show in stock parent product if any child product have stock. Please help me .

  • I doubt you are using this extension: github.com/tzyganu/Switcher, are you? – Adarsh Khatri Feb 8 '16 at 5:00
  • @Khatri Thanks for quick reply. No, not using this extension. – Kaka Feb 8 '16 at 5:18
  • Can you confirm you have set in-stock in your config items's inventory? – Adarsh Khatri Feb 8 '16 at 5:20
  • Yes,in simple product & configurable product show out of stock if those product stock limit is over, $qty = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); using this code get quantity of a product but how can i get child product quantity in configurable product – Kaka Feb 8 '16 at 5:22

Try this way:

//load parent product "$product"
if($product->getTypeId() == 'configurable'){
   $childProducts = Mage::getModel('catalog/product_type_configurable')

   // now get qty from collection
   $qtyModel = Mage::getModel('cataloginventory/stock_item');
   foreach($childProducts as $key => $child){
      $childQty[$key] = $qtyModel->loadByProduct($child)->getQty();

Now you can put your other logic.

Hope this helps.

Assumption $product is a config parent product object.

  • It's show an error. Call to undefined method Mage_Catalog_Model_Product_Type_Simple::getUsedProducts() in – Kaka Feb 8 '16 at 5:51
  • Have you defined $product before my code? Also check my edited answer. – Adarsh Khatri Feb 8 '16 at 5:51
  • Yes,$childProducts = Mage::getModel('catalog/product_type_configurable') ->getUsedProducts(null,$_product); $_product is the parent product – Kaka Feb 8 '16 at 5:58
  • Hi @Khatri, thanks for your help. At last, I've got my solution using your code :) +1 – Kaka Feb 8 '16 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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