Search code examples
sap-commerce-cloudimpex

Export same row multiple times with ImpEx


Is it possible to export the same row multiple times based on an attribute of the item? Let's say for example that the CategoryModel has a List<ProductModel>.

How can I do an export using ImpEx to get something like this:

| category_code | product_code |
|------------------------------|
|     cat1      |     prod1    |
|------------------------------|
|     cat1      |     prod2    |
|------------------------------|
|     cat1      |     prod3    |
|------------------------------|

Is it possible to achieve that using translators? The best I could do with them is the following:

| category_code | product_code |
|------------------------------|
|     cat1      |    prod1     |
|               |    prod2     |
|               |    prod3     |
|------------------------------|

EDIT: The ImpEx header is this:

INSERT_UPDATE Category; code; @product_translated[translator = ...]

Solution

  • For lists, I'm not sure if there's an easy way to do that.

    For relations, you can simply use the type. To get the the list of product-category mapping, you can do this:

    UPDATE CategoryProductRelation;source(code,catalogversion(catalog(id),version));target(code,catalogversion(catalog(id),version))
    

    source will be the category, while target will be the product.