Fatal error:Call to a member function getSource()on a non-object in\app\cose\core\Mage\Catalog\Model\Product.php on line1389

Fatal error:Call to a member function getSource()on a non-object in\app\cose\core\Mage\Catalog\Model\Product.php on line1389

July 7, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Fatal error:Call to a member function getSource()on a non-object in\app\cose\core\Mage\Catalog\Model\Product.php on line1389

Resolving “Call to Member Function getSource() on Non-object” Magento Error

Hello developers! Today we’re going to troubleshoot a common issue that crops up during Magento development - the dreaded Fatal error: Call to member function getSource() on non-object message. Don’t worry, by the end of this post you’ll have the knowledge and tools needed to fix it.

Understanding the Error

This error typically arises when you’re trying to call a method (getSource() in this case) on an object that is actually null. It’s usually due to a previous operation failing to create the expected object, or a misconfiguration somewhere in your code base.

Let me break down the provided error message:

Fatal error: Call to member function getSource() on non-object in
D:\wamp\www\magento\app\code\core\Mage\Catalog\Model\Product.php on line 1389

The key parts here are:

  • Call to member function: Magento is trying to execute the getSource() method.
  • on non-object: The thing it’s calling this method on isn’t actually an object, but a null value.
  • Line 1389: This points you directly to the problematic line in the Product.php model file.

Common Causes and Solutions

Incorrect Object Creation

The most common culprit is that somewhere earlier in your code flow, the Magento model wasn’t created correctly. For example, you might have:

$product = Mage::getModel('catalog/product');

However, the product doesn’t exist or there was an error during creation.

Solution: Double-check all calls to Mage::getModel(). Make sure the model exists and that any required parameters are passed correctly. If a model requires ID(s), make sure they’re valid IDs; if it requires other parameters (like product IDs for Mage::getModel('catalog/product')->load($productId)), ensure those values exist.

Misconfigured Varien Objects

The Varien_Object is Magento’s base object class, and it has its own rules. If you’re trying to access a property that doesn’t exist on the object, or if the property was never set in the first place, this error can occur.

Solution: Be mindful of your property names when working with Varien_Object. Always check if a property exists before accessing it:

$product = Mage::getModel('catalog/product')->load($id);
if ($product->hasData('name')) {
    $productName = $product->getData('name');
} else {
    throw new Exception("Product name not found");
}

Incompatible Methods

Sometimes, you might be calling a method on an object that simply doesn’t support it. This can happen if you’re using a third-party extension or if Magento has been heavily modified.

Solution: Check the documentation for your specific Magento version and any relevant extensions. Make sure the method you’re trying to call is actually available on the object you’re working with.

Best Practices for Avoiding These Errors

Preventing these errors starts with good coding practices:

  1. Check Object Existence: Always check if an object exists before calling methods on it.
  2. Use Try-Catch Blocks: Surround your critical code in try-catch blocks to handle exceptions gracefully.
  3. Validate Inputs: If your models rely on external data (like IDs), validate that data before passing it into the model.

Conclusion

The Call to member function getSource() on non-object error is a common one, but with a little bit of debugging and some good coding practices, you can avoid it entirely. By understanding what’s happening under the hood in Magento, you’ll be well-equipped to resolve these issues quickly.

Remember, if you’re stuck or need more advanced help with your Magento development, don’t hesitate to reach out to Laravel Company. We specialize in helping businesses build and maintain robust e-commerce platforms.

Happy coding!

Catalog Configuration Errors

Our network