Back to PhocacartReview class

Method getReviewsByProduct

public static
getReviewsByProduct
(mixed $productId)

Method getReviewsByProduct - Source code

public static function getReviewsByProduct($productId)
{
    $db = Factory::getDBO();
    if ((int) $productId > 0) {
        $columns = 'a.id, a.product_id, a.user_id, a.name, a.rating, a.review, a.date, a.published';
        $groupsFull = $columns;
        $groupsFast = 'a.id';
        $groups = PhocacartUtilsSettings::isFullGroupBy() ? $groupsFull : $groupsFast;
        $query = 'SELECT ' . $columns . ' FROM #__phocacart_reviews AS a' . ' WHERE a.product_id = ' . (int) $productId . ' AND a.published = 1' . ' GROUP BY ' . $groups;
        $db->setQuery($query);
        $reviews = $db->loadObjectList();
        return $reviews;
    }
    return false;
}