Coder Social home page Coder Social logo

magja's Introduction

Magja

Magja is a Java Connector for Magento’s API

The goal its build a java interface to access the Magento API and exchange data.

Getting Started

RSS Feed

Stay up to date with Magja RSS Feed

Create the Magento Connection Properties File

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

Magja Console

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._

Category

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)

Product

import com.google.code.magja.model.product._

Listing Products

List all products with dependencies (slower)

val products = RemoteServiceFactory.getProductRemoteService.listAll

List all products without dependencies (faster)

val products = RemoteServiceFactory.getProductRemoteService.listAllNoDep

Create Product

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)

Customer

val customerRemoteService = RemoteServiceFactory.getCustomerRemoteService
val customers = customerRemoteService.list
customers.foreach(c => println(c.getFirstName + " " + c.getEmail))

Maven Dependency

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/).

Acknowledgments

Bandung Everlasting Beauty logo downloaded from Info Bandung CodePlex project
designed by Achmad Sutarjono.

magja's People

Contributors

atangsutisna avatar ceefour avatar dhoepelman avatar farsiado avatar ihervin avatar svenakela avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.