Magento Themes and Magento Extensions

How to create a custom router in Magento?

Posted on December 11th, 2012 | Posted by admin

How to create a custom router in Magento?

If you want to create a router for your own modules, perform the following steps.

1. open /app/etc/local.xml
2. Insert the following source code between config tag

01 <frontend>
02 <routers>
03 <$name>
04 <use>standard</use>
05 <args>
06 <module>$module_name</module>
07 <frontName>$router</frontName>
08 </args>
09 </$name>
10 </routers>
12 </frontend>

$name = name of your router.
$module_name = name of your module where your router redirects. For example, Moon_Products.
$router = router name.

Programmatically Create Magento Product Packages

Posted on November 30th, 2012 | Posted by admin

On a recent project I had to write a piece of code which I thought I’d share with the Magento community in case it comes in useful for anyone. I have put all the code into one ‘add to cart’ controller below for the sake of simplicity, but you could break it up into separate methods to clean up the code a bit.

In a nutshell, all products on the site have a normal price and some have a package price. If they have a package price they are capable of being purchased with other products as part of a package deal, but only two at a time. Therefore these products had to be purchased as one product using the special prices as we can’t have customers adjusting the quantities of items added to the cart. Here’s the code in myPackageController.php broken up:

Magento: Create multi shipment for an order programmatically

Posted on November 11th, 2012 | Posted by admin

This is another post for Magento programmer who needs to work with an extension for creating shipment for Magento order. You will need to use this when you have a module which connects Magento store with a vendor store. Basically, you need to program a script to create shipment for Magento automatically.

First, you will need to load an order using order increment id:

$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);


Posted on September 29th, 2012 | Posted by admin

Reporting can be a very important part of the Module you might be developing for Mageneto. If you are showing your data in Grid that’s good, but it will be better if you add XLS file generation action on that grid, so that the site administrator can see the report in paper. And if you have in paper you can visualize more clearly than on screen.

I came this condition recently, and found out that Magento has functions to chanage your Grid (in Admin) to XLS files and if you dig more than you can change your data Array to XLS file using Magento’s function.

First let me say you about exporing data from the Admin Grid you have already populated. You need do the following in your grid Block’s _prepareColumn function.

$this->addExportType('router/controller/action', Mage::helper('reports')->__('Excel'));

And in your controller you will have to do this.

Create a Color Switcher in Magento

Posted on May 16th, 2011 | Posted by admin

Magento comes packed with a lot of options. But no matter how many options you put into some product you can never cover all of them. One of such options (for now) is a color switcher in Magento. To be more precise, an image switcher based on color selection.

Recently I’ve made a screencast on my site on this subject, with somewhat different title. The idea is to have a dropdown box from which you choose a color and based on the color selection product image changes. All of this is to be based on some simple javascript (in my case, jQuery).

We used this solution on our Kapitol Reef project. Unfortunately, the client switched Magento with some other solution, so the site we developed is no longer active there.

First you need to upload some images to your product and give them some meaningful names like Red, Blue, Green depending on your product color. When I say give them name, I mean on label values. Same goes for creating custom attribute. You create a dropdown selection box and create the same amount of dropdown options as you have images, giving them the same name Red, Green, Blue… and so on. Here are some images for you to see what I’m talking about:

Page 2 of 3«123»