Magento Extensions:Magento Order Export Module

From XTENTO Support Wiki
Jump to: navigation, search
Extension Logo

Contents

Overview

Sales Export functionality for Magento, integrated into the Magento Backend, including an export manager and a highly flexible output creation technique. Connect your Magento store to almost any ERP, CRM, warehouse, dropshipping or shipping system. Export orders, invoices, shipments, credit memos in an unlimited amount of profiles to an unlimited amount of remote/local destinations, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

Interested in this Magento Extension?

Head over to our store to purchase this extension: Magento Order Export Module

Got questions? Feel free to contact us! Contact Form

Setting up the extension

After installing the extension as instructed in our general installation guide, please go to System > XTENTO > Sales Export Configuration. Please enter your license key there and set Module Enabled to "Yes".

Upgrading from the old Magento Order Export Module

If you downloaded the extension before 1/1/2013, please go to My Downloadable Products in our store to download the latest version of the extension. You're using the old version if the menu entry Sales > Sales Export does not exist. The old extension version used Sales > Order Export. Both modules run stand-alone which means you can install them both at the same time, then make sure the new version works as expected, and disable the old version as described below.

You have to set up new export profiles at Sales > Sales Export. You can copy the XSL Templates from the old CSV/XML/Custom types you had from System > Configuration > Admin > Order Export Settings (this section is not used anymore - any settings are made at Sales > Sales Export)

To disable the old order export module, please open the file app/etc/modules/Sebastian_Export.xml. Look for the "active" node saying true and replace true with false. Save the file and refresh the Magento cache.

Configuring the extension

Before proceeding with the configuration, please make sure you're using the latest version of the extension. If you downloaded the extension before 1/1/2013, please go to My Downloadable Products in our store to download the latest version of the extension.

Export Profiles

Export Profiles
Editing an export profiles

Export profiles can be set up for manual and automatic exports. Every profile contains information about the data to export (i.e. orders/invoices/shipments/credit memos), the output format, when, how, and where to export to, as well as some other settings. The extension supports an unlimited amount of different profiles.

To set up new export profiles or to modify existing export profiles, please go to Sales > Sales Export > Export Profiles.

Setting up a new export profile is easy. Press the "Add New Profile" button. You will then be asked to select the entity (date type, i.e. orders/invoices/shipments/credit memos) to export, as well as to assign a name to the profile which can be used to identify the export profile in export logs. Press the Continue button.

You will then be presented with the profile configuration. The configuration of export profiles is split into several different sections ("tabs") which are explained below.

1) General Settings

General Configuration
Name: Enter the name of the profile. This name will show up in execution logs and will be used to identify the profile when exporting manually.
Enabled: If set to "No", this profile won't show up for manual exports nor will automatic exports be made.
Export Type: Can't be changed after profile creation. Defines which entity (data type) gets exported. Available entities:

 Entity  Description
Order Export orders placed
Invoice Export invoices created
Shipment Export shipments created
Credit Memo Export credit memos created
Customer Export customers created

Export Settings
Save local copies of exports: If set to yes, a copy of every export made will be saved in the ./var/export_bkp/ directory. This is especially useful if you're exporting to FTP destinations, because only then if this is set to "Yes" a local copy of the exported file will be kept so you can download it in Magento from the execution log or directly from the Magento server for whatever reason. Default value is "Yes".

2) Export Fields

This section defines which data will be made available for exporting. Only the types selected will be available in the XSL Template / CSV/XML output format. You can leave all fields turned on unless you want to speed up the export when exporting masses of orders/invoices/shipments/credit memos.

Attention: This tab was removed in version 1.2.2. It is not required anymore, as an intelligent field loading mechanism has been introduced instead.

3) Export Destinations

Select the export destinations where exported files should be saved/sent to after exporting simply by checking the checkbox right before the Destination ID.

Please refer to the Export Destinations section below to get an idea how to configure and set up destinations.

4) Output Format

This section defines the output format the profile will create. The extension uses so called XSL Templates to create output formats.

XSL Template

>>> Don't want to create the XSL Template yourself? Have us create the XSL Template for you - we will take care of the output format creation for you. Check out our XSL Template Creation Service. Please contact us before you purchase the XSL Template Creation Service. <<<

When exporting, internally a XML document is created by the module that contains ALL information about the exported objects: billing data, shipping data, payment data, item data and so on. A so called XSL Template then gets applied to this XML document, transforming the XML data into (almost) any other output format. The XSL Template basically "translates" the XML document into whatever output format you require. It is possible to create CSV, XML, ASCII, TXT, ... formats - just any format that is based on text.

The fields available for export (and thus the names used to access them in XSL Templates) can be found by clicking the Show fields available for export button in the Output Format section. A new window will open where the fields and the level they are on (object level, item level, billing level, ...) can be seen. At the very top of the window that was opened, a link called "Show raw XML" can be found which shows the internal XML we talked above. This is the XML document that gets "transformed" by the XSL Template.

