Use Cases
Import stock items into Craft entries
First, get POHODA stock data into the local buffer. Either sync from the mServer:
php craft pohoda/items/sync-buffer --queue=1
or, if the mServer isn't directly reachable, generate a list-response XML export from POHODA and upload it under Pohoda → Settings → Advanced → Import POHODA XML (see Settings).
Then open Pohoda → Items. Each row is a buffered stock item (code, name, price, stock, VAT,
warehouse) with its last sync time. Pick a target entry type from the dropdown — the page
reloads to show that entry type's custom fields as mapping targets — and a site. For each
target field, choose a source: the built-in fields (name, sku, price, stock, vat,
warehouse) or a data.* path into the raw POHODA payload for anything the built-ins don't cover
(e.g. data.stockHeader.EAN). Select the items to import (or leave the default "map to entry
title from item name" mapping and select all), then run Import. Import runs as a queued job;
each item is matched to an existing entry by whichever mapped field targets sku, or a new entry
is created if none matches.
Export an order as a POHODA invoice
If the yStore checkout/invoicing pipeline is installed, POHODA registers itself as an invoice
provider automatically — no extra wiring needed. Select Pohoda as the invoicing method
wherever the storefront or backoffice chooses an invoice provider, and PohodaInvoiceProvider
converts the order (customer, billing address, line items, shipping, payment fee) into a POHODA
order document and sends it through OrdersService::exportOrders() the next time an invoice is
created for that order.
To export an order manually (e.g. from a script, or for orders coming from outside yStore), build a JSON array of order objects and pipe it into the console command:
echo '[{
"number": "SO-2026-0142",
"date": "2026-08-01",
"currency": "EUR",
"total": 119.90,
"customer": {
"company": "Acme s.r.o.",
"name": "Ján Novák",
"email": "jan@example.com",
"address": {"street": "Hlavná 1", "zip": "81101", "city": "Bratislava", "country": "SK"}
},
"items": [
{"code": "SKU-001", "name": "Widget", "quantity": 2, "price": 49.95, "total": 99.90, "vat": "high"}
]
}]' | php craft pohoda/orders/export
--input=<path> reads the JSON from a file instead of stdin, and --output=<path> writes the raw
POHODA response XML to a file instead of stdout. Fields left out of an order/item fall back to the
plugin's default currency, country, and VAT code from Settings.
Pull orders/invoices back from POHODA
To reconcile or report on invoices that already exist in POHODA, import them instead of exporting:
php craft pohoda/orders/import --orderType=issuedInvoice --dateFrom=2026-07-01 --dateTo=2026-07-31 --format=json --output=@storage/pohoda/july-invoices.json
--number filters to a single order number, --includeUnpaid=0 restricts to already-paid
invoices, and --page/--limit control pagination (auto-pagination is on by default and keeps
fetching pages until POHODA returns a short page). Omit --output to print the result to stdout;
--format=xml writes a raw XML representation instead of JSON.
Populate the item buffer without a live mServer connection
Some POHODA installations only expose the mServer on an internal network that the Craft server can't reach directly. In that case, generate a stock list-response export from POHODA itself, then upload it via Pohoda → Settings → Advanced → Import POHODA XML — the file is parsed and saved straight into the same buffer table that a live sync would populate, so the Items import workflow works identically either way. The Use mServer API toggle on the Settings screen is unrelated to this workflow — as of v1.2.0 it has no effect on any active service, so leave it as is and rely on the manual upload action instead.
Automate sync and export from cron
Because every buffer/import/export operation has a console command, a full sync loop can run without any CP interaction:
# Pull the latest stock into the buffer (queued, so it doesn't block the cron job)
php craft pohoda/items/sync-buffer --lastChange="$(date -d '-1 day' +%Y-%m-%dT00:00:00)" --queue=1
# Import buffered items into an existing entry type/site with a saved mapping
php craft pohoda/items/import-buffer --entryTypeId=12 --siteId=1 --map="sku:sku,title:name,price:price"
--map takes comma-separated target:source pairs, matching what the Items CP screen builds
for you interactively. Use --queue=0 on either command to run synchronously instead of queuing,
useful for a cron job that already runs in its own process and wants a definitive exit code.
Debug a failed sync
Turn on Log XML payloads under Settings → Advanced, reproduce the
failing call, then check Craft's log for the Sending POHODA request: / Received POHODA response: entries — POHODA's own XML responses generally include a human-readable error message
per data pack item, which is the fastest way to tell a mapping/schema mismatch from an
authentication or connectivity problem. Turn logging back off afterwards; it logs every payload at
full verbosity.