magento: is there a way to "run profile" with cron?

magento: is there a way to "run profile" with cron?

August 18, 2026 · Illustrated author avatarBy Stefan Bogdanescu
magento: is there a way to "run profile" with cron?

Automating Magento Export Profiles via Cron Job: A Comprehensive Guide

As an experienced e-commerce developer, I frequently encounter scenarios where clients need to automate recurring tasks within their Magento stores. One such task is running export profiles on a scheduled basis. In this guide, we’ll explore how to set up a cron job in Magento 1.6 to trigger the execution of an export profile.

Understanding the Magento Cron System

Magento utilizes a built-in cron system for scheduling and executing tasks at specific intervals. The core cron configuration file is located at app/etc/crontab.xml. This file defines the available cron jobs, their frequency (default or custom), and the corresponding observer classes that handle the execution.

To add a new cron job, we need to extend this default XML configuration. We’ll create a new cron job entry pointing towards an observer class responsible for running our export profile.

Creating the Cron Job Observer

First, let’s develop the observer class that will run the desired export profile. Create a new file named Appname_ExportProfileObserver.php in your custom module (assuming you have a namespace and module called “Appname”).

// app/code/local/Appname/Module/Model/Observer.php
class Appname_ExportProfileObserver
{
    public function runExportProfile($observer)
    {
        // Load the export profile model
        $profile = Mage::getSingleton('dataflow/profile');
        $profile->load(123);  // Change 123 to your desired profile ID

        try {
            $profile->run();
            Mage::log("Export profile executed successfully.", null, 'your_log_file.log', true);
        } catch (Exception $e) {
            Mage::logException($e);
        }
    }
}

In this example, we’re loading an existing export profile with the ID 123 and running it. Make sure to replace 123 with your actual profile ID.

Configuring the Cron Job Entry

Next, we need to add a new cron job entry in our custom module configuration file config.xml. Update the <crontab> section as follows:

<config>
    <global>
        <!-- Add this inside the <crontab> section -->
        <crontab>
            <jobs>
                <your_export_profile_job_code>
                    <schedule>< minute></schedule>
                    <run><model>appname_module/observer::runExportProfile</model></run>
                </your_export_profile_job_code>
            </jobs>
        </crontab>
    </global>
    <!-- Rest of the configuration -->
</config>

Replace your_export_profile_job_code with a unique identifier for your cron job and update <minute> to specify the frequency (e.g., 0 0 * * * for daily at midnight).

Setting Up the Cron Job in Magento Admin

To enable our custom cron job, we need to refresh the cron configuration from the Magento admin interface:

  1. Log in to your Magento admin panel.
  2. Navigate to System > Configuration > Advanced.
  3. Click on the “Cron” tab under “Advanced.”
  4. Change the value of “Scheduled Jobs Ahead for (minutes)” and click “Save Config.”
  5. Finally, run the cron manually by clicking “Run Cron Job Now” in the admin panel.

Conclusion

Automating Magento export profiles via cron jobs is a powerful way to streamline your data management processes. By following this comprehensive guide, you can successfully set up scheduled exports without manual intervention.

Remember that proper testing and monitoring are essential when implementing automated tasks. Regularly review your log files (as configured in our observer) to ensure smooth operation and address any exceptions that may arise during the export process.

For more advanced Magento development techniques and best practices, I recommend exploring the extensive resources available at LaravelCompany.

Magento 1 Extensions Configuration Cron

Our network