A basic XSL introduction can be found here: http://www.w3schools.com/xsl/

Template Structure

We have modified the concept of XSL Templates slightly. In order to be able to create multiple output files with one profile, we have added <file> nodes to the XSL Template structure. Each XSL Template is contained in a <file> node, and multiple <file> nodes under the <files> node will create multiple output formats. Your XSL Templates structure should look like this:

<?xml version="1.0"?>
<files>
<file filename="export-%exportid%.csv">
...XSL Template here...
</file>
</files>

This would create one output file named export-%exportid%.csv where %exportid% is a variable and would get replaced with the export ID. If you wanted to create multiple output files, you would simply add another <file> node so it would look like this:

<?xml version="1.0"?>
<files>
<file filename="export-%exportid%.csv">
...1st XSL Template here...
</file>
<file filename="export2-another-file.csv">
...2nd XSL Template here...
</file>
</files>

Variables in the <file> node

There are several parameters (attributes) for <file> nodes:

 Variable  Description
 %d% Todays Date: Day (Two-Digit)
 %m% Todays Date: Month (Two-Digit)
 %y% Todays Date: Year (Two-Digit)
 %Y% Todays Date: Year (Four-Digit)
 %h% Current Time: Hour (Two-Digit)
 %i% Current Time: Minute (Two-Digit)
 %s% Current Time: Second (Two-Digit)
 %lastentityid% The entity_id of the last/newest object contained in the output file
 %lastincrementid% The increment_id (order/invoice/shipment/creditmemo number) of the last/newest object contained in the output file
 %lastorderincrementid% The order increment_id of the last/newest object contained in the output file
 %collectioncount% The count of objects contained in the output file
 %uuid% Random Unique ID, refer to: http://php.net/manual/en/function.uniqid.php
 %exportid% The ID of the export / execution log. Ever-incrementing and unique.

search="," replace=";"

