当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductCategory::worklist方法代码示例

本文整理汇总了PHP中ProductCategory::worklist方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::worklist方法的具体用法?PHP ProductCategory::worklist怎么用?PHP ProductCategory::worklist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductCategory的用法示例。


在下文中一共展示了ProductCategory::worklist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load_facets

 public function load_facets()
 {
     if ('off' == $this->facetedmenus) {
         return;
     }
     $output = '';
     $this->filters();
     $Storefront = ShoppStorefront();
     if (!$Storefront) {
         return;
     }
     $CategoryFilters =& $Storefront->browsing[$this->slug];
     $Filtered = new ProductCategory($this->id);
     $filtering = array_merge($Filtered->facetsql(array()), array('ids' => true, 'limit' => 1000));
     $Filtered->load($filtering);
     $ids = join(',', $Filtered->worklist());
     // Load price facet filters first
     if ('disabled' != $this->pricerange) {
         $Facet = $this->facets['price'];
         $Facet->link = add_query_arg(array('s_ff' => 'on', urlencode($Facet->slug) => ''), shopp('category', 'get-url'));
         if (!$this->loaded) {
             $this->load();
         }
         if ('auto' == $this->pricerange) {
             $ranges = auto_ranges($this->pricing->average, $this->pricing->max, $this->pricing->min, $this->pricing->uniques);
         } else {
             $ranges = $this->priceranges;
         }
         if (!empty($ranges)) {
             $casewhen = '';
             foreach ($ranges as $index => $r) {
                 $minprice = $r['max'] > 0 ? " AND minprice <= {$r['max']}" : "";
                 $casewhen .= " WHEN (minprice >= {$r['min']}{$minprice}) THEN {$index}";
             }
             $sumtable = ShoppDatabaseObject::tablename(ProductSummary::$table);
             $query = "SELECT count(*) AS total, CASE {$casewhen} END AS rangeid\n\t\t\t\t\tFROM {$sumtable}\n\t\t\t\t\tWHERE product IN ({$ids}) GROUP BY rangeid";
             $counts = sDB::query($query, 'array', 'col', 'total', 'rangeid');
             foreach ($ranges as $id => $range) {
                 if (!isset($counts[$id]) || $counts[$id] < 1) {
                     continue;
                 }
                 $label = money($range['min']) . ' &mdash; ' . money($range['max']);
                 if ($range['min'] == 0) {
                     $label = sprintf(__('Under %s', 'Shopp'), money($range['max']));
                 }
                 if ($range['max'] == 0) {
                     $label = sprintf(__('%s and up', 'Shopp'), money($range['min']));
                 }
                 $FacetFilter = new ProductCategoryFacetFilter();
                 $FacetFilter->label = $label;
                 $FacetFilter->param = urlencode($range['min'] . '-' . $range['max']);
                 $FacetFilter->count = $counts[$id];
                 $Facet->filters[$FacetFilter->param] = $FacetFilter;
             }
         }
         // END !empty($ranges)
     }
     // Identify facet menu types to treat numeric and string contexts properly @bug #2014
     $custom = array();
     foreach ($this->facets as $Facet) {
         if ('custom' == $Facet->type) {
             $custom[] = sDB::escape($Facet->name);
         }
     }
     // Load spec aggregation data
     $spectable = ShoppDatabaseObject::tablename(Spec::$table);
     $query = "SELECT spec.name,spec.value,\n\t\t\tIF(0 >= FIND_IN_SET(spec.name,'" . join(",", $custom) . "'),IF(spec.numeral > 0,spec.name,spec.value),spec.value) AS merge, count(DISTINCT spec.value) AS uniques,\n\t\t\tcount(*) AS count,avg(numeral) AS avg,max(numeral) AS max,min(numeral) AS min\n\t\t\tFROM {$spectable} AS spec\n\t\t\tWHERE spec.parent IN ({$ids}) AND spec.context='product' AND spec.type='spec' AND (spec.value != '' OR spec.numeral > 0) GROUP BY merge";
     $specdata = sDB::query($query, 'array', 'index', 'name', true);
     foreach ($this->specs as $spec) {
         if ('disabled' == $spec['facetedmenu']) {
             continue;
         }
         $slug = sanitize_title_with_dashes($spec['name']);
         if (!isset($this->facets[$slug])) {
             continue;
         }
         $Facet =& $this->facets[$slug];
         $Facet->link = add_query_arg(array('s_ff' => 'on', urlencode($Facet->slug) => ''), shopp('category', 'get-url'));
         // For custom menu presets
         switch ($spec['facetedmenu']) {
             case 'custom':
                 $data = $specdata[$Facet->name];
                 $counts = array();
                 foreach ($data as $d) {
                     $counts[$d->value] = $d->count;
                 }
                 foreach ($spec['options'] as $option) {
                     if (!isset($counts[$option['name']]) || $counts[$option['name']] < 1) {
                         continue;
                     }
                     $FacetFilter = new ProductCategoryFacetFilter();
                     $FacetFilter->label = $option['name'];
                     $FacetFilter->param = urlencode($option['name']);
                     $FacetFilter->count = $counts[$FacetFilter->label];
                     $Facet->filters[$FacetFilter->param] = $FacetFilter;
                 }
                 break;
             case 'ranges':
                 foreach ($spec['options'] as $i => $option) {
                     $matches = array();
//.........这里部分代码省略.........
开发者ID:forthrobot,项目名称:inuvik,代码行数:101,代码来源:Collection.php


注:本文中的ProductCategory::worklist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。