如何在外部文件中获取VirtueMart 2产品的产品数据? [英] How can I get product data of a VirtueMart 2 product in an external file?

查看:109
本文介绍了如何在外部文件中获取VirtueMart 2产品的产品数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在外部php文件中获取VirtueMart 2产品的数据?

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

我正在使用joomla 2.5和VirtueMart 2,并且需要在同一主机上的php文件中检索产品数据.该php文件不是VirtueMart组件的一部分,也不是其他组件的一部分.该文件应该将检索到的产品数据提供给jquery小部件...

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...

推荐答案

在我看来这是不可能的.

it seems to me that it isn't possible.

在我的情况下,最佳实践是构建一个joomla模块,并在helper-php中输入我的所有代码. 我的用于ajax响应的php文件现在是该模块的一部分.这样我就可以轻松访问VirtueMart 2产品:

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

这篇关于如何在外部文件中获取VirtueMart 2产品的产品数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