Exemplo n.º 1
0
 function listParentCategory()
 {
     global $toC_Json, $osC_Language;
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $records = array(array('id' => '0', 'text' => $osC_Language->get('top_category')));
     foreach ($osC_CategoryTree->getTree() as $value) {
         $records[] = array('id' => $value['id'], 'text' => $value['title']);
     }
     $response = array(EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 2
0
 function getCategories()
 {
     global $toC_Json, $osC_Language;
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $categories_array = array();
     if (isset($_REQUEST['top']) && $_REQUEST['top'] == '1') {
         $categories_array = array(array('id' => '', 'text' => $osC_Language->get('top_category')));
     }
     foreach ($osC_CategoryTree->getTree() as $value) {
         $categories_array[] = array('id' => $value['id'], 'text' => $value['title']);
     }
     $response = array(EXT_JSON_READER_ROOT => $categories_array);
     echo $toC_Json->encode($response);
 }
Exemplo n.º 3
0
 function loadVariantsProducts()
 {
     global $toC_Json;
     //get the filters
     $manufacturer = !empty($_POST['cManufacturer']) ? $_POST['cManufacturer'] : null;
     $products_sku = !empty($_POST['products_sku']) ? $_POST['products_sku'] : null;
     $products_name = !empty($_POST['products_name']) ? $_POST['products_name'] : null;
     //Get the current category - Fix the bug#78
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     $cPath = isset($_POST['categories_id']) && !empty($_POST['categories_id']) ? $_POST['categories_id'] : 0;
     $cPath_array = array_unique(array_filter(explode('_', $cPath), 'is_numeric'));
     $current_category_id = end($cPath_array);
     //get the categories
     $in_categories = array();
     if ($current_category_id > 0) {
         $osC_CategoryTree->setBreadcrumbUsage(false);
         $in_categories = array($current_category_id);
         foreach ($osC_CategoryTree->getTree($current_category_id) as $category) {
             $in_categories[] = $category['id'];
         }
     }
     //load the variants products
     $result = osC_Specials_Admin::loadVariantsProducts($in_categories, $manufacturer, $products_sku, $products_name);
     $response = array(EXT_JSON_READER_TOTAL => count($result), EXT_JSON_READER_ROOT => $result);
     echo $toC_Json->encode($response);
 }
 function loadProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $osC_CategoryTree = new osC_CategoryTree_Admin();
     //Get the current category - Fix the bug#78
     $cPath = isset($_POST['categories_id']) && !empty($_POST['categories_id']) ? $_POST['categories_id'] : 0;
     $cPath_array = array_unique(array_filter(explode('_', $cPath), 'is_numeric'));
     $current_category_id = end($cPath_array);
     if ($current_category_id > 0) {
         $osC_CategoryTree->setBreadcrumbUsage(false);
         $in_categories = array($current_category_id);
         foreach ($osC_CategoryTree->getTree($current_category_id) as $category) {
             $in_categories[] = $category['id'];
         }
         $Qproducts = $osC_Database->query('select p.products_id, pd.products_name, p.products_price from :table_products p, :table_products_description pd, :table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = :language_id and p.products_id = p2c.products_id and p2c.categories_id in (:categories_id)');
         $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qproducts->bindRaw(':categories_id', implode(',', $in_categories));
     } else {
         $Qproducts = $osC_Database->query('select p.products_id, pd.products_name, p.products_price from :table_products p, :table_products_description pd where p.products_id = pd.products_id and pd.language_id = :language_id');
     }
     if (!empty($_REQUEST['cManufacturer'])) {
         $Qproducts->appendQuery('and p.manufacturers_id = :manufacturers_id');
         $Qproducts->bindValue(':manufacturers_id', $_REQUEST['cManufacturer']);
     }
     if (!empty($_REQUEST['products_sku'])) {
         $Qproducts->appendQuery('and p.products_sku like :products_sku');
         $Qproducts->bindValue(':products_sku', '%' . $_REQUEST['products_sku'] . '%');
     }
     if (!empty($_REQUEST['products_name'])) {
         $Qproducts->appendQuery('and pd.products_name like :products_name');
         $Qproducts->bindValue(':products_name', '%' . $_REQUEST['products_name'] . '%');
     }
     $Qproducts->appendQuery(' and p.products_type <> :products_type');
     $Qproducts->appendQuery('order by pd.products_name');
     $Qproducts->bindTable(':table_specials', TABLE_SPECIALS);
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->bindInt(':products_type', PRODUCT_TYPE_GIFT_CERTIFICATE);
     $Qproducts->execute();
     $products = array();
     while ($Qproducts->next()) {
         $products[] = array('products_id' => $Qproducts->value('products_id'), 'products_name' => $Qproducts->value('products_name'), 'products_price' => $Qproducts->value('products_price'), 'special_price' => 0);
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $products);
     echo $toC_Json->encode($response);
 }
 function listProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language, $osC_Currencies;
     require_once '../includes/classes/currencies.php';
     $osC_Currencies = new osC_Currencies();
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $current_category_id = empty($_REQUEST['categories_id']) ? 0 : $_REQUEST['categories_id'];
     if ($current_category_id > 0) {
         $osC_CategoryTree = new osC_CategoryTree_Admin();
         $osC_CategoryTree->setBreadcrumbUsage(false);
         $in_categories = array($current_category_id);
         foreach ($osC_CategoryTree->getTree($current_category_id) as $category) {
             $in_categories[] = $category['id'];
         }
         $Qproducts = $osC_Database->query('select distinct p.products_id, p.products_type, pd.products_name, p.products_quantity, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p, :table_products_description pd, :table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = :language_id and p.products_id = p2c.products_id and p2c.categories_id in (:categories_id)');
         $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qproducts->bindRaw(':categories_id', implode(',', $in_categories));
     } else {
         $Qproducts = $osC_Database->query('select p.products_id, p.products_type, pd.products_name, p.products_quantity, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p, :table_products_description pd where p.products_id = pd.products_id and pd.language_id = :language_id');
     }
     if (!empty($_REQUEST['search'])) {
         $Qproducts->appendQuery('and pd.products_name like :products_name');
         $Qproducts->bindValue(':products_name', '%' . $_REQUEST['search'] . '%');
     }
     $Qproducts->appendQuery(' order by pd.products_name');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->setExtBatchLimit($start, $limit);
     $Qproducts->execute();
     $records = array();
     while ($Qproducts->next()) {
         $products_price = $osC_Currencies->format($Qproducts->value('products_price'));
         if ($Qproducts->valueInt('products_type') == PRODUCT_TYPE_GIFT_CERTIFICATE) {
             $Qcertificate = $osC_Database->query('select open_amount_min_value, open_amount_max_value from :table_products_gift_certificates where gift_certificates_amount_type = :gift_certificates_amount_type and products_id = :products_id');
             $Qcertificate->bindTable(':table_products_gift_certificates', TABLE_PRODUCTS_GIFT_CERTIFICATES);
             $Qcertificate->bindInt(':gift_certificates_amount_type', GIFT_CERTIFICATE_TYPE_OPEN_AMOUNT);
             $Qcertificate->bindInt(':products_id', $Qproducts->value('products_id'));
             $Qcertificate->execute();
             if ($Qcertificate->numberOfRows() > 0) {
                 $products_price = $osC_Currencies->format($Qcertificate->value('open_amount_min_value')) . ' ~ ' . $osC_Currencies->format($Qcertificate->value('open_amount_max_value'));
             }
         }
         $records[] = array('products_id' => $Qproducts->value('products_id'), 'products_name' => $Qproducts->value('products_name'), 'products_price' => $products_price, 'products_quantity' => $Qproducts->value('products_quantity'));
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }