VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: aqr996 on July 17, 2016, 15:55:34 PM

Title: Access virtuemart product data externally
Post by: aqr996 on July 17, 2016, 15:55:34 PM
Hi,
Is there a quick fire method of accessing all the data for a product from an external file by using its sku?

I have looked at http://stackoverflow.com/questions/24204394/how-can-i-get-prodcut-data-of-a-virtuemart-2-product-in-an-external-file

and tried to replace the Product ID with my desired id but to no avail:

    if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');
    VmConfig::loadConfig();
    if (!class_exists( 'VmModel' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'vmmodel.php');
   
    $productModel = VmModel::getModel('Product');
    $product = $productModel->getProduct(Product_ID);

In short terms, I'm looking for a way to access product data.
Title: Re: Access virtuemart product data externally
Post by: PRO on July 18, 2016, 14:27:38 PM
what kind of format do you want?

what is the data used for?

This can be done with using a separate product details template
Title: Re: Access virtuemart product data externally
Post by: Studio 42 on July 18, 2016, 21:12:14 PM
DS do not exist in Joomla 3.
So use
    if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR .'/components/com_virtuemart/helpers/config.php');
    VmConfig::loadConfig();
    if (!class_exists( 'VmModel' )) require(JPATH_ADMINISTRATOR .  '/components/com_virtuemart/helpers/vmmodel.php');
   
    $productModel = VmModel::getModel('Product');
    $product = $productModel->getProduct(Product_ID);

I removed since 1 year in all my creation the DS and it work always when it's a path to a file as here.