Skip to main content

menzzo:v2:sales

Overview​

Imports newly created Magento 2 Menzzo sales into LogiDAV.

This command is the entry point for new Menzzo order ingestion and is part of the broader Sales Import Workflow.

Disabled-import alert monitoring is handled by the separate command menzzo:v2:sales:check-disabled-import, which must be scheduled every 30 minutes.

Schedules​

  1. */10 * * * * - Line 3 in system-crontab.md

Command Details​

  1. menzzo:v2:sales

Intent & Purpose​

The command reads the last imported Magento sale ID from configuration, fetches Magento orders with a greater entity_id, and imports them one by one through SaleService::addOrder(..., true).

This makes it a cursor-based incremental importer rather than a full reconciliation job.

Dependencies​

  • Magento order API via mz.sale.api
  • SaleService for create/update logic
  • config storage for the last imported Magento sale ID
  • MZ_ACTIVATE_SALES_IMPORT feature flag in mz_config
  • SystemAlertService for failure reporting
  • RDV handling through SaleService::handleRdv()

Workflow​

Side Effects​

  • creates new Sale records when the order is not yet present locally
  • updates existing Sale records when the order already exists
  • creates or updates SaleProduct records
  • advances the persistent Magento import cursor
  • may trigger stock movement logging inside SaleService::addOrder()
  • may trigger RDV handling for imported sales in processing or complete
  • raises a system alert on import failure and continues with the next order

Error Handling and Recovery​

  • uses LockableTrait to avoid concurrent runs
  • exits with Sales import is disabled! when the sales import feature flag is disabled
  • throws if the Magento cursor is missing
  • catches per-order exceptions, alerts operators, and skips the failed order instead of aborting the whole batch
  • treats deadlock and closed entity manager failures as warning-level alerts rather than full-stop failures

Operator Notes​

  • The cursor is stored through SaleService::getLastMagentoId() / setLastMagentoId().
  • MZ_ACTIVATE_SALES_IMPORT is the feature flag controlling LogiDAV sales import. A value of 1 enables the importer; any other value disables this command before Magento orders are fetched.
  • If MZ_ACTIVATE_SALES_IMPORT is missing, the command recreates it idempotently with default value 1. This default is intentional so a deployment or config corruption does not leave the sales import cron unusable. Existing config values are never overwritten, so this does not change import behavior when the row exists.
  • This command does not create or resolve disabled-import alerts. That lifecycle belongs to menzzo:v2:sales:check-disabled-import.
  • The importer is incremental: if an order is skipped because of an exception, replay usually requires reviewing the cursor and the failed Magento order.
  • This command is not the main status reconciliation path. Status drift is handled by menzzo:v2:sales:update.

Risk Assessment​

Risk Level: critical

This command directly controls whether new orders enter LogiDAV. A failure here can lead to missing orders, delayed fulfillment, and downstream reconciliation issues.

Documentation Status​

  • Command class located
  • Business purpose documented
  • Side effects identified
  • Risk level confirmed
  • @doc.* annotations added to code