aimeos / ai-controller-jobs

Aimeos e-commerce job controllers
https://aimeos.org
GNU Lesser General Public License v3.0
28 stars 17 forks source link

Mimetype previews not added in CSV import #34

Closed nvindice closed 2 years ago

nvindice commented 2 years ago

When uploading a non-image media file via the admin interface, the media file gets a preview URL according to the mime type.

However, when importing products via CSV import, this does not work. The process function calls the update function which creates previews via the Media contoller's scale function: https://github.com/aimeos/ai-controller-jobs/blob/77a6d3ebcc98f0dfbd1a9de2a42f5dbdfaec5bed/controller/common/src/Controller/Common/Product/Import/Csv/Processor/Media/Standard.php#L233-L235

The scale function can only handle Images.

Solution 1 (ugly): checking the media type in the Media here: https://github.com/aimeos/aimeos-core/blob/f3fa1ec4b293ef2052f07fcdb082f0b6d947366d/controller/common/src/Controller/Common/Media/Standard.php#L199-L201 ...and set the $item preview to a mime type thumb

Solution 2: checking the media type in the CSV import processor (good) and either scale or add a mime type thumb - this would require to make this function public: https://github.com/aimeos/aimeos-core/blob/f3fa1ec4b293ef2052f07fcdb082f0b6d947366d/controller/common/src/Controller/Common/Media/Standard.php#L532

What do you think?

aimeos commented 2 years ago

The importer or any other class that is using the media controller should not need to know how to handle different files. Thus, adding similar code to scale() like in add() should do the job: https://github.com/aimeos/aimeos-core/blob/f3fa1ec4b293ef2052f07fcdb082f0b6d947366d/controller/common/src/Controller/Common/Media/Standard.php#L66-L68