Page 1 of 3
Customer manager save event
Posted: 29 Oct 2019, 14:40
by MikaelNazarenko
I need to export customer when it was saved. But not in all cases. In some case it must not do import. I have added logic to my custom customer manager saveItem() method. But problem is that I can't tell to manager when I don't need to make export or another action. I need make export of customer when it was saved on admin panel or front-end. I tried to add field 'makeExport' to manager or customer entity but it still makes export when I don't need it.... Can you, please, suggest me something.. ? I hope my problem is understandable )
Re: Customer manager save event
Posted: 30 Oct 2019, 07:14
by aimeos
Add your decorator only for frontend and backend but not for command in your ./config/shop.php:
https://github.com/aimeos/aimeos-larave ... #L104-L108
Re: Customer manager save event
Posted: 30 Oct 2019, 08:16
by MikaelNazarenko
Thank you! But can you please clarify how this settings with decorator must look like:
Code: Select all
'frontend' => [
],
'backend' => [
],
And how the decorator must look like for this specific case ? Ideally it must catch the customer saving. So when customer saved from backend or frontend - my logic will do necessary things
Re: Customer manager save event
Posted: 31 Oct 2019, 08:47
by aimeos
You have to implement the saveItem() and saveItems() method in your manager decorator:
https://aimeos.org/docs/Developers/Libr ... s#Easy_way
Configuration for frontend and backend would be:
Code: Select all
'frontend' => [
'customer' => [
'manager' => [
'decorators' => [
'local' => ['Myproject']
]
]
]
],
'backend' => [
'customer' => [
'manager' => [
'decorators' => [
'local' => ['Myproject']
]
]
]
],
Re: Customer manager save event
Posted: 31 Oct 2019, 09:29
by MikaelNazarenko
Aimeos, thank you very much !!
Re: Customer manager save event
Posted: 31 Oct 2019, 11:34
by MikaelNazarenko
One moment, it that documentation from your post, the class \Aimeos\MShop\Common\Manager\Decorator doesn't exist in newest versions of Aimeos. Which class should I use ? I guess \Aimeos\MShop\Common\Manager\Decorator\Base this one ?
My config looks like:
Code: Select all
'backend' => [
'customer' => [
'manager' => [
'decorators' => [
'local' => ['Customer']
]
]
]
],
My decorator:
Code: Select all
namespace Aimeos\MShop\Customer\Manager\Decorator;
class Customer extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
{
die;
// do something before
$result = $this->getManager()->saveItem( $item, $fetch );
// do somthing afterwards
return $result;
}
}
But when I save some customer in backend nothing happens..
What the problem ?
Versions of the components:
Code: Select all
aimeos/ai-admin-jqadm 2019.10.3 Aimeos ai-admin-jqadm extension
aimeos/ai-admin-jsonadm 2019.10.1 Aimeos ai-admin-jsonadm extension
aimeos/ai-client-html 2019.10.4 Aimeos ai-client-html extension
aimeos/ai-client-jsonapi 2019.10.1 Aimeos JSON API extension
aimeos/ai-controller-frontend 2019.10.2 Aimeos ai-controller-frontend extension
aimeos/ai-controller-jobs 2019.10.2 Aimeos ai-controller-jobs extension
aimeos/ai-gettext 2019.10.1 Aimeos Gettext extension
aimeos/ai-laravel 2019.10.1 Laravel adapter for Aimeos web shops and e-commerce solutions
aimeos/ai-payments 2019.10.1 Payment extension for Aimeos web shops and e-commerce solutions
aimeos/ai-swiftmailer 2019.10.1 SwiftMailer adapter for Aimeos web shops and e-commerce solutions
aimeos/aimeos-core 2019.10.2 Full-featured e-commerce components for high performance online shops
aimeos/aimeos-laravel 2019.10.1 Professional, full-featured and high performance Laravel e-commerce package for online shops and complex B2B projects
Re: Customer manager save event
Posted: 05 Nov 2019, 16:21
by MikaelNazarenko
Are you sure that it works ? For me doesn't.. And I can't find documentation for this for 2019 version..
Re: Customer manager save event
Posted: 05 Nov 2019, 16:26
by aimeos
Indeed, it's
Code: Select all
class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
Sorry for that, documentation is fixed.
Re: Customer manager save event
Posted: 05 Nov 2019, 16:58
by MikaelNazarenko
My problem is because nothing happens when I save the customer from admin panel (back-end). But there is a die; I described my files in couple posts above..
This is my decorators path /var/www/schmuck/ext/labor/lib/custom/src/MShop/Customer/Manager/Decorator/Customer.php
And decorator looks like:
Code: Select all
namespace Aimeos\MShop\Customer\Manager\Decorator;
class Customer extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
{
die;
// do something before
$result = $this->getManager()->saveItem( $item, $fetch );
// do somthing afterwards
return $result;
}
}
I can't understand what is the problem.. I also tried to set wrong decorator in settings like:
Code: Select all
'backend' => [
'customer' => [
'manager' => [
'decorators' => [
'local' => ['CustomerNotExisting']
]
]
]
],
But no any errors....
Maybe because I extended customer manager and sqls for insert, update, search.. But it should not..
Thanks for the help !
Re: Customer manager save event
Posted: 05 Nov 2019, 17:22
by aimeos
MikaelNazarenko wrote: ↑05 Nov 2019, 16:58
Code: Select all
'backend' => [
'customer' => [
'manager' => [
'decorators' => [
'local' => ['CustomerNotExisting']
]
]
]
],
You forgot the "mshop" key in your config:
Code: Select all
'backend' => [
'mshop' => [
'customer' => [
'manager' => [
'decorators' => [
'local' => ['Customer']
]
]
]
]
],