I am kinda stuck with this issue here. I am getting this error code in PHP:

PHP Fatal error:  Call to undefined method Mage_Catalog_Model_Product_Type_Simple::getUsedProducts() in line 23...

Since I am kinda new to Magento I am wondering if somehow this code snippet I got might be wrong or so. Maybe you guys could take a look and let me know if it all seems right. I can't even var_dump the $_products variable.

Here is the code snippet: https://ghostbin.com/paste/n9t23

Thanks in advance!


You have to check that product is configurable or child so you should change code like below

public function getStockInfo($_product)
        $stockVariants = array();
        $usedProducts = $_product->getTypeInstance(true)-     >getUsedProducts(null, $_product);

        foreach ($usedProducts as $simple) 
            $stock =(int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty();
            if ($stock >= 3) {
                $stock = 3;
            $stockVariants[$simple->getSize()] = $stock;

        return $stockVariants;


Hope it works.


Problem is that you are getting the child products from a simple product.

You need to add the following condition before declaring the $usedProducts variable:

if ($_product->getTypeId == "configurable")

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.