jruzafa
9/23/2014 - 12:47 PM

manual-dataflow-profile.php

<?php

/*
Author: Tegan Snyder <tsnyder@tegdesign.com>
Example of running a Dataflow profile via command line
you can change the profile_id to the one you want to 
run and issue:
time php manual-dataflow-profile.php
note you may need to increase the memory_limit in php cli's php_cli.ini
RHEL linux copy /etc/php.ini to /etc/php_cli.ini and make changes there then restart Apache.
*/

require_once('app/Mage.php');
umask(0);
Mage::app('admin');

$log_file = 'my-manual-run.log'

Mage::log('Dataflow Started', null, $log_file);

$profileId = 21;

Mage::log('profile started: ' . $profileId . ' at ' . date('Y-m-d H:i:s'), null, $log_file);

$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::log('error: ' . $profileId . ' - incorrect profile id', null, $log_file);
	return;
}

Mage::register('current_convert_profile', $profile);
$profile->run();

Mage::log('profile ended: ' . $profileId . ' at ' . date('Y-m-d H:i:s'), null, $log_file);
Mage::log('-----------------------------------', null, $log_file);