How can I get product data of a VirtueMart 2 product in an external file?

我的未来我决定 提交于 2019-12-12 03:01:10

问题


is it possible to get the data of a VirtueMart 2 product in an external php file?

I'm using joomla 2.5 and VirtueMart 2 and need to retrieve the product data in a php-file on the same host. this php file isn't part of the VirtueMart component and also not part of an other component. this file is supposed to give the retrieved product data to a jquery widget...


回答1:


it seems to me that it isn't possible.

the best practice in my case is to build a joomla module and enter all my code in the helper-php. my php file for the ajax response is now part of the module. with that i can easily access an VirtueMart 2 product:

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);


来源:https://stackoverflow.com/questions/24204394/how-can-i-get-product-data-of-a-virtuemart-2-product-in-an-external-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!