How To Export Products in Magento 1 From Terminal Via SSH

Prerequisites

You will need SSH access to your Magento website.

 

First you will need to find id of your data profile. Go to your Magento backend and:

System > Import/Export > Dataflow – Profiles

By default, for exporting products it should be id 1.

Create a file custom_product_export.php in the root of your magento app with following code:

 

<?php


set_time_limit(0);
// 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 = 1; // ID of your data profile

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();

now run the script with

php custom_product_export.php

 

If you will get error Allowed memory size exhausted, try run it like this

php -dmemory_limit=50G custom_product_export.php

Your Exported .csv file will be saved in magento root var/export/ folder.


Lukas
Lukas Stranovsky
I am the guy who made this. Sorry for typos.