/*
* We don't need catid, we get all categories for this product listed from group_concat
*/
public static function getProductByProductId($id)
{
if ($id < 1) {
return false;
}
$db = Factory::getDBO();
$query = ' SELECT a.id, a.title,' . ' group_concat(CONCAT_WS(":", c.id, c.title) SEPARATOR \',\') AS categories,' . ' group_concat(c.title SEPARATOR \' \') AS categories_title,' . ' group_concat(c.id SEPARATOR \',\') AS categories_id' . ' FROM #__phocacart_products AS a' . ' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id' . ' LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id' . ' WHERE a.id = ' . (int) $id . ' GROUP BY a.id, a.title' . ' ORDER BY a.id' . ' LIMIT 1';
$db->setQuery($query);
$product = $db->loadObject();
return $product;
}