1

I'm looking for a way to call the magento export (System->Import/Export->Export) product export from an URL for a 3rd party system. So I want something like https://my.domain.com/bla/blub/export.php?filterAttribute=2 and that shall return a csv of all products with filterAttribute 2. I managed to do this by using dataflow export and then readfile() to the client, just to realize that this is missing lots of attributes.

So, currently I basically do something like:

$profile = Mage::getModel("dataflow/profile")->load($profileId);
$adminUser = Mage::getModel('admin/user')->setUserId(0);
Mage::getSingleton('admin/session')->setUser($adminUser);
$profile->load($profileId);
$guiData = $profile->getGuiData();
$guiData['product']['filter']['filterAttribute'] = 2;
$profile->setGuiData($guiData);
$profile->save();
$profile = Mage::getModel("dataflow/profile")->load($profileId);
Mage::register('current_convert_profile', $profile);
$profile->run();
readfile($exportFile);

Now, how do I transfer this simple code to Import/Export? Magento 1.9

1 Answer 1

0

Once you know what to google for it is rather easy:

require_once('app/Mage.php');
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
ini_set('memory_limit', '2048M');

$skipAttrs = array();

$data = array(
    "entity" => 'catalog_product',
    "file_format" => 'csv',
    "export_filter" => array(
        "seller_id" => '6'
    ),
    "skip_attr" => $skipAttrs
);

$model = Mage::getModel('importexport/export');
$model->setData($data);
echo $model->export();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.