Skip to main content
Glama

trigger_catalog_sync

Synchronize catalog data between versions in SAP Commerce Cloud by specifying source and target versions to update product information.

Instructions

Trigger a catalog synchronization between versions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalogIdYesCatalog ID to sync
sourceVersionYesSource catalog version (e.g., "Staged")
targetVersionYesTarget catalog version (e.g., "Online")

Implementation Reference

  • The triggerCatalogSync method implements the logic to trigger a catalog synchronization in Hybris using a Groovy script.
      async triggerCatalogSync(
        catalogId: string,
        sourceVersion: string,
        targetVersion: string
      ): Promise<{ success: boolean; message: string }> {
        // Use Groovy script to trigger catalog sync by creating a properly configured CronJob
        const escapedCatalogId = this.escapeGroovyString(catalogId);
        const escapedSource = this.escapeGroovyString(sourceVersion);
        const escapedTarget = this.escapeGroovyString(targetVersion);
        const script = `
    import de.hybris.platform.catalog.model.synchronization.CatalogVersionSyncCronJobModel
    import de.hybris.platform.cronjob.enums.JobLogLevel
    
    try {
        def catalogVersionService = spring.getBean("catalogVersionService")
        def modelService = spring.getBean("modelService")
        def cronJobService = spring.getBean("cronJobService")
        def flexibleSearchService = spring.getBean("flexibleSearchService")
    
        def sourceCatalogVersion = catalogVersionService.getCatalogVersion("${escapedCatalogId}", "${escapedSource}")
        def targetCatalogVersion = catalogVersionService.getCatalogVersion("${escapedCatalogId}", "${escapedTarget}")
    
        if (sourceCatalogVersion == null) {
            println "ERROR: Source catalog version not found: ${escapedCatalogId}:${escapedSource}"
            return "SOURCE_NOT_FOUND"
        }
        if (targetCatalogVersion == null) {
            println "ERROR: Target catalog version not found: ${escapedCatalogId}:${escapedTarget}"
            return "TARGET_NOT_FOUND"
        }
    
        // Find sync job using flexible search
        def query = "SELECT {pk} FROM {CatalogVersionSyncJob} WHERE {sourceVersion} = ?source AND {targetVersion} = ?target"
        def params = [source: sourceCatalogVersion, target: targetCatalogVersion]
        def searchResult = flexibleSearchService.search(query, params)
    
        if (searchResult.result.isEmpty()) {
            println "ERROR: No sync job found for ${escapedCatalogId} ${escapedSource} -> ${escapedTarget}"
            println "Available sync jobs:"
            def allJobs = flexibleSearchService.search("SELECT {pk}, {code} FROM {CatalogVersionSyncJob}").result
            allJobs.each { job -> println "  - " + job.code }
            return "SYNC_JOB_NOT_FOUND"
        }
    
        def syncJob = searchResult.result[0]
        println "Found sync job: " + syncJob.code
    
        // Create a new CronJob with all mandatory attributes
        def syncCronJob = modelService.create(CatalogVersionSyncCronJobModel.class)
        syncCronJob.setJob(syncJob)
        syncCronJob.setCode("mcp_sync_" + System.currentTimeMillis())
    
        // Set all mandatory attributes
        syncCronJob.setCreateSavedValues(false)
        syncCronJob.setForceUpdate(false)
        syncCronJob.setLogToDatabase(false)
        syncCronJob.setLogToFile(false)
        syncCronJob.setLogLevelDatabase(JobLogLevel.WARNING)
        syncCronJob.setLogLevelFile(JobLogLevel.WARNING)
    
        modelService.save(syncCronJob)
        println "Created sync cronjob: " + syncCronJob.code
    
        // Trigger the cronjob
        cronJobService.performCronJob(syncCronJob, true)
    
        println "SUCCESS: Catalog sync triggered: ${escapedCatalogId} ${escapedSource} -> ${escapedTarget}"
        return "SUCCESS"
    } catch (Exception e) {
        println "ERROR: " + e.getMessage()
        e.printStackTrace()
  • The input schema definition for the trigger_catalog_sync tool.
    name: 'trigger_catalog_sync',
    description: 'Trigger a catalog synchronization between versions',
    inputSchema: {
      type: 'object',
      properties: {
        catalogId: {
          type: 'string',
          description: 'Catalog ID to sync',
        },
        sourceVersion: {
          type: 'string',
          description: 'Source catalog version (e.g., "Staged")',
        },
        targetVersion: {
          type: 'string',
          description: 'Target catalog version (e.g., "Online")',
  • src/index.ts:462-468 (registration)
    The registration logic in the main switch statement that calls the hybrisClient.triggerCatalogSync handler.
    case 'trigger_catalog_sync':
      result = await hybrisClient.triggerCatalogSync(
        validateString(args, 'catalogId', true),
        validateString(args, 'sourceVersion', true),
        validateString(args, 'targetVersion', true)
      );
      break;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcieunic/hybris-mcp-main'

If you have feedback or need assistance with the MCP directory API, please join our Discord server