Magento work on hiatus – Typo3 time!

Posted 6 months, 2 weeks ago at 10:20. 0 comments

We’re currently busy with several ongoing web site efforts. My area of work will be to revise and enhance a Typo3-based ecommerce site. As much as I love working with Magento, that means that I won’t have much time for Magento in the next few months. I’ll still visit the official Magento forums from time to time.

That also means that the planned article series about Magento development will be delayed some more. I hate that as I have much to write, but I’ll wait until I’m back in the Magento pipeline again and have some experience worked with the current version 1.4.

Fixing JavaScript/Prototype problems in IE 8: A matter of class(Name)

Posted 8 months, 2 weeks ago at 09:55. 2 comments

While testing our pages in Internet Explorer 8, we found quite a lot of JavaScript errors. It turned out that, among other differences, Internet Explorer 8 doesn’t support getAttribute(‘className’) on DOM nodes as IE 7 did before, but requires the (correct) getAttribute(‘class’). The old way will now just create a ‘className’ attribute which does nothing.

This surfaced indirectly through the use of the (old) version 1.6.0.3 of Prototype in Magento. Upgrading to version 1.6.1 fixed most JavaScript issues with Internet Explorer 8.

State of PHP 5.3 on Windows

Posted 11 months, 2 weeks ago at 19:51. 1 comment

While developing our last project, I thought it would be a good time to upgrade to PHP 5.3. I’ve been running it for a year now on my home FreeBSD desktop, while it was still in development, and everything was humming  along flawlessly.

So what happened after I installed PHP 5.3 on my Windows development machine? Good things. I noticed a speed increase, and I found a few Magento incompatibilities which I fixed for the future. I was about to forget PHP 5.2 and embrace PHP 5.3′s new functionality, among them closures and the new MySQL Native Driver.

Next was installing APC. I couldn’t get it to work, so I browsed over to pecl4win to grab an up-to-date binary. As you can see, that endeavor ended rather fruitless. After trying every combination of VC6/VC9/TS/NTS binaries, I gave up. Summary: APC for PHP 5.3 doesn’t work on Windows with Apache.

Then I started debugging. And it didn’t work. My PHP IDE/debugger, PHPEdit, timed out trying to read the value of any variables. That was a major show stopper, so I wasted the better half of an afternoon reverting everything to PHP 5.2.11.

All in all, I lost a full day to this experiment. Wouldn’t be so bad if I had not been in dire crunch time already, trying to get the shop out in time.

Magento Notes – Part 2: Development tools

Posted 12 months ago at 09:45. 0 comments

It’s a not a secret that Magento is complex and has a quite steep learning curve. Part of that problem stems from the fact that there isn’t much documentation on the developer API. Without a good introductory book and reading lots of forum and blog posts, it’s a pain to get even the simplest things done. Digging deeper, a working understanding of OOP design patterns and the Zend Framework is almost necessary.

Let’s see a rough estimate what we’re facing when developing for Magento (version 1.3):

  • 783564 lines of PHP (in 3110 .php class files and 617 .phtml template files)
  • 474182 lines of XML (in 120 configuration files and 41 layout files)
  • 77426 lines of JavaScript (in 61 files, some of it is from Ext or Prototype/Scriptaculous)
  • 53430 lines of CSS (in 7 files)
  • Quite a lot of SQL hidden away in .php files.

That’s quite a lot to choke on. While it isn’t necessary to read each and every line of XML, JavaScript, PHP or CSS, one will read through quite a lot of them while modifying templates and design and yet much more when developing additional modules for it.

Since there’s so much stuff going on here, you’ll quickly learn to value good development tools, for things like debugging, code browsing, CSS inspection and so on.

