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

Article ID #1241
Revision: 1.1
Last update: 2012-05-20

applies to Magento 1.5 and earlier versions

 

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.

 

Some known themes and extensions affected:

Gala Eva Magento theme: app/design/frontend/galaeva/default/template/checkout/cart/item/default.phtml

Accessories Car Magento theme: app/design/frontend/default/ma_carstore/template/checkout/cart/item/default.phtml

MagikFees extension: app/design/frontend/default/<your_theme>/template/magikfees/checkout/cart/item/default.phtml (replace <your_theme> with exact path to your theme)


Did this article help you solve your issue?


Average rating: 4.24 (17 votes)

completely useless 1 2 3 4 5 most valuable

Tags: ,