Skip to content

June Grab Bag

A comprehensive resource for learning about HTML5 that I’ve been poking at lately: Dive into HTML 5. How it’s evolved, how the new tags work and how to test for them. My guess is that HTML 5 is about to hit and that two years from now, the websites that people are talking about will use these features in creative innovative ways. Perhaps most usefully, the site features a comprehensive guide to browser testing to determine if a new tag is supported.

This blog has begun to get a lot of spam comments, which probably means it’s starting to get crawled by search engines. I haven’t done any search engine optimization yet; I’ll take a look at how good WordPress is for SEO right out of the box and make a post about how to make it better this week, and start tracking the site with some analytics. While we’re discussing upcoming posting news, we’re also due for another installment in the Magento product import series, and a post or two about a database-driven web toy side project that I’ve been working on lately.

I’ve been doing some software design lately, but I’ve been feeling like my skills are lagging at both the macro and micro level: finding appropriate design patterns, and writing clean efficient maintainable code. Leaning on this Stack Overflow post about influential books for programmers, I’ve ordered the following classics, which I’ve never read:

I’m looking forward to digging into them over the rest of 2010. I’ll keep my eye out for good posting material from within them, as I apply them to my projects.

Adding a Configurable Attribute to an Existing Configurable product

In Magento, you might make a mistake, and create a configurable product without the attribute that you need. Or your products might change over time-your shirts might come in different colors now, when before they only came in different sizes. You can’t add a new configurable attribute to an existing product through the CMS; Here is how to do it; I don’t think that this is documented anywhere:

1) Access your Magento database using your preferred method. I usually use phpMyAdmin when I am inserting something into the database-the web form is an additional failsafe against making a SQL mistake.
2) Look at the catalog_product_super_attribute table. You’ll need to add an entry to this table in order to add a new configurable attribute for your product. This table has four columns:
-product_super_attribute_id (the primary key for this table)
-product_id (the id of the configurable product)
-attribute_id (the id of the attribute to add)
-position (attributes will be ordered by default from lowest position to highest position, in the CMS and on the front end)
3) Gather data for your insert
-Your product_super_attribute_id will be one more than the highest existing product_super_attribute_id.
-You can get the product_id from the CMS.
-Get the attribute id of the attribute that you are looking for from the eav_attribute table.
-position can be whatever you like-default is 0. If attributes have the same position, they will be sorted by initial insertion order.
4) Insert your data in the the catalog_product_super_attribute table, by your preferred method.

Magento Bulk Product Import Guide Part 2: Images

Step 0 – Gather Images
A nicely framed, high resolution image of your product is absolutely necessary for e-commerce success; I have seen sales increase by 200% simply by moving from a low res image that didn’t highlight the best features of the product to a high res, professional quality image. Some manufacturers will give you a .zip file of images for their products, but sometimes you have to go digging on their website. A useful tool for this is DownThemAll, a free Firefox extension for mass image downloads. There are many tools like this out there, and I have tried some and even written my own (Applescipt/Automator) tool for one special case, but this one is integrated right into the browser, gives you an intuitive GUI that lets you select exactly the images that you want, and is robust enough to handle thousands on images in one go. I’ve also tried DeepVacuum, WebDumper, SiteSucker, WebCopier. It is likely that you will want to experiment with many of these to find one that suits your needs.

A lot of times, your images will have garbage names, and you’ll want to rename them in order to keep track of them on your import, and to optimze them for search engines. A nice tool for this on OS X is A Better Finder Rename-you will want to pay the shareware fee in order to rename more than 10 files at a time.

Once I’ve gathered and renamed the images, I upload them to the media/import folder of our Magento installation-this is where the import script will expect them. I use Panic Software’s Transmit S/FTP program for file transfers.

Stay tuned for Part 3, “Evaluating the Product Spreadsheet and Setting up Magento

Running a Software Consulting Business

Not exactly what I’m doing at the moment, but these were very useful tips when I was getting started:

Starting a Consulting Business

Part 2 of Magento Import Guide Coming Wednesday!

Absolute vs. Relative Links

This link is an absolute link to my projects page: Projects. If you view the source on that link, you’ll see the following:

 <a href="">Projects</a>

As you can see, the entire uri,, is referenced in the anchor tag.

This link is a relative link to my projects page: Projects. If you view the source on that link, you’ll see the following:

 <a href="/projects.php">Projects</a>

Rather than specifying the complete uri to the file, a relative link finds the file by reference to a known location: in this case from the web root of, since I used a leading slash. If you omit the leading slash, the link will be relative to the current directory, as in the following link to the wordpress install readme page, which is located in the same directory as this blog: ReadMe

 <a href="readme.html">ReadMe</a>

Using relative internal links whenever possible makes it very easy to move to a new domain name. Suppose I change domains from to of the relative links will still work, as long as the file structure remains the same on my host/server. But all of the absolute links will need to be painstakingly changed. Maintainable, migratable websites use relative links in place of absolute links whenever possible.

Useful Magento Links

A list of Magento-specific links that I find useful:

  • Active Codeline. Branko Ajzele posts really useful code snippets, and is very good about explaining why what he’s doing is the right method-many bloggers just post a code snippet with a blurb about what it’s supposed to do–if you’re lucky.
  • Mukesh Chapagain’s blog. Mukesh posts extremely regularly, and has an uncanny knack for trying to solve exactly the same problem as me.
  • Quoting SQL in Magento. Magento utilizes the Zend framework, which has a built-in paramaterized SQL query system to defend against SQL injection attacks. This post shows you how to use it; you can usually use some Magento class or other to get around running arbitrary SQL queries in your scripts, but when you can’t, this post is quite useful.
  • Magento Forums. Usually the best place to begin a search when you have a problem you can’t solve. Very active and helpful.
  • Alan Storm’s Magento Articles An outstanding series about the guts of Magento’s MVC framework. A must-read series, if you want to understand the structure of Magento’s codebase. If my blog is a third as useful as Alan’s, I’ll consider it a victory.

Magento Product Import Guide Part 1: What’s wrong with the Magento Built In Product Importer?

My company uses the Magento e-commerce platform for many projects. Magento is an open-source, PHP/MYSQL platform; it’s very flexible and powerful, but complex, and requires powerful hardware to achieve acceptable performance. Magento comes in a free community edition, which as of this writing has a current version of There is also a paid Enterprise edition, which comes with many additional features and support. All information here covers community edition (CE), which is our live version at present.

Magento has a nice web GUI for adding products one at a time, but it is impractical for bulk product imports-if your store has a catalog of thousands of products, that’s a lot of clicking! There is a bulk product importer included with Magento, but it doesn’t work as well as you might hope.

What’s wrong with the Standard Magento Importer?

Magento Community Edition includes a bulk product importer out of the box, accessible at System->Import/Export->Profiles. This importer requires a .csv file. The best practice is to set up your categories, attributes, and attribute sets through the GUI, and then create a test product with some values filled in. Use a standard export profile to export your test products to your server in a .csv file, and then you can look at that file, edit/add products as needed, and then import the file with the confidence that you’ve got your import columns named correctly.

However, this method has some serious limitations.

  • No support for multiple product gallery images. Selling shirts that come in more than one color? You’ll have to go into the product through the web GUI and add more images after your import.
  • No link between simple products and configurable products.Suppose you are selling fitness t-shirts that come in S,M,L sizes and Black, Blue, and Red colors. For Magento purposes, you need a simple product for each possible combination of attributes-an “S-Black” simple product, an “S-Blue” simple product, etc. You also need a configurable product, that ‘associates’ each of the simple products together. You can create your simple products and your configurable product through a product import. But you can’t tell the system to associate the simple products with the configurable-you’ll have to manually go into each configurable product, and click a checkbox to assign them: Bummer.
  • No super attribute price modification.Take a look at the above picture. Suppose you want to sell your Blue shirt for $10, your Black shirt for $15, and your Red Shirt for $20, and sell them all under the Fitness T-Shirts configurable product. You’ll be able to import those three simple products with those prices-but that won’t have any effect on the configurable product price. To repeat: the simple products associated with a configurable product will have prices, but those prices will have no effect on the price displayed to or charged to the customer. To get that to change, you’ll have to go set the price difference between the Black/Red and the cheaper Blue option by option through the GUI-there’s no way to do it through an import.
  • No support for custom options. Suppose you sell suits. You want to offer a matching tie as an upsell to a suit purchase, but you don’t want to sell the ties on their own-suppose you can’t buy them competitively enough to make them worthwhile. Magento offers custom options for this purpose:

    But you’ll have to do that through the GUI as well-product by product. There’s no facility for it on a bulk import.

  • Can’t add upsells, or related products, or cross sells. Just like with associating simple products to configurable, you’ll be going into the GUI and clicking chexboxes. Lots. of. checkboxes.

If your store has very simple products, or you don’t care very much about the user experience of your customers, the out-of-the-box import will work fine for you. If your store has products of any complexity, or you want to optimize user experience for your customers, you’ll want to make changes to how the bulk importer works-like many things in Magento, it is designed to be extensible and can be made to do almost anything, but methods will be complex and poorly documented, even for fairly simple tasks. I thought that it might be useful for me to document my bulk import process, including how I get around these limitations, for others in the Magento community and for my own future reference. Stay Tuned for Part Two.