cancel
Showing results for 
Search instead for 
Did you mean: 

Need to understand Impex Macros

Former Member
0 Kudos

Hi Experts,

Can someone explain me this impex macros as to how the macros definition is resolved.

$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]

Mainly as to how relation types are included in Macros resolution.

Taken from categories.impex from catalog-items.xml in platform extension.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Tuhin

Here is some official documentation about macros that can help you out with this doubt. https://wiki.hybris.com/display/release5/ImpEx+Syntax#ImpExSyntax-DefinitionLine-Macro

Commonly speaking macros are constants that you can define in your impex scrip and use it latter or your impex headers. Basically you will create a new variable, in your cause “$catalogVersion”, that is using another macro, that should be reference before this one, called “$productCatalog” and with the following properties:

  • unique=true

  • default:$productCatalog:Staged

The main purpose of it, is inject latter this macro to the header so you don’t have to take care of the catalog version anymore in you import process.

Example

 $catalog=Default
 $catalogVersion=catalogVersion(catalog(id[default=$catalog]),version[default='Staged'])[unique=true]
 
 INSERT_UPDATE product; code [unique=true]; name; $catalogVersion
 ;2111;test;

Notice that I haven’t define any catalog version in the impex and with the help of the default I had already injected the catalog and the version I wanted to the macro, so I don’t have to pay attention to that attribute anymore in the header. Notice also that I have set the unique=true, so the header automatically will check the uniqueness of the code and the catalogversion during the insert or update

I hope this helps

Best Regards

JC

Former Member
0 Kudos

Hi JC,

Thanks for your reply.

It clarified my 70% doubt. If we talk in type perspective then while defining macros :

catalogVersion : Is a type with attributes catalog and version. So are catalog and version also types ?

Former Member
0 Kudos

Hello

The types are catalogVersion and catalog . we are just "creating a instance" of the catalogVersion

In catalogVersion(catalog(id),version) you are doing 2 searches in 1

  • First you look for the catalog(id)= that will return a catalog type

  • Later for the catalogVersion(catalog(id),version), using the previous catalog and the version to return the CatalogVersion type

basically is the same as if you were searching using unit(code), in this you are going to look the type unit by code

https://wiki.hybris.com/display/release5/ImpEx+Syntax#ImpExSyntax-ItemReferenceAttributes

Best