on ‎2018 Dec 06 2:28 AM
How can multiple categories be removed from Product using impex something like:
REMOVE CategoryProductRelation;target[unique=true](code,$catalogVersion);source[unique=true](code,$catalogVersion)
;xyz;cat1,cat2,cat3
Thanks!!
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
You can use batchmode=true as folllows:
REMOVE CategoryProductRelation[batchmode=true];target[unique=true](code,$catalogVersion);source(code,$catalogVersion)
;xyz;cat1,cat2,cat3
For example, the following script removes categories, 576 and brand_10 for product, 1934794 using :
$productCatalog=electronicsProductCatalog
$productCatalogName=Electronics Product Catalog
$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
REMOVE CategoryProductRelation[batchmode=true];target[unique=true](code,$catalogVersion);source(code,$catalogVersion)
;1934794;576,brand_10
You can verify the result by executing the following Flexible Search query:
SELECT {p:code}, {c:code} FROM
{
Product as p JOIN CategoryProductRelation as rel
ON {p:PK} = {rel:target}
JOIN Category AS c
ON {rel:source} = {c:PK}
}
WHERE {p:code}='1934794' AND {p:catalogVersion}=({{ SELECT {PK} FROM {catalogVersion} WHERE {catalog}=({{SELECT {PK} FROM {catalog} WHERE {id}='electronicsProductCatalog'}}) AND {version}='Staged' }})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Remove it 1 line each.
REMOVE CategoryProductRelation;target(code,$catalogVersion)[unique=true];source(code,$catalogVersion)[unique=true]
;xyz;cat1
;xyz;cat2
;xyz;cat3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, NO, because changing the categories this way doesn't change the modified time of the Product. So, it will not sync. There are cases where you want to do this.
In cases where you want the sync to work, it's better to update via Product type. i.e. UPDATE Product;supercategories...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.