Author Topic: Custom field cloning to trigger a plugin function  (Read 984 times)

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1455
Custom field cloning to trigger a plugin function
« on: May 28, 2021, 12:45:28 pm »
Seems like the custom field cloning, just a duplicates a record of the #__virtuemart_customs db table.

This is ignoring custom plugins using 3rd party tables to store part of their configuration/state.

I suggest triggering a plugin call, after the custom field cloning, so that 3rd party plugins can make use of it.

Suggestion:
In the file: administrator/components/com_virtuemart/models/custom.php
function createClone

After that code:
Code: [Select]
if (!$clone = $row->store()) {
            vmError('createClone failed for ' . $id);
        }

add:

Code: [Select]
elseif ($row->field_type == 'E') {
            JPluginHelper::importPlugin('vmcustom');
            $dispatcher = JDispatcher::getInstance();
            $result = $dispatcher->trigger('plgVmOnClonePluginTable', array($row));
        }

So far tested that in my plugins.