使用Commerce CLI同步馈送
magento/saas-export程序包中的saas:resync命令允许您管理Adobe Commerce SaaS服务的数据同步。
saas:resync命令还适用于Adobe Commerce Optimizer Connector源,如products、categories和priceBooks。 有关连接器馈送和索引器名称的完整列表,请参阅支持的馈送。Adobe不建议定期使用saas:resync命令。 使用该命令的典型情况包括:
- 初始同步
- 更改SaaS数据空间ID后,将数据同步到新数据空间
- 故障排除
监视var/log/saas-export.log文件中的同步操作。
初始同步
aco:config:init命令通过使所有连接器馈送索引器失效来计划初始完全同步。 请参阅启用 Commerce Optimizer 集成和管理与 Commerce Optimizer的同步。当从命令行触发saas:resync时,根据目录大小,数据更新可能需要几分钟到几小时的时间。
馈送同步可以按任意顺序运行 — 它们之间没有硬依赖关系。 以下序列首先从范围数据开始,这是一个逻辑起点,因为范围定义了其他馈送引用的存储视图。
bin/magento saas:resync --feed scopesWebsite
bin/magento saas:resync --feed scopesCustomerGroup
bin/magento saas:resync --feed productAttributes
bin/magento saas:resync --feed categories
bin/magento saas:resync --feed products
bin/magento saas:resync --feed prices
bin/magento saas:resync --feed variants
bin/magento saas:resync --feed productoverrides
命令选项
saas:resync命令支持各种同步操作:
- 按SKU进行部分同步
- 恢复中断的同步
- 在不同步的情况下验证数据
查看所有命令选项和标志:
bin/magento saas:resync --help
有关选项说明和示例,请参阅以下部分。
--feed
必需。 指定要重新同步的馈送实体。
bin/magento saas:resync --help文档命令选项和标志。 它不会列出您环境中可用的每个馈送。 有关包含CLI馈送名称、索引器ID和馈送表的完整馈送列表,请参阅支持的馈送。
productOverrides需要云、内部部署或Commerce as a Cloud Service上的Adobe Commerce,而orders需要销售订单模块。示例:
bin/magento saas:resync --feed products
--by-ids
按其ID部分重新同步特定实体。 支持products、productAttributes、productOverrides、inventoryStockStatus、prices、variants和categoryPermissions信息源。
默认情况下,在使用--by-ids选项时,您会使用产品SKU值指定值。 要使用产品ID,请添加--id-type=productId选项。
示例:
bin/magento saas:resync --feed products --by-ids='ADB102,ADB111,ADB112'
bin/magento saas:resync --feed products --by-ids='1,2,3' --id-type='productId'
--cleanup-feed
在重新索引并将数据发送到SaaS之前,请清理馈送索引器表。 仅支持products、productAttributes、productOverrides、inventoryStockStatus、prices、variants和categoryPermissions。
如果与--dry-run选项一起使用,则该操作将对所有项目执行试运行重新同步操作。
cleanup-feed选项的resync命令会清除本地馈送导出状态,这可能会导致同步不完整。 例如,Adobe Commerce中的实体删除可能未反映在连接的Commerce Services中,或者即使过时实体在Adobe Commerce中被删除或更新,它们仍可能保留在远程Commerce Services索引中。 此选项仅用于完全环境重建,例如在清理SaaS数据空间之后。示例:
bin/magento saas:resync --feed products --cleanup-feed
--continue-resync
恢复中断的重新同步操作。 仅支持products、productAttributes和productOverrides馈送。
示例:
bin/magento saas:resync --feed productAttributes --continue-resync
--dry-run
在不将馈送提交到SaaS且不保存到馈送表的情况下,运行馈送重新索引过程。 此选项对于识别数据集的任何问题很有用。
添加EXPORTER_EXTENDED_LOG=1环境变量以将有效负载保存到var/log/saas-export.log。
示例:
EXPORTER_EXTENDED_LOG=1 bin/magento saas:resync --feed products --dry-run
测试特定信息源项目
通过将--by-ids选项与扩展日志集合一起添加来测试特定馈送项目,以查看var/log/saas-export.log文件中生成的有效负载。
示例:
EXPORTER_EXTENDED_LOG=1 bin/magento saas:resync --feed products --dry-run --by-ids='ADB102,ADB111,ADB112'
测试所有馈送项目
默认情况下,在resync --dry-run操作期间提交的信息源仅包含新项目,或以前无法导出的项目。 要在要处理的信息源中包含所有项,请使用--cleanup-feed选项。
示例:
bin/magento saas:resync --feed products --dry-run --cleanup-feed
--no-reindex
将现有目录数据重新提交到Commerce Services而不重新编制索引。 与产品相关的信息源不支持。
行为因导出模式而异:
- 旧版模式:重新提交所有数据而不截断。
- 立即模式:忽略选项,仅同步更新/失败。
示例:
bin/magento saas:resync --feed productAttributes --no-reindex