-
-
Save avocadoslab/dff5744820844664a23bdb21734000c8 to your computer and use it in GitHub Desktop.
Programmatically running a Magento Dataflow Profile export and appending timestamp to filename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('app/Mage.php'); | |
umask(0); | |
Mage::app(); | |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); | |
ini_set('memory_limit', '2048M'); | |
$profile_id = 44; | |
$profile = Mage::getModel("dataflow/profile")->load($profile_id); | |
$admin_user = Mage::getModel('admin/user')->setUserId(0); | |
Mage::getSingleton('admin/session')->setUser($admin_user); | |
$profile->load($profile_id); | |
if (!$profile->getId()) { | |
echo 'Error'; | |
exit(); | |
} | |
$filename = 'es-catalog_backup-' . time() . '.csv'; | |
$gui_data = $profile->getGuiData(); | |
$gui_data['file']['filename'] = $filename; | |
$profile->setGuiData($gui_data); | |
$profile->save(); | |
$profile = Mage::getModel("dataflow/profile")->load($profile_id); | |
Mage::register('current_convert_profile', $profile); | |
$profile->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment