Magento - Export products (with Dataflow) to CSV with a cronjob

Magento - Export products (with Dataflow) to CSV with a cronjob

October 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Export products (with Dataflow) to CSV with a cronjob

Exporting Magento Products via Dataflow to CSV with a Scheduled Cronjob

Exporting product data from your Magento store is a crucial task for inventory management, marketing purposes, or integrating with third-party systems. While the built-in Dataflow feature offers robust export capabilities, configuring an automated nightly cron job can be challenging.

In this guide, we’ll walk you through the process of exporting your Magento products using Dataflow and scheduling it via a cron job to run every 24 hours at midnight.

Prerequisites

Before proceeding, ensure you have the following in place:

  • Access to your server’s command line interface (CLI) with appropriate permissions.
  • Familiarity with basic cron syntax and scheduling concepts.

Step-by-Step Guide

Step 1: Setting up Dataflow for CSV Export

First, we need to configure our Dataflow profile to export the desired product data to a CSV format. Here’s how:

  1. Navigate to System > Import/Export > Dataflow - Batch Export.
  2. Click on “Add New Profile” in the top right corner.
  3. Enter a name for your profile and select “CSV” as the file format.
  4. In the “Entity Type” dropdown, choose “Products”.
  5. Select the desired store view and set other options according to your needs (e.g., include thumbnails, export products with specific attributes).
  6. Click on “Save Profile”.

Step 2: Generating the Export CSV File

Now that our Dataflow profile is set up, we can create a script to trigger the export process.

  1. Create an SSH shell script named export_products.sh in your Magento root directory.
  2. Add the following content to the script:
#!/bin/bash

# Set the path to the magento bin directory
MAGENTO_BIN="vendor/magento/bin/magento"

# Run the dataflow batch export command
$MAGENTO_BIN setup:dataflow-export --batch-size 1000 -f products.csv
  1. Make sure the script has executable permissions:
chmod +x /path/to/your/magento/installation/export_products.sh

Step 3: Scheduling the Cron Job

To schedule our export script to run every night at midnight, we’ll create a new cron job.

  1. Open your server’s crontab file using:
crontab -e
  1. Append the following line to the end of the file, replacing /path/to/your/magento/installation/ with the actual path to your Magento installation directory:
0 0 * * * /bin/bash /path/to/your/magento/installation/export_products.sh >> /path/to/your/logs/export_log.log

This line tells cron to execute our export_products.sh script every night at midnight, and redirect the output (including any errors) to a log file named export_log.log.

  1. Save and close the crontab editor.

Monitoring the Export Process

To ensure your exports are running smoothly, regularly check the cron job’s log file for any errors or exceptions:

tail -f /path/to/your/logs/export_log.log

If everything is configured correctly, you should see the CSV export files (e.g., products.csv) appearing in your Magento root directory every 24 hours.

Troubleshooting Tips

  • Double-check that your cron job file permissions are set to executable (chmod +x).
  • Make sure the Dataflow profile’s settings match your desired export criteria.
  • Monitor the log file for any error messages or missing dependencies.

Conclusion

Automating product exports in Magento using Dataflow and cron jobs is a powerful combination that saves time and ensures consistent data backups. By following this guide, you can now efficiently generate nightly CSV product exports tailored to your business needs without manual intervention.

Remember that the key to successful automation lies in regular monitoring and occasional fine-tuning of your export settings and scripts.

Do you need further assistance with Magento development or any other technical challenges? Reach out to our team at Laravel Company for expert guidance and solutions.

Catalog Security Configuration Cron

Our network