Wednesday, November 11, 2009

Magento and Drupal Integration

There are numerous ways to integrate Magento with Drupal. Here I will share my experiences while working on that with very smart people at Optaros. I don't take credit for all the points in this post, because they are the product of the whole team.

The motivation for this kind of integration is the innovative look into where e-commerce is moving. To get a grasp of it look at OCentric. To keep it short, content is free advertisement for products. It allows customers to get more input about products and provides the meat for search engines to index.

Briefly, there are several main approaches to integrate Drupal and Magento:

  1. let Magento be the main component, while leaving Drupal just as a subcomponent

  2. let Drupal be the main component, and have Magento as an e-commerce  module

  3. let  both Magento and Drupal be main components

These are general approaches and each of them have different pros and cons. They will be further detailed by usecases, complexity, technicalities, etc. in the following sections.

Moreover, we will release much of the code as open source, so it's not only a theoretical discussion here:)

Magento as the Main Component

This is probably the most acceptable approach in terms of implementation complexity. Moreover you can choose different level of complexity to implement.

The straightforward solution is to integrate on the service layer. Meaning that whenever we are on the e-shop product page we have to call a Drupal service to bring related content, for instance blog posts. The same holds for category pages. How to do that:

  • Create a Drupal module that allows you assigning categories and products  to a content node in Drupal

  • Implement XML-RPC client on Magento side and use it to talk to services on Drupal in order to pull the content (e.g. using view.get or node.get funuctions)

  • Rewrite the category and product controllers on Magento to take the content from Drupal into account

There are some challenges in taking this way. They are mainly for those who want to implement features in a generic way. Specifically, whenever you add a CCK field or a feature like rating to a content type, you have some work to do on the Magento side. Namely, you need to modify layout and write templates to handle this additional data coming from Drupal. Hence it's pretty cumbersome to use Drupal community contributed modules as you need to do some coding on Magento side for every new Drupal feature. This is quite easy when the content from Drupal is read-only, but as soon as you want commenting, rating, flagging, etc. it becomes an issue, because you need to not only redo rendering on Magento but also map the functionality.

A more complex path to take  is to integrate the whole Drupal rendering engine into Magento, however, this means a very tightly coupled architecture... Still, if you plan to use many many many of the Drupal features it may make sense. This will require writing a Drupal module for Magento that will adapt every Drupal core function to Magento. Could end up as a very complicated solution.

We chose the XML-RPC because of the given time frame and specific requirements. Normally a product or a category will be associated with a very specific set of content types, and therefore the fully generic solution may not pay off.

