Magento: Remove all categories from a store

This is just theĀ Sql commands that I just discovered today in order to to remove all categories. For more information, please check here. Please also notice that you may have to change the prefix of database tables, enjoy šŸ™‚


TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;
INSERT INTO `catalog_category_entity`
(1,3,0,0,‘0000-00-00 00:00:00’,‘2009-02-20 00:25:34’,‘1’,1,0,1),
(2,3,3,0,‘2009-02-20 00:25:34’,‘2009-02-20 00:25:34’,‘1/2’,1,1,0);
INSERT INTO `catalog_category_entity_int`
INSERT INTO `catalog_category_entity_varchar`
(1,3,31,0,1,‘Root Catalog’),
(3,3,31,0,2,‘Default Category’),

Building a Magento Admin Module

Have you ever wanted to build a custom module for the Magento admin panel? Today I am going to share this information hoping you will find this post useful!

Creating the Module Folder Structure

Lets start by creating the following folders:


Building the Module

Within the ā€˜etcā€™ folder create a file called config.xml and paste in the following code:


Next create a file called adminhtml.xml within the ā€˜etcā€™ folder and paste in the following:


We need to tell Magento to load our module and to do this we need to create a file within /app/etc/modules. I called my file Toto_ImportXml.xml and it contained the below XML code:


Now if you refresh your Magento admin panel, you should notice a new tab called ā€˜Tofu & Tomato Commerceā€™. However, if you click on it you will be given a PHP error saying that Magento canā€™t find a helper class. This is because within adminhtml.xml we told Magento that the tab is associated with the module ā€˜importxmlā€™ and by default Magento looks for a helper file called Data.php.


In the config file we also declared the helper class within the global node.


To fix this problem we need to create a file called Data.php with the Helper folderĀ (/app/code/community/Ā Toto/ImportXml/ Helper/Data.php). This will be an empty class for the time being but it will fix the warning we are currently getting. Paste the following into Data.php:


Note:Ā The class name needs to be file path structure to Helper/Data.php.

The final stage is to add the controller. This will route the user to the method specified within adminhtml.xml. For example lets take the following:


Magento will look in the module ā€˜Greenmoduleā€™ for an index controller with the method called indexAction. So lets create a php file called ā€˜IndexController.phpā€™ within the controllers folderĀ (/app/code/community/Toto/ImportXml/controllers/ IndexController.php). Paste in the below PHP code:


The above method simply creates a block with a the heading ‘Tofu & Tomato Commerce’Ā by using Magento factory methods. Refresh your browser and you click on the custom menu tab ā€“ you should now see a brand new page with the h1 tag.

Note: You may have to clear your magento cache or log out and log back in for the new page to show. This has caught me out many times.



Magento: How can I format / shorten a price to two decimal

I was having trouble displaying some prices on my Magento store in currency format (2 decimal places). Instead the values were being displayed at 4 decimal places. Bellow is a snippet. (for example: from +0.8500 to +0.85)

$numberformatted = number_format($number, 2, '.', '');

More information:Ā


Magento: Get Bundled Items name / title by bundled product Id

This post is jut a small snippets that will help you to get all bundle items’ title.

Of course, Iā€™m not sure how useful can it be as is, so if you need optimized version of it, you will need to play with it for a while.Ā I tried to find it on google few days ago and I had no luck, so if anybody has better solution, please comment.

Here we go:

bundle products

Bundled Products, Magento will not recalculate the Price – Bundle.reloadPrice()

Hello, I’m Tofu, nice to see you again.

My client gave me a purchased Magento templateĀ and asked meĀ to install and configureĀ a new Magento store for him. The template was very clean and professional. However, there was an weird issue since it didĀ not support the latest Magento version 1.9.

I created serveral bundle products just for testing purpose then IĀ added or subjected items to the cart, the price didĀ not change. I got js errors:

Uncaught ReferenceError: taxCalcMethod is not definedĀ 
Uncaught TypeError: Cannot call method ā€˜reloadPriceā€™ of undefined

Finally, I figured out the problem. We will need to copy the following javascript snippetsĀ from BASE themeĀ to our activated theme in



[Magento] 503 error after installing extensions

Hello, I just installed Magento shopping cart, via host monster. Earlier in the day, I installed a bunch of extensions through Magento Connect Manager. When I went to go back to my Admin section, I got the 503 Error.

ā€œService Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.ā€


Iā€™ve seen this happen before after upgrading or installing extensions and in many of the cases it appeared to be that the maintenance.flag stuck.Ā Check your Magento installation root folder, look for that file and then delete it.