SyliusImportExportPlugin
SyliusImportExportPlugin copied to clipboard
Property config for exporter causing incomplete exports
src/Resources/config/services_export_json.yaml
sylius.exporter.customers.json uses the following array as config for the exportable properties of customer:
["Email", "Email_canonical", "First_name" , "Last_name" , "Birthday", "Gender", "Phone_number", "Subscribed_to_newsletter"]
src/Explorer/Plugin/ResourcePlugin.php - keysToExport The method "addDataForId" registers properties of a resouce using entityManager->getClassMetadata. This registers properties in camelCase. For example: "Email", "EmailCanonical", "FirstName", "LastName",...
src/Explorer/Plugin/ResourcePlugin.php - data These key sets get compared in getData when hasPluginDataForExportKey gets called.
This ends up comparing "First_name" (keysToExport) to "FirstName" (data), which leads to first name not being exported properly.

The config is the same for spreadsheet and csv causing the same issue.
I am using the default config of the ImportExprtConfig. friendsofsylius/sylius-import-export-plugin: 0.18.0 sylius/sylius: 1.8.8 doctrine/doctrine-bundle: 1.12.13
Hello,
I managed to make the complete export for clients by re-declaring the required properties in services.yaml So, for customer, I have the right export in CSV,XLSX,JSON with:
#config/services.yaml
sylius.exporter.spreadsheet_writer_factory:
class: FriendsOfSylius\SyliusImportExportPlugin\Writer\PortSpreadsheetWriterFactory
sylius.exporter.spreadsheet_writer:
class: FriendsOfSylius\SyliusImportExportPlugin\Writer\SpreadsheetWriter
arguments:
- '@sylius.exporter.spreadsheet_writer_factory'
sylius.exporter.customers.csv:
class: FriendsOfSylius\SyliusImportExportPlugin\Exporter\ResourceExporter
arguments:
- "@sylius.exporter.csv_writer"
- "@sylius.exporter.pluginpool.customers"
- [ "Email", "EmailCanonical", "FirstName" , "LastName" , "Birthday", "Gender", "PhoneNumber", "CreatedAt", "UpdatedAt", "SubscribedToNewsletter" ]
- "@sylius.exporters_transformer_pool" # Optional
tags:
- { name: sylius.exporter, type: sylius.customer, format: csv }
sylius.exporter.customers.xlsx:
class: FriendsOfSylius\SyliusImportExportPlugin\Exporter\ResourceExporter
arguments:
- "@sylius.exporter.spreadsheet_writer"
- "@sylius.exporter.pluginpool.customers"
- [ "Email", "EmailCanonical", "FirstName" , "LastName" , "Birthday", "Gender", "PhoneNumber", "CreatedAt", "UpdatedAt", "SubscribedToNewsletter" ]
- "@sylius.exporters_transformer_pool"
tags:
- { name: sylius.exporter, type: sylius.customer, format: xlsx }
sylius.exporter.customers.json:
class: FriendsOfSylius\SyliusImportExportPlugin\Exporter\JsonResourceExporter
arguments:
- "@sylius.exporter.pluginpool.customers"
- [ "Email", "EmailCanonical", "FirstName" , "LastName" , "Birthday", "Gender", "PhoneNumber", "CreatedAt", "UpdatedAt", "SubscribedToNewsletter" ]
- "@sylius.exporters_transformer_pool"
tags:
- { name: sylius.exporter, type: sylius.customer, format: json }
sylius.exporter.pluginpool.customers:
class: FriendsOfSylius\SyliusImportExportPlugin\Exporter\Plugin\PluginPool
arguments:
- [ "@sylius.exporter.plugin.resource.customer" ]
- [ "Email", "EmailCanonical", "FirstName" , "LastName" , "Birthday", "Gender", "PhoneNumber", "CreatedAt", "UpdatedAt", "SubscribedToNewsletter" ]
-
sylius.exporter.plugin.resource.customer:
class: FriendsOfSylius\SyliusImportExportPlugin\Exporter\Plugin\ResourcePlugin
arguments:
- "@sylius.repository.customer"
- "@property_accessor"
- "@doctrine.orm.entity_manager"