0

the following question mentions the information about accessing the collection types using Flexible Search:

Reading collection type data using Flexible search

I was wondering if we want to download this report using ImpEx export or so,then how to go about this.

Rachit
  • 403
  • 10
  • 32

1 Answers1

0

if you want to run a Flexible Search Query in the impex export, it is possible like this example:

insert_update ContentPage;uid[unique=true];name;catalogVersion;approvalStatus;label;title[lang=de];masterTemplate
"#% impex.exportItemsFlexibleSearch(""select {pk} from {ContentPage} where {CatalogVersion}=8796125823577"");" 

Otherwise, if you don't need any special query with conditions, you can run it simple as:

insert_update ContentPage;uid[unique=true];name;catalogVersion;approvalStatus;label;title[lang=de];masterTemplate
"#% impex.exportItems(""ContentPage"", false);"

In your case you have to make 2 insert_update commands for each type. Country and Region. The flexible search queries would be something like this:

SELECT {r.PK}
FROM  {Region as r}
 WHERE {r.country} =
   (
      {{
         SELECT {c.PK}
            FROM {Country as c}
            WHERE {c.isocode} = 'DE'
      }}
)

And simple one

select {c.pk} from {Country as c} where {c.isocode} = 'DE'

Here are some references https://wiki.hybris.com/display/forum/Export+with+Flexible+Search

https://wiki.hybris.com/display/release5/ImpEx+API

Hristo Staykov
  • 939
  • 7
  • 13
  • ,actually I have a scenario,whereby I have an itemtype say Country having an attribute which is a collection type of another itemtype,say Region.I want to extract the attributes of both countries and region.How to go about this? – Rachit Aug 07 '17 at 18:14
  • I changed my answer, so the code can fit. In general via impexes you can extract only 1 type at a query. There is no way to extract 2 types with the same query. However, it is possible to do it in one impex files with 2 separate insert_updates. – Hristo Staykov Aug 07 '17 at 19:28
  • The region wont have a reference to the country as collections are unidirectional so if country has collection of regions,there wont be a backward mapping from region to country. – Rachit Aug 09 '17 at 18:36