我正在尝试获取产品的自定义字段的值。我只有该产品的ID。我知道自定义字段的标题。

如何获得该自定义字段的价值?

请帮忙。

PS:我非常了解PHP,但是我是Joomla / Virtuemart的新手。

最佳答案

这将适用于VM2.x

VM将自定义字段值存储在#__virtuemart_customs中

产品和自定义字段之间的关系保持在#__virtuemart_product_customfields中

您具有标题和产品ID,因此可以尝试

$db = &JFactory::getDBO();
$sql = "SELECT F.custom_value #__virtuemart_customs AS C LEFT JOIN #__virtuemart_product_customfields AS F ON F.virtuemart_customfield_id = C.virtuemart_custom_id where (C.custom_title='$your_customtitle' and F.virtuemart_product_id = '$product_id')";
$db->setQuery($sql);
$db->query();
$res = $db->loadAssoc();
echo $res['custom_value'];


您也可以尝试使用内部子查询。

关于joomla2.5 - 在Virtuemart中获取产品自定义字段值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13279619/

10-13 02:54