2

I want to load 3rd party component's model to my custom created component. I tried following:

JLoader::import('joomla.application.component.model'); 
JLoader::import( 'manufacturer', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' );
$model = JModel::getInstance( 'Manufacturer', 'VirtueMartModel' );

But it didn't work. Is there any way to get model? I am trying to load viretuemart manufacturer model to my component.

I am using Joomla 3.4.1 and viretuemart 3.0.6.2.

I would like to know how to achieve this from my developed component's controller, model and also from view.

1 Answer 1

3

There is no standard way to integrate 3rd party component's model. Every developer implements its own way.

After integrating 50+ plugins in AutoTweetNG and Joocial, the method that usually works is to check extension's modules or plugins, looking for the way the model is integrated.

For instance, VirtueMart works in this way:

    if (!class_exists('VmConfig'))
    {
        require JPATH_ROOT . '/administrator/components/com_virtuemart/helpers/config.php';
        VmConfig::loadConfig();
    }

    $productModel = VmModel::getModel('Product');
2
  • It worked for me as I wanted to load model from virtuemart. But as per joomla documentation the method I have used should wok too. isnt it? Commented Mar 26, 2015 at 2:50
  • In my experience, each extensions implement its own models. From 50+ extensions, 1 extension (hwMediaShare) based on JModel and 18 extensions directly working on JTable.
    – Anibal
    Commented Mar 26, 2015 at 11:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.