Skip to content

Generating and Publishing Data

Iva Koevska edited this page Jan 18, 2017 · 3 revisions

NOTE: This page builds on the information provided in README.md and Wiki: Extension Overview.

After you have installed the extension locally and you have configured the export logic, you need to trigger the cron job fredhopperIndexExportCronJob. It uses your configuration to export data from hybris, transform it into the CSV format required by Fredhopper, and then load it in your Fredhopper cloud instance.

The following diagram illustrates the flow of the fredhopperIndexExportCronJob job:

TIP: You can implement and inject pre- and post-publishing hooks in this process using a Spring bean configuration. The CleanUpHook is a prepackaged example of a post-publishing hook.

Jump to the following sections for more detailed information about fredhopperIndexExportCronJob:

Generating Data

Three separate collectors identify and gather attribute, category, and product data. The Generator construct is responsible for transposing the collected data to the CSV standard used by Fredhopper.

Categories

The following diagram illustrates how CategoryDataCollector identifies and gathers data about your categories from hybris:

The top-level category in the Fredhopper categorisation is the universe. Typically, a Fredhopper setup has a single universe. In the Spring bean definition of the fredhoppersearch extension, you can set the top-level category name using the universe attribute of the CategoryDataCollector bean.

CategoryDataCollector consults fhCategorySource to determine the children of the top-level category (the universe) and to populate the sub-category data. To set one or more hybris root categories as sub-categories, you need to assign their codes to a fhCategorySource bean.

The following XML snippet illustrates how to configure the Spring beans to gather category and sub-category data:

<bean id="defaultfhCategoryCollector" 
    class="com.fredhopper.connector.index.collector.DefaultCategoryDataCollector">
    <property name="indexCode" value="default"/>
    <property name="indexConfigService" ref="indexConfigService"/>
    <property name="categorySource" ref="fhCategoriesSource"/>
    <property name="converter" ref="fhCategoryConverter"/>
    <property name="universe" value="catalog01"/>
</bean>

<bean id="fhCategorySource" class="com.fredhopper.connector.index.provider.FHCategorySource">
    <property name="categoriesQualifier" value="supercategories" />
    <property name="modelService" ref="modelService" />
    <property name="categoryService" ref="categoryService" />
    <property name="findCatalogVersionStrategy" ref="fhFindProductCatalogVersionStrategy" />
    <property name="includeClassificationClasses" value="false" />
</bean> 

<bean id="fhCategoriesSource" parent="fhCategorySource">
    <property name="rootCategoryCodes">
        <set value-type="java.lang.String">
            <value>categories</value>
        </set>
    </property>
</bean>

Products

The following diagram illustrates how ProductDataCollector identifies and gathers data about your products from hybris:

The default implementation of the ProductDataCollector bean identifies the products to be indexed using the query executed in the encapsulated fhProductDao. Relevant attributes and locales are identified using the supplied configuration IndexConfig object, which is managed in the database.

ProductModels are retrieved in batches. The ProductDataCollector delegates the conversion of the ProductModel batches to FhProductData objects to the FhProductConverter. The ProductEssentialsPopulator is called upon during ProductModel conversion by the FhProductConverter to take care of populating the product identifier and category values.

The Generator construct outputs these data transfer objects (DTOs) ID, attribute, and category values to the various CSV files of the Fredhopper input.

TIP: To change the search criteria for product identification, override the default fhProductDao query. You can use Spring to configure the various populators called during the conversion.

Attributes

The following diagram illustrates how MetaAttributeCollector identifies and gathers data about your attributes from hybris:

All attributes apart from product identifier and category must be specified by their own MetaAttribute type instance. These MetaAttribute definitions are saved to the database in relation to an IndexConfig configuration object. The IndexConfig object is assigned to an indexing job and will be consulted by the indexing process to collect and convert the meta attribute data.

The MetaAttribute definition specifies if it concerns an attribute at base product or variant product level and identifies the relevant Fredhopper basetype.

These definitions can contain a reference to a corresponding attribute qualifier of the variant or base product, or to a Spring bean identifier which acts as a value provider.

The following XML snippet illustrates how to configure a value provider:

<bean id="fhProductPriceValueProvider"
    class="com.fredhopper.connector.index.provider.ProductPriceValueProvider">
    <property name="priceService" ref="priceService" />
</bean>

Publishing Data

The Fredhopper/SAP Hybris Connector provides a default REST implementation for the PublishingStrategy interface. PublishingService calls it to upload the ZIP archive of your exported data and to trigger the indexing process.

To configure the connector to work with your Fredhopper instance, provide values for the corresponding properties in your config/local.properties files.