Last active
May 16, 2017 22:11
-
-
Save tegansnyder/1595961ee572739de079 to your computer and use it in GitHub Desktop.
Programmatically running a Magento Dataflow Profile export and appending timestamp to filename
This file contains 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(); |
Thanks for this. Very useful. FYI don't forget to mention your dataflow profile id you wish to export on this line
$profile_id = 44;
I am facing following issue.
PHP Fatal error: Call to a member function setDataflowProfile() on a non-object in /chroot/home/helllooo/heloooo.com/html/app/code/core/Mage/Dataflow/Model/Profile.php on line 204
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to select certain fields only?
For now i follow this