MageBridge FAQ: Development

The following FAQ contains questions and answers on MageBridge development.

Does MageBridge use the Magento API?

Yes and no. The Magento API is a collection of classes that could be called remotely by another application like Joomla!. MageBridge makes use of these classes, but instead of using SOAP or XML-RPC to access these classes, a different protocol is introduced - JSON. The reason for this is that the Magento API does not allow for a second entry-point into Magento, while the MageBridge solution needs exactly that. However MageBridge introduces its own API which accesses the API-classes in exactly the same way as the regular SOAP and XML-RPC interfaces do.

What is event forwarding?

When a Joomla! event occurs, one of the MageBridge plugins catches this event and registers the event with the bridge. When the bridge is ready to send the HTTP-request to Magento (to fetch blocks, headers and other data) the Joomla! event is sent along with it and used in Magento. In Magento the bridge handles all bridge-requests shipped in the HTTP-requests, adds data to it and sends the original request as HTTP-response back to Joomla!.

With Magento events things get a little bit more complicated, as an event can occur without the bridge-connection being present. In this case the MageBridge listener catches all events and sends seperate XML-RPC messages to Joomla!. These XML-RPC messages are received by the MageBridge XML-RPC plugin within Joomla! and converted to regular Joomla! events in the group "magento". This allows for extra plugins to be created.

Why use JSON?

The architecture of MageBridge allows for multiple bridge-requests to be combined in one single HTTP-request. This means that when the bridge fetches a shopping cart, a login-request and the main content-block it only involves one call to the Magento application which gives the best performance.

With a protocol like XML-RPC or SOAP it's possible to call an API-method to fetch data, and its even possible to combine calls into one single multi-call - which would give the same performance-benefit as the MageBridge API. However, if there is a relation between multiple bridge-calls in the same request, with XML-RPC it's much harder to make one call depend on another.

The strategy of MageBridge is therefor to bind all requests into one single data-structure and send this data-structure as a JSON-array through the bridge. Each API-call uses one and the same data-structure, so common data is combined between all calls and not transmitted twice. The data-structure also contains more than just method-arguments, it contains meta-data as well which could be cached on the Joomla! side.

Note that for the main bridge-architecture JSON is used to transmit data. But as soon as requests need to fullfilled at once, for instance when sending events from Magento to Joomla!, MageBridge falls back to XML-RPC for which support is present in both Joomla! as Magento.

Can you enable event X or add extra information to event Y?

Yes, we can. We are enthousiastic about this way of extending MageBridge. As soon as you need some kind of event to be forwarded, let us know through the forum.

What about custom fields in the Magento user profile?

Actually this is not related to MageBridge, but Magento. Unfortunately there is no easy way to add custom fields to the profile of a customer in Magento. However, if you manage to add fields (through core hacks or any other way) you will find that MageBridge replicates these fields automatically to the Joomla! side.

MageBridge has the responsibility to synchronize user profiles between Joomla! and Magento. While the core Joomla! fields (name, username, email and password) are of course synced, by adding extra profile connectors in Joomla! you can also add support for Community Builder or JomSocial profiles.

If the Magento customer profile contains a field with the same name as the profile on the Joomla! side (Joomla!, Anahita, CB, Jomsocial) it will automatically be synced.