This is a skeleton of calling impex translator.

Helpful Links:

Link to Impex FAQ.

What Possibilities Do I Have to Give Special Logic for Column Translation?

In case you need business logic not implemented in the default translator class specified for an attribute, there are the following options at your disposal:

  • Implementing a custom translator. Refer to ImpEx API, section Writing Own Translator.
  • Implementing a custom special translator. Refer to ImpEx API, section Writing Own Special Translator.
  • Implementing a cell decorator Refer to ImpEx API, section Writing Own Cell Decorator.
  • Using Bean Shell code. Refer to the ImpEx API section BeanShell.
  • Implementing own import processor.

Impex Script: Assuming the model we are inserting-updating is the Address model:

INSERT_UPDATE Address;billingaddress(duplicate[unique=true,default=false, batchmode=true]);shippingAddress[translator=com.hybris.core.dataimport.TestTranslator][unique=true]
;true;;

The Java class. MUST extend AbstractValueTranslator class in some way:

package com.hybris.core.dataimport;

import de.hybris.platform.servicelayer.model.ModelService;
import de.hybris.platform.servicelayer.search.FlexibleSearchService;
import de.hybris.platform.servicelayer.search.SearchResult;
import org.apache.log4j.Logger;

import java.io.File;
import java.util.Scanner;

public class TestTranslator extends AbstractValueTranslator{

    private static final Logger LOG = Logger.getLogger(TestTranslator.class);
    private static final String FLEXIBLE_SEARCH_SERVICE = "flexibleSearchService";
    private static final String MODEL_SERVICE = "modelService";

    private FlexibleSearchService flexibleSearchService;
    private ModelService modelService;

    @Override
    public Object importValue(String s, Item item) throws JaloInvalidParameterException {
        return null;
    }

    @Override
    public String exportValue(Object o) throws JaloInvalidParameterException {
        return null;
    }
}
Categories: Hybris

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *