function listProducts() { global $toC_Json, $osC_Database, $osC_Language; $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start']; $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit']; $variants = isset($_POST['variants']) ? $_POST['variants'] : 0; $osC_Tax = new osC_Tax_Admin(); $Qtc = $osC_Database->query('select tax_class_id, tax_class_title from :table_tax_class order by tax_class_title'); $Qtc->bindTable(':table_tax_class', TABLE_TAX_CLASS); $Qtc->execute(); $tax_class_array = array(); while ($Qtc->next()) { $tax_class_array[$Qtc->valueInt('tax_class_id')] = $osC_Tax->getTaxRate($Qtc->valueInt('tax_class_id')); } //get the variants products if ($variants == 1) { $result = osC_Specials_Admin::getVariantsProducts($start, $limit); //get the general products } else { $result = osC_Specials_Admin::getProducts($start, $limit); } $records = array(); if (count($result['products']) > 0) { foreach ($result['products'] as $product) { $rate = $product['products_tax_class_id'] == 0 ? 0 : $tax_class_array[$product['products_tax_class_id']]; $records[] = array('products_id' => $product['products_id'], 'products_name' => $product['products_name'], 'rate' => $rate); } } $response = array(EXT_JSON_READER_TOTAL => $result['total'], EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }