Shopware Product Export via CLI

The product-export:generate command can be used to generate single or multiple product exports, e.g. for Google Shopping in Shopware.



Command syntax

The following syntax is available in Shopware:

bin/console product-export:generate <storefront-sales-channel-id> (<export-id>) (--force) (--include-inactive)


Parameter Required Description
storefront-sales-channel-id Yes The storefront sales channel ID of the respective sales channel
export-id No The exact ID of the export
-force No Forces the regeneration
-include-inactive No Also performs generation for inactive product exports



Execution types

Exports can be generated either via the Shopware message queue or synchronously via the CLI command.


Execution via the message queue (asynchronous)

To map the execution via the Shopware Message Queue, the option generate via scheduler must be activated. Otherwise the export is generated synchronously via the CLI command.


Execution via the CLI command (synchronous)

To map the execution synchronously via the CLI command, the option generate via scheduler must be deactivated. Otherwise the export is generated asynchronously via the message queue.




Determination of the correct parameters

Unfortunately, Shopware does not provide the storefront-sales-channel-id and the id of the export in the Shopware administration. For this reason, the parameters must be determined via the database.


The Shopware database can be accessed in the following ways, among others:

  • PhpMyAdmin
  • Adminer
  • Direct MySQL connection


To do this, call up the product_export table and determine the required parameters using the database columns:

  • id
  • storefront_sales_channel_id


Use the parameters determined to compose the CLI command. The correct syntax can be found at the beginning of the article.



Example script

You can use the following sample script to generate all exports for a specific sales channel. To do this, create a new file in the document root directory of your store.\n\nExample:

touch /var/www/creoline-demo.com/product-exports.sh
#!/bin/bash

echo "[$(date '+%d/%m/%Y %H:%M:%S')] Generating Exports for Sales-Channel #1"
/usr/bin/php -d memory_limit=-1 /var/www/creoline-demo.com/bin/console product-export:generate 082...5c00 --force
echo "[$(date '+%d/%m/%Y %H:%M:%S')] [DONE] Sales-Channel #1"

echo "[$(date '+%d/%m/%Y %H:%M:%S')] Generating Exports for Sales-Channel #2"
/usr/bin/php -d memory_limit=-1 /var/www/creoline-demo.com/bin/console product-export:generate 082...5c00 --force
echo "[$(date '+%d/%m/%Y %H:%M:%S')] [DONE] Sales-Channel #2"


The script then requires execution authorization:

chmod +x /var/www/creoline-demo.com/product-exports.sh


The script can then be executed using the following command:

/var/www/creoline-demo.com/product-exports.sh


If you want to execute the script automatically, you can either create a cronjob via our customer center or schedule the execution via crontab.


crontab -e

# Generate Product Exports every day at 00:00
0 0 * * * * /var/www/creoline-demo.com/product-exports.sh