To replace quotes (") with something else, for example a space, use: search="quote" replace=" "

XSL Template Structure

As explained above, XSL Templates are contained in <file> nodes. The XSL Template will create the actual output file created for the <file> node. Let's have a look at every line of a sample XSL Template in detail, explanations after every line. A (simple) CSV export template for the extension could look like this:

<?xml version="1.0"?> <!-- XML Declaration, leave as is -->
<files> <!-- Files node, can contain multiple <file> nodes, each defining one output format -->
<file filename="orders_%d%_%m%_%Y%.csv"> <!-- File node, contains the actual XSL Template, with parameters filename and encoding (optional) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl"> <!-- The XSL Template begins here. Namespaces get defined. Leave as is. -->
<xsl:output method="text" encoding="UTF-8"/> <!-- The xsl:output directive defines settings that apply to the whole XSL Template. Method can be set to xml for example, encoding will be output for XML files into the XML declaration of the file. More parameters can be found here: http://www.w3schools.com/xsl/el_output.asp -->

<xsl:variable name="sepstart" select="'&#34;'"/> <!-- A variable that can be accessed using $sepstart in the XSL Template. It contains &#34; which is the representation of the " character. -->
<xsl:variable name="sepend" select="'&#34;,'"/> <!-- Again, a variable. This time with the " character as well as a comma. Whenever it is called, it will output: ", -->

<xsl:template match="/">

<xsl:text>"Order Number","SKU","Quantity"&#xD;&#xA;</xsl:text> <!-- This is the header line of the CSV file. It gets output once only, the &#xD;&#xA; characters represent a line break that gets output after the header line. -->

<xsl:for-each select="objects/object"> <!-- for-each means that the template will loop through the objects/object nodes in the XML processed. So for every object (order, invoice, ...) the code below will be applied. -->
<xsl:for-each select="items/item"> <!-- Loop through items ordered -->
<!-- This means, loop through all items of an object and output the following: -->

<xsl:value-of select="$sepstart" /><xsl:value-of select="../../increment_id"/><xsl:value-of select="$sepend" /> <!-- The $sepstart variable outputs " to start a new field in the CSV file. Then using xsl:value-of select="../../increment_id" the "increment_id" field is pulled from the object level. ../../ means to get data from the "parent" level (we are looping through items and not through objects (orders). The $sepend variable then outputs ", to denote the end of the field in the CSV file. -->
<xsl:value-of select="$sepstart" /><xsl:value-of select="sku"/><xsl:value-of select="$sepend" /> <!-- Get the "sku" field on item level -->
<xsl:value-of select="$sepstart" /><xsl:value-of select="round(qty)"/> <!-- Get the "qty_ordered" field on item level and apply the round() function to it. --><xsl:value-of select="$sepend" />

<xsl:text>&#xD;&#xA;</xsl:text> <!-- Output a line break. -->
</xsl:for-each> <!-- End item foreach -->
</xsl:for-each> <!-- End object foreach -->

</xsl:template>
</xsl:stylesheet>
</file>
</files>

This template would create one output file, called orders_day_month_year.csv. It would contain one header row (defining the fields, it's optional, just so you can view column names in Excel for example), and would then loop through each <object>s <item> in the XML processed, creating one line in the CSV file for each item ordered.

Sample XSL Templates

Sample XSL Templates can be downloaded here: Sample Templates

Use them as references to learn XSL and to build your own XSL Template.

Calling PHP functions in XSL Templates

It is possible to call PHP functions in XSL Templates.

Important: In order to be able to call PHP functions in the XSL Template, please make sure your <xsl:stylesheet> tag in the XSL Template looks like this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">

You can now call PHP functions in your XSL Template.

Sample call for PHP function "FUNCTIONNAME" with two parameters:

<xsl:value-of select="php:functionString('FUNCTIONNAME', 'parameter1', 'parameter2')"/>

Examples:

<xsl:value-of select="php:functionString('number_format', price, 2, '.', '')"/> <!-- This would call the PHP number_format function on the price field --> <xsl:value-of select="php:functionString('substr', billing/firstname, -10)"/> <!-- This would call the PHP substr function on the billing/firstname field -->


An often used function is strftime, to format the date the order was placed for example.

<xsl:value-of select="php:functionString('strftime', '%d/%m/%Y %H:%M:%S', created_at_timestamp)"/>

It is also possible to call Mage::getStoreConfig from the XSL Template. Example:

<xsl:value-of select="php:functionString('Mage::getStoreConfig', 'tax/display/type', store_id)"/>

Static values

It is possible to output text (for example static values) like this in the XSL Template:

<xsl:text>Whatever you want to output goes here.</xsl:text>

This will be output as-is in the output file.

Mapping fields (if then, if then, ... else)

It is also possible to map fields and output other values based on the results of the "if" conditions.

A sample mapping would look like this: <xsl:choose>
<xsl:when test="shipping_method='abc'"><xsl:text>output this text</xsl:text></xsl:when>
<xsl:when test="shipping_method='xyz'"><xsl:text>output something else</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>nothing matches, output this</xsl:text></xsl:otherwise>
</xsl:choose>

This evaluates the value of the shipping_method field. If it's abc or xyz, it matches one of the xsl:when lines. If it doesn't match any condition, the xsl:otherwise value is output.

Conditional statements (if then ...)

For "if then, if then, ... else" conditions have a look at "Mapping fields" above.

A simple if then condition can be set up like this: <xsl:if test="shipping_method='abc'"><xsl:text>output this text if shipping_method is exactly abc</xsl:text></xsl:if>

Sample for a negotiated condition: <xsl:if test="not(shipping_method='abc')"><xsl:text>output this text if shipping_method is NOT abc</xsl:text></xsl:if>

Arithmetic operations / Calculations

It is possible to calculate values based on fields in the XSL Template. The following arithmetic operations can be used:

 Arithmetic Operator  Description
+ Addition, e.g. <xsl:value-of select="subtotal + custom_field"/>
- Subtraction, e.g. <xsl:value-of select="grand_total - tax_amount"/>
* Multiplication, e.g. <xsl:value-of select="subtotal * 1.19"/>
div Division, e.g. <xsl:value-of select="subtotal div custom_field"/>
Note: You cannot use / for divisions. The "div" operator must be used.
mod The "modulo" operator can be called like this to get the remainder of a division: <xsl:value-of select="position() mod 2"/>
Two line items get output for one item ordered

This is not a bug. Magento saves both the configurable as well as the simple product in the database, so both get output. The "configured" price gets saved with the configurable product only, so the simple product line will say "price 0".

First of all you would set up a product filter which does not show configurable products. To do so, go to the "Filters / Actions" tab and hide configurable products there using the "Hidden Product Types" option. (Item filter feature introduced in version 1.1.4)

To grab the right price (or any other field from the parent product, the configurable product), instead of your value-of select="price" field:

<xsl:value-of select="$sepstart" /><xsl:value-of select="price"/><xsl:value-of select="$sepend" />

Use this:

<xsl:choose>
<xsl:when test="string-length(parent_item_id/text())!=0">
<xsl:value-of select="$sepstart" /><xsl:value-of select="parent_item/price"/><xsl:value-of select="$sepend" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$sepstart" /><xsl:value-of select="price"/><xsl:value-of select="$sepend" />
</xsl:otherwise>
</xsl:choose>

This works for any field, you can retrieve any field from the parent item using the parent_item node.

Replacing characters in all fields

You can define certain characters that get replaced in ANY field. This can be important for example if you want to set up a CSV format, where no comma or semi-colon may show up in field values.

Setting this up is easy. In your XSL Template, modify your <file> node like this: <file filename="file_name.csv" search=",;" replace="--">

This would replace both commas as well as semi-colons with dashes. The first parameter search defines which characters you want to replace. The second parameter replace defines with which character these characters get replaced.

(This feature was introduced in version 1.1.8)

Outputting custom date/time formats

If you want to output the order date in a custom date format, do it like this:

<xsl:value-of select="php:functionString('strftime', '%Y-%m-%d', created_at_timestamp)"/>

You can pass any parameters of the strftime variable there.

Exporting custom options

You can access each custom option separately using the name of the custom option:

<xsl:value-of select="custom_options/custom_option[name='Exact name of the custom option goes here']/value"/>

Date calculations

It is also possible to add 1 day to the order date for example.

<xsl:value-of select="php:functionString('strftime', '%Y-%m-%d', php:functionString('strtotime', concat(php:functionString('date', 'Y-m-d', created_at_timestamp), ' +1 day')))"/>

Creating CSV formats using XSL

Please refer to the sample XSL Templates.

Creating TAB delimited formats using XSL

Use a CSV XSL Template to start. You only have to replace the delimiter in the header line and adjust the sepstart and sepend variables.

The sepstart and sepend variables located at the top of the template need be set like this: (&#09; is the tab character)

<xsl:variable name="sepstart" select="''"/>
<xsl:variable name="sepend" select="'&#09;'"/>

Also if this was your header line: <xsl:text>Date,Order #,Purchased From (Store),Billing First Name</xsl:text><xsl:text>&#xD;&#xA;</xsl:text>

You would simply replace all the commas with &#09; as well so it would look like this:

<xsl:text>Date&#09;Order #&#09;Purchased From (Store)&#09;Billing First Name</xsl:text><xsl:text>&#xD;&#xA;</xsl:text>

Creating XML formats using XSL

Please refer to the sample XSL Templates.

Creating ASCII formats using XSL

Creating fixed-length formats is possible as well using XSL.

Using the PHP sprintf function which can be called from the XSL Template, fixed length fields can be set up. Example:

<xsl:value-of select="php:functionString('sprintf', '%-10.10s', 'ABC')"/> <xsl:value-of select="php:functionString('sprintf', '%-7.7s', ../../increment_id)"/>

This would output two fields, the first being 10 characters long (and cut off if longer than 10 chars) and expanded with spaces, and the second being 7 characters long containing the increment_id cut off after 7 characters, and if shorter, expanded with spaces.

Testing your template

When editing your profile and working on your XSL Template, you can easily test the template you created by going to Output Format > XSL Template . Just paste your XSL Template and press the Test XSL Template button. Errors will be displayed, if the template is well-formed, the output file(s) created will be displayed. You can also use the editor there to develop your XSL template.

Don't want to create the XSL Template yourself? Have us create the XSL Template for you - we will take care of the output format creation for you. Check out our XSL Template Creation Service.

Adding own export classes / Rewriting existing export classes

You can create own export class and register them in the export module.

To rewrite the items class, create a copy of the Model/Export/Data/Shared/Items.php file, and save it in the Model/Export/Data/Custom/Order/ folder.

Then rename the file etc/xtento/export_data.own.xml.sample to etc/xtento/export_data.own.xml and insert the following export class:

<config>
<data>
...
<items>
<class>xtento_orderexport/export_data_custom_order_items</class>
</items>
...
</data>
</config>

This class manages registered export classes. As the <items> node already exists in the built-in export_data.xml file, your custom defined version will be used instead. You can also register other export classes there, but make sure to not use identifiers which already exist in the export_data.xml file, unless you want to rewrite export classes.

You can now customize the Items.php output in your own, copied class and still have the extension upgradeable.

Attention: This features requires version 1.3.2 or newer.

5) Filters / Actions

Filters

Filters set up will be applied to both manual as well as automatic exports.

Order/Invoice/Shipment/Credit Memo filters
Item filters

Hidden Product Types: The selected product types won't be exported and won't show up in the output format for this profile. You can still fetch information from the parent product in XSL using the parent_item/ node.

"Export only if the following conditions are met" filter

It is possible to set up almost any filter in addition to the above filter using the "Export only if the following conditions are met" section. You can set up complex filters there, for example only export if an item was found where the price is greater than 0 and if the billing country is US.

Please note this filters only the objects to export. If you have a filter that matches "if an item is found where manufacturer = X", and an order is exported where two items are contained, one where manufacturer = X and one where manufacturer = Y, still the whole order and both items will export. If you want to avoid this, you have to set up a filter both at "Filters / Actions" as well as in the XSL Template using an xsl:if condition like this:

<xsl:if test="product_attributes/manufacturer='X'">...whole value-of select fields go here...</xsl:if> <!-- This will only output items where the product attribute manufacturer is "X". -->

Actions

There are certain actions that can be applied to orders after exporting:

6) Manual Export

These settings only apply to manual exports.

Save files on destinations for manual exports: Do you want to save exported files on the configured export destinations when exporting manually? Or do you just want them to be saved on the configured export destinations for automatic exports? This is especially useful if you want to use the manual export without sending export files to the configured FTP/HTTP/whatever destinations.

7) Automatic Export

