public static
getAllParameterValues
(mixed $parameterId, mixed $ordering = 1, mixed $onlyAvailableProducts = 0, mixed $lang = '', mixed $filterProducts = array(), mixed $limitCount = -1)
public static function getAllParameterValues($parameterId, $ordering = 1, $onlyAvailableProducts = 0, $lang = '', $filterProducts = array(), $limitCount = -1)
{
/* $db = JFactory::getDBO();
$orderingText = PhocacartOrdering::getOrderingText($ordering, 12);
$query = 'SELECT t.id, t.title, t.alias FROM #__phocacart_tags AS t WHERE t.published = 1 ORDER BY '.$orderingText;
$db->setQuery($query);
$tags = $db->loadObjectList();
return $tags;*/
$wheres = array();
$lefts = array();
$related = '#__phocacart_parameter_values_related';
$db = Factory::getDBO();
$orderingText = PhocacartOrdering::getOrderingText($ordering, 13);
$columns = 'pv.id, pv.title, pv.alias, pv.count_products';
/*$groupsFull = $columns;
$groupsFast = 'm.id';
$groups = PhocacartUtilsSettings::isFullGroupBy() ? $groupsFull : $groupsFast;*/
$wheres[] = ' pp.published = 1';
// Parameter (parameter group)
$wheres[] = ' pv.published = 1';
// Parameter Value
if ($onlyAvailableProducts == 1) {
if ($lang != '' && $lang != '*') {
$wheres[] = PhocacartUtilsSettings::getLangQuery('p.language', $lang);
}
$lefts[] = ' #__phocacart_parameter_values_related AS pr ON pr.parameter_value_id = pv.id';
$lefts[] = ' #__phocacart_products AS p ON pr.item_id = p.id';
$rules = PhocacartProduct::getOnlyAvailableProductRules();
$wheres = array_merge($wheres, $rules['wheres']);
$lefts = array_merge($lefts, $rules['lefts']);
} else {
if ($lang != '' && $lang != '*') {
$wheres[] = PhocacartUtilsSettings::getLangQuery('pv.language', $lang);
$lefts[] = ' #__phocacart_parameter_values_related AS pr ON pr.parameter_value_id = pv.id';
$lefts[] = ' #__phocacart_products AS p ON pr.item_id = p.id';
}
}
if (!empty($filterProducts)) {
$productIds = implode(',', $filterProducts);
$wheres[] = 'p.id IN (' . $productIds . ')';
}
if ($limitCount > -1) {
$wheres[] = 'pv.count_products > ' . (int) $limitCount;
}
$lefts[] = ' #__phocacart_parameters AS pp ON pv.parameter_id = pp.id';
$wheres[] = 'pp.id = ' . (int) $parameterId;
$q = ' SELECT DISTINCT ' . $columns . ' FROM #__phocacart_parameter_values AS pv' . (!empty($lefts) ? ' LEFT JOIN ' . implode(' LEFT JOIN ', $lefts) : '') . (!empty($wheres) ? ' WHERE ' . implode(' AND ', $wheres) : '') . ' ORDER BY ' . $orderingText;
$db->setQuery($q);
$items = $db->loadObjectList();
return $items;
}