Here’s what I  did:

  • Installed the  Xdebug PHP debugging extension. This extension communicates with a PHP debugger to inspect variables (which is very helpful for the complex nested classes Magento uses), set breakpoints, step through the code and so on.
  • Installed Magento 1.3. I use the full download installation method, but as long as you meet the server requirements, installation should proceed painless.
  • Installed PHPEdit (Windows only). This PHP-centric web development IDE has a good debugger (including a Firefox extension to switch on/off the debugger) and is especially suited for large projects. A little extra feature of it is that it can dynamically blend in/out different code languages in the same file, which is very helpful for .phtml templates, which contain a wild mixture of HTML, PHP and JavaScript.
  • Installed a current Firefox (3.5), the Web Developer extension, Firebug and it’s addon FirePHP
  • Headed over to Active Codeline, grabbed the Firebug logging code and placed it in the Magento index.php
  • Activated the JIT JavaScript compiler options in Firefox by opening about:config, typing jit into the search bar, and set both options to true. The result is that the chrome internal JavaScript engine becomes a lot faster, which makes FirePHP much more responsive while displaying huge, deeply nested Magento objects. Saved me a lot of time and nervous breakdowns.
  • Installed Cygwin (again, Windows only). This gives me basic UNIX power on Windows (something that is really handy because a lot of useful (PHP) scripts are for the UNIX environment). It’s also a requirement for my primary IDE, the TextMate clone
  • e Text Editor. I like this editor because of its simple code snippet functionality, which is really useful for boilerplate code and the like; and it’s Windows Explorer integration which allows usage of Shell plugins, like
  • TortoiseSVN. This handy tool allows using SVN directly from the Windows Explorer. If SVN is not your favorite version control software, there are also Tortoise implementations for CVS, Git and Mercurial and probably a few others. Using version control has multiple benefits, the less obvious I will talk about later (in another post).
  • Another really handy tool for dealing with the enormous amounts of text Magento throws at you is a full text search utility. I use dnGREP for its Explorer integration and overall speed and ease of use.
  • With the deep file hierachies of Magento and multiple tools we’re using to work on it, we need a quick and easy way to get the path of a file or directory into the clipboard. Ninotech PathCopy is a simple and good tool that allows exactly this via – you guessed it – an explorer context menu entry.
  • Last but not least, more complex Magento extensions will require some reverse-engineering of the SQL queries Magento generates. The MySQL GUI tools are invaluable here.

Now, this setup is quite huge, but now you can sift through code and debug Magento with relative comfort.

So the “basic” environment is covered now. Of course, there are many tools I didn’t mention, like FTP and SCP programs, but I assume everyone of the audience (I’ve got one, right? …right??) has their own preferred tools.

The topic for the next article isn’t decided yet, but it will probably be about the Magento architecture. Stay tuned!

Magento Notes – Part 1: What is Magento?

Posted 12 months ago at 06:35. 0 comments

Hi and welcome to the first part of our ongoing, independent Magento documentation effort, Magento Notes!

In this series, I’m going to keep track about my progress and findings about Magento. As some of you might know, Magento is famous for many things, but not for its beginner-friendliness. There’s a lot of concepts and tricks to be learned, and it can be quite frustrating in the beginning. It’s a fun and challenging experience, but the wealth of built-in functionality and lack of official documentation for the trickier parts makes working with it quite an adventure sometimes. So I’m writing development notes and tricks down here so I won’t forget them.

So, back to topic. What is Magento?

  • It’s a feature-rich, extensible, modern ecommerce software
  • It supports most, if not all techniques and payment gateways that are “hot” in ecommerce through plugins (extensions)
  • At the time of this writing, over 1000 extensions are available over Magento Connect
  • It’s PHP and MySQL based
  • It has a crafty designed, object-oriented MVC implementation
  • It uses the Zend Framework and many of it’s coding conventions
  • There are not much limits to what you can do with it
  • Alas, this rich feature set comes with a price: complexity.

Magento is used by several major retailers, and won several awards (such as the Bossie Award). It’s being actively developed, and it’s good base to built shops upon.

Well, in case you didn’t notice, I quite like this system. With all the rambling out of the way, let’s get productive. The next post is about installing a development environment for this beast.