Magento Debugging Tips: Filename cannot be empty

Problem You may have seen this kind of error frequently logged in your Magento log file var/log/system.log: Warning: include(): Filename cannot be empty in /app/code/core/Mage/Core/Block/Template.php on line xxx This error means Magento is trying to include a template block with an empty string set as it’s template. Solution In order to find which template file …

Read moreMagento Debugging Tips: Filename cannot be empty

Using get_defined_vars() for debugging local scope variables

Suppose say, you want to debug variables in some observer method. You can either log each variable or simply dump it. But when you have many variables, debugging each variable can be an overhead task. For this purpose we can use PHP’s inbuilt function: get_defined_vars() How to use it? //put this line at the top …

Read moreUsing get_defined_vars() for debugging local scope variables

How to fix the issue: Product images missing in backend but not in the frontend

Introduction Recently I have to fix a strange issue for one of my clients. The issue was that product images were missing from ‘Images’ tab of product edit form (as depicted below), though they were displaying fine in the frontend. After going through the table relationship for catalog product images (as shown below), it was …

Read moreHow to fix the issue: Product images missing in backend but not in the frontend

How to find the current URL in Magento?

You must be wondering we can simply use: $currentUrl = Mage::helper(‘core/url’)->getCurrentUrl() or $currentUrl = Mage::getUrl(‘*/*/*’, array(‘_current’ => true)); in order to find the current URL. But it doesn’t always work as expected. Try to use the above code in a page which has some missing CSS, js, images, etc.(You can use Firebug in order to …

Read moreHow to find the current URL in Magento?

Debugging technique in Magento: Process of elimination

Introduction: Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected. Source: Wikipedia Nobody is perfect so don’t expect an application to be perfect. As a developer you may face many bugs during your …

Read moreDebugging technique in Magento: Process of elimination