Daily Archives: March 6, 2012


Magento Exception with message ‘Warning: include(Mage\xxxx\Helper\Data.php)

If you receive this error with Magento Exception with message ‘Warning: include(Mage\xxxx\Helper\Data.php) then it means you’re calling a helper somewhere and the helper’s XML config is missing. For this example, let’s say we have a helper called “custom”. First, ensure you’ve created a class at /app/code/local/Yourcompany/Custom/Helper/Data.php . Inside Data.php, there should be the following class:

<?php
class Yourcompany_Custom_Helper_Data extends Mage_Core_Helper_Abstract{}

Then in the file /app/etc/config.xml OR /app/code/local/Yourcompany/Custom/etc/config.xml, add the below xml:

<global>
	<helpers>
	    <lpcustom>
	        <class>Yourcompany_Custom_Helper</class>
	    </lpcustom>
	</helpers>
  </global>

Which file is Mage::helper

The way to call helper classes and functions is to use the static helper function in the Mage class providing the component name and desired helper class. For example Mage::helper(‘customer’) would return an instance of the class “Mage_Customer_Helper_Data” which is located in app/code/core/Mage/Customer/Helper/Data.php. The choice of helper to be returned can be specified by adding a slash to the helper parameter and naming the class desired. Mage::helper(‘customer/address’) would return an instance of the “Mage_Customer_Helper_Address” located at app/code/core/Mage/Customer/Helper/Address.php.

If you are wondering just what file Mage::helper(’catalog’) relates to as I was wondering (there is no ‘catalog.php’ helper file amongst the helpers in the core catalog module) you can add this code in your block to test:

echo get_class(Mage::helper('catalog'));
//outputs Mage_Catalog_Helper_Data

Zend Studio debugger doesn’t work on Magento

Learning Magento is hard enough and when you’re debugger won’t stop at any breakpoints, that’s enough to take any developer out of his game. I was fortunate to find this blog post http://rocinantesoftware.blogspot.com/2009/06/debugging-magento-vista-xampp-zend.html detailing how to configure various debuggers to work with Magento. Below is how to configure your magento project with Zend Studio for Eclipse.

ZEND STUDIO FOR ECLIPSE
The following assumes that Magento can be reached from http://127.0.0.1/magento
– From the “Run” menu, select “Debug Configurations”
– On the left, right-click on “PHP Web Page” and select “New”
– Name: Magento
– Server Debugger: Zend Debugger
– PHP Server: Click on the “New” link
– Name: Magento Server, URL http://127.0.0.1 (do NOT use localhost – I don’t have notes on this, but I’m sure that I had trouble accessing the admin area using local host, and switching to http://127.0.0.1 fixed the problem).
– Hit next, going to the Server Path Mapping, and “Add”
– Path on Server: the windows path to your magento dir, e.g. C:\Users\Ed\workspace\magento
– Path in Workspace: /magento
– Click Finish
– Now back in the “Debug Configurations” dialog, set file to magento/
– uncheck “Auto Generate (URL)”, and set the path (first part of which is auto-generated) to /magento
– In the “common” tab, click “run” and “debug” for showing in the favorite menus.

Also, for me personally I had to edit the php server and clear out the “Local Web Root” input and on the “path mapping” tab ensure you have one entry – the “path on server” should be the full directory path to your application and the “local path” should be the name of your zend studio project, such as “/magento”.