简体   繁体   English

从模块访问Virtuemart ps_product函数

[英]Accessing Virtuemart ps_product functions from a module

Joomla 1.5.26 Joomla 1.5.26
Virtuemart 1.1.9 Virtuemart 1.1.9

I'd like to get data from VM database in a module using the functions of ps_product.php. 我想使用ps_product.php函数从VM数据库中获取数据。 Some work, some don't. 有些工作,有些没有。

Calling functions in ps_product that call other functions with "$this->" result in such an error message: ps_product中的调用带有“ $ this->”的其他函数的函数会导致这样的错误消息:

Fatal error: Call to undefined method JDocumentRendererModule::get_field() in (URL)/administrator/components/com_virtuemart/classes/ps_product.php on line XXX 致命错误:XXX行上(URL)/administrator/components/com_virtuemart/classes/ps_product.php中的未定义方法JDocumentRendererModule :: get_field()的调用

I included in my code: 我包含在我的代码中:

if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
    require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
} else {
    require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}

require_once(CLASSPATH.'ps_product.php');

How could I resolve this problem? 我该如何解决这个问题?

Ok, I found a solution but not sure that it was perfect. 好的,我找到了解决方案,但不确定是否完美。

I tried to call the ps_product function in the following way: 我尝试通过以下方式调用ps_product函数:

$a = ps_product::get_field('product_id', 'product_s_desc'); $ a = ps_product :: get_field('product_id','product_s_desc');

That doesn't work if the called function calls other functions in the class. 如果被调用的函数调用该类中的其他函数,那将不起作用。

Solution: 解:
Add

$ps_product = new ps_product;

and call functions like 并调用诸如
$a = $ps_product->get_field ('product_id', 'product_s_desc'); $ a = $ ps_product-> get_field ('product_id','product_s_desc');

Still some functions don't seem to work properly. 某些功能似乎仍无法正常工作。 For example product_has_attributes function should tell if aa product had assigned attributes or not and it returns always false.(?) 例如product_has_attributes函数应该告诉一个产品是否已分配了属性,并且它始终返回false。(?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM