Use the Pagination Concept in an Integration

When you must fetch a large number of results in Salesforce Commerce Cloud, you can use the Salesforce Commerce Cloud Adapter’s pagination feature. Pagination helps you segregate the total number of results. You can specify the number of results per page according to your requirement while triggering an integration and receive sorted results.

This use case discusses how to use the pagination to sort results while fetching catalog results. Similarly, you can use pagination for the Stores object, Roles object, Products object, and so on. To perform this operation, you create an integration for the Salesforce Commerce Cloud Adapter in Oracle Integration using pagination with the orchestrator.
  1. Create an app-driven orchestrated integration.
  2. Drag the SOAP Adapter connection into the integration as a trigger connection.
  3. Drag an assign action to the workspace next to the SOAP Adapter.
  4. Provide a unique name for this action, and click Create.
  5. Assign the following two variables to your integration. Specify the values to variables as follows.
    Start = 0.0
    flag = “true”
    
  6. Click Validate, and then click Close.
  7. Drag a while action below the assign action.
  8. Provide a unique name for this action, and click Create.
  9. Set the condition for the specified variables as follows.
     flag! = “false”
  10. Click Validate, then click Close.
  11. In the mapper, map the start assign variable to start in the Salesforce Commerce Cloud request mapper and the input from SOAP to search_data.
    Mapper shows the source Request element mapped to the target search_data element and the source start_var element mapped to the target start element.

    Note:

    The start element is a numeric value required to search and access a specific record in the results. The search_data is a text field designed for the user to enter search queries into.
  12. Drag a Salesforce Commerce Cloud Adapter inside a while action.
  13. Specify the following details in the Adapter Endpoint Configuration Wizard.
    1. On the Basic Info page, provide a name.
    2. On the Actions page, select the Query action.
    3. On the Operations page, select Query/Search as an operation type, select catalog_search as an object, and select Post Catalog Search as an operation.
    4. Review your selections on the Summary page.
  14. Drag an FTP adapter and configure it with .json data file.
  15. Perform the required mapping.
    Mapper shows the source hits element mapped to the target hits element.

  16. Drag a switch action and specify the following IF condition:
    start<=total
    $getDataInfo/nsmpr8:postCatalogSearchResponse/nsmpr8:
    catalog_search_result/nsmpr9:next/nsmpr8:start<= $getDataInfo/nsmpr8:postCatalogSearchResponse/nsmpr8:catalog_search_result/nsmpr9:total
    
  17. Drag an assign action to update the specified variables as follows:
    start_var = start
    flag = “true”
    

    The while loop runs next in Salesforce Commerce Cloud. Each page gets triggered and fetches the required data.

  18. Drag an assign action in the Otherwise branch of the switch action to update the specified variables as follows:
    flag = “false”
  19. When complete, save and activate the integration.

    The completed integration looks as follows.
    This image shows the completed integration.

  20. After successful activation, you can submit the integration and monitor the runtime in Oracle Integration. The integration keeps running until it completes all cycles of fetching product results, respectively, to each page in the FTP location.