Any filters set in the "Filters / Actions" section will be applied when exporting automatically. It is possible to set up cronjob exports as well as event-based exports for one profile.

Cronjob Export

If you want to automate exports, you can set up cronjobs for profiles which execute the export for this profile at certain times automatically. First of all, make sure to set up your Magento cronjob as explained here. You can easily control the cronjob status right from the export module, by going to "Cronjob Export" when editing a profile. The Cronjob Status field will contain information about the status of the cronjob and whether any action is required or not.

To enable cronjob exports for this profile, simply set Enable Cronjob Export to "Yes". Select the Export Frequency of how often you want the export to run. That's it.

It is also possible to set up multiple, different cronjobs for one profile, for example if you wanted the cronjob to run at certain times during the week and only at 10pm on weekends. To do so, select "Use custom export frequency" from the Export Frequency dropdown, and enter one or more cron expressions separated by a semi-colon (;) in the Custom Export Frequency field. You can enter an unlimited amount of cron expressions there separated by semi-colons, just make sure they are valid cron expressions.

Example custom cron expression calling the cronjob for a profile at 8am, 1pm, 3pm at every full hour from Monday to Friday: 0 8,13,15 * * 1-5

Further examples:

Minute Hour Day Month Weekday Cron Expression Description
0 0 * * * 0 0 * * * Every day at 00:00
5 * * * * 5 * * * * Five minutes after every full hour
*/5 * * * * */5 * * * * Every 5 minutes
59 23 * * 0 59 23 * * 0 Every Sunday (Sunday can be 0 or 7) at 11:59pm
20,30 1 * * 1-5 20,30 1 * * 1-5 Monday to Friday at 01:20am and 01:30am
0 1 1-7 12 1 0 1 1-7 12 1 From Dec 1 to Dec 7, as well as on every Monday in December at 00:00

Important: Automated exports will only be made if the profiles status (under General Configuration) is "Enabled".

Event-based Export

Magento dispatches events to Magento modules when certain things happen. For example, Magento would dispatch an event after the order has been saved, or placed, or after the invoice has been created. The export module is able to "listen" and wait for these events, and once they've been called, to export data.

In the Automatic Export tab of a profile you can select the events the profile should be exporting upon. Simply select the checkboxes of events you want to export upon and save the profile. Whenever one of these events get called, the profile will export just this one object that the event refers to: For example the invoice that was created, or the order that has been created. In addition, any filters set up at Filters / Actions in the profile will be taken into account.

The following events are available for exporting out of the box:

 Event  Available for exports of  Description
sales_order_save_after Orders Called whenever an order is saved in Magento, i.e. also when it's modified, for example when the order status changes. Note: Orders get saved in Magento quite often, for example when the order status changes. To avoid multiple exports using this event, set Export only new objects at Filters / Actions to "Yes" or, alternatively, set a filter that only status "Processing" gets exported for example.
sales_order_place_after Orders Called once after an order has been placed, be it in the checkout, by the admin, or third party scripts.
sales_order_invoice_register Orders, Invoices Called once after an invoice has been created. When exporting orders, the order belonging to the invoice will be exported. When exporting invoices, the invoice created will be exported.
sales_order_invoice_pay Orders, Invoices Called when an invoice has been marked as paid, i.e. when the payment gateway or admin tells Magento that the order has been paid. When exporting orders, the order belonging to the invoice will be exported. When exporting invoices, the invoice created will be exported.
sales_order_shipment_save_after Orders, Shipments Called once a shipment has been created. When exporting orders, the order belonging to the shipment will be exported. When exporting shipments, the shipment created will be exported.
sales_order_creditmemo_save_after Orders, Credit Memos Called once a credit memo has been created. When exporting orders, the order belonging to the credit memo will be exported. When exporting credit memos, the credit memo created will be exported.

Important: Automated exports will only be made if the profiles status (under General Configuration) is "Enabled".

8) Profile Execution Log

The profile execution log shows any exports made using this profile, be it manual or automatic. It is also possible to download the exported files, however, only if Save local copies of exports is set to "Yes" under General Configuration.

9) Profile Export History

This section shows which objects (orders, invoices, shipments, credit memos) were exported by this profile and when. If the Export only new objects filter is set to "Yes", you should only see every object once there. If you want to re-export an object that has been already exported and is not exported because Export only new objects is set to "Yes", you can remove the entry from the export history grid by selecting Delete Entry.

Export Destinations

Export Destinations
Editing an export destination