By the way there is already a CMS module for Magento as part of the core. And the question is why would one want to struggle integrating Drupal instead of using that CMS module? Moreover, with enterprise 1.6 version of Magento the module offers quite cool features. Some things from the top of my head to consider:

  • Drupal has a solid community, and it is more stable and feature-rich than the Magento CMS module will ever be (of course it's good as soon as you make the Drupal-Magento integration reasonably flexible)

  • There is the CCK module that allows to very quickly add additional fields to a content type and make it available to the content producing team

  • Content versioning, workflow, etc. is easy in Drupal

  • ...more ?

Drupal as the Main Component

This approach has been already taken by others and you can start digging for it here. We've tried out the available modules but didn't stick with them... Basically there the implementation is based on the notion of synchronizing Magento products, categories, orders, etc.  into Drupal using a cron job.

In general, although Drupal-as-the-main-component approach in the end may give a lot of  flexibility, it may be too complex to implement. Imagine that the whole Magento frontend functionality needs to be rewritten for Drupal. Magento would then only be an e-commerce backend (the admin part) accessible via Web services. Of course you'd be able to use plenty of Drupal modules as well as flexible templating without any hassle, have better performance, and many other goodies but it just looks too expensive to implement.

Still, bringing only a part of Magento into Drupal makes a lot of sense (as in that module that synchronizes products and orders into Drupal using cron job). In this case it's a decision to make whether the site is more about content or about commerce. When it's about content, then you don't really care about SEO for products, fancy business logic, etc.

Both Mangento and Drupal as the main Components

This is reasonable when the content will be displayed on the Drupal site and e-shop on the Magento site. Meaning that no proxying for content happens behind the scenes. So if a product has a blog post attached, then on the product page you'll have a link (maybe even the post itself loaded using Ajax call) and clicking it will open a Drupal page with that blog post.

One of the challenges here is to maintain two different themes in order not to harm user experience. So that when the customer clicks on the blog link inside the product page the blog is displayed with the same look and feel as the shop. For that you can't avoid coding on two different frameworks. Apart from theming SEO will have to be also maintained on both components.

Another challenge would be the ability to mix content with product information on the same page. Some kind of communication on the service layer will be necessary for that, which means that it's not really reasonable to use this dual approach with such a usecase present.

It may make sense, however, to take this path when there are only some of the things to be shared between both components, e.g. users, and everything else is completely separate. For example, when a company has an e-commerce site, a customer community site, and a corporate site.

Additional Points for Integration

The end user display is only one part of the story. When you integrate this kind of monster systems to work seamlessly you get trapped with other things besides templating.

One of them is single sign on. A good thing to do here is to use CAS. Drupal already has the CAS module. Magento, however, needs one (we've been writing one). The good news that all the low level protocol implementation is available for PHP as open source.

Another thing is search. Independently of the integration approach chosen eventually you want to search for products and content in the same search box. This may become pretty challenging but it's not impossible. We've got a proof of concept for the store front in Magento, where we leverage Solr search. It performs really well for our suggest box functionality.

There are numerous ways to integrate Magento with Drupal. And here I will share my experiences while working on that with very smart people at Optaros. asdfa sfd

asdf adsfasdf asdfasdf


  1. Replies
    1. Great Article Cloud Computing Projects

      Networking Projects

      Final Year Projects for CSE

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. As you say "Moreover, we will release much of the code as open source"

    Where can i find that code?

    can you please provide me link for that.

  3. We're refactoring and cleaning up the code currently. Drupal and Magento modules should show up somewhere January-February.

  4. hey you write:
    One of them is single sign on. A good thing to do here is to use CAS. Drupal already has the CAS module. Magento, however, needs one (we’ve been writing one). The good news that all the low level protocol implementation is available for PHP as open source.

    Have you made that code available? Any learnings from that? Do you have that integration run on prod?


  5. Hi Wolfgang,

    We haven't made the code available yet. Still cleaning it up. When it's out I'll make a blog post.

    I can't tell you if there is already a running instance on production as I'm currently working on something else. I'd suggest to keep an eye on OCentric ( if you're interested in Content+Community+Commerce and what Optaros is up to.

  6. Hey since I am more in interested in that, can you connect me with the guys working on it? I would do testing and could do development, do not like to work on it while knowing someone else is also inventing the wheel meanwhile.

  7. Sure, as soon as we publish the source code you can join to collaborate. Looking forward to it.

    For now the code is still closed, the decision to open-source must come from the OCentric team.

  8. ditto @wolfgang. I'm having to work on this exact problem/solution right now (with a delivery in two weeks) and would love to not be building from scratch if I could be contributing to the development of a solution that already is in progress.

  9. What about SSO ? have you finished the CAS magento module ? do you plan to open CAS module' source ?

  10. I just came across this blog while searching for CAS/Magento integration. Any luck on creating this?

  11. The CAS module is finished, I hope it's going to be open sourced soon. It doesn't depend on me personally, but rather on the company's politics...

  12. I think this would be great thing to see published, or at least put somewhere like google code where we can add to it ;-)

  13. Is this code for the Drupal and Magento integration available jet? Would be great! think people can help if u put the code on "google code". :) hope to here from u!

  14. I was wondering the same. Where can we get the updated code?

  15. I would like to know if you already have the CAS module for magento finished?

  16. the Drupento module integrates Drupal and Magento SSO without the need for CAS:

    right now it's in the alpha stage but it is being actively developed.

  17. How can we Integrate mgento and druapl.Can anyone help me ?

  18. Hi all

    I just Need to Integrate Magento and Drupal.How can we do ?CAn any one help me to do this?IS it possible?

  19. We have a Magento webshop in ipad accessoires like covers and sleeve. we would like to integrate this shop white drupal. How can we do this?

  20. Fantastic blog!..This is so enjoyable..I forgot my stress after landing gave me the real feeling of ecstacy!..i would love to visit here over and over again..thanks for showing those beatiful chics. Picking a content management system is highly Critical I am a big fan of Drupal. Because Considering the most notable non-profits with Fight Hunger and UNICEF use Durpal, my decision was easy For a development platform I run GetPantheon including automated back-up retention.. which CMS is best in your opinion?
    Drupal Git

  21. Hats off to your presence of mind..I really enjoyed reading your blog. I really appreciate your information which you shared with us.
    Magento course in chennai

  22. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating.
    Web Design Training

  23. You can begin by downloading the free version, then upgrade to the Enterprise-level software once you've gained proficiency in using the program.small business web design Toronto