cancel
Showing results for 
Search instead for 
Did you mean: 

Can we create target item based on some condition

0 Kudos

Can we create target item based on some condition? E.g. I have category and super category and I want to create category-superCategory relationship(CategoryRel CategoryCategoryRelation). So in csv file which I will receive from client, I will get some categories without super category. In this case we don't want to create CategoryRel.

Accepted Solutions (0)

Answers (1)

Answers (1)

Slava
Advisor
Advisor
0 Kudos

If I understand your question correctly, there is nothing special to do for that case. Let's say you load these items in the CSV:

 code, name, supercategories, isoCode
 C1, Category 1, , en
 C2, Category 2, C1, en
 C3, Category 3, C1, en
 C3, Category 3, C2, en

Then just map this raw item type to a CanonicalCategory, which has supercategories as a Collection, and then map the CanonicalCategory to Category in the target system definition. After the composition and publication are done, you will find category C1 published to the target system without supercategories; C2 will have C1 assigned as its supercategories; and C3 will have both C1 and C2 in the supercategories field.

If you need to delete (clear) the supercategores field, then you need to explicitly specify its empty value, e.g.

 code, supercategories
 C3, <empty>

This explicit emptiness is documented. Let us know, if did not find the documentation. If you receive a category without supercategories field, it's treated like "I don't want to change that field", and therefore if, for example, category C1 already has category C0 assigned to field supercategories in the target system, then first sample CSV snippet, will not change it. In other words, if the field value is empty in the CSV, it's ignored.

Conditional target item creation is possible but I don't think it's needed for the case you're describing. If you still need to know about it, I can direct you to the documentation on this topic.

0 Kudos

Hi ,

The csv you have mentioned in the answer is exactly what we have. Super Category is mandatory in our case. So we need to create relationship item only if super category is not null. It will be great if you provide documentation on this topic.

Slava
Advisor
Advisor
0 Kudos

Kaushik,

  1. If you downloaded a datahub-suite, you can find pcm-apparel.zip file inside its solution-book folder. The pcm-apparel has an example similar to your case. Product has field 'category', which is a collection of categories similar to 'supercategories' in your scenario. You can play with it to see how it works and model 'supercategories' similarly.

  2. The CSV Web Service Extension document contains information about collection attributes in CSVs and emptying attribute values

  3. Publication Grouping Handler can be used to filter canonical items during publication (conditional publication). Subpages in that document contain examples.

  4. Grouping Handler can be used to filter out raw items based on a condition during composition.

However I sincerely believe you don't need to go to items 3 and 4.