News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

get product ratings from product id

Started by JLinker, June 01, 2015, 00:12:41 AM

Previous topic - Next topic

JLinker

Hi,

I'm in VM 3.0.8, trying to pull a list of reviews by providing the product id.
The only function I've found which could do this is the following one.
File administrator/components/com_virtuemart/models/ratings.php line 174, there is the following function:

function getRatingByProduct($product_id,$onlyPublished=true){
    $q = 'SELECT * FROM `#__virtuemart_ratings` WHERE `virtuemart_product_id` = "'.(int)$product_id.'" ';
if($onlyPublished){
$q .= 'AND `published`="1" ';
}
$db = JFactory::getDBO();
$db->setQuery($q);
return $db->loadObject();
    }


The problem is that it returns only one record, because of $db->loadObject();
Shouldn't it return a $db->loadObjectList()?

If it's a bug, has the issue already been addressed?
Thanks a lot


JLinker - Mass Menu Link Generator for Joomla 2.5 and Joomla 3.x.
Generate hundreds of menu links in a few seconds for Joomla, K2, Community Builder, Phoca Download, JDownloads, SobiPro, Virtuemart. Website: http://www.jlinker.com

JLinker

JLinker - Mass Menu Link Generator for Joomla 2.5 and Joomla 3.x.
Generate hundreds of menu links in a few seconds for Joomla, K2, Community Builder, Phoca Download, JDownloads, SobiPro, Virtuemart. Website: http://www.jlinker.com

PRO

do you want ratings? or reviews?

They are different

you want the text reviews right?

also: where are you trying to display them?

Milbo

I think you missed just getReviewsByProduct

$ratingModel = VmModel::getModel('Ratings');
$productrating = $ratingModel->getReviewsByProduct($product->virtuemart_product_id);

I just notice it is missing the publish param
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/