on ‎2018 Sep 18 9:56 PM
I have a requirement to insert keywords and relate them to products via impex, but the syntax on the relation is unknown to me. This is the IMPEX
$productCatalog=testProductCatalog
$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
$lang=Language(isocode)[default='en']
$keyword=Keyword
$products=target(code, $catalogVersion)[unique=true]
$keywords=source($keyword, $lang, $catalogVersion)
INSERT_UPDATE Keyword;$catalogVersion;$keyword;$lang
;;TestKeyword;en;
INSERT_UPDATE Product2KeywordRelation;$keywords;$products;
;TestKeyword;TestProduct;
The Keyword imports fine, but I cannot get the Product2KeywordRelation to import. This is the error that is displayed:
,,,,item reference TestKeyword for attribute Language.isocode does not provide enough values at position 1;TestKeyword;TestProduct;
Can anyone help me get the proper syntax?
Request clarification before answering.
I figured out that the solution is the colon character. It is used to separate entries when one needs to pass multiple parameters into the same impex method. Here is a working solution to insert a keyword and then link it to a product via impex:
$productCatalog=testProductCatalog
$productCV=catalogVersion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
$lang=Language(isocode)[default='en']
$products=target(code, $productCV)[unique=true]
$keywords=source(Keyword, $lang, $productCV)[unique=true]
INSERT_UPDATE Keyword;keyword[unique=true];$lang;$productCV
;TestKey;en;;
INSERT_UPDATE Product2KeywordRelation;$keywords;$products;$lang
;TestKey:en;TestProduct;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Per the catalog-items.xml, Product2KeywordRelation is a many to many relationship, so you should be able to add multiple keywords on a product. Just do each one on separate lines as you have in your example.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
richpa
If I have to add multiple keywords in a product, how can I do that ?
INSERT_UPDATE Keyword;keyword[unique=true];$lang;$productCV
;test1;de;;
;test2;de;;
INSERT_UPDATE Product2KeywordRelation;$keywords;$products;$lang
;test1:de;product_code1;
;test2:de;product_code1;
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.