/** * 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); }
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();