Customer manager save event
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Customer manager save event
Thank you very much! It works. But another problem( Method saveItem from my decorator also called when I delete customer in backend. How can I know if saveItem was called because of deletion ? Or how to solve it.. ?
Re: Customer manager save event
Currently, that's hard to distingish. In the next version, we will delete the referenced items directly instead of using saveItem().
In the meantime, you can overwrite the JQAdm customer class and replace saveItem() in https://github.com/aimeos/ai-admin-jqad ... d.php#L152 by:
In the meantime, you can overwrite the JQAdm customer class and replace saveItem() in https://github.com/aimeos/ai-admin-jqad ... d.php#L152 by:
Code: Select all
$rmIds = [];
foreach( $view->item->getListItemsDeleted() as $listItem )
{
if( $listItem->getRefItem() !== null ) {
$rmIds[$listItem->getDomain()][] = $listItem->getRefId();
}
}
foreach( $rmIds as $refDomain => $ids ) {
\Aimeos\MShop::create( $context, $refDomain )->deleteItems( $ids );
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Customer manager save event
Another problem I faced with (( In the decorator's saveItem method can I know if $item was modified ? And which fields was modified ?
For now I only have stupid idea to fetch this item from DB and compare fields. But it will be one more query each time when saveItem...
For now I only have stupid idea to fetch this item from DB and compare fields. But it will be one more query each time when saveItem...
Re: Customer manager save event
For the main items, you can use:
But you have to check the referenced items and properties too if you want to know if ANYTHING changed (each item has the isModified() method).
Code: Select all
$item->isModified()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Customer manager save event
Hmmm, I check isModified() method in my decorator before saveItem. And when I go to some customer in backend and change nothing, just click save - it gives me true.. But I have not changed any fields.. Can I solve it somehow ?
Re: Customer manager save event
The database driver converts fetched data to unexpected types ('' => NULL and 5 => '5'). That lead to modified items whenever you press save in the admin interface. We've implemented a workaround for that. Can you please run that commands and test if the modified flag isn't set any more without change?
Code: Select all
composer req aimeos/aimeos-core 2019.10.x-dev
composer req aimeos/ai-admin-jqadm 2019.10.x-dev
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Customer manager save event
Thank you for great cooperation! I have executed that commands and successfully got dev versions:
But no success ((
I tried $item->isModified() in my customer manager decorator and in my custom customer manager in saveItem() method. It always returns true. I tried from back-end, just went into some customer and clicked save. Nothing changed (
How can I revert back my composer to exact versions which I used before ?
Code: Select all
"aimeos/ai-admin-jqadm": "2019.10.x-dev",
"aimeos/aimeos-core": "2019.10.x-dev",
I tried $item->isModified() in my customer manager decorator and in my custom customer manager in saveItem() method. It always returns true. I tried from back-end, just went into some customer and clicked save. Nothing changed (
How can I revert back my composer to exact versions which I used before ?
Re: Customer manager save event
You can find out what's causing the modified flag if you add the code below here:
https://github.com/aimeos/aimeos-core/b ... e.php#L135
https://github.com/aimeos/aimeos-core/b ... e.php#L135
Code: Select all
if( !strncmp( $name, 'customer', 8 ) ) {
error_log( 'modified: ' . $name . ' :: ' . var_export( $this->bdata[$name] ?? null, true ) . ' -> ' . var_export( $value, true ) );
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Customer manager save event
Ok, I have tried it with this:
And I have changed nothing as usual and the log looks like this:
Can I solve this problem ?
Code: Select all
"aimeos/ai-admin-jqadm": "2019.10.x-dev",
"aimeos/aimeos-core": "2019.10.x-dev",
Code: Select all
[15-Nov-2019 15:18:15 UTC] modified: customer.groups :: NULL -> array (
0 => 1,
)
Re: Customer manager save event
We've found the problem with get/setGroups(). Can you run "composer update" to get the latest aimeos/aimeos-core 2019.10.x-dev version and try again?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star