本文整理汇总了PHP中Products::getByCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP Products::getByCategory方法的具体用法?PHP Products::getByCategory怎么用?PHP Products::getByCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products::getByCategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getByCategoryName
/**
* retrieve products by their category name
*
* @param string $name name of the category
* @param int $enabledFilter whether to allow enabled/disabled products
*
* @return object instance of Products object
*/
static function getByCategoryName($name, $enabledFilter = 0, $noRecurse = 0)
{
$arr = explode('/', $name);
if ($arr[0] == '') {
array_shift($arr);
}
$cid = 0;
foreach ($arr as $name) {
$cid = dbOne('select id from products_categories where parent_id=' . $cid . ' and name="' . addslashes($name) . '" limit 1', 'id', 'products_categories');
if (!$cid) {
break;
}
}
if (!$cid) {
return Products::getAll('', 0, $enabledFilter);
}
return Products::getByCategory($cid, array(), '_name', 'asc', 0, $noRecurse);
}
示例2: isset
if ($sort_dir != 'des') {
$sort_dir = 'asc';
}
$search = isset($_REQUEST['sSearch']) ? $_REQUEST['sSearch'] : '';
$search_arr = array();
for ($i = 0; $i < count($columns); ++$i) {
if (!isset($_REQUEST['sSearch_' . $i]) || $_REQUEST['sSearch_' . $i] === '') {
continue;
}
$search_arr[$columns[$i]] = $_REQUEST['sSearch_' . $i];
}
switch ($PAGEDATA->vars['products_what_to_show']) {
case '1':
// { by type
$id = (int) $PAGEDATA->vars['products_type_to_show'];
$products = Products::getByType($id, $search, $search_arr, $sort_col, $sort_dir);
break;
// }
// }
case '2':
// { by category
$id = (int) $PAGEDATA->vars['products_category_to_show'];
$products = Products::getByCategory($id, $search, $search_arr, $sort_col, $sort_dir);
break;
//}
//}
default:
Core_quit();
}
$total_records = count($products->product_ids);
$returned_products = array();