示例#1
0
 private function add_product_rows_query_where_filter_menu_params(JDatabaseQuery $query)
 {
     $db = JFactory::getDbo();
     $model_options = WDFHelper::get_model('options');
     $options = $model_options->get_options();
     //category
     if (WDFInput::get('type') && WDFInput::get('id') !== '') {
         $query->where('T_PRODUCTS.category_id = ' . WDFInput::get('id'));
     } else {
         if (WDFParams::get('category_id')) {
             $query->where('T_PRODUCTS.category_id = ' . WDFParams::get('category_id'));
         }
     }
     //manufacturer
     if (WDFInput::get('type') && WDFInput::get('manufacturers_id') !== '') {
         $product_manufacturers = WDFInput::get('manufacturers_id');
         $man_ids = str_replace("_", ',', $product_manufacturers);
         $query->where('T_PRODUCTS.manufacturer_id IN (' . $man_ids . ')');
     } else {
         if (WDFParams::get('manufacturer_id')) {
             $query->where('T_PRODUCTS.manufacturer_id IN (' . WDFParams::get('manufacturer_id') . ')');
         }
     }
     //prices
     $select_price = 'T_PRODUCTS.price';
     if ($options->option_include_discount_in_price) {
         $select_price .= ' * (1 - IFNULL(T_DISCOUNTS.rate, 0) / 100)';
     }
     if ($options->option_include_tax_in_price) {
         $select_price .= ' * (1 + IFNULL(T_TAXES.rate, 0) / 100)';
     }
     if (WDFInput::get('type') && WDFInput::get('min_price') !== '') {
         $query->where($select_price . ' >= ' . WDFInput::get('min_price'));
     } else {
         if (WDFParams::get('min_price')) {
             $query->where($select_price . ' >= ' . WDFParams::get('min_price'));
         }
     }
     if (WDFInput::get('type') && WDFInput::get('max_price') !== '') {
         $query->where($select_price . ' <= ' . WDFInput::get('max_price'));
     } else {
         if (WDFParams::get('max_price')) {
             $query->where($select_price . ' <= ' . WDFParams::get('max_price'));
         }
     }
     //date added
     if (WDFInput::get('type')) {
         switch (WDFInput::get('date')) {
             case 1:
                 $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 1 DAY) AND CURDATE()');
                 break;
             case 2:
                 $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 1 WEEK) AND CURDATE()');
                 break;
             case 3:
                 $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 2 WEEK) AND CURDATE()');
                 break;
             case 4:
                 $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 1 MONTH) AND CURDATE()');
                 break;
         }
     } else {
         if (WDFParams::get('date_added')) {
             switch (WDFParams::get('date_added')) {
                 case 1:
                     $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 1 DAY) AND CURDATE()');
                     break;
                 case 2:
                     $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 1 WEEK) AND CURDATE()');
                     break;
                 case 3:
                     $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 2 WEEK) AND CURDATE()');
                     break;
                 case 4:
                     $query->where('DATE_FORMAT(T_PRODUCTS.date_added,"%Y-%m-%d" ) BETWEEN SUBDATE(CURDATE(), INTERVAL 1 MONTH) AND CURDATE()');
                     break;
             }
         }
     }
     //rating
     if (WDFInput::get('type') && WDFInput::get('rating')) {
         $query->where('T_RATINGS.rating >= ' . WDFInput::get('rating'));
     } else {
         if (WDFParams::get('min_rating')) {
             $query->where('T_RATINGS.rating >= ' . WDFParams::get('min_rating'));
         }
     }
     // tags
     if (WDFInput::get('type') && WDFInput::get('tags') !== '') {
         $product_tags = WDFInput::get('tags');
         $tag_ids = explode("_", $product_tags);
         foreach ($tag_ids as $tag_id) {
             $row_tag = WDFDb::get_row('tags', array($db->quoteName('id') . ' = ' . $tag_id, $db->quoteName('published') . ' = 1'));
             if ($row_tag->id != 0) {
                 $query->where('T_PRODUCT_TAGS.tag_names LIKE ' . $db->quote('%' . $row_tag->name . '%'));
             }
         }
     } else {
         if (WDFParams::get('tags')) {
             $tag_ids = WDFJson::decode(WDFParams::get('tags'));
             foreach ($tag_ids as $tag_id) {
                 $row_tag = WDFDb::get_row('tags', array($db->quoteName('id') . ' = ' . $tag_id, $db->quoteName('published') . ' = 1'));
                 if ($row_tag->id != 0) {
                     $query->where('T_PRODUCT_TAGS.tag_names LIKE ' . $db->quote('%' . $row_tag->name . '%'));
                 }
             }
         }
     }
     return $query;
 }
示例#2
0
 public function get_row()
 {
     $db = JFactory::getDbo();
     if (WDFInput::get('type')) {
         $id = WDFInput::get('id');
     } else {
         $id = WDFInput::get('category_id', WDFParams::get('category_id', 0, 'int'));
     }
     $row = WDFDb::get_row('categories', array($db->quoteName('id') . ' = ' . $id, $db->quoteName('published') . ' = 1'));
     if ($row->id == 0) {
         $row->id = 0;
         $row->name = JText::_('root');
     }
     // additional data
     // path categories
     $row->path_categories = $this->get_category_path_categories($row->id);
     // info
     if (WDFInput::get('type')) {
         $row->show_info = WDFInput::get('show_info');
     } else {
         $row->show_info = WDFParams::get('show_info', 1);
     }
     // image
     if ($row->images != null) {
         $images = WDFJson::decode($row->images);
         $row->image = empty($images) == false ? $images[0] : '';
     } else {
         $row->image = '';
     }
     // subcategories
     if (WDFInput::get('type')) {
         $row->show_subcategories = WDFInput::get('show_subcategories');
     } else {
         $row->show_subcategories = WDFParams::get('show_subcategories', 1);
     }
     if (WDFInput::get('type')) {
         $row->subcategories_cols = WDFInput::get('number_columns');
     } else {
         $row->subcategories_cols = WDFParams::get('subcategories_cols', 1);
     }
     $subcategories = $this->get_category_subcategories($row->id);
     if ($subcategories === false) {
         WDFHelper::redirect('systempages', 'displayerror', '', 'code=2');
     }
     $row->subcategories = $subcategories;
     if (empty($row->subcategories) == true) {
         $row->show_subcategories = 0;
     }
     // category tree
     if (WDFInput::get('type')) {
         $row->show_tree = WDFInput::get('show_path');
     } else {
         $row->show_tree = WDFParams::get('show_tree', 1);
     }
     // products and count
     if (WDFInput::get('type')) {
         $row->show_products = WDFInput::get('show_products');
     } else {
         $row->show_products = WDFParams::get('show_products', 1);
     }
     if (WDFInput::get('type')) {
         $row->products_count = WDFInput::get('products_count');
     } else {
         $row->products_count = WDFParams::get('products_count');
     }
     $row->products = array();
     if ($row->show_products == 1) {
         $products = $this->get_category_products($row->id, $row->products_count);
         if ($products === false) {
             WDFHelper::redirect('systempages', 'displayerror', '', 'code=2');
         }
         $row->products = $products;
     }
     if (empty($row->products) == true) {
         $row->show_products = 0;
     }
     // url view products
     $row->url_view_products = JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=products&task=displayproducts&search_category_id=' . $row->id);
     return $row;
 }