Pergunta

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 .

Foi útil?

Solução

Try this way:

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

   // 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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top