Skip to content

Sync Triggers & Cron Methods

All sync is initiated from application/modules/cli/controllers/Cron.php in Zwerfkei Old.

Legacy reference

These cron methods belong to the current (legacy) CodeIgniter application. They are documented here as reference during the migration to the new platform.


Inbound sync — k3retail_webservices

The most important cron method. Polls Navision continuously for any queued changes via the sync buffer.

php index.php cli/cron k3retail_webservices
php index.php cli/cron k3retail_webservices --cron   # loop mode: runs for ~50 sec then exits
php index.php cli/cron k3retail_webservices --all    # process all buffered items at once

In --cron mode the method loops internally for ~50 seconds (sleeping 2 seconds between cycles), so an OS cron running it every minute produces continuous coverage with no gaps.

Entities handled by this method:

Buffer type SOAP call Target table
products GetProduct k3_articles
salesPrices GetSalesPrice k3_article_salesprices
salesLineDiscounts GetSalesLineDiscount k3_article_line_discounts
offers GetOffer k3_article_offers
orderStatus GetOrderStatus order status fields
categories GetCategory menu/category tables
categoryItems GetCategoryItems menu_articles
periodicDiscounts GetPeriodicDiscount k3_periodicDiscounts
itemAvailability GetItemAvailability k3_article_availability

Outbound sync — k3retail_sync

Processes the outbound queue. Reads the k3_synchronization table and calls Navision for each pending record.

php index.php cli/cron k3retail_sync

Dispatches to the appropriate handler per record:

Model Action Handler SOAP call
Order 1 (positive) Order_positive.php SubmitOrder
Order 2 (negative) Order_negative.php SubmitOrder (cancellation/return)
Customer CustomerSync.php SetMemberAccount
K3_periodicDiscount PeriodicDiscount.php SubmitPeriodicDiscount

A database lock (GET_LOCK('k3_sync', 1)) prevents concurrent runs.


Customer sync — syncCustomers

php index.php cli/cron syncCustomers

Pulls members changed since the last run from Navision (GetMemberAccount, Kei WSDL). New or updated web customers are also queued outbound via k3retail_sync.


POS transaction sync

php index.php cli/cron getTransactions         # incremental (since last run)
php index.php cli/cron getTransactionsAll      # full history
php index.php cli/cron getTransSalesFromCsv    # import from CSV file

Pulls POS transactions from Navision (Kei WSDL). Typically run hourly.


Value entries / ledger

php index.php cli/cron getValueEntries
php index.php cli/cron getValueEntriesAll

Pulls accounting ledger entries from Navision (Kei WSDL). Typically run nightly.


Purchase orders

php index.php cli/cron getPurchasesFromNav              # all open POs
php index.php cli/cron getPurchasesFromNav [PO_NUMBER]  # single PO
php index.php cli/cron refreshOpenPurchasesFromNav      # refresh open POs

Member loyalty points

php index.php cli/cron getMemberPointEntries
php index.php cli/cron getMemberPointEntries all

Maintenance methods

Method Description
checkK3Sync Validates queue completeness; sends alert email if records are stuck
navItemSyncBatch Forces a batch refresh of individual items outside the normal buffer
syncColourThemes Syncs vendor colour code → display colour mappings per brand
checkForDeletedDiscounts Cleans up discounts deleted in Navision
softDeleteAndDeleteExpiredDiscounts Archives expired periodic discounts
sendEmailToNonPaidOrders Emails customers with unpaid orders
updateWebactive Updates webactive status flags in Navision
navItemFixMissingPostingGroup Fixes missing Navision posting groups on items
runMemberPosting Triggers member posting job in Navision
runJobQueues Triggers Navision job queues
CreateMembershipCards Creates membership cards in Navision

Inferred schedule

The schedule below is inferred from the codebase. Verify against the actual server crontab.

# Continuous inbound sync (every minute, loops internally for ~50 sec)
* * * * * php index.php cli/cron k3retail_webservices --cron

# Outbound queue processor (every 5 minutes)
*/5 * * * * php index.php cli/cron k3retail_sync

# Customer sync (every 15 minutes)
*/15 * * * * php index.php cli/cron syncCustomers

# POS transactions (hourly)
0 * * * * php index.php cli/cron getTransactions

# Sync health check (every 30 minutes)
*/30 * * * * php index.php cli/cron checkK3Sync

# Nightly maintenance
0 2 * * * php index.php cli/cron softDeleteAndDeleteExpiredDiscounts
0 3 * * * php index.php cli/cron getValueEntries

Legacy Integration overview K3 Data Models