User Tools

Site Tools


Sidebar

magento_2:export_products

For more details see how the Export Products for Magento 2 extension works.

Guide for Export Products for Magento 2

Migrate product data to third-party systems or other Magento instances without coding. Build multiple flexible export profiles and set automatic migration with Export Products for Magento 2.

  • Transfer all types of products
  • Include any product attributes to export files
  • Run export profiles by cron or event
  • Perform regular or one-time exports with additional export interfaces
  • Adjust export flow based on your server capacity

Solution Structure

Amasty Export by now includes 3 separate modules to perform export tasks:

  • Export Products: a separate export to deal with product entities
  • Amasty Export: suitable for one-time export of any available entity
  • Amasty Export PRO: a tab to create cron jobs concerning export activity

The more Amasty modules you have, the more entities you will be able to export in the first simplified module and in the PRO version. Follow Import & Export solution updates to discover new possibilities.

Note, that if your export managers have specific permissions to the admin panel, you need to grant them access to both Export Products Profiles and Amasty Export. Otherwise, they won't be able to execute the export.

Export Products Configuration

Prior to creating export profiles, please configure the basic product export options.

Go to Stores → Configuration → Amasty Extensions → Export Products.

Enable module - choose Yes to activate the extension.

Export Batch Size - set the number of products that will be processed in an iteration.

Log Auto-Cleaning - set Yes to clean logs automatically. The records will be removed from Export History after the period specified below.

Log Auto-Cleaning Period (Days) - define the period after which export history will be cleaned.

Export Files Auto-Cleaning - if enabled, the generated export files will be automatically removed from the server after the period specified below.

Export Files Auto-Cleaning Period (Days) - identify the period after which the files will be removed from the server.

Enable Multi-Process Export - set to Yes to speed up the export. Remember, that this option is added specifically for products. The multi-process for Amasty Export and Amasty Export Pro should be enabled in the other tab.

The 'Multi-Process Export' feature requires the PHP extension 'pcntl' to be installed on the server. If you enable the feature and no performance boost happens, please ask your hoster/system administrator to check if the 'pcntl' extension is installed.

Number of Parallel Processes - specify the number of processes according to your server capabilities. The more parallel processes are set, the faster the export process goes, but the higher the server loads.

Export Product Profiles

The extension allows you to create flexible profiles for the products export and execute it on regular basis. To view all the profiles, please go to System → Export Products → Profiles.

You can view, delete, add new profiles or run any of them manually right from the grid.

To create a new profile, hit the Add New Profile button and follow a profile set up steps.

General Configuration

In the first tab, you can adjust the general information of the profile.

Profile Name - specify the profile name for internal usage. This name will be displayed in the grid.

Export Only New Entities - enable this setting to skip the previously exported products. The option is useful in case you export the profile regularly and only recently created products are needed.

Batch Size - set the number of products that will be processed in one iteration. You may configure batch size for each profile separately or specify the value in general configuration settings and use this default value.

Output Options

Proceed to the configuration of output options.

File Name - add the title for the export file.

Use {date|format} to customize filename. Example: Filename-{date|Y_m_d_h_i_s}. Here you may explore more options for date format.

Output File Encoding - choose the suitable type of export file encoding from the dropdown. UTF-8 is used by default.

Compress Export File With Gzip - enable the toggle to compress the file and save extra space on a server.

Export File Storage

Choose where to export the profile: on the internal or external server, send the exported file by email or API.

If Store Exported File On Server is enabled, provide File Path and File Name on Server. The file will be saved in Magento 'var' directory relative to the specified path.

If you want to Upload Exported File By FTP / SFTP, you will need to fill the following fields:

  • Host
  • User
  • Password
  • File Path
  • File Name for FTP/SFTP.

For FTP you can also enable a Passive Mode.

In case you want to Send Exported File to E-mail, provide:

  • Email Sender
  • E-mail Recipients
  • E-mail Message Subject
  • Email Template.

If you are using Send to Rest Api Endpoint, provide:

  • Rest Api Endpoint
  • Auth (No Auth / Bearer / Basic)
  • Method (POST / PUT)
  • Content Type (JSON / XML).

