March 24th, 2010

In a previous post, I demonstrated some basic steps to improve Magento performance.
Now we are going dig deeper and work on more complicated methods. Many of these methods require addition installation or hands-on tuning, and their effects will vary a lot depending on the exact setup. So the key is to experiment and find out the combination best for your site.
First, an overview of the key subjects:
- Improve Magento cache: ramdisk and tempfs
- PHP Accelerator: Alternative PHP Cache and XCache
- Keeping connection alive?
- Combining JavaScript and CSS: Minify library
- Magento beyond single server
Read the rest of this entry »
Posted in Uncategorized | 5 Comments »
March 22nd, 2010

Let’s begin with the basics. Tips here are mainly just configuration tweaks. They are easy to implement and test. And if you don’t like them you can easily revert all your changes. Make sure you restart your service after the configuration change.
I will cover 5 easy points in this article, additional methods will be explained in the advanced article:
- Save the sessions in database
- Enable Magento Cache
- MySQL Query Cache
- Enable file compression in .htaccess
- Clean up the template
Read the rest of this entry »
Posted in Uncategorized | No Comments »
March 16th, 2010

Many of us actively use social network sites like Facebook and Twitter to promote our businesses. A sleek plug-in will allow your Magento store to tap in the ‘power of the people’, which will help your products to ’sell themselves’.
To fully support a social network is an open question. However, there are many quick improvements you can make which will take effect almost immediately.
Let’s begin with Twitter. It’s a perfect tool for your customers to follow your website. You can post updates for featured product, promotions, events and etc.
The advantage for Twitter is that it provides a very straight forward API implementation, cURL is enough to handle the communication.
Read the rest of this entry »
Posted in Uncategorized | No Comments »
February 22nd, 2010

One of the missing for Magento is the security tests on all POST forms. This may be a serious problem in 2 cases:
- Highly sensitive forms like Admin Panel login form, which is very vulnerable to attacks
- And forms that need manual processing like Contact Us form, which can be an easy target for spamming.
The industry standard solution is to add a challenge-response test, like CAPTCHA, to ensure that the response is not generated by a computer, and ReCAPTCHA (http://recaptcha.net) is a well-packaged free CAPTCHA service.
Adding a reCaptcha box to a Magento page is not difficult, but it is going to be time consuming if you need to add it to multiple pages. To deal with this, I created a recaptcha module so that the recaptcha form can be inserted into a page in a nice and easy way.
Read the rest of this entry »
Posted in Uncategorized | No Comments »
January 22nd, 2010
The Magento Admin panel is controlled by the Adminhtml module, which does not have a strict layout mapping. This is a problem when we want to add our own JavaScript and CSS to create a new module or improve old modules.
(This post is a developer’s guide.)
For pages lacking .xml layout, the common method like the following will not work:
<action method="addJs"><script>jquery/jquery.js</script></action>
Instead, we should directly inject the JS into the ‘blocks’ given by .php files.
Read the rest of this entry »
Posted in Magento Admin Panel | No Comments »
October 29th, 2009

Often, we need to integrate other platforms (for example Wordpress, phpBB, etc) with Magento. This usually begins with unifying the design and then synchronizing the user account. Towards the end if the cross-talk becomes too complicated, it would be easier to build some specific APIs to tackle this.
Here we are going to walk through a quick and neat way to extract the Magento header and footer, and the inject them into another platform, in the following steps:
- Create a blank Magento CMS page for the extraction
- Build Ajax code to retrieve the header and footer
- Update the HTML page
Read the rest of this entry »
Posted in Magento Integration | No Comments »
September 3rd, 2009
The Magento Onepage Checkout is quite a tricky component. For simple tasks, it is quite possible to change the PHP code with surgical precision without messing around with the JavaScript part. But unfortunately, in many complicated tasks, like adding a new step with a bunch of new functions, would inevitably involve JavaScript handling.
Here come a couple of useful tips:
Our final target is the opcheckout.js, located at: skin/frontend/default/default/js/opcheckout.js
Before we jump into hundreds of lines of JS codes, our first stop should be the template files for the Onepage Checkout. At the end of those files, you will see something like:
<script type="text/javascript">
//<![CDATA[
var billing = new Billing('co-billing-form', ...);
//]]>
</script>
Yes, this is the critical link between our PHP part and JS part.
Read the rest of this entry »
Posted in Magento Onepage Checkout | No Comments »
August 11th, 2009

One of the major features of Magento is the Entity-Attribute-Value (EAV) data model.
This is indeed quite a block to play with. However with the right leverage, it can become rather handy.
To some extent, using EAV is, arguably, an improvement. The major advantage of EAV is: there won’t be endless ad hoc attributes inserted to the table, which is one of the critical flaw for older platforms, say OS-commerce, where table columns rapidly grow to an unmanageable size.
On the other hand, EAV basically means no raw queries of the database, or at least very challenging if you are really determined to query directly into the database, not to mention that an upgrade will easily break your code. This is, indeed, very clumsy for simple things like selecting a group of products or customers. In addition, there is quite an efficiency trade-off since there would be quite a few table joint to load an EAV object. Also, quite a lot of data a duplicated throughout different tables, a small price we have to pay.
Despite all these, personally, I find EAV quite okay. I guess the decision making factor for the Magento team to choose EAV tables against flat table is that EAV is generically more flexible. It’s relatively easy to maintain given the fact more than often multiple developers/teams are involved in the same project.
Read the rest of this entry »
Posted in Uncategorized | No Comments »
July 30th, 2009
The Magento admin panel is quite different from other modules for the frontend. The Adminhtml module has a distinct implementation of the Model-Controller-View scheme. In fact, forms, tables, graphs and etc. are usually stereotypical and highly repetitive comparing to the large varieties in the frondend. As a result, in Adminhtml page, such elements are generalized into block ‘widgets’ to boost coding efficiency.
However, when building a new module, we often need to modify the frontend and the backend together. And in many cases, since the we already build the functions in frontend module, it’s really a waste of energy if we have to rewrite everything in terms of ‘widget’ in the backend. Simply, we would like to migrate the controller and view to the backend and reuse the code.
Here, I’m going to go through the basic steps the Mage_Adminhtml_Block_Template rather than widgets.
(This is a developer’s guide.)
Let’s begin with creating a new menu in the Admin panel. We added to the config.xml to our new module:
<adminhtml>
<menu>
<new_module translate="title" module="new_module">
<title>New Module Name</title>
<sort_order>50</sort_order>
<action>new_module/new_controller</action>
</new_module>
</menu>
</adminhtml>
Read the rest of this entry »
Posted in Magento Admin Panel | No Comments »
July 8th, 2009
More than often, we need to create a new attribute to extend some Magento functions, or even a new attribute group to serve our own module. Here is how we do it using the sql setup file.
First, a few words about the sql setup file.
If this is the first time building the module or fresh installation, create a php file, say “mysql4-install-0.1.0.php”, in [company]/[module]/sql/[module]/[module]_setup/ folder, where the version 0.1.0 is defined the the config.xml file.
In case of module upgrade, try something like “mysql4-upgrade-0.1.0-0.2.0.php”, again, verify your upgrade version in the config.xml file.
Inside this file, first we need to initiate:
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
Read the rest of this entry »
Posted in Uncategorized | 1 Comment »