VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: balai on January 28, 2020, 12:21:49 PM

Title: Bug deleting custom field plugin values in the product
Post by: balai on January 28, 2020, 12:21:49 PM
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.

Title: Re: Bug deleting custom field plugin values in the product
Post by: pinochico on January 28, 2020, 19:28:18 PM
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
Title: Re: Bug deleting custom field plugin values in the product
Post by: pinochico on February 27, 2020, 02:41:12 AM
Helo Max,

can you feedback for this pls?

Thanks

Rudolf
Title: Re: Bug deleting custom field plugin values in the product
Post by: pinochico on July 19, 2020, 15:20:47 PM
Helo Max or VM DEV,

can you feedback for this pls?

Thanks

Rudolf
Title: Re: Bug deleting custom field plugin values in the product
Post by: 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 = '' ));
}
Title: Re: Bug deleting custom field plugin values in the product
Post by: balai on November 03, 2020, 12:23:56 PM
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.
Title: Re: Bug deleting custom field plugin values in the product
Post by: pinochico on November 03, 2020, 13:38:13 PM
jupííí :)
Title: Re: Bug deleting custom field plugin values in the product
Post by: pinochico on November 27, 2020, 13:10:44 PM
is fixed this bug with this diff ? - http://dev.virtuemart.net/projects/virtuemart/repository/revisions/10373
Title: Re: Bug deleting custom field plugin values in the product
Post by: balai on November 27, 2020, 14:44:56 PM
Yes it does