Export destinations are the actual "destinations" where exported files will be sent to/saved on. If your only goal is to manually export and download orders from the Magento backend, you won't need to set up any export destinations. If you have to send exported files to remote FTP servers or certain local directories on the Magento servers, you will have to set up export destinations.

The module supports an unlimited amount of different export destinations. The following destination types are supported:

 Destination Type  Description
Local Directory Exports get saved in a local directory on the Magento server
FTP Server Exports get sent to a remote FTP(S) server
SFTP Server Exports get sent to a remote SFTP server. Supports SFTPv3 only.
HTTP Server Exports get sent to remote HTTP servers by sending a POST request for example
E-Mail Recipient(s) Exports get sent to email recipients, with the exported files attached
Webservice/API Exports get sent to webservices/API. The webservice/API code must be set up by you.
Custom Code / Custom Class Exports can be handled by a custom class you can set up. This class could parse and modify, and then send the exports for example.

Setting up Export Destinations

To set up export destinations, go to Sales > Sales Export > Export Destinations. You can modify existing destinations there or add new destinations.

Setting up a new export destination is easy. Press the "Add New Destination" button. You will then be asked to select the destination type (to which type of "server" the exported files will be sent to) to create, as well as to assign a name to the destination which can be used to identify the destination in export profiles and logs. Press the Continue button. You will then be presented with the destination configuration.

Destination Types

Local Directory

This destination type will simply save the exported file in a local directory on the Magento server.

If you begin the path with a dot in front of it, for example ./var/export/ the path will be relative to the Magento root directory. This means the file would be saved in the /var/export/ directory located in the root directory of Magento.

Supplying an absolute path is possible by beginning the path with a dash, for example: /var/www/tmp/export/

Please make sure the path you enter is writable by the webserver. It must be possible for the webserver to save the file in that directory, otherwise a warning will be shown/logged.

FTP Server

The FTP destination type supports uploading files to FTP servers.

The following configuration must be entered for FTP servers:

 Field Name  Description
IP or Hostname Enter the hostname (address) or IP address of the FTP server you want to upload files to
Server Type You can select FTP or FTPS server types. Please note that FTPS (FTP "with SSL") is only supported if PHP has been compiled with OpenSSL support and also the PHP implementation is quite picky with regards to which servers it supports.
Port Enter port of FTP server. This is port 21 usually.
Username Enter the username used to log into the FTP server
Password Enter the password used to log into the FTP server
Timeout Connection timeout in seconds after which the connection will fail
Enable Passive Mode If your server is behind a firewall, or if the extension has problems uploading the exported files, please set this to "Yes".
Export Directory Enter the directory into which files should be uploaded to
Potential issues: Connection/upload fails
SFTP Server

