Back to PhocacartCategoryMultiple class

Method getCategoryByProduct

public static
getCategoryByProduct
(mixed $id, mixed $catid)

Method getCategoryByProduct - Source code

public static function getCategoryByProduct($id, $catid)
{
    $db = Factory::getDBO();
    $query = ' SELECT c.id AS catid, c.title AS cattitle, c.alias AS catalias' . ' FROM #__phocacart_categories AS c' . ' LEFT JOIN #__phocacart_product_categories AS pc ON c.id = pc.category_id' . ' WHERE pc.product_id = ' . (int) $id . ' AND c.id = ' . (int) $catid . ' ORDER BY c.id' . ' LIMIT 1';
    $db->setQuery($query);
    $categories = $db->loadAssoc();
    return $categories;
}