I use these lines below to get the CMS page data,

// Get current cms page from Mage:getSingleton
$cms_id = Mage::getSingleton('cms/page')->getIdentifier();
$cms_title = Mage::getSingleton('cms/page')->getTitle();
$cms_content = Mage::getSingleton('cms/page')->getContent();

What about if I want to get a catalog product data? I want to get the product's name for instance,

$_helper = $this->helper('catalog/output');
$product_id = Mage::getSingleton('catalog/product')->getIdentifier();
$product = Mage::getModel('catalog/product')->load($product_id);
echo $_helper->productAttribute($_product, $_product->getName(), 'name');


Fatal error: Call to a member function getName() on a non-object in C:\wamp\www\mywebiste.com\app\design\frontend\mywebsite\default\template\page\html\banner.phtml on line 6

Any ideas?

1 Answer 1


The error basically means that the $product object is not an object, it is most likely null. I would check what is being returned from Mage::getSingleton('catalog/product')->getIdentifier();

If you are on a product page you can use Mage::registry('product')->getId() to get the id of the current product.

Or if you are simply wanting to load an arbitrary product then you can simply specify the id to use.


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.