Back to PhocacartProduct class

Method getProductsByCategories

public static
getProductsByCategories
(mixed $cidA, mixed $limitOffset = 0, mixed $limitCount = 0, mixed $orderingItem = 1)

Method getProductsByCategories - Source code

public static function getProductsByCategories($cidA, $limitOffset = 0, $limitCount = 0, $orderingItem = 1)
{
    if (!empty($cidA)) {
        $cidS = implode(',', $cidA);
        $ordering = PhocacartOrdering::getOrderingCombination($orderingItem);
        $db = Factory::getDBO();
        $wheres = array();
        $wheres[] = 'c.id IN (' . $cidS . ')';
        $where = count($wheres) ? ' WHERE ' . implode(' AND ', $wheres) : '';
        $q = ' SELECT a.*, c.id as category_id, c.title as category_title, t.id as taxid, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle';
        // No Images, Categories, Attributes, Specifications here
        $q .= ', CONCAT_WS(":", t.id, t.alias) AS tax';
        $q .= ', CONCAT_WS(":", m.id, m.alias) AS manufacturer';
        $q .= ' 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' . ' LEFT JOIN #__phocacart_taxes AS t ON t.id = a.tax_id' . ' LEFT JOIN #__phocacart_manufacturers AS m ON m.id = a.manufacturer_id' . $where;
        if ($ordering != '') {
            $q .= ' ORDER BY c.ordering, ' . $ordering;
        }
        if ((int) $limitCount > 0) {
            $q .= ' LIMIT ' . (int) $limitOffset . ', ' . (int) $limitCount;
        }
        $db->setQuery($q);
        $products = $db->loadAssocList();
        return $products;
    }
}