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.
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
If you need to delete (clear) the
supercategores field, then you need to explicitly specify its empty value, e.g.
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.