October 26, 2016
Hot Topics:

Working with Magento E-commerce Extensions, Page 2

  • November 22, 2011
  • By Jason Gilmore
  • Send Email »
  • More Articles »

Creating a New Extension for the Magento Admin Interface

Remember that the goal is to revise what the Magento administrator sees when viewing the order review page while not actually touching the default app/design/adminhtml/default/default/template/sales/order/view/info.phtml file. In order to accomplish this, we need to extend Magento using a custom extension.

In order to prevent namespace collisions, extensions are typically identified by a unique string associated with the developer, in addition to a name which identifies the specific extension. For the purpose of this example I'll use the namespace Gilmore and the extension name Backend.

Begin by creating a file named Gilmore_Backend.xml and placing it within the directory app/etc/modules/. Add the following contents to the file:

<?xml version="1.0"?>

After saving this file, log in to the Magento administration console and navigate to System &gt Configuration > Advanced and make sure the extension is enabled (Figure 3).

Magento Admin Interface
Figure 3.
Ensuring the Gilmore_Backend Extension Is Recognized

Configuring the Magento Extension

Next, you'll need to configure the extension. This is done by creating a--you guessed it -- configuration file. This file should be named config.xml and placed in a directory app/code/local/Gilmore/Backend/etc/. Of course, this directory tree doesn't yet exist, so you have to create it. Within config.xml, place the following contents:

<?xml version="1.0"?>


The bolded <layout> section is the particularly important part, as it tells Magento that we want to update the Magento administration HTML (known as adminhtml), and the update instructions are found in a file named gilmore.xml. Because gilmore.xml doesn't exist, you'll need to create it too, placing it in the directory app/design/adminhtml/default/default/layout/gilmore.xml. Within this file add the following:

<?xml version="1.0"?>
<reference name="order_info">
<action method="setTemplate">

This file is where many beginners tend to stumble, precisely because the XML syntax is so confusing. However, when broken down into the various parts it is actually quite easy to understand. The adminhtml_sales_order_view enclosure refers to the very same enclosure found in sales.xml. The reference element associated with the order_info attribute tells Magento that we want to update the block identified by order_info (identified within sales.xml) with whatever is found within the reference enclosure. In this particular instance, we are using the setTemplate method to identify a new template, which is found in app/design/adminhtml/default/default/template/gilmore/backend/info.phtml.

Updating the Sales Order View Template in Magento

The only remaining step is to actually update the page HTML to reflect the new layout. To do so, copy the contents of app/design/adminhtml/default/default/template/sales/order/view/info.phtml into app/design/adminhtml/default/default/template/gilmore/backend/info.phtml, change as desired, save the changes, and reload the order review page!

Where To From Here?

Admittedly, the update sequence seems rather lengthy, particularly because we're interested in updating only a small part of a page. However, after working through the process a few times, you'll find that it takes only a few quick moments to configure. Additionally, this is but the most simple of changes; when creating much more complex changes you'll find this approach to be incredibly convenient. And as always, if you have any questions, be sure to get in touch!

About the Author

Jason Gilmore is founder of the publishing, training, and consulting firm WJGilmore.com. He is the author of several popular books, including "Easy PHP Websites with the Zend Framework", "Easy PayPal with PHP", and "Beginning PHP and MySQL, Fourth Edition". He is currently writing a new book titled Easy Magento. Follow him on Twitter at @wjgilmore.

Tags: e-commerce platform

Originally published on http://www.developer.com.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel