本文整理汇总了PHP中DataList::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP DataList::getList方法的具体用法?PHP DataList::getList怎么用?PHP DataList::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataList
的用法示例。
在下文中一共展示了DataList::getList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildAllAttributeFacets
/**
* Builds facets from all attributes present in the data set.
* @param DataList|PaginatedList $matches
* @return array
*/
protected function buildAllAttributeFacets($matches)
{
$q = $matches instanceof PaginatedList ? $matches->getList()->dataQuery()->query() : $matches->dataQuery()->query();
// this is the easiest way to get SiteTree vs SiteTree_Live
$baseTable = $q->getFrom();
if (is_array($baseTable)) {
$baseTable = reset($baseTable);
}
$q = $q->setSelect(array())->selectField('"ProductAttributeType"."ID"', 'TypeID')->selectField('"ProductAttributeType"."Label"', 'TypeLabel')->selectField('"ProductAttributeValue"."ID"', 'Value')->selectField('"ProductAttributeValue"."Value"', 'Label')->selectField('count(distinct ' . $baseTable . '."ID")', 'Count')->selectField('"ProductAttributeValue"."Sort"')->addInnerJoin('Product_StaticAttributeTypes', $baseTable . '."ID" = "Product_StaticAttributeTypes"."ProductID"')->addInnerJoin('ProductAttributeType', '"Product_StaticAttributeTypes"."ProductAttributeTypeID" = "ProductAttributeType"."ID"')->addInnerJoin('Product_StaticAttributeValues', $baseTable . '."ID" = "Product_StaticAttributeValues"."ProductID"')->addInnerJoin('ProductAttributeValue', '"Product_StaticAttributeValues"."ProductAttributeValueID" = "ProductAttributeValue"."ID"' . ' AND "ProductAttributeValue"."TypeID" = "ProductAttributeType"."ID"')->setOrderBy(array('"ProductAttributeType"."Label"' => 'ASC', '"ProductAttributeValue"."Sort"' => 'ASC'))->setGroupBy(array('"ProductAttributeValue"."ID"', '"ProductAttributeType"."ID"'))->execute();
$curType = 0;
$facets = array();
$curFacet = null;
foreach ($q as $row) {
if ($curType != $row['TypeID']) {
if ($curType > 0) {
$facets['ATT' . $curType] = $curFacet;
}
$curType = $row['TypeID'];
$curFacet = array('Label' => $row['TypeLabel'], 'Source' => 'ATT' . $curType, 'Type' => ShopSearch::FACET_TYPE_LINK, 'Values' => array());
}
unset($row['TypeID']);
unset($row['TypeLabel']);
$curFacet['Values'][$row['Value']] = new ArrayData($row);
}
if ($curType > 0) {
$facets['ATT' . $curType] = $curFacet;
}
return $facets;
}