shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

store.php (4710B)


      1 <?php
      2 class ModelSettingStore extends Model {
      3 	public function addStore($data) {
      4 		$this->db->query("INSERT INTO " . DB_PREFIX . "store SET name = '" . $this->db->escape($data['config_name']) . "', `url` = '" . $this->db->escape($data['config_url']) . "', `ssl` = '" . $this->db->escape($data['config_ssl']) . "'");
      5 
      6 		$store_id = $this->db->getLastId();
      7 
      8 		// Layout Route
      9 		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_route WHERE store_id = '0'");
     10 
     11 		foreach ($query->rows as $layout_route) {
     12 			$this->db->query("INSERT INTO " . DB_PREFIX . "layout_route SET layout_id = '" . (int)$layout_route['layout_id'] . "', route = '" . $this->db->escape($layout_route['route']) . "', store_id = '" . (int)$store_id . "'");
     13 		}
     14 
     15 		$this->cache->delete('store');
     16 
     17 		return $store_id;
     18 	}
     19 
     20 	public function editStore($store_id, $data) {
     21 		$this->db->query("UPDATE " . DB_PREFIX . "store SET name = '" . $this->db->escape($data['config_name']) . "', `url` = '" . $this->db->escape($data['config_url']) . "', `ssl` = '" . $this->db->escape($data['config_ssl']) . "' WHERE store_id = '" . (int)$store_id . "'");
     22 
     23 		$this->cache->delete('store');
     24 	}
     25 
     26 	public function deleteStore($store_id) {
     27 		$this->db->query("DELETE FROM " . DB_PREFIX . "store WHERE store_id = '" . (int)$store_id . "'");
     28 		$this->db->query("DELETE FROM " . DB_PREFIX . "layout_route WHERE store_id = '" . (int)$store_id . "'");
     29 
     30 		$this->cache->delete('store');
     31 	}
     32 
     33 	public function getStore($store_id) {
     34 		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "store WHERE store_id = '" . (int)$store_id . "'");
     35 
     36 		return $query->row;
     37 	}
     38 
     39 	public function getStores($data = array()) {
     40 		$store_data = $this->cache->get('store');
     41 
     42 		if (!$store_data) {
     43 			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "store ORDER BY url");
     44 
     45 			$store_data = $query->rows;
     46 
     47 			$this->cache->set('store', $store_data);
     48 		}
     49 
     50 		return $store_data;
     51 	}
     52 
     53 	public function getTotalStores() {
     54 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "store");
     55 
     56 		return $query->row['total'];
     57 	}
     58 
     59 	public function getTotalStoresByLayoutId($layout_id) {
     60 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_layout_id' AND `value` = '" . (int)$layout_id . "' AND store_id != '0'");
     61 
     62 		return $query->row['total'];
     63 	}
     64 
     65 	public function getTotalStoresByLanguage($language) {
     66 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_language' AND `value` = '" . $this->db->escape($language) . "' AND store_id != '0'");
     67 
     68 		return $query->row['total'];
     69 	}
     70 
     71 	public function getTotalStoresByCurrency($currency) {
     72 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_currency' AND `value` = '" . $this->db->escape($currency) . "' AND store_id != '0'");
     73 
     74 		return $query->row['total'];
     75 	}
     76 
     77 	public function getTotalStoresByCountryId($country_id) {
     78 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_country_id' AND `value` = '" . (int)$country_id . "' AND store_id != '0'");
     79 
     80 		return $query->row['total'];
     81 	}
     82 
     83 	public function getTotalStoresByZoneId($zone_id) {
     84 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_zone_id' AND `value` = '" . (int)$zone_id . "' AND store_id != '0'");
     85 
     86 		return $query->row['total'];
     87 	}
     88 
     89 	public function getTotalStoresByCustomerGroupId($customer_group_id) {
     90 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_customer_group_id' AND `value` = '" . (int)$customer_group_id . "' AND store_id != '0'");
     91 
     92 		return $query->row['total'];
     93 	}
     94 
     95 	public function getTotalStoresByInformationId($information_id) {
     96 		$account_query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_account_id' AND `value` = '" . (int)$information_id . "' AND store_id != '0'");
     97 
     98 		$checkout_query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_checkout_id' AND `value` = '" . (int)$information_id . "' AND store_id != '0'");
     99 
    100 		return ($account_query->row['total'] + $checkout_query->row['total']);
    101 	}
    102 
    103 	public function getTotalStoresByOrderStatusId($order_status_id) {
    104 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_order_status_id' AND `value` = '" . (int)$order_status_id . "' AND store_id != '0'");
    105 
    106 		return $query->row['total'];
    107 	}
    108 }