I haven’t written any articles in a while, and thought I should write a quick one about a Magento ‘fix’ I needed to do today. Magento isn’t the cleanest and most straight-forward software to extend, so I usually find myself doing a quick search to see if anyone has already tackled whatever customization a customer is asking for. This time, I only found bad examples of how to do this.
The best way to extend Magento in order to future-proof your modifications is to define overrides in a local.xml layout and doing everything you possibly can to avoid hacking up or overriding any default layouts or templates. Adding the Google Checkout button to the side bar cart is a typical example where I found several people outlining how to hack up existing templates to accomplish this.
None of this is necessary.
The following is the app/design/frontend local.xml modification that will insert Google Checkout into the cart side bar. Put this in the layout -> default section.
Please make sure you comment what your modifications to local.xml do. It’s not always intuitive months later, and I might have to work on it after you do. 🙂