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

Problems with ImageTransformation #201

Closed
stephangrass opened this issue Aug 20, 2021 · 2 comments
Closed

Problems with ImageTransformation #201

stephangrass opened this issue Aug 20, 2021 · 2 comments

Comments

@stephangrass
Copy link

stephangrass commented Aug 20, 2021

Hi,

I have an Excel spreadsheet with import data. There is a cell there with several links to PDF files. This would like to import. I use the following configuration for this:

            'external' => [
                '0' => [
                    'field' => 'product_downloads',
                    'multipleRows' => true,
                    'transformations' => [
                        10 => [
                            'userFunction' => [
                                'class' => \Cobweb\ExternalImport\Transformation\ImageTransformation::class,
                                'method' => 'saveImageFromUri',
                                'parameters' => [
                                    'storage' => '2:downloads',
                                    'defaultExtension' => 'pdf'
                                ]
                            ]
                        ]
                    ],
                    'children' => [
                        'table' => 'sys_file_reference',
                        'columns' => [
                            'uid_local' => [
                                'field' => 'my_field'
                            ],
                            'uid_foreign' => [
                                'field' => '__parent.id__'
                            ],
                            'title' => [
                                'field' => ''
                            ],
                            'tablenames' => [
                                'value' => 'my_table'
                            ],
                            'fieldname' => [
                                'value' => 'my_field'
                            ],
                            'table_local' => [
                                'value' => 'sys_file'
                            ]
                        ],
                        'controlColumnsForUpdate' => 'uid_local, uid_foreign, tablenames, fieldname, table_local',
                        'controlColumnsForDelete' => 'uid_foreign, tablenames, fieldname, table_local'
                    ]
                ]
            ]

Inserting and changing a file works perfectly.

But if the corresponding field is emptied for a data record, the entry in sys_file_reference will be not deleted.

Also 'multipleRows' => true, will not work.

@fsuter
Copy link
Contributor

fsuter commented Aug 20, 2021

Hmm, I thought I had a test scenario for the deletion of children records, but maybe not. I would have to check again. In the meantime I have no good solution for you, except maybe using a user function to clean up.

About multipleRows, it will work if you really have multiple rows, not if you have multiple lines inside a single value. The cell values would need to be split, but that is currently possible only when mapping to a secondary table. I have thought about introducing this for all values (#186), but I haven't come around to implement it yet. Your best bet would be to create a custom step and denormalize the data yourself.

@stephangrass
Copy link
Author

Ok, thanks ...

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