Dropbox Configuration

To export to Dropbox, you will need to provide the access token. Follow the steps below to get the token.

1. Go to https://www.dropbox.com/developers and sign in.

2. Hit the Create Apps button.

3. Choose an API, a type of access you need and specify the title for your folder.

Agree with the terms & conditions and click Create App. You will be automatically redirected to the folder configuration.

4. Proceed to the Permissions tab.

Grant the permissions to write the files and click Submit.

5. Return to the Settings tab.

6. Find the OAuth 2 section and hit the Generate button below the Generated access token field.

7. Copy the token and paste it into the Generated Access Token field.

Google Drive Configuration

To set the integration with Google Drive, you need a specific API key. To get the key and configure this output option correctly, follow the steps below.

1. First of all, you need to install Google APIs Client Library on your Magento instance. Click here and install composer require google/apiclient:“^2.0”.

2. Go here and choose a project or create a new one if necessary.

3. When the required project is chosen, return to this page and enable Google Drive API.

4. If everything is correct, you will see the following status:

5. Click Manage and proceed to APIs & Services → Credentials. There click Create Credentials →Service account.

6. Provide Service account details. You can skip Step 2 and Step 3.

Click Done.

7. Navigate to the Service accounts tab and find the required service. Expand the Actions dropdown and hit the Manage keys option.

8. Expand the Add Key dropdown and select Create new key.

9. Choose JSON file format and hit the Create button.

The file will be automatically generated and downloaded.

10. Proceed to the Details tab and copy the email.

11. Go to My Drive. Create a folder to which export files will be output from Magento. Specify the title.

12. Now click Share and insert the email that you've copied. Click Done.

13. Return to the admin panel. Upload a JSON file, provide the path to the created folder and specify an export file naming with or without data format.

The configuration is ready. Run export profile and check the file in the Drive folder.

File Settings

Now you need to choose the required file type and configure its settings.

The following formats are available:

  • CSV
  • XML
  • ODS
  • XLSX
  • JSON
  • Template

For CSV, ODS and XLSX formats you can:

Add Header Row - column titles will be displayed in this row.

Merge Rows into One - if this setting is enabled, the information from multiple rows will be merged into one cell. The character that delimits each field of the child rows is customizable. Check the GIF in a demo to see how it works.

Duplicate Parent Entity Data - if enabled, the values of the child entities will be duplicated from the parent one.

See how it works

If disabled, child values are empty:

If enabled, the values are duplicated:

Please, use the setting while exporting one sequence of subentity, e.g. Order - Order Item - Product - Product Attribute, to avoid duplicating independent data.

For a CSV file you can additionally set:

  • Field Delimiter
  • Field Enclosure Character

For an XML file you can customize:

  • XML Item Tag
  • Header
  • Footer

XSLT Editor

The extension includes an XSLT editor so that you could output XML files with any custom formatting. Using this functionality, you can create custom templates for XML documents and add, remove, rearrange or sort elements in the file.

What is XSLT?

A lot of 3rd-party platforms you are integrating with use custom XML table formatting. Magento itself can't adapt such files automatically since each platform has its own requirements. XSLT (Extensible Stylesheet Language Transformations) helps to interpret the values from the Magento database and put them in an XML document. The editor helps to organize data in the file and make it acceptable for the platform you are exporting to.

Find out how the XSLT works in this tutorial.

Before exporting a custom XML file, review the formatting requirements and find out how the attributes provided in the document are named and structured in Magento. Then, create an Xsl Template to match the values.

To simplify template creation, download this ready-made sample file: xsl-template-for-export.zip


For JSON specify:

  • Header
  • Footer

For Template:

Using the Template option, you can build a unqiue file suitable for specific needs. Thanks to the integrated Twig PHP template engine, you can create any template you want to:

See Twig documentation to learn more about the features and configuration.

Fields Configuration

In the following step, you can start building your product export file by choosing the data to export. The functionality has a tree structure. Thus, you can add any entity, any field within a particular entity, customize prefixes/tags/delimiters, and so on to match the requirements of the system you are exporting to.

See how the tree-structured file is built:

Add any of the available entities to your export file:

Step 1. Add root entities

