Skip to content
Ralph Soika edited this page Aug 20, 2014 · 23 revisions

Magento Adapter

The module 'imixs-adapters-magento-ejb' provides several classes to connect to magento. The module uses the Magento Rest API. For authentification Magento uses the OAuth 1.0.a protocoll. See the Magento API documentation for further information.

The Imixs Magento Adapter provides a Plugin to connect to the Magento Rest API. This Plugin provides a set of methods to be used by a business application based on the Imixs Marty project.

The Plugin can be configured by the imixs.property file and the imixs property service EJB. The imixs.properties file contains a set of keys to configure the magento host:

##############################
# Magent REST Service Configuration 
##############################
magento.uri-basis=http://localhost/magento/index.php/
magento.uri-api=http://localhost/magento/api/rest

# api token
magento.token.api-key=9abde0f96ce9a38899.....
magento.token.api-secret=34aa69d7ee0782f9a6....

# access token... (use testRequestNewToken to generate a new one)
magento.token.access-key=7ec2d5c3ef2ad29d.......
magento.token.access-secret=19002a261f4b4........

Generating an Access-Token

To access the magento host it is necessary to configure the magento rest api and provide an application token as also a valid access token. The access token need to be generated. The Magento Plugin provides a set of methods to generate a valid access token. For easy usage the junit Test class 'org.imixs.workflow.magento.test.TestMagentoPlugin' provides a separate test case called 'testRequestNewToken'. If you run this test the MagentoPlugin requests a new access token in an interactive way. Running the test will print a request URL to call from a web Browser. Then you can authenticate into magento and gain the access. The verifier need to be entered into the live console:

Open Browser Window and authorize the Imixs MagentoPlugin here:
http://localhost/magento/index.php/admin/oauth_authorize?oauth_token=261a3514776fbaeef5638efd01c908ab
And paste the verifier here
>>949775df82a747d09b72e85a96514ed3
Got the Access Token!
   key=7ec2d5c3ef2ad29d5519773dd0537a44
   secret=19002a261f4b42a0d4b86388757fa2b4

The access-key and access-secret need to be entered into the imixs.porperties file to run further tests.

MagentoService EJB

The EJB org.imixs.workflow.magento.MagentoService provides serveral methods to access the Magento Rest API. The service EJB is also used by the MagentoPlugin class. The service initialize the OAuth Data to access the Magento Web Service Rest API. There for the EJB uses the Scribe library. The configuration can be stored in a config Entity 'ConfigMagento' or in the imixs.properties file. The configuration is read during the @PostConstruct call back method. The method getService() returns a OAuthService object which can be used to interact in a flexible way with the OAuth Service.

Caching

The EJB MagentoCache provides a caching mechanism to cache products and customer entities. This EJB is used by the MagentoService.

Clone this wiki locally