VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: exolut on July 03, 2012, 16:42:36 PM

Title: Add metod :: getProductRelatedIds ($product_id)
Post by: exolut on July 03, 2012, 16:42:36 PM
I suggest adding the following method to extract the id of the related products
in administrator / com_virtuemart / models / product.php

function getProductRelatedIds ($product_id) {

if (empty($product_id)) {
return array();
}
$db = JFactory::getDBO ();
$db->setQuery (' SELECT field.`custom_value` FROM `#__virtuemart_customs` AS C LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id` WHERE `virtuemart_product_id` ='. (int)$product_id .' AND `field_type` = "R"' );

return $db->loadResultArray ();

}


I think it is useful to know immediately what products are related and may be used in the detail page without using the $ field-> display