Branko Ajzele posted a really interesting post today on the Inchoo blog about extending the Magento core API. Surprisingly, it’s not as easy as one would think…
Its all about simple things, right? Well, here is one bottom line simple thing I would like to do with my Magento API. I would like to get a list of all available websites, stores and store views. Can I do that with the latest (as of this writing, 1.4.1.1) Magento? No I cannot! Can I get a list of … etc. For any serious scenario you will most likely be out of luck. What’s interesting is that rarely even a combination of several method calls will give you what you might need. Trust me on this one, I am writing Android application for Magento and its killing me.
I’ve oftentimes thought about this, but to be honest, every time I’ve had to use the core API, it’s been because the project was really, really simple or because it was my last resort (trust me, I avoid anything Soap-related like it’s the plague).
If you’re not trying to do anything complicated, the API is actually one of the more pleasant parts of Magento to work with. Unfortunately, it’s Soap-based and slow as hell, but for simple tasks it does the job well.
As Branko points out, the moment you try to do anything interesting with it (like build a mobile app), you quickly realize that it’s simplicity is actually a weakness and a point of great frustration.
The key to overcoming this limitation is to extend every core API method with your own library, made available via a plugin. When you need to add functionality, you add the method to your subclass and publish the method via the extension’s configuration.
Branko was kind enough to make his solution available on Github and he promises to document it more in the coming weeks.
via Inchoo.