First, you need to configure the basic product entity and select the fields that will be added to the file on the root level.

Click Add Fields button and choose the relevant data to add to the export file.

You may also use a search window right in the popup to find the required fields faster. After selecting all needed fields, click Add Selected Fields.

When a field is added, you can customize a column title that will be displayed in the exported file. Moreover, use the Add Static Filed button to create columns that will remain unchanged in the file.

By clicking the Add Merged Field button, you can create custom columns that combine data from multiple fields. Also, it’s possible to customize the names of these columns and use symbols or words (such as 'and' or '/') to separate the data within them.

Please note that adding merged fields is available as a part of an active product subscription or support subscription.

Customize fields sorting within each entity using the drag-and-drop option.

For each file level, you can set custom tags, prefixes, and delimiters. See how it works:

Step 2. Add subentities

Then you can scroll down the entity list and enable any of them you need for your export file.

Just click the Enabled toggle and Add Fileds button. As it was shown above, a popup will appear and you will be able to add all the needed fields concerning a particular entity. For example, for the Product Attribute entity, you may add product name, sku, description, status, etc.

The same can be done for the entities with a lower level.

Also, the extension support MSI functionality. You can find the required fields on the Inventory Source Item level.

This way, you can build a unique profile, suitable for a particular system. Check the requirements from a system (as, for example, an ERP system or Marketplace platform needs different product data) and match the details.

Modify Values in Export Files

Now you can use modifiers to change the values in the export file. For example, you can change the date format, add any text and apply various mathematical actions to prices (e.g. rounding, multiplication, etc.).

Modifiers are added right during the fields configuration.

Hit the Add Modifier button and choose the required action in a dropdown.

Types of modifiers you can use:

  • Text Modifiers: Adjust the text of the text values by appending, prepending, capitalizing, etc.
  • Numeric Modifiers: Use for number modifications, e.g. rounding prices.
  • Date Modifiers: Specify a suitable date format and timezone.
  • Custom Modifiers: Replace the output of one field with the value of another.

Text Modifiers

Append - Adds the text after the value in the column. The text is specified in an additional field that appears when this modifier is selected.

Prepend - Adds text before the value in the column. The text is specified in an additional field that appears when this modifier is selected.

Capitalize - After selecting this modifier, the value in the column is capitalized.

Lower Case - After selecting this modifier, the whole word is written in lowercase.

Upper Case - After selecting this modifier, the entire word in a value field is capitalized.

Capitalize Each Word - After selecting this modifier, each word starts with a capital letter.

Strip Html Tags - Modifier removes all HTML tags from the string (the modifier is useful when exporting meta titles, descriptions, etc.).

Replace - After choosing this modifier, 2 fields appear: in the first one we indicate the word that needs to be replaced, and in the second one - the word to be replaced with.

Full Match Replace modifier functions similarly to the Replace modifier. However, it only replaces the value from the first field (From) with the value from the second field (To) when the value from the first field is fully matched.

For example, if you specifically need to replace only '2' with '3', it's better to choose the Full Match Replace modifier. This is because if you opt for the Replace modifier instead, specifying From: '2' and To: '3', it might result in '122' being replaced with '133' due to the presence of '2'.

Replace First - the same as Replace, but for the first case only.

Replace Text Wrapping - After selecting this modifier, the wrapping of multiline text is replaced with space by default. You can remove the space in the dependent field and enter another character you’d like to replace the wrapping of multiline text with.

Default value - When this modifier is selected, indicate the value that is added to the corresponding column by default (there is already a defaultValue).

Trim - This modifier removes spaces from the beginning and the end of the string (there is already a trim).

Numeric Modifiers

Price - Modifier adds currency to the value in the column.

Absolute Value - Modifier changes the negative value in the column to positive. Example: was -5 → now is 5.

Round To - When this modifier is selected, an additional field appears, in which we indicate the number of decimal places to which we round the number in the column. Example: 33.75 → enter 1 → get 33.8.

Plus - When this modifier is selected, indicate the number that is added to the number in the column.

Minus - Indicate the number that is subtracted from the number in the column.

Multiplied By - Specify the number that is multiplied by the number in the column.

