本文整理汇总了PHP中ProductCategory::load方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::load方法的具体用法?PHP ProductCategory::load怎么用?PHP ProductCategory::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductCategory
的用法示例。
在下文中一共展示了ProductCategory::load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: screen
/**
* Interface processor for the product list manager
*
* @author Jonathan Davis
* @return void
**/
public function screen($workflow = false)
{
if (!current_user_can('shopp_categories')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$defaults = array('pagenum' => 1, 'per_page' => 500, 'id' => 0, 's' => '');
$args = array_merge($defaults, $_GET);
extract($args, EXTR_SKIP);
$pagenum = absint($pagenum);
if (empty($pagenum)) {
$pagenum = 1;
}
if (!$per_page || $per_page < 0) {
$per_page = 20;
}
$start = $per_page * ($pagenum - 1);
$CategoryProducts = new ProductCategory($id);
$CategoryProducts->load(array('order' => 'recommended', 'pagination' => false));
$num_pages = ceil($CategoryProducts->total / $per_page);
$page_links = paginate_links(array('base' => add_query_arg(array('edit' => null, 'pagenum' => '%#%')), 'format' => '', 'total' => $num_pages, 'current' => $pagenum));
$action = esc_url(add_query_arg(array_merge(stripslashes_deep($_GET), array('page' => ShoppAdmin::pagename('categories'))), admin_url('admin.php')));
include $this->ui('products.php');
}
示例2: 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']) . ' — ' . 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();
//.........这里部分代码省略.........
示例3: shopp_product_category
/**
* Get a ShoppProductCategory object
*
* @api
* @since 1.2
*
* @param int $cat the category id
* @param array $options (optional) loading options
* @return bool|ProductCategory returns false on error, ProductCategory on success
**/
function shopp_product_category($cat = false, $options = array())
{
if (!$cat) {
shopp_debug(__FUNCTION__ . " failed: Category id required.");
return false;
}
$Cat = new ProductCategory((int) $cat);
if (!$Cat->id) {
return false;
}
$defaults = array('pagination' => false);
$options = array_merge($defaults, $options);
$Cat->load($options);
return $Cat;
}