News:

Support the VirtueMart project and become a member

Main Menu

Trigger plgVmOnStoreProduct

Started by sbou, March 02, 2016, 18:17:07 PM

Previous topic - Next topic

sbou

Hi,

In the plugin plugins/vmcustom/specification/specification.php i can see a function probably call by a trigger:

function plgVmOnStoreProduct($data,$plugin_param){


But i don't see how is trigged this function.

I'm looking for a trigger in virtuemart onStoreProduct i need for a custom component.

Stéphane


GJC Web Design

yes-- I've been confused/sad about this one

only available from administrator\components\com_virtuemart\models\customfields.php if a custom field is set

I don't know why

JPluginHelper::importPlugin('vmcustom');
      $dispatcher = JDispatcher::getInstance();
      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 ));
         }
      }
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

Salut Stéphane,
plgVmOnStoreProduct permit to save in an external table for eg.
I use a hidden customfield_params in product  form that on save this is triggered and use another input name for the other fields
eg
<input type="hidden" name="customfield_params[45][255]">
<input type="text" name="my_plugin_name[45][255][position]" value="default">
<input type="text" name="my_plugin_name[45][255][date]" value="default">
.....

GJC Web Design

nice!!!!!

excellent sideways thinking..  kudos and bookmarked  :)
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

sbou

Hi Studio42,

I need to synchronize another table when the product stock or price change.
What do you think it's the best way to do this.

There are no trigger on product update.

Stéphane

GJC Web Design

that's what he saying

use a hidden (dummy) customfield_params in the product form to call the customfields trigger
haven't tried...
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

If you need to trigger it in all products, then do not check for the plugin in onProductEdit function but use a static value in the plugin to prevent multiple add
set the hidden fields one time.
And use plgVmOnStoreProduct to get your values.

Another way is to use a Joomla system checking "task" and "option" input, but the problem is that the ID is only set after and VM redirect, so you can only check for updates and not for a new product.

sbou

Hi,

I follow your idee and make a customvm plugin.

I use plgVmOnProductEdit to display some info i need to configure
and plgVmOnStoreProduct to trigger database save information when product is saved.

It's work fine when i save the product in virtuemart product page.

But the trigger are not send :
- when i update an order in backend manually
- when the product is purchased in front-end.

The idee is to save data in another table when the product quantidy is changed (backend or cart completed)

Stéphane


Stéphane

GJC Web Design

investigate

plgVmOnUpdateSingleItem($data, $order) 
&& 
plgVmConfirmedOrder ($cart, $order)
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

sbou

Thanks i was on plgVmGetProductStockToUpdateByCustom