View source | Discuss this page | Page history | Printable version   
Main Page
Upload file
What links here
Recent changes

PDF Books
Add page
Show collection (0 pages)
Collections help


How To Create An Import Process With Images



The objective of this article is to show you how to make a massive image importation process. Specificilly, we are going to import product images.

Execution Steps

We are going to create a custom importation process, using the Initial Data Load for Java module. We are going to use the java class SampleProductsProcess, included in this module... For that we will use the java class as the base that is included in the Initial Data Load Module for Java, and through a series of single modifications we will include a new column within the import .csv that will allow us to specify the path of the image that is associated to the product.

Installing Required Modules


The following modifications need to be made:

public String getEntityName() {
    return "Simple Products With Image";
    new Parameter("ImageLocation", Parameter.STRING) };
    validator.checkString(values[21], 255);
public BaseOBObject internalProcess(Object... values) throws Exception {
    return createProduct((String) values[0], (String) values[1], (String) values[2],
        (String) values[3], (String) values[4], (String) values[5], (String) values[6],
        (String) values[7], (String) values[8], (String) values[9], (String) values[10],
        (String) values[11], (String) values[12], (String) values[13], (String) values[14],
        (String) values[15], (String) values[16], (String) values[17], (String) values[18],
        (String) values[19], (String) values[20], (String) values[21]);
    File imageFile = new File(imagelocation);
    if (imageFile.exists()) {
      FileInputStream is = new FileInputStream(imageFile);
      long length = imageFile.length();
      byte[] bytes = new byte[(int) length];
      int offset = 0;
      int numRead = 0;
      while (offset < bytes.length 
         && (numRead =, offset, bytes.length - offset)) >= 0) {
          offset += numRead;
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
      BufferedImage rImage =;
      Image productImage = OBProvider.getInstance().get(Image.class);
      productImage.setWidth(new Long(rImage.getWidth()));
      productImage.setHeight(new Long(rImage.getHeight()));

Registering the Process

  • Go to Master Data Management -> Initial Data Load -> Setup -> Entity Default Value
  • Register your Java file here as shown in the screen shot.
View larger

Importing the Data

The .csv file that contains the data, must include the new column we have added, with the string "ImageLocation" in the header.

View larger

Pay special attention on the class name while adding the entity default value.

  • Import the data using import window
  • Go to Master Data Management -> Initial Data Load -> Process -> Import
  • Choose the input file
  • Choose the entity as "Product With Image"
View larger



As the result, we have the product imported with its corresponding product image. Result.png

Retrieved from ""

This page has been accessed 2,538 times. This page was last modified on 21 May 2013, at 14:18. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.