on ‎2018 Mar 14 10:53 AM
Hi experts,
I'm trying to add a product into category with this impex. But my problem is this impex remove the already assigned categories. I need to add the category into the product without deleting the rest of them. Is it possible??
$productCatalog=xxxxxxProductCatalog
$productCatalogName=xxxxx Product Catalog
$catalogVersion = catalogversion(catalog(id[default = $productCatalog]), version[default = 'Staged'])[unique = true, default = $productCatalog:Staged]
$supercategories = supercategories(code, $catalogVersion)
UPDATE Product;code[unique=true];$supercategories;$catalogVersion
;000000000000302848;0032
Thanks a lot!
Request clarification before answering.
Hello,
yes, you can do this by slightly modifying your header. Just add [mode=append] to $supercategories, like this:
UPDATE Product;code[unique=true];$supercategories[mode=append];$catalogVersion
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rather than using [mode=append] on the supercategories attribute, which creates duplicate relationships if you run the same impex multiple times, I prefer to create the relationship itself directly, which allows you to mark both source and target as unique and avoid duplicates.
e.g.
INSERT_UPDATE CategoryProductRelation;source(code,$catalogVersion)[unique=true];target(code,$catalogVersion)[unique=true]
;category1;product1
;category2;product1
;category1;product2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.