Magja is a Java Connector for Magento’s API
The goal its build a java interface to access the Magento API and exchange data.
Stay up to date with Magja RSS Feed
Create the file /src/main/resources/magento-api.properties
(or in your default classpath) with your proper data to magento installation, for example:
# connection to magento parameters magento-api-username=yourMagentoApiUser magento-api-password=youtMagentoApiPassword magento-api-url=http://localhost/magento/index.php/api/soap/
# the ID of the default attribute set in magento default-attribute-set-id=4
# the ID of the default root category in magento default-root-category-id=2
Make sure you have created magento-api.properties
file as described above.
Usage:
./magja-console
import collection.JavaConversions._ import com.google.code.magja.soap._ import com.google.code.magja.model.customer._ import com.google.code.magja.service._ import com.google.code.magja.service.customer._
Get only the basic information of a Category, without its dependencies:
val category = RemoteServiceFactory.getCategoryRemoteService.getByIdClean(2)
println(category)
Get category with its children:
val category = RemoteServiceFactory.getCategoryRemoteService.getByIdWithChildren(2)
category.getChildren.foreach(c => println(c.getId + " " + c.getName))
Get category with its parent:
val category = RemoteServiceFactory.getCategoryRemoteService.getByIdWithParent(2)
println(category.getParent)
Get category with its parent and children:
val category = RemoteServiceFactory.getCategoryRemoteService.getByIdWithParentAndChildren(2)
import com.google.code.magja.model.product._
List all products with dependencies (slower)
val products = RemoteServiceFactory.getProductRemoteService.listAll
List all products without dependencies (faster)
val products = RemoteServiceFactory.getProductRemoteService.listAllNoDep
import com.google.code.magja.model.product._ import com.google.code.magja.model.category._
val product = new Product product.setSku("DUMMYPRD") product.setName("Lovely Umbrella") product.setShortDescription("This is a short description") product.setDescription("This is a description for Product") product.setPrice(250.99) product.setCost(100.22) product.setEnabled(true) product.setWeight(0.500) product.setType(ProductTypeEnum.SIMPLE.getProductType) product.setAttributeSet(new ProductAttributeSet(4, "Default")) product.setMetaDescription("one two tree") product.setGoogleCheckout(true)
// category product.setCategories(List(new Category(2)))
// websites - set the website for product product.setWebsites(Array(1))
// inventory - set the inventory for product product.setQty(20) product.setInStock(true)
// Optional: you can set the properties not mapped like the following too: product.set("meta_description", "one two tree")
// then, we just instanciate the service to persist the product RemoteServiceFactory.getProductRemoteService.save(product)
val customerRemoteService = RemoteServiceFactory.getCustomerRemoteService
val customers = customerRemoteService.list
customers.foreach(c => println(c.getFirstName + " " + c.getEmail))
Magja continuous integration builds are automatically deployed to Sonatype OSS repository:
https://oss.sonatype.org/content/groups/public/
<dependency>
<groupId>com.google.code.magja</groupId>
<artifactId>magja</artifactId>
<version>1.0.3-SNAPSHOT</version>
</dependency>
You can use the search UI from https://oss.sonatype.org/
Snapshots will be deployed periodically from Jenkins CI provided by [Bippo](http://www.bippo.co.id/) & [Soluvas](http://www.soluvas.com/).
Bandung Everlasting Beauty logo downloaded from Info Bandung CodePlex project
designed by Achmad Sutarjono.