Skip to content
Ralph Soika edited this page Sep 21, 2015 · 23 revisions

Magento Adapter

The Imixs-Magento-Adapter is a connector module providing a set of classes to connect to the Ecommerce Softwareplattform Magento. Magento provides two different WebService Interfaces. The Magento Rest API for a simple Rest Service based on a the OAuth 1.0.a protocol and the Magento SOAP API for a SOAP interface.

See details about the two client implmentations here:

  • [Rest Client](Magento Rest Client)
  • [Soap Client](Magento Soap Client)

The Imixs-Magento-Adapter can use both client types. The MagentoService EJB provides methods to request both clients.

Deployment

For deployment of the Imixs-Magento-Adapter you can simply add the following maven dependency into your EJB module:

<dependencies>
	<dependency>
		<groupId>org.imixs.workflow</groupId>
		<artifactId>imixs-workflow-engine</artifactId>
	</dependency>
	<!-- magento -->
	<dependency>
		<groupId>org.imixs.workflow</groupId>
		<artifactId>imixs-adapters-magento-ejb</artifactId>
	</dependency>
	<dependency>
		<groupId>org.apache.axis</groupId>
		<artifactId>axis</artifactId>
		<scope>provided</scope>
	</dependency>		
	<dependency>
		<groupId>org.apache.axis</groupId>
		<artifactId>axis-jaxrpc</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>commons-discovery</groupId>
		<artifactId>commons-discovery</artifactId>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>wsdl4j</groupId>
		<artifactId>wsdl4j</artifactId>
		<scope>provided</scope>
	</dependency>
</dependencies>	

In the ejb-jar.xml descriptor of the EJB module add the following session bean configuration:

<!-- Magento Service Refs -->
<session>
		<ejb-name>MagentoCache</ejb-name>
		<ejb-class>org.imixs.workflow.magento.MagentoCache</ejb-class>
		<session-type>Stateless</session-type>
		<ejb-ref>
                <ejb-ref-name>ejb/ConfigService</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
                <remote>org.imixs.marty.ejb.ConfigService</remote>
        </ejb-ref>
</session>

Configuration

The Imixs-Magento-Adapter provides multiple configurations. So with one Workflow Instance multiple instances of Magento Shop systems can be connected. A configuration document contains all necessary information to connect to a shop via the Rest API or the SOAP API. The configuration entity type is 'magento' and the property 'txtName' holds a unique name for a specific shop configuration.

The OrderID

If a workitem is based on the import of a magento order the order id is stored in the property 'txtName' in the following format:

magento:order:ID

All properties of the magento order are stored in properties with the prafix 'm_'.

MagentoPlugin

The class org.imixs.workflow.magento.MagentoPlugin synchronizes the Order Data of a worktiem and creates the following workitem attributes:

  • txtMagentoCustomer=combined magento customer name (First- and Lastname)

  • txtMagentoCustomerEmail = E-Mail address of customer

  • txtMagentoOrderID = Order id of magento order

  • txtMagentoBillingFirstname = Firstname of Billing address

  • txtMagentoBillingLastname = Lastname of Billing address

  • txtMagentoBillingTelephone = telephone of Billing address

  • txtMagentoBillingCompany = company of Billing address

  • txtMagentoBillingstreet = String of Billing address

  • txtMagentoBillingPostcode = Postcode of Billing address

  • txtMagentoBillingCity = City of Billing address

  • txtMagentoShippingFirstname = Firstname of Shipping address

  • txtMagentoShippingLastname = Lastname of Shipping address

  • txtMagentoShippingTelephone = telephone of Shipping address

  • txtMagentoShippingCompany = company of Shipping address

  • txtMagentoShippingstreet = String of Shipping address

  • txtMagentoShippingPostcode = Postcode of Shipping address

  • txtMagentoShippingCity = City of Shipping address

MagentoSchedulerService

The MagentoSchedulerService implements a Timer EJB to import order items from a Magento Shop system. The EJB can be configured through the config entity 'Type=Magento'. The JSF page /pages/admin/magento.xthml and the MagentoController provides a way to easy configure the timer in the web frontend of Imixs-Office-Workflow for a specific Shop system. The Imixs-Magento-Adaper provides multiple configurations. So for each shop system a configuration can be created. The MagentoSchedulerService checks all configurations and run an import for each shop system.

Workflow Model

When a new order is imported or updated the scheduler calls the activityID 800. This activity should be defined in every status the order should be updated. Each new created workitem hols a reference to the magento shop configuration in the property 'txtMagentoConfiguration'. This reference is necessary to lookup the corresponding shop configuration if a Plugin need to reconnect to the shop.

MagentoCache

The EJB MagentoCache provides a caching mechanism to cache products and customer entities. This EJB is used by the MagentoService. The config property 'magento.cache.refresh' defines the maximal time in seconds a magento object is cached. If an object is older then the refresh time the object will be refetched by the MagentoService.

magento.cache.refresh=600

The method flush() provides a way to force the flush of older items. This method is called automatically by the MagentoScheduelerService. To clear the cache the method clear() can be called.

MagentoStatusPlugin

With the org.imixs.workflow.magento.MagentoStatusPlugin it is possibel to send comments and status changes back to magento. The Plugin can be configured by the Activity Result.

  • txtMagentoStatus - new state
  • txtMagentoComment - optional comment
  • keyMagentoNotify - indicates if a customer notification should be send

Example:

<item name="txtMagentoStatus">complete</item>
<item name="txtMagentoComment">some comment</item>
<item name="keyMagentoNotify">true</item>

The plugin uses the SOAPClient to send a comment with a new state

List of Status codes:

  • new=New
  • pending=Pending
  • pending_payment=Pending Payment
  • pending_paypal=Pending PayPal
  • pending_amazon_asp=Pending Amazon Simple Pay
  • processing=Processing
  • complete=Complete
  • closed=Closed
  • canceled=Canceled
  • holded=On Hold