Divided By - Provide the number by which the number in the column is divided.

Modulo - Indicate the number by which the number in the column is divided, and when division occurs, we get the remainder of the division in the export file. Example: we have 10, entered the number 3, received 1 in the file.

Truncate - Modifier removes decimal numbers without rounding. For example: 33.75 → Truncate → 33.

Ceil - Modifier allows you to round a number up to the nearest whole number.

Floor - Modifier allows you to round a number down to the nearest whole number.

Date Modifiers

Date Format - Specify the date format that is applied to the date in the file.

Apply Timezone - Choose the modifier for a timezone in UTC format.

Custom Modifiers

Сustom modifiers replace the output of the value of one field with the value of another. For example:

  • Value to Label: instead of value, the label will be displayed. Use case: with the Value to Label modifier, you can display a color label (like Black, Blue, etc.) instead of a color code;
  • Set Id to Set Name: instead of id, the name will be displayed;
  • Attribute Set Name to Set ID modifier allows to export an attribute set by specifying its name instead of id (this modifier is available only for the attribute_set_id field);
  • Product ID to Product SKU modifier enables the use of product IDs instead of product SKUs in subentities where there is no Product ID field;
  • Product ID To Product SKU modifier enables the use of product IDs instead of product SKUs for the 'parent_id' field of the Configurable Product Super Attribute Link subentity.

Export Filters

In the next tab, you can apply filtering to specify which products should be exported. The values of all entities and fields you've added to the file in a previous step are available for filtering. For example, you may add the products at a particular price or the products of a particular type.

Expand the necessary entity, click Add Filter, and specify the value you need to export.

Additionally, you can use specific filters for the Date parameter, e.g. export products created in the last X days or weeks.

Filter After Modifier Applied - check this toggle to filter data only after apllying particular modifier. For example, you can modify the timezone and apply date filter to the 'created_at' field after the modification.

You can also Exclude Parent Entity Row If No Results Found. It means that the parent entity row will be excluded from the export file if the child entity doesn't have filter results relative to the parent entity.

Have a look how it works:

Automatic Export

Configure the frequency to run the profile. 2 modes to run a profile are available:

  • by Cron
  • by Event

For exporting by cron, you can set one of the ready-made schedules or create a custom one.

For exporting by event, choose the event that will trigger a profile export. For now, only the export event Product Save is available.

Alert Notifications

Using this tab, you can enable email notifications about errors for a particular profile.

Enable Email Alert - set to Yes to notify the recipients about failed exports.

Email Sender - choose the contact that will send automatic emails.

Email Recipients - set to whom the emails will be sent.

Email Template - select the template for failure notifications.

Profile Export History

You can track the dynamics of each specific export profile right in its settings, in the Export History tab. Check the statuses, dates, logs, and the exported number of products. Download a file if necessary.

General Export History

You may also check the logs for all exported profiles in one place. Navigate to System → Amasty Export → Export History. See the statuses and check details to get a full picture.

REST API and CLI requests

It is possible to run import and export profiles using the REST API and CLI.

REST API:

  • “/V1/am_import_export/get_profile_runners/” method=“GET” - to get available profile runners
  • “/V1/am_import_export/run_profile/” method=“POST” - to run a profile
  • “/V1/am_import_export/check_profile_status/” method=“POST”- to check profile status

CLI:

  • php bin/magento am-import-export:show-profile-runners-list
  • php bin/magento am-import-export:run-profile product_import_profile 1
  • php bin/magento am-import-export:check-profile-status product_import_profile %identity_from_run_command%

3rd Party Connections

With the extension, you can link the data generated by 3rd party extensions to the export functionality. All created connections are displayed in the System → Export Products → 3rd Party Connections tab.

Click the Add New Connection button to create a new connection.

Name - specify the connection title for internal usage.

Table to Join - indicate a table name that needs to be joined.

Parent Entity - choose the entity table to which the foreign table will be joined.

Referenced Table Key - the field from the foreign table, by which the table chosen in 'Table to join' will be joined to the parent entity table.

Base Table Key - specify the field from the parent entity table which will be used for joining with the foreign table.

Save the changes. Now you can add this entity to the export file.

Amasty Export: Quick & Simple

This extension also helps to perform one-time operations as it has a simplified UI. If you have only Export Products extension, you will be able to export any product and inventory entity, but if you have other export extensions by Amasty, you will easily export any available entity in one place.

Go to System → Amasty Export → Export and select the entity to export.

As soon as you choose the entity, you will be able to configure export details, such as format, title, included fields, etc. Explore the configuration details for each tab in the Export Profile Configuration sections.

General Settings

To configure the general options for Amasty Export, go to Stores → Configuration → Amasty Extensions → Export.

Enable Multi-Process Export - set to Yes to speed up the export.

The 'Multi-Process Export' feature requires the PHP extension 'pcntl' to be installed on the server. If you enable the feature and no performance boost happens, please ask your hoster/system administrator to check if the 'pcntl' extension is installed.

Number of Parallel Processes - specify the number of processes according to your server capabilities. The more parallel processes are set, the faster the export process goes, but the higher the server loads.

Enable Debug Mode - set to Yes to allow the system to detect errors and display detailed information about them in the popup (including server errors). Also, error information can be found in var/log/amasty_import_debug.log.

Process Status Check Mode - select the Statuses option if you are using a multi-node environment (this helps prevent possible errors). If you are not using a multi-node environment, please leave the System Process ID option selected.

Enable Export without Memory Limit - enable the setting if the export process terminates because the memory limit exceeds to allow using all available memory volume for the export process.

CLI PHP Path - using this option, you can check the Magento path which is used by our extension when running the commands directly during the processing of PHP requests. To change it, please run the following command:

bin/magento config:set amasty_base/system/cli_php_path %CLI_PHP_PATH%
If you run a command and a new path is not displayed in this setting, please recheck the path you've specified. In case the path is incorrect, the changes won't be applied to the admin panel and you'll see the default path.

Amasty Export Pro: Cron Jobs

The extension also includes Amasty Export Pro features: you can create regular cron jobs to export any available entity.

Navigate to System → Amasty Export → Cron Jobs.

The more installed Amasty Export extensions you have, the more entities you can export by cron.

To add a new cron job, click New Export Job.

Specify the cron job title for internal use and set the schedule for exporting. The file configuration algorithm is the same as described in the Export Profile section.

Google Product Review templates

Please note that the Google Product Review and Advanced Product Review templates are available only as a part of an active product subscription or support subscription.

The ready-made Google Product Review cron job template is designed and configured for exporting product reviews to the feed (XML file type) suitable for Google. However, you can customize this cron job according to your needs: specify the export file name, set the schedule, choose the storage, etc.

This extension is compatible with Amasty Advanced Product Reviews. When both extensions are installed, the Advanced Product Review template with additional fields also becomes accessible on the Export Cron Jobs grid.

To restore the default templates in case they were modified or deleted, follow these steps:

1. Execute the command in the database

  • for the Google Product Review template:
DELETE FROM patch_list WHERE patch_list.patch_name = 'Amasty\ProductReviewExport\Setup\Patch\Data\ExportReviewProfile'
  • for the Advanced Product Review template:
 DELETE FROM patch_list WHERE patch_list.patch_name = 'Amasty\ProductAdvancedReviewExport\Setup\Patch\Data\ExportAdvancedReviewProfile'

2. Execute the command in the console

php bin/magento setup:upgrade

Additional packages (provided in composer suggestions)

To make additional functionality available, please install the suggested packages you may need.

Available as a part of an active product subscription or support subscription:

  • amasty/module-export-merged-fields - This package provides the possibility of merging several export field values into one field.
  • amasty/module-product-review-export - This package provides the option to utilize the 'Google Product Review' template placed on the Export Cron Jobs grid.
  • amasty/module-product-advanced-review-export - This package provides the option to utilize the 'Advanced Product Review' template placed on the Export Cron Jobs grid (if you have the Amasty Advanced Product Reviews extension also installed).

Find out how to install the Export Products extension for Magento 2 via Composer.

Rate the user guide
 stars  from 2 votes (Details)
magento_2/export_products.txt · Last modified: 2024/12/04 13:37 by kkondrateva