top of page

Overview

 

​The hot folder in  Hybris is a widely used integration tool for bulk importing data into the system. It enables automated imports of data from external systems into the Hybris database by monitoring a designated folder where data files are dropped. This mechanism is especially useful for scenarios that require regular and large data imports, such as updating product catalogs, customer records, prices, or orders.

​

​

​

​

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hot folder Key features :

​

    1) Automation: Automatically picks up files for import, making it ideal for recurring or scheduled imports.

    2) Scalability: Can handle large volumes of data, ensuring quick imports.

    3) Error Handling: The hot folder import process typically has error-handling mechanisms to manage faulty data or issues with the import process, such as logging errors or sending notifications.

​

​

​

​

 

 

Hot Folder Configuration Steps

​

The hot folder in Hybris provides a flexible and automated solution for integrating external data into Hybris Cloud, offering efficiency and scalability for businesses with large data import needs. Following is the  flow diagram of the hot folder.

​

​

​

 

 

 

 

 

Fo

 

Following are highlighted points for hot folder setup:  

​

  •  Inbound Channel Adapter :The Inbound Channel Adapter refers to a component that facilitates the integration between the file system and Hybris import services. It is responsible for monitoring the hot folder, picking up files when they are added, and initiating the data processing based on the files detected.

  • File Order Comparator : File Order Comparator is a component used to define the order in which files are processed. Since hot folder jobs may need to handle multiple files, the order of processing can be critical, especially when file dependencies exist. The File Order Comparator allows you to specify the sequence in which files are picked up from the hot folder and processed.

  • Header Setup Task : The header setup task refers to configuring the header section of a CSV or XML file to ensure proper mapping of the file data to the system's data model. The header contains metadata that defines the structure of the file, such as the column names (in CSV files) or the field mappings (in XML files). Proper header setup is essential for the hot folder import process to interpret the data correctly and map it to the corresponding entities in the SAP Commerce system.

  • Header Init Task : The Header Init Task in the context of the hot folder in SAP Hybris (SAP Commerce) refers to the setup and initialization process for handling file headers before data import. It ensures that the headers in files (usually CSV or XML) are properly recognized, mapped, and aligned with the data model in SAP Commerce. This process is critical for interpreting and validating the structure of the incoming data to prevent import errors and ensure smooth processing. In this step we extract the sequenceId and the language then we add them to the BatchHeader for later use.

        For example for this file name product-de-2313213672234.csv the sequenceId is 2313213672234 and the language is de

  • Impex Transformer Task : The Impex Transformer Task in the context of a hot folder in  Hybris is a component that transforms incoming data files (typically CSV or XML) into Impex format. Impex is the standard format in hybris for importing and exporting data. This task helps convert the data extracted from the hot folder into an Impex script, which is then executed to insert or update the corresponding data in the database. This is one of the important steps in the flow, basically here where the original file (csv) is converted to an impex with the help of a pre-configured ImpexConverter.

  •  Impex Runner Task : The Impex Runner Task in the context of the hot folder in Hybris is responsible for executing the Impex scripts that have been transformed and generated from incoming files, typically by tasks like the Impex Transformer Task. This imports the transformed file (impex) using ImportService.importData() method.

  • Cleanup Task : Deletes the transformed file (impex) and archive the original file (csv).

​

​

​Following are coding change steps discussed in brief: 

​

Step 1: Create an xml file hot-folder-training-spring.xml inside the …\custom\training\trainingcore\resources\trainingcore\integration

 

Step2: Import the above file into the trainingcore-spring.xml.

                 <import resource="classpath:/trainingcore/integration/hot-folder-training-spring.xml"/>

​​​​​

Step 3: Create the base directory to declare the scan path directory.

                <bean id="testbaseDirectoryTraining" class="java.lang.String">

                             <constructor-arg value="{baseDirectory}/${tenantId}/training" />

                     </bean>

​

Step 4: Create the inbound channel to scan the baseDirectory, 

                 <file:inbound-channel-adapter id="testBatchFilesTraining" directory="#{testbaseDirectoryTraining}" filename-regex="^(.*)-(\d+)\.csv"                                                 comparator="fileOrderComparator">

                           <int:poller fixed-rate="1000" />

                     </file:inbound-channel-adapter>

​

Step 5: To move the file to the processing folder it invokes the first step of flow by outbound gateway. 

                 

                <file:outbound-gateway request-channel="testBatchFilesTraining"

                                reply-channel="batchtestFilesTrainingProc"

                    directory="#{testbaseDirectoryTraining}/processing" delete-source-files="true" />

​

​

​Step 6: To feeds the flow with relevant information use the service-activator. This is the first step of flow. 

​

                 <int:service-activator input-channel="batchtestFilesTrainingProc"

                           output-channel="batchTestFilesHeaderInit"

                    ref="trainingHeaderSetupTask" method="execute" />

​

                    <bean id="trainingHeaderSetupTask" class="de.hybris.platform.acceleratorservices.dataimport.batch.task.HeaderSetupTask">                                                              <property name="catalog" value="trainingProductCatalog" />

                                        <property name="net" value="false" />

                                        <property name="storeBaseDirectory" ref="baseDirectoryTraining" />

                    </bean>

​

​

​

​Step 7: Create ImpexConverter and ConverterMapping.

​

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns... >

<context:annotation-config/>

        <bean id="b2bUnitConverter" class="de.hybris.platform.acceleratorservices.dataimport.batch.converter.impl.DefaultImpexConverter">

                <property name="header">                                                                                                                                                                                                                                                                                                                 <value> # {defaultImpexProductHeader}

                                 INSERT_UPDATE B2BUnit;uid[unique=true];name[lang=$lang] 

                     </value>                                                                                                                                                                                                                                                                                                                                                        </property>                                       

                <property name="impexRow">                                                                                                                                                                                                                                                                                                        <value>

                                {+0};{1}

                    </value>                                                                                                                                                                                                                                                       

                </property>

       </bean>

</beans>

​

​

​

<bean id="b2bUunitConverterMapping" class="de.hybris.platform.acceleratorservices.dataimport.batch.converter.mapping.impl.DefaultConverterMapping" p:mapping="b2bUnit" p:converter-ref="b2buUnitConverter"/>

​

​

​

About the Author

 

Piyush Singh is a seasoned technology enthusiast and educator with a passion for making complex concepts accessible to everyone. With over 10 years of experience in the tech industry working as consultant,  Piyush specializes in Java, Sap Hybris technology and has a knack for breaking down intricate topics into easy-to-follow tutorials.

​​​​​​​

   Connect with Author

LinkedIn

Email

​

​

bottom of page