Hi,
I'm currently using vm3.0.12, Joomla! 3.4.6 and PHP 5.5.22.
I would like to develop a new plugin for vm3 for implementing a new way in managing stock of products. I have pretty clear which files I have to modify in vm but I would like to develop it like a plugin for easier portability to next versions of vm and manutebility. In this optic I have a lot of doubts, can someone indicate me the way in which to proceed?
I try to describe better my needs.
In order to do this I need to change the behaviour of some existing models (like product.php) and existing views.
It's possible to extend existing models of vm within the models of a plugin? It's sufficient to include the class that I want to extend and extend it in a new model file of the plugin?
And for add functionalities to existing controllers?
How can I procced to override existing views with the plugin? It's possible or it's just possible to add new views?
Thanks for any indication!
the VM plugins work by being called by various triggers within the VM core
Just look at a bundled vmcustom one.. note the functions and find those triggers in the core
e.g. in the orders model is
JPluginHelper::importPlugin('vmpayment');
$_dispatcher = JDispatcher::getInstance();
$_returnValues = $_dispatcher->trigger('plgVmOnUpdateOrderPayment',array(&$data,$old_order_status));
this would trigger the function plgVmOnUpdateOrderPayment in any vmpayment plugin that had this function
I have also seen plugins/ext that over ride whole vm core functions
something like this may work
jimport('joomla.application.component.modellist');
jimport( 'joomla.application.module.helper' );
require_once(JPATH_VM_ADMIN . '/models/product.php');
class MynameModelProduct extends VirtueMartModelProduct
{
public function getProductListing($group = false, $nbrReturnProducts = false, $withCalc = true, $onlyPublished = true, $single = false, $filterCategory = true, $category_id = 0){
//do something but I think u need to recreate the whole function?
}
}
So if I search for all the trigger function call in vm core I should find all the possible functions that I may use in my plugin, right?
For the model is quite what I was thinking about,for sure I will try it.
For override existing views the only solution that I had was to copy the override files with the modifications to the html folder of the template on plugin installation. I don't realy like it, I would like a cleaner way to modify existing views. Do you know any alternative?
Thanks for help!
QuoteSo if I search for all the trigger function call in vm core I should find all the possible functions that I may use in my plugin, right?
correct
re views if you mean just the template what u describe is correct