sap-commerce-cloudimpexflexible-search

Hybris export data of two joined tables using flexible search


I am new to Hybris. what I am trying to do is Export Data (code from product and name from catalog) of two joined tables using flexible search. I Wrote a query but cant understand how use it as impex export. This will be My Query

SELECT {p:code},{c:name} FROM {product AS p JOIN catalog AS c ON {p:catalog}={c:pk}} 
WHERE {p:description} LIKE '%meat%'

How write Impex header for this export ?


Solution

  • Try this

    INSERT_UPDATE Product;code[unique=true];catalogVersion(catalog(name[lang=en]));
    "#% impex.exportItemsFlexibleSearch(""SELECT {p:pk} FROM {product AS p} WHERE {p:description} LIKE '%meat%'"");"
    

    For export with flexible search, you need to select only PK. To get the catalog's name from the product model, you need to get it from

    product -> catalogVersion -> catalog -> name.

    Note that name in the catalog is localized, hence I put "lang" there, change en to any language code that you use.