Magento: is there a way to “run a profile” with cron?

I have an export profile on magento 1.6 and I can start it manually ("Run profile in pop-up window"), but I need it to start automatically every day. Is there a way to create a cron job to do it somehow?

+1
source share
3 answers

I used the following taken from (note: broken link, code copied below):

http://www.premasolutions.com/content/magento-dataflow-exportimport-form-command-line

<?php
//THIS SCRIPT JUST INITIALS THE PROFILE TO BE RUN VIA MAGENTO ADMIN "RUN PROFILE IN POPUP". Its the same thing as click just via this file that you can run via cron
$profileId = 8; // SYSTEM - IMPORT/EXPORT - ADVANCED PROFILES <-- you need to go into your magento admin and grab the exact profile ID
   
require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  
$profile = Mage::getModel('dataflow/profile');
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(0);
Mage::getSingleton('admin/session')->setUser($userModel);
$profile->load($profileId);
if (!$profile->getId()) {
    Mage::getSingleton('adminhtml/session')->addError('ERROR: Incorrect profile id');
}
  
Mage::register('current_convert_profile', $profile);
$profile->run();
$recordCount = 0;
$batchModel = Mage::getSingleton('dataflow/batch');
echo "EXPORT COMPLETE. BATCHID: " . $batchModel->getId();

It worked correctly on 1.5.x (not yet tested on 1.6.x, sorry).

If this works, you only need to schedule the cron job to automatically invoke the script.

Regards, Alessandro

-2
source

, , , , , ,

Mage::getModel("dataflow/profile")
    ->load(5) // id of the desired profile
    ->run();
+2

Here is the cron script from 1.4.xx that will run the profile. Script Export Profile

In version 1.4.xx and later, provided the resources are correct, in the final part, where he opens the dataflow_batch_export table and truncates it, it can be commented if your system correctly clears the contents when the export is completed. For some time, we had problems with the growth of the dataflow_batch_import and dataflow_batch_export tables due to the inability to clear after any operation, since a memory leak interrupted their correct operations.

+1
source

All Articles