VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: BillyMontoya on December 08, 2015, 11:42:33 AM

Title: How to use virtuemart models in my custom components?
Post by: BillyMontoya on December 08, 2015, 11:42:33 AM
I have developed a custom component to import different types of data in virtuemart. I am facing trouble to load virtuemart module in my custom component. I am using Joomla 3.4.1 and virtuemart 3.0.6.2

I have tried several ways to load model to my component.
I have 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' );

is there any way to get model?
Title: Re: How to use virtuemart models in my custom components?
Post by: GJC Web Design on December 08, 2015, 12:11:14 PM
if (!class_exists( 'VmConfig' ))
require(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php'); // make sure DS is defined in your comp
e.g.
defined('DS') or define('DS', DIRECTORY_SEPARATOR);

$model = VmModel::getModel('Manufacturer');
$manufacturers = $model->getManufacturers(true, true,true);

QuoteI am using Joomla 3.4.1 and virtuemart 3.0.6.2

both way out of date and insucure