Magento 2 Extensions:Tracking Number Import Module
Overview
Importing order status updates and invoices/shipments/credit memos/tracking numbers from CSV or XML files into Magento 2 has never been easier. Using the Magento Tracking Number Import Module by XTENTO, you will be able to automatically import invoices, shipments, credit memos and tracking data into Magento.
Interested in this Magento Extension?
Head over to our store to purchase this extension: Magento Tracking Number Import Module
Got questions? Feel free to contact us! Contact Form
Setting up the extension
- Please refer to our general Extension Installation and Setup Guide for installation instructions.
After installing the extension as instructed in our general installation guide, please go to System > XTENTO > Tracking Number Import. Please enter your license key there and set Module Enabled to "Yes".
- Please make sure the Magento cronjob has been set up for the Magento installation you're installing the extension in. If the Magento cronjob hasn't been set up, you won't be able to automate imports.
- (Only required if you want to process spreadsheets such as XLS/XLSX/ODS, not required for CSV): NOT required if installing via composer, but required when installing extension via ZIP upload: Connect via SSH, go into the root directory of Magento and install the spreadsheets library by running the command:
cat composer.json | grep -q 'magento/project-community-edition' && (composer require phpoffice/phpspreadsheet "^1.0" ; composer dump-autoload) || echo 'composer.json seems to be broken! cannot install.'
Migrating from Magento 1 to Magento 2
Migrating your settings from Magento 1 to Magento 2 couldn't be easier. Unless you have customized the modules code, usually all your settings can be migrated without any additional work. In your Magento 1 environment, simply go to Sales > Tracking Import > Tools and export your profiles and sources. Then, log into Magento 2 and go to Sales > Tracking Import > Tools and import them there. That's it! Test everything and make sure it works as expected, but usually all settings are compatible with Magento 2 as well.
Configuring the extension
The following description will cover the modules configuration located at Sales > Tracking Import.
Import Profiles
Import profiles can be set up for manual and automatic imports. Every profile contains information about the data to import (e.g. field mapping), when, how, and where to import from, as well as some other settings. The extension supports an unlimited number of different import profiles.
To set up new import profiles or to modify existing import profiles, please go to Sales > Tracking Import > Import Profiles.
Setting up a new import profile is easy. Press the "Add New Profile" button. You will then be asked to select the entity (just "order update" - supports shipment/invoice/credit memo related actions) to import, the file format (CSV/XML/TXT/...), as well as to assign a name to the profile which can be used to identify the import profile in import logs. Press the Continue button.
You will then be presented with the profile configuration. The configuration of import 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 importing.
Enabled: If set to "No", this profile won't show up for manual imports nor will automatic imports be made.
File Processor: This defines the file format which will be imported, e.g. CSV/TXT/XML/...
Import Type: Can't be changed after profile creation. Defines which entity (data type) gets imported. Available entities:
Entity | Description |
---|---|
Order Update | Run various order related actions such as invoice/shipping/credit memo creation, etc. |
2) Settings & Filters
Order Identifier: This is what is called the Order Identifier in the import settings and is what's used to identify the orders in the import file. Almost always you will want to use the Order Increment ID (Example: 100000001). You can also use the internal order entity_id, invoice, shipment or credit memo number here to identify orders to import in the file you're uploading.
Product Identifier: This is what is called the Product Identifier in the import settings and is what's used to identify the product in the import file. Almost always you will want to use the SKU. You can also use the products entity_id or a custom product attribute to identify products to invoice/ship.
Process order only if...: You can set up various filters that are checked against the order before importing here. If an order does not match the specified filters, it will be skipped and not thus not imported.
3) File Mapping
This section maps your import file format to the fields which will be adjusted/updated in Magento.
The options you see depend on the file processor selected in the "General Configuration" tab of the profile.
CSV/TXT/Tab-delimited
Use this processor if you want to import CSV/TXT/Tab-delimited file formats, so any format where fields are delimited by some character, e.g. , ; | etc.
Configuration
Skip header line: Set this to "Yes" if you want to skip the first line of each imported CSV file as it's the header line containing the column names. You must set this to "Yes" if the first line contains the column names and you want to map fields by column name.
Field Delimiter: REQUIRED: Set the field delimiter (one character only). Example field delimiter: ; (Hint: If you want to use a tab delimited file enter: \t)
Field Enclosure Character: Set the field enclosure character (one character only). Example: "
File Mapping
You can can map the import fields to the actual column names in the CSV/TXT/etc. file here. Make sure to enter the EXACT same column name (case-sensitive).
If there are no column headers in the import file, you can also map by index. The first field in the file would be 0 - the second field in the file would be 1 and so on.
"Additional Configuration"
The "Configure" button shown right next to each field mapped using the Field Mapper opens a popup where custom XML "code" can be specified. This custom XML can be used to manipulate the data mapped for this field, coming from your import file.
If you open the configuration popup for the first time it will have the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
</configuration>
This is the default configuration markup. Various actions can be specified there to manipulate field data, for example to map field values (if your mapped field "order status" contains "X", set the value to "processing" for example) or skip import rows, etc.
The following actions can be used:
map: Map values, for example if the data in the file for your mapped field equals "mytracker" (case-sensitive) map that to "tracker1" instead, and if it *matches* the regular expression "[0-9]" (no // delimiters may be used) map that to "tracker2" instead:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<map from="mytracker" to="tracker1"/>
<map from="[0-9]" to="tracker2" method="preg_match" regex_modifier="i" />
<map from="^1Z" to="tracker3" method="preg_match" negate="true" regex_modifier="i" /> <!-- Negate option, added in module version 2.2.4 - matches only if the "from" value does NOT match -->
</configuration>
replace: Replace data in field values for your mapped field. For example, if your field contains "order_" and you want to replace that with "" (empty string), or replace using a regular expression, for example remove numbers from the data:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<replace search="order_" replace=""/>
<replace search="[0-9]" replace="" method="preg_replace" regex_modifier="i"/>
</configuration>
Example to replace everything after the last dot and the dot itself:
<replace search="\..*$" replace="" method="preg_replace" regex_modifier="i"/>
Example to prepend / prefix text to the current field, for example add "GS" in front of the field value:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<replace search="^([A-Za-z0-9\.\-\s]+)$" replace="GS\1" method="preg_replace" regex_modifier="i"/>
</configuration>
Example to append text to the current field, for example add "Hello" at the end of the field value:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<replace search="^([A-Za-z0-9\.\-\s]+)$" replace="\1Hello" method="preg_replace" regex_modifier="i"/>
</configuration>
use: If a field from your import file matches or equals "X", use a different field from the file for this mapped field instead. For example, if the first field in your file (index 0) is X use the third field (index 2) from the file for this field instead, or if it matches the regular expression "[0-9]" use the 8th field (index 7) from the file instead:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<use field="2" if="0" is="X"/>
<use field="7" if="0" is="[0-9]" method="preg_match" regex_modifier="i"/>
<use field="7" if="0" is="[0-9]" method="preg_match" negate="true" regex_modifier="i"/> <!-- Negate option, added in module version 2.2.4 - matches only if the "is" value does NOT match -->
</configuration>
skip: If a field in your import file matches or equals "X", the current import line/row will be skipped, so the order won't be updated. For example, if you have a field with the column header "Indicator" that is "X" or matches the regular expression "[0-9]", the row will be skipped:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<skip if="Indicator" is="X"/>
<skip if="Indicator" is="[0-9]" method="preg_match" regex_modifier="i"/>
<skip if="Indicator" is="[0-9]" method="preg_match" negate="true" regex_modifier="i"/> <!-- Negate option, added in module version 2.2.4 - matches only if the "is" value does NOT match -->
</configuration>
All actions can be combined, for example:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<map from="mytracker" to="tracker1"/>
<map from="[0-9]" to="tracker2" method="preg_match" regex_modifier="i" />
<replace search="order_" replace=""/>
</configuration>
XLS/XLSX/ODS/Excel
Since version 2.7.3 (released in September 2019) it is possible to import and process XLS/XLSX/ODS/Excel files using the extension. When setting up a new profile, simply select the XLSX file processor. Then, map your profile exactly like described in the CSV section above - it's the same mapping-wise, but in the background magically your XLS/XLSX file will be processed.
XML
Use this processor if you want to import XML file formats.
Configuration
Data XPath: Set the XPath for the node containing the order updates.
Example XML file:
<orders>
<order>
...
</order>
<order>
...
</order>
</orders>
The order updates would be located in each "order" node, which are located in the "orders" node, so the XPath would be: //orders/order
Every "order" node located under the "orders" node would be processed then.
More information about XPath can be found here: http://www.w3schools.com/xpath/
File Mapping
You can map the actual import fields to the fields in the XML file here. Make sure to enter the EXACT same name (case-sensitive).
What you enter into the "Field Name" field is XPath. So for example if you had this XML markup:
<orders>
<order id="100000123">
<trackingnumber>1Z12343123123123123</trackingnumber>
</order>
</orders>
To fetch the "id" field you would enter: @id (@ in front because it's an attribute) To fetch the qty you would enter: trackingnumber (This is the field name of the field you want to fetch, as it's on order level you don't need a prefix.)
More information about XPath can be found here: http://www.w3schools.com/xpath/
Nested Nodes
If your fields are nested in nodes, you can specify additional XML using the "Configure" button that defines whether a field should be retrieved from a different / looping node below the current XPath. For example, if you want to import this format (tracking information NESTED under the order information):
<orders><order><id>X</id><tracks><track><number>1123</number><carrier>test</carrier></track></tracks></order></orders>
The nested tracking data node would be //tracks/track then as the tracks are child nodes of the data node. The following XML would be specified using the "Configure" button for the "Tracking Number" field (for the "File Field Name / Index" you would enter "number" (without the quotes) as that is the name of the field on //tracks/track level):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<nested_xpath xpath="//tracks/track"/>
</configuration>
"Additional Configuration"
Please refer to the Additional Configuration section of the CSV processor. It's the same as for XML.
Fixed-Length Formats
It is also possible to import fixed-length formats using the module. Just select the CSV/TXT/Tab processor when creating a profile.
For the Field Delimiter column enter: FLF When mapping a field at "File Mapping", you would enter the starting and ending position of the field into the "Field Name / Index" field.
For example if you want fetch position 5 to 30 you would enter: 5-30
4) Actions
The Import Actions tab defines which actions will be executed for an order found in your import file. The import actions are executed in the sort order set up in the import actions table.
Import Actions
Invoice Actions
Create invoice for imported order: If enabled, the module will try to create an invoice for the imported order. Please note no invoices can be created for an order if it has been completely invoiced already or if the order status does not allow invoicing (complete, or canceled, etc.).
Note: The "Create invoice for imported order" action must ALWAYS be added to your import profile if you want to run any of the following invoice related actions. It will NOT re-create any invoice falsely if it already exists or anything, but it is the "base" action and the following actions listed below will only execute if the above "Create invoice" action is added.
Send invoice email to customer: If enabled, and if an invoice was created, the invoice email will be sent to the customer.
Capture payment for invoice: This will try to capture the payment at the payment gateway, i.e. charge the credit card if possible.
Set invoice status to "Paid": Marks the invoice as paid. This happens automatically if the payment is captured using the above action.
Import partial invoices: This requires the SKU and quantity fields in the import file to be filled with data. The order will then only get invoiced for the SKUs and quantities specified in the import file. If disabled, the order will always be invoiced for all items in the order. Make sure the products specified in the import file exist in the order, as otherwise if this is enabled and no products from the file are in the order, the order will not be invoiced.
Shipment Actions
Create shipment for imported order: If enabled, the module will try to create a shipment for the imported order. Please note no shipments can be created for an order if it has been completely shipped already or if the order status does not allow shipping (complete, or canceled, etc.).
Note: The "Create shipment for imported order" action must ALWAYS be added to your import profile if you want to run any of the following shipment related actions. It will NOT re-create any shipment falsely if it already exists or anything, but it is the "base" action and the following actions listed below will only execute if the above "Create shipment" action is added.
Send shipment email to customer: If enabled, and if a shipment was created, the shipment email will be sent to the customer.
Import no shipments without tracking numbers: If set to "Yes" orders without tracking numbers won't be imported.
Add tracking numbers to existing shipments & import multiple tracking numbers: If the import file contains more than one tracking number for one order or if the order has been already shipped, these tracking numbers will get added to the most recent shipment of the order.
Import partial shipments: This requires the SKU and quantity fields in the import file to be filled with data. The order will then only get shipped for the SKUs and quantities specified in the import file. If disabled, the order will always be shipped for all items in the order. Make sure the products specified in the import file exist in the order, as otherwise if this is enabled and no products from the file are in the order, the order will not be shipped.
Credit Memo Actions
Create credit memo for imported order: If enabled, the module will try to create a credit memo for the imported order. Please note no credit memo can be created for an order if it has been completely refunded already or if the order status does not allow refunding (closed, etc.).
Send credit memo email to customer: If enabled, and if a credit memo was created, the credit memo email will be sent to the customer.
Return refunded items to stock: If enabled, refunded items will be returned to stock, this means the stock level for products will go up again.
Import partial credit memos: This requires the SKU and quantity fields in the import file to be filled with data. The order will then only get refunded for the SKUs and quantities specified in the import file. If disabled, the order will always be refunded for all items in the order. Make sure the products specified in the import file exist in the order, as otherwise if this is enabled and no products from the file are in the order, the order will not be refunded.
Order Status Actions
Change order status after importing partial order: If a partial shipped/invoiced order gets imported, change the order status to a specific status. Attention: Do not use the "On Hold" status for partial invoices/shipments, as otherwise no further invoices/shipments can be created!
Change order status after import (or when order has been completely invoiced/shipped): You can either import the status from the file you're importing (see processor options), or statically change the order status to the status set here after the order has been completely shipped.
"Additional Configuration"
The "Configure" button shown right next to each import action opens a popup where custom XML "code" can be specified. This custom XML can be used to manipulate action values, for example if a mapped field contains "X" don't run this action.
If you open the configuration popup for the first time it will have the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
</configuration>
This is the default configuration markup. The following actions can be used:
set: Manipulate the action value. For example if you configure the action "Create invoice for imported order", and want its value to be set to "No" (=don't create an invoice) if the mapped field "Custom Field 1" (mapped in the "File Mapping" tab) equals "X", and want it to be set to "Yes" (=create an invoice) if the "Custom Field 1" value matches the regular expression "[0-9]", you would use:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<set value="false" if="custom1" is="X"/>
<set value="true" if="custom1" is="[0-9]" method="preg_match" regex_modifier="i" />
<set value="true" if="custom1" is="^1Z" method="preg_match" negate="true" regex_modifier="i" /> <!-- Negate option, added in module version 2.2.4 - matches only if the "is" value does NOT match -->
</configuration>
5) Import Sources
Select the import sources where files should be downloaded from before importing simply by checking the checkbox right before the Source ID.
Please refer to the Import Sources section below to get an idea how to configure and set up import sources.
6) Automatic Import
It is possible to set up cronjob imports for import profiles, so profiles are executed automatically on a time schedule.
Cronjob Import
If you want to automate imports, you can set up cronjobs for profiles which execute the import for this profile at certain times automatically. First of all, make sure to set up your Magento cronjob as explained here. You can easily check the cronjob status by looking at the "Cronjob Import" section when editing a profiles "Automatic Import" tab. The Cronjob Status field will contain information about the status of the cronjob and whether any action is required or not.
To enable cronjob imports for this profile, simply set Enable Cronjob Import to "Yes". Select the Import Frequency of how often you want the import 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 import frequency" from the Import Frequency dropdown, and enter one or more cron expressions separated by a semi-colon (;) in the Custom Import 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 imports will only be made if the profiles status (under General Configuration) is "Enabled".
6) Profile Execution Log
The profile execution log shows any imports made using this profile, be it manual or automatic.
Import Sources
Import sources are the actual "sources" where imported files will be downloaded from. If your only goal is to manually import and upload import files from the Magento backend, you won't need to set up any import sources. If you need to download import files from remote FTP servers or certain local directories on the Magento server, you will have to set up import sources.
The module supports an unlimited amount of different import sources. The following source types are currently supported:
Source Type | Description |
---|---|
Local Directory | Files are retrieved from a local directory on the Magento server |
FTP Server | Files are retrieved from a remote FTP(S) server |
SFTP Server | Files are retrieved from a remote SFTP server. |
HTTP Server | Files are retrieved from remote HTTP servers by sending a GET/POST request for example |
HTTP Download | Files are retrieved from remote HTTP servers, simply enter the URL to download from |
Webservice/API | Files are retrieved from webservices/API. The webservice/API code must be set up by you. |
Custom Code / Custom Class | Imports can be handled by a custom class you can set up. This class could parse and modify, and then return files to process to the module. |
Setting up Import Sources
To set up import sources, go to Sales > Tracking Import > Import Sources. You can modify existing sources there or add new sources.
Setting up a new import source is easy. Press the "Add New Source" button. You will then be asked to select the source type (from which type of "server" the imported files will retrieved from) to create, as well as to assign a name to the source which can be used to identify the source in import profiles and logs. Press the Continue button. You will then be presented with the source configuration.
Source Types
Local Directory
This source type will simply fetch imported files from a local directory on the Magento server.
If you begin the path with a dot in front of it, for example
./var/import/
the path will be relative to the Magento root directory. This means the file would be loaded from the /var/import/ 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/import/
Please make sure the path you enter is readable by the webserver. It must be possible for the webserver to read the files in that directory, otherwise a warning will be shown/logged.
FTP Server
The FTP source type supports downloading files from 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 download files from |
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 downloading the import files, please set this to "Yes". |
Import Directory | Enter the directory from which files should be downloaded from |
Filename Pattern | This needs to be a valid regular expression. The regular expression will be used to detect import files. The import will fail if the pattern is invalid. Example: /csv/i for all files with the csv file extension or for all files in the import directory: // |
Archive Directory | If you want to move the imported file(s) to another directory after they have been processed, please enter the path here. This is the absolute path to the archive directory on the FTP server. This directory has to exist on the FTP server. Leave empty if you don't want to archive the import files. |
Delete imported files | Set this to "Yes" if you want to delete the imported file from the FTP server after it has been processed. You can't delete and archive at the same time, so choose either this option or the archive option above. |
Potential issues: Connection/upload fails
- A firewall is probably blocking the ingoing or outgoing FTP connection. Please make sure no firewall is blocking the connection - both on your side as well as on the remote (FTP server) side. You could also try enabling passive mode in the import source.
SFTP Server
The SFTP (Secure File Transfer Protocol) source type is identical with the FTP source type, except that it loads files from a SFTP server. This source type supports SFTPv2 and SFTPv3 servers only, other SFTP server types are not guaranteed to be compatible. 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
- A firewall is probably blocking the ingoing or outgoing SFTP connection. Please make sure no firewall is blocking the connection - both on your side as well as on the remote (SFTP server) side.
- Please make sure the SFTP server is a SFTPv2/SFTPv3 server as explained above.
HTTP Server
To download files from a HTTP server, please follow the following steps:
- Go into the app/code/Xtento/TrackingImport/Model/Source/ directory and rename the file "Http.php.sample" to "Http.php"
- Enter the function name you want to call in the Http.php class in the field below.
- Open the Http.php file and add a function that matches the function name you entered. This function will be called by this source upon importing then.
Example: If you enter server1 in the function name field below, a method called server1() 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 import source, separated by the function name that is called. The function you add then gets called whenever this source is executed by an import profile.
Important: Please make sure the function you enter exists like this in the app/code/Xtento/TrackingImport/Model/Source/Http.php file:
public function yourFunctionName() { ... }
Potential issues: Connection fails
- Please go through the steps above one or two more times again to make sure you really set it up exactly as explained.
- Please make sure there is no firewall blocking outgoing HTTP connections. Get in touch with your hoster if in doubt.
HTTP Download
Downloading a file from a static URL and using this to import is very easy using the "HTTP Download" source. Simply enter the URL to download from after creating a new source with this type, and the extension will download the data to import from this URL when this source is enabled for an import profile.
Additional Guides:
Potential issues: Connection fails
- Please make sure there is no firewall blocking outgoing HTTP connections. Get in touch with your hoster if in doubt.
Webservice/API
To import data from a webservice, please follow the following steps:
- Go into the app/code/Xtento/TrackingImport/Model/Source/ directory and rename the file "Webservice.php.sample" to "Webservice.php"
- Enter the function name you want to call in the Webservice.php class in the field below.
- Open the Webservice.php file and add a function that matches the function name you entered. This function will be called by this source upon importing then.
Example: If you enter server1 in the function name field below, a method called server1() must exist in the Webservice.php file. This way multiple webservices can be added to the Webservice class, and can be called from different import source, separated by the function name that is called. The function you add then gets called whenever this source is executed by an import profile.
Important: Please make sure the function you enter exists like this in the app/code/Xtento/TrackingImport/Model/Source/Webservice.php file:
public function yourFunctionName() { ... }
Potential issues: No connection
- Please go through the steps above one or two more times again to make sure you really set it up exactly as explained.
- Please make sure there is no firewall blocking outgoing HTTP connections. Get in touch with your hoster if in doubt.
Sample Code / Sample Implementations
Please refer to this article for sample code & further information on how to connect Magento to custom REST/JSON/SOAP/... APIs.
Custom Code / Custom Class
You can set up an own class in our (or another) module which gets called when importing. The loadFiles() function would be called in your class. If your class was called \Xtento\TrackingImport\Model\Source\Myclass then the identifer to enter here would be \Xtento\TrackingImport\Model\Source\Myclass
Please make sure the following function exists in your custom class:
public function loadFiles() { ...your code here... }
Logging errors in the profile log for custom sources
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 = $this->_registry->registry('trackingimport_log');
$logEntry->setResult(\Xtento\TrackingImport\Model\Log::RESULT_WARNING);
$logEntry->addResultMessage(__('Source "%1" (ID: %2): %3', $this->getSource()->getName(), $this->getSource()->getId(), 'Something went wrong'));
Enabling Import Sources in Profiles
To associate created import sources to import profiles, open an import profile and go to the Import Sources tab on the left and select the import sources where the file should be retrieved from by selecting the checkbox in front of it. Then save the profile.
You can associate an unlimited number of sources to a profile.
Using the extension
The following functions can found at Sales > Tracking Import.
Manual Import
Importing updates manually is easy. After configuring the extension and creating profiles, just go to Sales > Tracking Import > Manual Import.
First of all, select the profile you want to import. You can then select a file to upload (no files will be loaded from configured sources then) OR if you don't select a file to upload, files will be downloaded from configured sources in the import profile.
There are two more options to enable here. Test Mode and Debug Mode. If test mode is enabled, no real updates will be imported, nothing will be updated. If debug mode is enabled, a detailed log showing information about the last import will be shown. Both can be enabled at the same time.
If you're ready to import, just press the Import button. You will be presented with a success message if the import completed successfully. (Or an error message alternatively)
Automatic Import
To set up automatic imports, please have a look at the Automatic Import section configurable for each import profile. You can check/control whether automatic imports were made or not in the Execution Log.
Execution Log
The profile execution log shows any imports made using all profiles, be it manual or automatic.
Tools
Export Settings
The extension comes with functionality to export certain module configuration. All or certain import profiles as well as import sources can be selected for exporting at Sales > Tracking Import, 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 your 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 import profiles or import sources using the Export Settings functionality, you can import it here again.
Please note no passwords of import sources will be imported. These will have to be re-entered manually for destinations.
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 Tracking Number Import Module
Troubleshooting
Or: How to fix the most common issues.
FTP Download does not work
- A firewall is probably blocking the ingoing or outgoing FTP connection. Please make sure no firewall is blocking the connection - both on your side as well as on the remote (FTP server) side. You could also try enabling passive mode in the import source.
Error "Unable to unserialize value." when using module or opening profile
You are using an outdated module version and upgraded to Magento 2.2 or newer. A change in Magento 2.2 requires an update of our module, please update this module to the latest version.
Only 1 email is sent, not multiple emails for multiple orders
A bug in the Magento core existing in Magento >=2.2.4 && <= 2.3.0. This is supposed to be fixed in Magento 2.3.1. See here and the referenced issues: https://github.com/magento/magento2/issues/7739
It happens when one tries to send more than one email in one execution under certain circumstances. Suggestions on how to fix this can be found here: https://github.com/magento/magento2/pull/18472
Duplicate shipments
Running the tracking import and shipments get imported twice? You may have an "auto invoice/ship" extension installed that does something it's not supposed to do.
Missing $debugHintsPath when sending email via command
Core bug in Magento <2.2.8, <2.3.1. See here for potential fixes: https://github.com/magento/magento2/issues/10440
Warning: Invalid argument supplied for foreach() in [...]/packaging/packed.phtml on line 12
Core bug in Magento <2.3.1, fixed in 2.3.1, see here for patch: https://github.com/magento/magento2/pull/18231
Blank screen "Shipped by" when creating shipments
Alternate error message: "Uncaught Error: Call to a member function getUrl() on null"
Core bug in Magento 2.3.3/2.3.4/2.3.5, see here for patch: https://github.com/magento/magento2/issues/25221 (Temporary solution: https://github.com/magento/magento2/issues/25221#issuecomment-545111331 )
Easiest solution: Use our Custom Carrier Trackers extension which also fixes this: https://www.xtento.com/magento-extensions/magento-custom-generic-carrier-trackers-extension.html
XML processor: Issues with namespaces
If you are trying to import a XML file that has namespaces, such as "ns1:" or "oc:" or whatever in front of nodes, it is recommend to remove them to simplify the import.
Doing so is easy. You can do this via the "Data XPath" field. Let's say your file looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?> <oc:orderConfirmation xmlns:oc="http://www.despec.de/oc" creationDate="2020-03-10T00:00:00"> <order> <orderid>0001695503</orderid> <orderSequence>0</orderSequence> </order>
In the Data XPath field, you would enter this:
//orderConfirmation/order!|!oc:,ns1:
What's special about this? After the normal XPath to get to orderConfirmation/order, you add this: !|! and then add the namespaces you want to remove. In the above example, oc: and ns1: will be removed from files.
Magento 2: Order status changes to closed instead of complete
This seems to be a Magento 2 core bug: https://github.com/magento/magento2/issues/22337
Apparently this happens for orders where an invoice exists but the invoice isn't paid but is "pending". And for orders where no invoice exists. So make sure to add the "Capture payment / set paid" option in your import profile when creating an invoice.
A workaround to change the status to "Complete" is setting the status without setting the order state (which triggers the internal bug in Magento). To do so, customize the following file via a preference: \app\code\Xtento\TrackingImport\Model\Import\Action\Order\Status.php
Look for and remove this line:
$this->setOrderState($order, $newOrderStatus);
Multiple emails sent in one import run are attached to previous emails sent
This is definitely not caused by our extension. We've encountered this once before and it was caused by an extension called "Mageplaza Email Attachments". We are unsure if they have fixed this issue, however, if you have this extension, try upgrading it.
Error: Not all of your products are available in the requested quantity.
This is caused by MSI in Magento 2, it is not possible to ship orders when the stock level is lower than the ordered one. This is not related to our module, this is how MSI works unfortunately. You will see the same happens if you manually try to ship an order.
No tracking numbers in shipment email
Possibly a bug in Magento 2.3.4/2.3.5, fixed in Magento 2.4.0: https://magento.stackexchange.com/a/313318
Cannot instantiate interface Magento\InventoryApi\Model\SourceValidatorInterface
Reason: You disabled all Magento MSI modules, but you forgot to disable the module Magento_Inventory. It is also part of MSI and you need to disable it as well.
Credit memo creation via "PayOne" module fails
PayOne does not support automated credit memo creations. See here for a possible solution (if the pull request hasn't been merged yet, that means they didn't add official support yet): https://github.com/PAYONE-GmbH/magento-2/pull/231
Error: Not all of your products are available in the requested quantity
This is caused by Magento MSI.
While we haven't tested it, the following module could be a solution for this Magento MSI issue: https://github.com/AmpersandHQ/magento2-disable-stock-reservation
No debug messages are shown during manual import
This applies to all our import/export modules:
If you're importing big files, and there is a huge log, it may be necessary to increase the session size at "Stores > Setting > Configuration > Advanced > System > Security" to a higher limit.