Call to undefined method Mage_Catalog_Helper_Data::canApplyMsrp() in template/checkout/cart/item/default.phtml

Symptoms

Shopping cart page is not loaded or loaded blank or partially blank, the following error message is shown in PHP error log:
PHP Fatal error: Call to undefined method Mage_Catalog_Helper_Data::canApplyMsrp() in template/checkout/cart/item/default.phtml
Cause

Mage_Catalog_Helper_Data::canApplyMsrp() method is implemented since Magento 1.6 version, attempts to use this method in earlier Magento versions, like Magento 1.5.1.0 or Magento 1.5.0.1 will result in fatal error.

Solution

The proper fix is to prepend any calls to canApplyMsrp() method with if method_exists call.
before:
$canApplyMsrp = Mage::helper(‘catalog’)->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
after:
if (method_exists(Mage::helper(‘catalog’)->canApplyMsrp))
$canApplyMsrp = Mage::helper(‘catalog’)->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);

The exact file name to be patched is shown in PHP error log.
Another fix can be upgrade to Magento 1.6 or later version.

Kyle.

Advertisements
Categories: Magento | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: