News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Bug deleting custom field plugin values in the product

Started by balai, January 28, 2020, 12:21:49 PM

Previous topic - Next topic

balai

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.


pinochico

#1
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
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

pinochico

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

pinochico

Helo Max or VM DEV,

can you feedback for this pls?

Thanks

Rudolf
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Milbo

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 = '' ));
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

balai

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.

pinochico

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

pinochico

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

balai