The function plgVmOnStoreProduct is triggered only when a plugin custom field is found in the product.
That means that if we delete the custom plugin's record from a product, the function plgVmOnStoreProduct will not be triggered.
If the plugin uses it's own database tables to store the product>value relationship, this row will never deleted from it's tables, because the plgVmOnStoreProduct will not be called, for that plugin.
The problem resides in the following code in the file: administrator/components/com_virtuemart/models/customfields.php
if (isset($datas['customfield_params']) and is_array($datas['customfield_params'])) {
foreach ($datas['customfield_params'] as $key => $plugin_param ) {
$dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param ));
}
}
My suggestion is to trigger the function even if a custom plugin is not found.
if (isset($datas['customfield_params']) and is_array($datas['customfield_params'])) {
foreach ($datas['customfield_params'] as $key => $plugin_param ) {
$dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param ));
}
} else {
$dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param = '' ));
}
This way the plugins can clear records related with that product.
I would really appreciate any feedback from the VM devs on that.
Hi Balai,
Thank you for a detailed description of the error, I wouldn't notice it until the customer noticed me that something was wrong.
And I think that this last year at one e-shop dealt that the correct saving products in administration.
At the time in the past, our client reported, this as a mistake from CustomFilters (I don't know how he checked it).
Now it's the same, but I'll wait for the result == client informed that we are waiting for the statement Virtuemart DEV.
Thanks
Rudolf
Helo Max,
can you feedback for this pls?
Thanks
Rudolf
Helo Max or VM DEV,
can you feedback for this pls?
Thanks
Rudolf
Sorry, I did not see this post. Yes, very good hint. I think for this case we should add a new trigger, or?
Otherwise we need a switch in the other trigger. So unclean, or not?
if (isset($datas['customfield_params']) and is_array($datas['customfield_params'])) {
foreach ($datas['customfield_params'] as $key => $plugin_param ) {
$dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param ));
}
} else {
$dispatcher->trigger('plgVmOnStoreProductRemove', array($datas, $plugin_param = '' ));
}
Quote from: Milbo on November 02, 2020, 19:43:44 PM
Sorry, I did not see this post. Yes, very good hint. I think for this case we should add a new trigger, or?
Otherwise we need a switch in the other trigger. So unclean, or not?
if (isset($datas['customfield_params']) and is_array($datas['customfield_params'])) {
foreach ($datas['customfield_params'] as $key => $plugin_param ) {
$dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param ));
}
} else {
$dispatcher->trigger('plgVmOnStoreProductRemove', array($datas, $plugin_param = '' ));
}
Hi Max
A new trigger would be great.
Otherwise a variable/flag in the passed parameters that will indicate that everything is removed.
jupííí :)
is fixed this bug with this diff ? - http://dev.virtuemart.net/projects/virtuemart/repository/revisions/10373
Yes it does