-
Notifications
You must be signed in to change notification settings - Fork 2
Scheduling and CLI
Run connector commands from the store root, with the same PHP version and filesystem user used by the application. Every data-processing example on this page can read or change records in the configured store and NetSuite account. Establish the connection and test the selected flow before scheduling it.
The module's Magento cron declarations schedule maintenance only. They do not schedule product, customer, order, fulfillment, or stock synchronization. Add a separate scheduler entry for netsuite:cron.
Example OS crontab, after replacing all paths with the actual installation paths:
*/2 * * * * /path/to/php /path/to/store/bin/magento netsuite:cron --mode=all >> /path/to/log/netsuite-cron.log 2>&1Two minutes is an example cadence, not a throughput guarantee. Size it against queue age, record volume, job duration, NetSuite concurrency limits, and the stock interval. Stock defaults to a six-hour interval even when this command runs more frequently.
Use one coordinated worker schedule. The connector uses local flock files under var/netsuite; lock names are derived from the requested mode list with punctuation removed. Different lists such as all and import do not share the same lock. The lock is not a cross-host distributed worker coordinator.
bin/magento netsuite:cron --mode=all| Mode | Actual behavior |
|---|---|
all |
Process import queue, fetch changed import records, process exports, and check whether stock is due. Does not bootstrap locations. |
import |
Process existing import queue, then fetch changed records. Newly fetched messages normally wait for the next pass. |
export |
Process pending customer/order/invoice exports. |
importToQueue |
Fetch eligible changed records into the import queue. |
processQueue |
Process the existing import queue without fetching more records. |
stock |
Run stock synchronization if enabled and due. |
location |
Dedicated multi-location import path exists but calls a missing method in this version. Do not rely on it. |
--mode is required and accepts comma-separated values. Invalid or omitted mode input is rejected. Use the exact case shown for importToQueue and processQueue.
Explicit import and export modes select their corresponding connection sections, while explicit stock selects the stock section. all, importToQueue, and processQueue use the general connection selection. An all run does not rotate credentials automatically for each stage. See NetSuite setup.
Use Symfony verbosity flags for diagnostic output:
bin/magento netsuite:cron --mode=import -vvvThe command also declares an optional-value --debug option. Prefer the explicit verbosity flags when following a run. Per-record errors can be caught while the process still exits with code 0; inspect monitor and application results.
bin/magento netsuite:utils:processrecord --type=order_export --id=123--type (-t) and --id (-s) are required. The ID option accepts a comma-separated list. Registered types are:
| Type | ID belongs to |
|---|---|
customer_export |
Magento customer entity |
customer_import |
NetSuite Customer |
order_export |
Magento order entity |
invoice_export |
Magento invoice entity |
invoice_import |
NetSuite CashSale |
shipment_import |
NetSuite ItemFulfillment |
An entity ID is not the order's displayed increment number. These aliases invoke processors directly and can bypass normal observer gating. Do not replay an uncertain export until the remote record has been reconciled. There are no registered order_import, refund_import, or product_import aliases here.
bin/magento netsuite:utils:processsingleitem --mode=import --message-id=123Mode must be import or export. --message-id is the connector queue message ID, not the monitor ID or a business-record ID. Success removes the queue message; failure follows rejection handling. Preserve the original evidence before replaying a message with a remote-write ambiguity.
bin/magento netsuite:utils:importdaterange --type=cashsale --from='2026-09-01T00:00:00+00:00' --to='2026-09-02T00:00:00+00:00' --batch=50Only cashsale is registered for this command. --from (-f) and --to (-e) define the dateCreated search range. --batch (-b) defaults to 50. Include an explicit timezone; the request builder otherwise uses GMT-8. This is direct processing and can report individual failures without a nonzero final exit status.
# NetSuite item internal IDs
bin/magento netsuite:utils:importsingleproduct --id=123,124
# Existing store SKUs with NetSuite mappings
bin/magento netsuite:utils:importsingleproduct --sku=EXAMPLE-SKU
# Positional dry-run argument, not --dry-run
bin/magento netsuite:utils:relinkbysku dry-run --netsuite-sku-field=itemIdimportsingleproduct --delete-existing deletes an existing product and can also delete configurable children. It is not an ordinary refresh option. The default import path does not require it.
relinkbysku rewrites product NetSuite-ID associations by matching SKUs. Its options include --netsuite-sku-field (-s, default itemId), --sku-custom (-f, default 0), --start_id (-o, default 0), and --batch-size (-b, default 500). Run the positional dry-run first and review every proposed association before an intentional relink. See Products.
bin/magento netsuite:utils:updatestocks
bin/magento netsuite:maintenance:cleanmonitor
bin/magento netsuite:maintenance:sendqueuewarningupdatestocks still obeys the stock interval. cleanmonitor removes eligible old monitor history. The warning command currently reads the wrong queue backend; it cannot establish connector queue health.
The normal Magento cron group schedules:
| Job | Schedule | Effect |
|---|---|---|
send_queue_warnings |
1 * * * * |
Intended queue warning mail; affected by the queue-count defect. |
fix_stuck_messages_in_queue |
42 * * * * |
Recover or discard stale in-progress queue messages. See recovery rules below. |
clean_monitor |
0 1 * * * |
Remove eligible monitor history older than the configured lifetime, default 30 days. |
Do not copy netsuite:utils:importproducts, netsuite:utils:importorder, netsuite:utils:importcustomer, netsuite:utils:importcompany, Magento 1 shell scripts, or netsuiterelinkproductsbysku from older guides. The old --wipe-existing, --multi-login, and --sku-resume-at options are not registered by the current product command.
Sources: main command, registered commands and aliases, record utility, queue utility, date-range command, date-range search, product commands, stock command, maintenance schedule, lock implementation.
Mage-OS Labs · Source · Reviewed commit fec65e2 · September 9, 2026 · Validation and limitations
Mage-OS NetSuite Connector
Setup
Data flows
Operations and development