The SFTP (Secure File Transfer Protocol) destination type is identical with the FTP destination type, except that it sends files to a SFTP server. This destination type supports SFTPv3 servers only. To find out which SFTP server version your server is using, connect to it using WinSCP (download here and look at the very bottom status bar. It will show the SFTP server version.

Most of the time port 22 is used for SFTP servers.

Potential issues: Connection/upload fails
HTTP Server

To export data to a HTTP server, please follow the following steps:

  1. Go into the app/code/local/Xtento/OrderExport/Model/Destination/ directory and rename the file "Http.php.sample" to "Http.php"
  2. Enter the function name you want to call in the Http.php class in the field below.
  3. Open the Http.php file and add a function that matches the function name you entered. This function will be called by this destination upon exporting then.

Example: If you enter server1 in the function name field below, a method called server1($fileArray) must exist in the Http.php file. This way multiple HTTP servers can be added to the HTTP class, and can be called from different export destination, separated by the function name that is called. The function you add then gets called whenever this destination is executed by an export profile.

Important: Please make sure the function you enter exists like this in the app/code/local/Xtento/OrderExport/Model/Destination/Http.php file: public function yourFunctionName($fileArray) { ... }

Potential issues: Connection fails
  1. Please go through the steps above one or two more times again to make sure you really set it up exactly as explained.
  2. Please make sure there is no firewall blocking outgoing HTTP connections. Get in touch with your hoster if in doubt.
E-Mail Recipient(s)

This destination type simply sends an email to the configured recipients, with the exported files attached.

The following configuration must be entered for this destination type:

 Field Name  Description
E-Mail From Address Enter the email address that should be set as the sender of the email, i.e. what shows up in the "From" field
E-Mail Recipient Address Enter the email address where exported files should be sent to. Separate multiple email addresses using a comma. Example for two email addresses: email1@store.com,email2@anotherstore.com
E-Mail Subject Subject of email. Available variables: %d%, %m%, %y%, %Y%, %h%, %i%, %s%, %exportid%
E-Mail Text Email text (body text). Available variables: %d%, %m%, %y%, %Y%, %h%, %i%, %s%, %exportid%, %content% (%content% contains the data generated by the export)
Potential issues: No emails are sent
  1. Please make sure whether normal Magento emails are sent or not. If you don't receive an order confirmation from Magento either, the email function is probably broken and this is a problem not related to the extension
  2. Please try to send the export emails to your email address instead to test if you receive them or if it's a problem with the intended recipient of the email.
Webservice/API

To export data to a webservice, please follow the following steps:

  1. Go into the app/code/local/Xtento/OrderExport/Model/Destination/ directory and rename the file "Webservice.php.sample" to "Webservice.php"
  2. Enter the function name you want to call in the Webservice.php class in the field below.
  3. Open the Webservice.php file and add a function that matches the function name you entered. This function will be called by this destination upon exporting then.

Example: If you enter server1 in the function name field below, a method called server1($fileArray) must exist in the Webservice.php file. This way multiple webservices can be added to the Webservice class, and can be called from different export destination, separated by the function name that is called. The function you add then gets called whenever this destination is executed by an export profile.

Important: Please make sure the function you enter exists like this in the app/code/local/Xtento/OrderExport/Model/Destination/Webservice.php file:

public function yourFunctionName($fileArray) { ... }

Potential issues: No connection
  1. Please go through the steps above one or two more times again to make sure you really set it up exactly as explained.
  2. Please make sure there is no firewall blocking outgoing HTTP connections. Get in touch with your hoster if in doubt.
Custom Code / Custom Class

You can set up an own class in our (or another) module which gets called when exporting. The saveFiles($fileArray) function would be called in your class. If your class was called Xtento_OrderExport_Model_Destination_Myclass then the identifer to enter here would be xtento_orderexport/destination_myclass

Please make sure the following function exists in your custom class: public function saveFiles($fileArray) { ...your code here... }

Logging errors in the profile log for custom destinations

If you developed a custom class or set up a custom webservice/HTTP connection function, and in case of errors want to log them in the execution log, you can access the log entry like this to add a warning for example:

$logEntry = Mage::registry('export_log');
$logEntry->setResult(Xtento_OrderExport_Model_Log::RESULT_WARNING);
$logEntry->addResultMessage(Mage::helper('xtento_orderexport')->__('Destination "%s" (ID: %s): %s', $this->getDestination()->getName(), $this->getDestination()->getId(), 'Something went wrong'));

Enabling Export Destinations in Profiles

To associate created export destinations to export profiles, open an export profile and go to the Export Destinations tab and select the export destinations where the file should be sent to by selecting the checkbox in front of it. Then save the profile.

You can associate an unlimited number of destinations to a profile.

Using the extension

The following functions can found at Sales > Sales Export.

Manual Export

Manual Export Screen

Exporting objects manually is easy. After configuring the extension and creating profiles, just go to Sales > Sales Export > Manual Export.

First of all, select the profile you want to export. You can select from order export profiles, invoice export profiles, shipment export profiles and credit memo export profiles, depending on which profiles you set up.

There are several different filters available now to narrow down the exported objects.

 Filter  Description
Store Views Select one or multiple store views by holding down CRTL while selecting them. If "All Store Views" is not selected, only objects from selected store views will be exported.
Starting Increment ID Allows to limit the exported objects by the order/invoice/shipment/creditmemo ID, for example 1000000001. Starting Increment ID means "export only objects placed after this ID, including the ID supplied"
Ending Increment ID Allows to limit the exported objects by the order/invoice/shipment/creditmemo ID, for example 1000000010. Ending Increment ID means "export only objects placed before this ID, including the ID supplied"
Status Depending on the data type you're exporting, this allows to filter objects by order/invoice status.
Date Range From Limit the export by a date range. Only export objects placed *after* date X, but also including date X.
Date Range To Limit the export by a date range. Only export objects placed *before* date X, but also including date X.
Export only not yet exported objects If enabled, only objects that haven't been exported before will be exported. This overrides the profile filter "Export only new objects" and can be turned off here for example.
Change order status after export Available for order exports only. Overrides the profile setting "Change order status after export". Set to "No change" if you don't want the order status to change.

Please keep in mind that any filters you set up in the profile will also be taken into account when exporting manually.

If you're ready to export, just press the Export button. You will be presented with a file download dialogue and a success message if the export completed successfully.

Automatic Export

To set up automatic exports, please have a look at the Automatic Export section configurable for each export profile. You can check/control whether automatic exports were made or not in the Execution Log.

Execution Log

Execution Log

The profile execution log shows any exports made using all profiles, be it manual or automatic. It is also possible to download any exported files, however, only if Save local copies of exports is set to "Yes" under General Configuration of the profile the export was made with.

Export History

Export History

This section shows which objects (orders, invoices, shipments, credit memos) were exported by which profile and when. If the Export only new objects profile filter is set to "Yes", you should only see every object once there for each profile. If you want to re-export an object that has been already exported and is not exported because Export only new objects is set to "Yes", you can remove the entry from the export history grid by selecting Delete Entry.

Tools

Import/Export Screen

Export Settings

The extension comes with functionality to export certain module configuration. All or certain export profiles as well as export destinations can be selected for exporting at Sales > Sales Export > Tools, and can be exported by simply pressing the Export Settings button then. The exported file (ending in .json) can then be imported into another Magento installation using the Import Settings functionality, making it very easy to transfer you settings between development/staging/test/live environments or for clients.

Import Settings

The extension comes with functionality to import certain module configuration from other Magento installations. This means if you've previously exported export profiles or export destinations using the Export Settings functionality, you can import it here again.

Please note no passwords of export destinations will be imported. These will have to be re-entered manually for destinations.

Example Setups - What's possible with this extension?

What kind of exports can be set up using this extension? The possibilities are almost endless.

The extension supports an unlimited number of export profiles, which means an unlimited number of different, completely customizable, output formats can be set up. The export profiles can be exported at different times using cron jobs automatically or after certain events have happened in Magento. The exported files can be sent to an unlimited number of remote/local destinations, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

There is no export extension more flexible.

ERP/CRM Export

Export orders, invoice and credit memos after they have been created automatically, manually, or on a cron schedule. Any output format based on text, i.e. CSV/XML/ASCII/..., can be created using a custom XSL Template. Send them to almost any destination type, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

Warehouse Export

Export your orders after they have been placed or paid to your warehouse. Any output format based on text, i.e. CSV/XML/ASCII/..., can be created using a custom XSL Template. Send them to almost any destination type, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

Shipping Data Export

Make your orders available for a shipping software. Any output format based on text, i.e. CSV/XML/ASCII/..., can be created using a custom XSL Template. Send them to almost any destination type, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

Reporting Export

Export orders, invoice, shipments and credit memos after they have been created automatically, manually, or on a cron schedule. Any output format based on text, i.e. CSV/XML/ASCII/..., can be created using a custom XSL Template. Send them to almost any destination type, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

Accounting Export

Export orders, invoice, shipments and credit memos after they have been created automatically, manually, or on a cron schedule. Any output format based on text, i.e. CSV/XML/ASCII/..., can be created using a custom XSL Template. Send them to almost any destination type, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

Dropshipping

Export your orders after they have been placed or paid to your dropshippers. Any output format based on text, i.e. CSV/XML/ASCII/..., can be created using a custom XSL Template. Send them to almost any destination type, including FTP Servers, SFTP Servers, E-Mail Recipients, HTTP Servers and Webservices/APIs.

Also, each profile can be set up to include items where the "vendor" is "X". You would set up one export profile for each vendor so they only get the orders/items they should get.

Questions? Concerns?

Got questions? Feel free to contact us! Contact Form

Interested in this Magento Extension?

Head over to our store to purchase this extension: Magento Order Export Module

Troubleshooting

Or: How to fix the most common issues.

FTP Upload does not work

Unknown column 'manual_export_enabled'

Error message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'manual_export_enabled' in 'where clause'

Somehow the upgrade script for the column modification hasn't executed. Please manually execute this query in the DB:

ALTER TABLE xtento_orderexport_profile ADD `manual_export_enabled` INT(1) NOT NULL DEFAULT '1' AFTER `save_files_manual_export`;

Randomly changing order numbers

The "Aitoc Pre-Order" extension (not sold by us) has a bug where the pre-order extension randomly re-saves orders when loaded in a collection, and then saves them without a proper order number (increment_id). This does not happen just with our extension but with any module that loads the sales order collection.

To fix this, open the app/code/local/Aitoc/Aitpreorder/Model/Rewrite/Mysql4SalesOrderCollection.php file and comment/remove the whole _afterLoad() function.

Export invoices in "PDF Invoice Plus" format

If you are using the commercial "PDF Invoice Plus" extension sold by an extension company (not XTENTO), the following customization will be required in order to export invoices in their custom PDF format.

Please open the file app\code\local\Xtento\OrderExport\Model\Output\Xsl.php and look for: $pdf = Mage::getModel('sales/order_pdf_' . $pdfType)->getPdf($collection); Replace with: if ($fileType == 'invoice_pdf') {
$pdf = Mage::getSingleton('pdfinvoiceplus/entity_masspdfinvoice')->getPdfDataInvoice($collection->getAllIds());
} else if ($fileType == 'packingslip_pdf') {
$pdf = Mage::getModel('sales/order_pdf_' . $pdfType)->getPdf($collection);
}

Look for: return $pdf->render(); Replace with: if ($fileType == 'invoice_pdf') {
return $pdf;
} else if ($fileType == 'packingslip_pdf') {
return $pdf->render();
}

Save the file. Done.

Personal tools
Namespaces
Variants
Actions
Navigation
General Information
Magento Extensions
Magento Integration Suite
Toolbox