Publish and synchronize: Re-synchronization and re-generation
Edit on GitHubThe automatic execution of the Publish and Synchronize (P&S) process may not always address all of your use cases. In certain situations, you might need to manually re-synchronize or regenerate published data to ensure the correct information is available in Redis and Elasticsearch.
Example use cases:
-
Refresh Redis and Elasticsearch with updated data for your shop frontend.
-
Regenerate published data to correct issues after an import, ensuring the Storage and Search modules reflect the latest changes.
You can perform these actions manually using the instructions in the following sections.
Data re-sync
Resynchronization is useful when Redis or Elasticsearch data is lost–for example, because of a flush operation. This command re-exports data from the Storage and Search tables into Redis and Elasticsearch.
Re-synchronize command:
vendor/bin/console sync:data
This command performs the following steps:
-
Reads aggregated data from the database tables used by Storage and Search modules.
-
Sends the data to RabbitMQ queues.
-
Proceed RabbitMQ and sync to Redis and Elasticsearch.
To synchronize a specific entity, include the resource name:
vendor/bin/console sync:data {resource_name}
Example:
vendor/bin/console sync:data cms_block
To enable synchronization for a specific resource, you need to implement a corresponding sync plugin. For instructions, see Implement synchronization plugins.
Data re-generation
Re-generating data is helpful when you need to completely rebuild published content. For example, after a failed import or data corruption, you may want to overwrite the Storage and Search tables. Updates on Redis and Elasticsearch depend on *storage
and *_search
entities; if it was changed, data will be synced. If you need to sync all data, use vendor/bin/console sync:data
.
Re-generate command:
vendor/bin/console publish:trigger-events
This command performs the following steps:
-
Re-generates data in the Storage and Search tables.
-
Updates records in Redis and Elasticsearch if the entity was changed.
To target a specific resource (entity), use the -r
option:
vendor/bin/console publish:trigger-events -r {resource_name}
You can also specify one or more entity IDs using the -i
option:
vendor/bin/console publish:trigger-events -r {resource_name} -i {ids}
Example:
vendor/bin/console publish:trigger-events -r availability -i 1,2
For each resource you want to re-publish, you need to implement a publisher plugin. For instructions, see Implement synchronization plugins.
Thank you!
For submitting the form