October 25, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

E-commerce Platform Customization: Tweaking the Magento Admin Interface

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

I've spent the past several months working on a non-trivial Magento-driven e-commerce project for a local client. The project involved more than 14,000 products segmented into more than 50 categories and they were further broken down into those which are purchasable, rentable, and available only via special quote. It goes without saying that we encounter some pretty interesting challenges on a daily basis. Other trying factors include a fairly sophisticated custom theme and integration of a sophisticated order-fulfillment pipeline.

Throughout it all, Magento has repeatedly proved itself up to even the most demanding configuration tasks. The level of thought and effort put into all aspects of the platform is in a word, striking. Much of my praise stems from Magento's extensibility. The fact is, there have been numerous instances where Magento does not meet the exacting requirements of a particular project, necessitating modifying or adding new features to the software. Magento's architecture is such that it's possible to deeply integrate new features into the existing design and capabilities by way of custom extensions. These extensions never touch the core files, meaning that the Magento upgrade process is seamless and easy rather than a nightmare fraught with mistakes and errors.

But the project documentation falls well short of expectations in terms of properly documenting exactly how one goes about extending the platform. The community wiki, though voluminous and in places rather well-written, tends to focus on specific aspects of integration rather than presenting a general introduction to the topic.

In fact, my own frustrations regarding the lack of substantial documentation have been such that I've recently started work on a new book titled Easy Magento, which introduces effective extension development and layout management alongside a host of other indispensable topics. In the meantime, I thought it would be useful to provide those of you who are just getting started modifying developing your own extensions with a simple but practical example involving modifying the default Magento administration interface, which you can use as the basis for making your own forays into enhancing Magento's capabilities.

How the Magento E-commerce Platform Builds Pages

Perhaps more than any other factor, the key to truly mastering Magento's approach to extensibility lies in understanding the important role XML has to play in both page layouts and functional extensions. In fact, every single page you encounter when navigating a Magento-driven website is in some manner defined within an XML file! Consider for instance the Magento administration console's interface for viewing orders (Figure 1).

Magento Admin Interface
Figure 1.
Viewing an Order in the Magento Admin Interface

This interface is actually defined within an XML file named sales.xml, which resides in app/design/adminhtml/default/default/layout/sales.xml. A very small part of sales.xml is presented here (formatted for improved readability):

....
<reference name="left">
<block type="adminhtml/sales_order_view_tabs"
name="sales_order_tabs">
<block type="adminhtml/sales_order_view_tab_info"
name="order_tab_info"
template="sales/order/view/tab/info.phtml">
<block type="adminhtml/sales_order_view_messages"
name="order_messages"></block>
<block type="adminhtml/sales_order_view_info"
name="order_info"
template="sales/order/view/info.phtml"></block>

...

The bolded lines identify just one of many blocks which comprise any given Magento page. This particular block is responsible for generating the two sections titled Order # 100000041 (the order confirmation email is not sent) and Account Information, in addition to two other address-related sections not presented in Figure 1.

The type attribute refers to the block responsible for retrieving the dynamic order information which is retrieved from the database and inserted into the view template, which is identified by the template attribute. Therefore the block is adminhtml/sales_order_view_info and the template is sales/order/view/info.phtml. Taking Magento's autoloading approach into account, this means the block is found at app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Info.php and the template is found at app/design/adminhtml/default/default/template/sales/order/view/info.phtml.

Take a few moments to review in particular the template, as we'll be overriding its layout in order to produce the updated version found in Figure 2.

Magento Admin Interface
Figure 2.
The Revised Order Review Page in the Magento Admin Interface


Tags: e-commerce platform

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

Page 1 of 2



Comment and Contribute

 


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

 

 


Sitemap | Contact Us

Rocket Fuel