product-export:generate does nothing — until you turn off „Generate via scheduler“
Fabian Blechschmidt
We run several product exports (Google Shopping, a couple of price comparison feeds) with „Generate via scheduler“ checked in the Sales Channel settings. One night the queue worker died with an OOM kill — two big exports had become due in the same tick and the box didn’t have RAM for both at once. Fine, workers die, that’s what schedulers are for, right? Except the feed never regenerated. Not on the next scheduled tick, not the one after that. I SSH’d in and ran bin/console product-export:generate <sales-channel-id> --force to force it by hand. Nothing happened. No error, no new file, no log line. --force just… didn’t force anything. That sent me into vendor/shopware/core/Content/ProductExport, and it turns out there are two separate undocumented mechanisms stacked on top of each other here.
The CLI command that quietly refuses to run
The command reference lists product-export:generate in one line („Generates a product export file“) and nothing else. What it doesn’t say: whether it actually generates anything depends on the export’s „Generate via scheduler“ checkbox — the admin label for the generate_by_cronjob field. ProductExporter::createFile() decides whether to skip generation via ProductExportFileHandler::isValidFile():
public function isValidFile(string $filePath, ExportBehavior $behavior, ProductExportEntity $productExport): bool
{
if (!$this->fileSystem->fileExists($filePath)) {
return false;
}
return $productExport->isGenerateByCronjob() || !$this->isCacheExpired($behavior, $productExport);
}
Read that || carefully. If the file already exists and generateByCronjob is true, the whole expression is true — full stop. isCacheExpired() never even gets evaluated for its result, and neither does the --force flag you just passed, because --force only maps to ExportBehavior::ignoreCache(), which is an input intoisCacheExpired():
$this->productExportService->export(
$salesChannelContext,
new ExportBehavior($forceGeneration, $includeInactive),
$productExportId
);
So: any export with „Generate via scheduler“ checked is, from the CLI’s point of view, always a valid file as long as one exists on disk — --force included. The only way product-export:generate actually regenerates such an export is if the file is missing entirely. Delete the file first and it works; run the command against an export still flagged for scheduler generation and it’s a silent no-op.
Where the RAM actually goes
On the scheduler side, product_export_generate_task runs every 60 seconds by default (ProductExportGenerateTask::getDefaultInterval()). Each tick, ProductExportGenerateTaskHandler::run() loops over every active storefront sales channel, fetches every export on it with generateByCronjob = true, and for each one whose cache interval has expired, dispatches a ProductExportPartialGeneration message to the queue — all in the same pass:
foreach ($productExports as $productExport) {
if (!$this->shouldBeRun($productExport, $now)) {
continue;
}
$this->messageBus->dispatch(
new ProductExportPartialGeneration($productExport->getId(), $salesChannelId)
);
}
If two or more exports happen to become due in the same 60-second window — which is likely if you set them all to the same interval, or just by coincidence over time — they all land in the queue together. Depending on how many worker processes you run in parallel, that’s several full product loops buffering rows in memory at the same time, on top of whatever else the queue is chewing through. That’s the actual mechanism behind „the scheduler gives us less control“: it doesn’t stagger anything, it just fires everything that’s due, whenever that happens to line up.
The export that never comes back
Here’s the part that matches what we saw in production. Every product export row has an is_running flag. ProductExportPartialGenerationHandler::runExport() sets it true before generating the first batch:
It’s only set back to false in finalizeExport() — the very last step, run once the entire batched export (all partial chunks, header, footer) has finished successfully. There’s no try/finally around the generation itself. If the worker process gets SIGKILLed by the OOM killer mid-batch — which is exactly what happened to us — nothing ever runs that resets is_running. It just stays 1, permanently.
And ProductExportGenerateTaskHandler::shouldBeRun() checks exactly that flag before ever dispatching a new generation for that export:
private function shouldBeRun(ProductExportEntity $productExport, \DateTimeImmutable $now): bool
{
if ($productExport->getIsRunning()) {
return false;
}
// ...
}
So a crashed export doesn’t just miss one tick — it’s silently skipped forever, on every future tick, with no error, no log entry, no retry, no timeout. One small correction to how I originally described this to myself: the scheduled_task table entry for product_export_generate_task is fine — dispatching messages is fast, so ScheduledTaskHandler::rescheduleTask() runs and re-schedules that row normally every time. The thing that gets stuck is the export’s own is_running column in product_export, which nothing in core ever resets on its own. The only way out is manual:
SELECT LOWER(HEX(id)), file_name, is_running FROM product_export WHERE is_running = 1;
UPDATE product_export SET is_running = 0 WHERE id = 0x...;
Switching an export from scheduler to CLI
Given both of the above, the fix we wanted — full control over when and how many exports run at once — meant getting these exports off generateByCronjob entirely, not just running the CLI command alongside the scheduler:
In the admin, open the Sales Channel → Product export tab and uncheck „Generate via scheduler“ for each export you want to control yourself. This flips generate_by_cronjob to 0.
With that off, product_export_generate_task stops picking the export up at all — it’s filtered out by EqualsFilter('generateByCronjob', true) in fetchProductExports(). It’s now entirely your responsibility, which is the point.
isValidFile()’s || no longer short-circuits, so cache expiry and --force actually do something again. Now product-export:generate <sales-channel-id> <product-export-id> --force genuinely regenerates the file every time you call it.
Put each export on its own staggered cron line instead of letting them all become „due“ together, e.g.:
Sequential, predictable, one export’s memory footprint at a time — no more guessing which exports happened to line up this hour. And before you flip the switch, run that SELECT ... is_running = 1 query once: any export still stuck from a previous crash needs the manual reset regardless, or it stays invisible to everything, scheduler or CLI, forever.
TL;DR
product-export:generate silently no-ops (even with --force) for any export flagged „Generate via scheduler,“ because ProductExportFileHandler::isValidFile() treats generateByCronjob = true as always-valid whenever the file already exists — cache expiry is never checked. Separately, the scheduler path has no crash recovery: product_export.is_running is set before generation and only cleared on full success, so a worker that gets OOM-killed mid-export leaves that flag stuck at 1 forever, and shouldBeRun() silently skips the export on every future tick — no error, no log, no retry. The scheduled_task table itself is fine and reschedules normally; it’s the export’s own is_running column that gets orphaned. Fix: uncheck „Generate via scheduler“ per export, reset any is_running = 1 rows by hand once, and run each export on its own staggered cron line with --force.
Had your own feed silently stop updating and spent an afternoon staring at an unhelpful CLI command? Drop me an email.
Found in Shopware 6.7.0.0: Content/ProductExport/Service/ProductExportFileHandler.php:57-64,88-97 (isValidFile/isCacheExpired), Content/ProductExport/Service/ProductExporter.php:72-85 (createFile), Content/ProductExport/Command/ProductExportGenerateCommand.php:45-65, Content/ProductExport/Struct/ExportBehavior.php:10-23, Content/ProductExport/ScheduledTask/ProductExportGenerateTaskHandler.php:41-131 (run/fetchProductExports/shouldBeRun), Content/ProductExport/ScheduledTask/ProductExportPartialGenerationHandler.php:130-151,153-215 (runExport sets isRunning, finalizeExport clears it), Content/ProductExport/ProductExportDefinition.php:68,75 (generate_by_cronjob/is_running fields), Framework/MessageQueue/ScheduledTask/ScheduledTaskHandler.php:92-111 (for contrast — the scheduled_task row itself reschedules fine). Admin label „Generate via scheduler“ from administration/.../module/sw-sales-channel/snippet/en-GB.json:181. Docs status verified against a fresh pull of shopware/docs on 2026-07-21: resources/references/core-reference/commands-reference.md:294 lists product-export:generate in one line with no mention of the cronjob gating; guides/hosting/infrastructure/scheduled-task.md and its debugging_scheduled_tasks.md snippet describe scheduled_task states and manual commands but say nothing about per-export is_running or the missing crash recovery. Not live-tested against an actual OOM kill in this session — behavior traced from source, not reproduced.