Magento

Common Magento theming issues

Breadcrumbs and page titles Removing the breadcrumbs block should not be very difficult since it is just one line in the /layout/page.xml file. However, if you were to remove breadcrumbs by changing the /layout/page.xml file it will adversely affect page titles, which may not be what you expect. The underlying issue is related to Magento's built-in flexibility that allows breadcrumbs to be used with page titles. The breadcrumbs block needs to be part of the page in order for page titles to be processed correctly. Read more →

Using jQuery with Magento

Installing jQuery jQuery can be downloaded from jquery.com and to install it you need to copy the file to the following directory: skin/frontend/default/your_theme/js To include jQuery you need to edit layout/page.xml where you need to add the following to the head block: <action method="addItem"><type>skin_js</type><name>js/jquery.js</name></action> Normally, this would be all you need to do, however because Magento also includes Prototype, there is a subtlety we need to deal with. jQuery uses '$' as shorthand for accessing the jQuery library. Read more →

How to set up a Magento store for Australia

Looking for instructions for Magento 2? Take a look at the new post How to set up a Magento 2 store for Australia. Running Magento stores in Australia differs very little from any other country, but there are a few things that you need to do for compliance with ATO requirements and to ensure that Magento calculates taxes correctly. The following is an outline of the necessary configuration and settings you may need to consider when setting up Magento for an Australian store. Read more →

Add product custom options

Like rating summaries, custom options are stored separately to the product object. The best way to set them is to first create an array with the data for the option: $options = array(); $options[$sku] = array( 'title' => 'Option Title', 'type' => 'radio', 'is_require' => 1, 'sort_order' => 0, 'values' => array() ); $options[$sku]['values'][] = array( 'title' => 'Option Value 1', 'price' => 0.00, 'price_type' => 'fixed', 'sku' => '', 'sort_order' => '1' ); $options[$sku]['values'][] = array( 'title' => 'Option Value 2', 'price' => 89. Read more →

Alternative Magento category tree structure

The underlying issue is that the 'Default Category' is not easily accessible in code. For example, the default top navigation in Magento uses the getStoreCategories() method to access all categories. But that method starts by returning the 'Default Category' child categories and never returns the 'Default Category' itself. A solution to this is to add a subcategory, such as 'Products', under the 'Default Category' so that we can effectively treat the 'Products' category as the root of the category tree. Read more →

Accessing product rating summaries

Product ratings are an important tool for gaining credibility and driving sales in any online store, and are yet another powerful feature built-in to the Magento core. Ratings can be a valuable criteria to make visible to people browsing the site, so rather than hide them away on product pages only, it can be desirable to display rating summary data elsewhere, or to use the data in developing other custom functionality. Read more →

Adding order comments

For all orders, Magento keeps a Comments History of all activity on that order. This allows an administrator to track changes that have been applied to the order status, as well as to attach comments for internal use or to be sent to the customer. If you are writing a custom extension that modifies orders then it's best to work within this system and to have your code update orders with the results of any processing done on them. Read more →

Creating Magento products from a script

Magento allows several different ways to add products to the catalog, including manual editing, upload via spreadsheet and the web services Magento Core API. For developers who want to add products through PHP however, there are a few caveats to be aware of for the product to be displayed on the frontend. The basics of adding a new product are trivial - you get a new copy of the appropriate model, fill in the details and call the save() method: Read more →

Loading large collections

Working with large Magento collections in PHP can often cause problems with memory usage and, to a lesser extent, computational overhead. The common method of loading all objects in the collection quickly becomes problematic as collection size increases. For stores with thousands of products or categories, chances are you'll be running into PHP memory limits more often than not. This post explains how to process collections in a less memory intensive way and should be a starting point for working with any large collection. Read more →

Magento Connect 2.0 developer survey

The Magento Connect system is a vital part of the Magento ecosystem and has had a lot of success since it launched a bit more than a year ago. As always, there is room for improvement and hence we were very glad to see Varien provide the community with an opportunity to participate in the future direction of the system by running two surveys, one for extension users, and one for extension developers. Read more →