Drupento aims to integrate two of the most powerful open source systems available - Drupal and Magento. The goal of this project is to provide an lightweight static caching layer between the two systems. Drupento allows each system to operate independently, letting the developer or themer choose the points of integration.

Drupento consists of 2 parts - the Drupal module, and the Magento extension. The Magento extension is required if you are using the Drupento Auth add-on module. It is optional otherwise, however, there are some API enhancements included that are useful when using the Drupento cache layer as well.

Drupento is developed and maintained by Context (http://contextllc.com). This project came out of necessity when a client specifically requested Drupal and Magento, and the layout required elements of both systems on many pages.

DRUPENTO POWERED SITES

http://laurazindel.com http://keystoneballast.com http://waldensurfboards.com

What it Does

The primary issue that prompted the development of Drupento was that the Magento theme on our client's site needed to share the same menu as the Drupal theme. We also needed to do this WITHOUT bootstrapping Drupal on each page load inside Magento, for obvious performance reasons.

Drupento makes this easy with a single, static method: This static method does a lot, making it the primary component of the module. The method and its parameters are explained in detail in the Usage section.

What it DOESN'T

Installation & Requirements

REQUIREMENTS:

NOTE: The server must have a copy of the Simple HTML DOM library somewhere that is accessible by the user account running the site. There is a configuration option for the path to the library. Normally, you will want to put this in /sites/all/libraries, which is the default location Drupento looks for.
http://simplehtmldom.sourceforge.net/

NOTE: These instructions assume your Magento install lives within your Drupal base directory. This is no longer a requirement for usage of the module, but depending on where Magento lives in relationship to where Drupal is installed, you may experience permissions issues.

Typically (for us, at least), a Drupento project's directory layout looks something like:

The installation instructions will assume this layout.

TO INSTALL:

  1. Copy the drupento directory to your module directory and then enable on the admin modules page.
  2. Set up the initial permissions:
  3. Install the Magento extension here: http://www.magentocommerce.com/extension/packages/module/6035/drupento
    There are no configuration options for the Magento module
  4. Configure the drupal module - See next section.

Configuration

Configuration of Drupento is done via the settings page at: http://domain.tld/admin/settings/drupento These configuration options are shared between both the Magento and Drupal installations through a config file that gets written upon saving the form.

THE OPTIONS:

*** NOTE: All paths must be ABSOLUTE ***

Main Settings
Path Settings
Cookie Settings
*NOTE: Upon saving the configuration values, a config file is written in the base of the Magento directory.

How it Works

Working with Drupento requires a bit of knowledge about how exactly it accomplishes it's task. From start to finish, here is an example of a 'dom_element' cache request made by Drupento.

  1. When the above code is executed, Drupento will look for a cache file for the '#primary_nav' element at the path '/home'
  2. If the cache file exists (and is not stale), it is simply included. Otherwise, Drupento will the invoke a cli "bridge" script and request a cache file for that path/element
  3. Before the element can be cached, the path itself must be cached. If it is not cached already, and it is not stale, Drupento will bootstrap Drupal and cache the entire output of the path.
  4. After the path has been cached, the Simple HTML Dom library is used to extract the element from the markup.
  5. The element is cached, and then Drupento includes the cache file. Processing continues.

Usage

As mentioned previously, most of the functionality of Drupento on the Magento side stems from the Drupento::Output method. The output method can cache the following:

This method is overloaded in a sense - for ease of use, we allow Output() to be called with only two parameters, even though the first parameter is sometimes a cache type (e.g. 'callback'), and other times it is a uri path (e.g. 'home').

PATH/ELEMENT CACHING:

If the first param is not a cache type of either 'callback' or 'node', Drupento will assume you are trying to cache a path/element.

CALLBACK CACHING:

This is useful both on the Magento side AND the Drupal side. Callback caching allows us to generate any markup, and cache it to a file. The primary example of this, and the reason callback caching exists, is for use with the API:

Say you wanted to generate a menu of Magento categories and use it on your Drupal homepage. The Magento API is sometimes a reasonable option for getting data, but the overhead of making a SOAP or XML-RPC call on every load makes this less-than-ideal in our case.

In your callback config file (which is specified in the configuration), you can write functions to generate the required markup.
Additionally, Drupento provides a simple API wrapper to manage the client and session transport.

You can then invoke this callback and cache/output the return by calling:

NODE CACHING:

If the node is not already cached, Drupento will bootstrap Drupal, perform a node_load, and then cache the serialized $node object. Otherwise, the $node object will be loaded from the cached copy. You can then work with the node object just as you would inside of Drupal.

Whenever a node is updated in Drupal, Drupento will check to see if there is a cached copy. If one exists, Drupento will re-cache it to keep the Magento side up to date ***

Drupento SSO (drupento_auth)

The Drupento Auth module provided with Drupento allows you to use shared credentials for users on your site. Drupento Auth modifies the login form to use email addresses rather than a username.

The only step needed to enable SSO is to enable the module. Assuming all of your settings are correct, the authentication routines of both systems should then be synced.

NOTES:

  1. Make sure your cookie domain is set properly in the Drupento config, as well as the Magento configuration. The cookie domain should always include the leading '.'.