Author Topic: Bug deleting custom field plugin values in the product  (Read 1061 times)

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1426
Bug deleting custom field plugin values in the product
« 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
Code: [Select]
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.

Code: [Select]
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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 798
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Bug deleting custom field plugin values in the product
« Reply #1 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
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 798
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Bug deleting custom field plugin values in the product
« Reply #2 on: February 27, 2020, 02:41:12 am »
Helo Max,

can you feedback for this pls?

Thanks

Rudolf
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 798
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Bug deleting custom field plugin values in the product
« Reply #3 on: July 19, 2020, 15:20:47 pm »
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 from products, orders and database table
Virtuemart Email Manager - customs email templates

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10073
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bug deleting custom field plugin values in the product
« Reply #4 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?

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

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1426
Re: Bug deleting custom field plugin values in the product
« Reply #5 on: November 03, 2020, 12:23:56 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?

Code: [Select]
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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 798
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Bug deleting custom field plugin values in the product
« Reply #6 on: November 03, 2020, 13:38:13 pm »
jupííí :)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates