Skip to content

feat(cli): add datasync:options-container + datasync:resync-stale recovery commands - #6

Merged
mageaustralia merged 3 commits into
mainfrom
feat/recovery-cli-commands
Jun 2, 2026
Merged

feat(cli): add datasync:options-container + datasync:resync-stale recovery commands#6
mageaustralia merged 3 commits into
mainfrom
feat/recovery-cli-commands

Conversation

@mageaustralia

Copy link
Copy Markdown
Owner

Adds two recovery / diagnostic CLI commands. Both follow the existing DatasyncStock pattern (connectToLive() via .env.local, dry-run flag, batched destination writes).

datasync:options-container

Restores the options_container attribute on the destination from the source by SKU — pairs with #4. Once PR #5 (the empty-overwrite guard) lands, this is the one-shot recovery for installs already affected.

  • Discovers source products with a non-empty options_container
  • Maps to destination products by SKU
  • Only fills empty destination values (won't clobber set values, unless --overwrite)
  • Groups updates by target value for efficient batched updateAttributes calls
  • --dry-run reports counts per value before any write

datasync:resync-stale

Discovery-only catch-up tool for the gap described in #1. Compares destination vs source catalog_product_entity.updated_at per SKU and reports products where source is newer than destination by more than --threshold days.

  • Catches everything regardless of how source got updated (observer-fired or not)
  • Resolves destination IDs via datasync_entity_registry
  • Breakdown by destination type (configurable / simple / etc.)
  • Per-product status + image count diff so the report shows "what would actually change"
  • Sync wiring deliberately deferred — pair with the live-side reconciler proposed in Tracker misses bypass paths → silently stale products #1 (insert tracker rows so the existing incremental picks them up — cleaner)

Both safe to drop into a maho-datasync install; no schema or core changes.

Matthew Campbell added 3 commits May 26, 2026 13:01
…overy commands

datasync:options-container restores the options_container attribute on the
destination from the source by SKU. Pairs with #4 — once PR #5 lands, this
is the one-shot recovery for installs already affected.

datasync:resync-stale is a discovery-only catch-up tool for the gap in #1.
Compares destination vs source catalog_product_entity.updated_at per SKU
and reports stale products with per-product status + image-count diff.
Sync wiring deliberately deferred pending the live-side reconciler
proposed in #1.

Both follow the existing DatasyncStock pattern (connectToLive via
.env.local, dry-run flag, batched destination writes).
…un read

- Adds the apply path (was previously discovery-only): reuses
  datasync/adapter_openmage + datasync/engine with on_duplicate=merge and an
  entity_ids filter, batched in configurable chunks (--batch-size, default 50).
  Same engine path as datasync:incremental, just bypassing the live tracker.

- Fixes a real bug introduced in the previous version: $dryRun was referenced
  but never assigned from $input->getOption('dry-run'), so APPLY mode always
  ran regardless of the flag. Now correctly defaults to dry-run preview unless
  --dry-run is omitted.

Safe to pair with PR #5 (value-level merge) — re-syncing a stale product no
longer churns option_type_ids, so the dependent-options config restored by the
companion CLI in maho-module-dependentoptions stays valid.
@mageaustralia
mageaustralia merged commit d4dae61 into main Jun 2, 2026
1 check passed
@mageaustralia
mageaustralia deleted the feat/recovery-cli-commands branch July 8, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant