Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property config for exporter causing incomplete exports #248

Open
seizan8 opened this issue Jan 25, 2021 · 1 comment
Open

Property config for exporter causing incomplete exports #248

seizan8 opened this issue Jan 25, 2021 · 1 comment

Comments

@seizan8
Copy link

seizan8 commented Jan 25, 2021

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.

Bildschirmfoto 2021-01-25 um 16 51 01

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

@corlanalexandru
Copy link

corlanalexandru commented Apr 21, 2021

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants