cancel
Showing results for 
Search instead for 
Did you mean: 

How can we create a generic content catalog?

Former Member
0 Kudos

Currently we maintain 11 different content catalogs in our code base for individual websites we support. If we create a new component, then we have to add this component to the impex file(s) in all 11 content catalogs. For the most part these content catalogs are the same (the business then customizes them later via the cockpit and/or hmc). So my question is how can we roll these into a single generic content catalog? The individual catalogs seem to be necessary due to the header variables, $contentCatalog for example. Is there a way to pass in header variables either via bean shell or java? If not is there a way to pass a variable from one impex file to another?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can have beanshell code in your impex that's executed upon import. That way you can create a website specific impex file, that contains only macro definition headers, like $contentCatalog. After the section defining the header macros you just do a "include" of the generic impex file.

I should have a code sample of this, will look it up later and paste it here.

Ok, try this:

 #%import java.io.FileInputStream
 #%impex.enableCodeExecution(true)
 #%impex.enableExternalSyntaxParsing(true)
 #%impex.includeExternalData(System.getProperty("HYBRIS_BIN_DIR") + "/ext-custom/xyzsampledata/resources/xyz/import/site/de/AT/impex/header-at.impex", "UTF-8", 0)

In the file "header-at.impex" you would now find any macros that set up an Austria (AT) environment, like:

 $locale=de_AT
 $languages=de
 $language=de
 $country=AT
 $defaultTranslation=de
 $websiteName=xyz-at
 $websiteTitle=xyz.at
 $deliveryCountries=at
 $defaultCurrency=EUR

In the file where you have the above mentioned include ("includeExternalData") you would then use these macros like this:

 $contentCatalog=$websiteName-ContentCatalog
 $productCatalog=$websiteName-ProductCatalog
 $online=Online
 $staged=Staged
 $serverConfigName=$websiteName-SolrServerConfig
 $indexConfigName=$websiteName-SolrIndexConfig
 $searchConfigName=$websiteName-SearchConfig
 $facetSearchConfigName=$websiteName-Index
 $facetSearchConfigDescription=$websiteName Solr Index
 $searchIndexNamePrefix=$websiteName

Former Member
0 Kudos

Thanks for your response, I kind of understand your answer but the code sample would help immensely.

Former Member
0 Kudos

Just added a code sample how this works. Have fun :-)

Former Member
0 Kudos

Or you do it the other way around and include the generic file like this into your website specific header file.

Former Member
0 Kudos

Thanks again, it's starting to come together. For us the preferred method would be to have a website specific header file and to include the generic file. I tried this approach and got stuck on this error: no current header for value line: INSERT_UPDATE I think I'm missing something. The header file is as you describe above and I'm trying to includeExternalData with a file that has a bunch of INSERT_UPDATE statements. I also tried adding enableExternalImpExSyntaxParsing and enableExternalDataCodeExecution (both set to true). No luck. What am I missing?

Former Member
0 Kudos

It's a long time ago, but I remember that it has taken a couple of tries until this worked.

Possibly you can't share the headers into an include, but only from an include to outside. Just a guess, you need to try.

andyfletcher
Active Contributor
0 Kudos

This thread from the old forums may have the answer https://wiki.hybris.com/display/forum/Include+secondary+impex+files

Specifically the reply from

Note: The second/last "0" in the statements above is critical to this working! I missed it out and continued to get the "no current header" error.

Former Member
0 Kudos

I got it to work using this syntax:

 #%impex.includeExternalData(new FileInputStream(System.getProperty("HYBRIS_BIN_DIR") + "/ext-custom/xyzsampledata/resources/xyz/import/site/de/AT/impex/header-at.impex"), "UTF-8", 0, 0)

Thanks so much!

Answers (0)