Decorator to use when importing products via CSV

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
yeh
Posts: 39
Joined: 27 Jun 2022, 13:26

Decorator to use when importing products via CSV

Post by yeh » 26 Aug 2022, 14:51

I would like to alter some product attributes after it is saved during a CSV import.

What is the best way to go about this? I have already implemented decorators on the jqadm/product config which works fine when updating products on the admin pages, but these decorators aren't used when importing via CSV.

User avatar
aimeos
Administrator
Posts: 7893
Joined: 01 Jan 1970, 00:00

Re: Decorator to use when importing products via CSV

Post by aimeos » 29 Aug 2022, 06:44

Maybe it's better to implement a decorator for the manager save() method as this covers admin and import cases.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

yeh
Posts: 39
Joined: 27 Jun 2022, 13:26

Re: Decorator to use when importing products via CSV

Post by yeh » 30 Aug 2022, 14:26

Okay that looks like it might work.

Is it possible to find out the method being used (CSV import or admin page save) when using the product manager decorator?

Also, is it possible to use the view access helper (https://aimeos.org/docs/2022.x/infrastr ... rs/#access) from a manager decorator?

User avatar
aimeos
Administrator
Posts: 7893
Joined: 01 Jan 1970, 00:00

Re: Decorator to use when importing products via CSV

Post by aimeos » 01 Sep 2022, 10:56

yeh wrote: 30 Aug 2022, 14:26 Is it possible to find out the method being used (CSV import or admin page save) when using the product manager decorator?
No, so this method is best when the data should be always transformed in the same way.
yeh wrote: 30 Aug 2022, 14:26 Also, is it possible to use the view access helper (https://aimeos.org/docs/2022.x/infrastr ... rs/#access) from a manager decorator?
In a job controller for importing the CSV, there's no logged in user so this won't work.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

yeh
Posts: 39
Joined: 27 Jun 2022, 13:26

Re: Decorator to use when importing products via CSV

Post by yeh » 01 Sep 2022, 15:06

Thanks for the feedback. I have decided to look at overriding the

Aimeos\Controller\Common\Product\Import\Csv\Processor\*

classes as I also need to compare existing product data with what is being uploaded via CSV before making changes.

Basically I would like to set the product status to review if certain fields change.

Post Reply