first commit

This commit is contained in:
Konstantin
2026-05-30 09:27:58 +03:00
commit de0344d218
2371 changed files with 661486 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
<?php
class ModelAccountActivity extends Model {
public function addActivity($key, $data) {
if (isset($data['customer_id'])) {
$customer_id = $data['customer_id'];
} else {
$customer_id = 0;
}
$this->db->query("INSERT INTO `" . DB_PREFIX . "customer_activity` SET `customer_id` = '" . (int)$customer_id . "', `key` = '" . $this->db->escape($key) . "', `data` = '" . $this->db->escape(json_encode($data)) . "', `ip` = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', `date_added` = NOW()");
}
}
+145
View File
@@ -0,0 +1,145 @@
<?php
class ModelAccountAddress extends Model {
public function addAddress($customer_id, $data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "address SET customer_id = '" . (int)$customer_id . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', company = '" . $this->db->escape($data['company']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', postcode = '" . $this->db->escape($data['postcode']) . "', city = '" . $this->db->escape($data['city']) . "', zone_id = '" . (int)$data['zone_id'] . "', country_id = '" . (int)$data['country_id'] . "', custom_field = '" . $this->db->escape(isset($data['custom_field']['address']) ? json_encode($data['custom_field']['address']) : '') . "'");
$address_id = $this->db->getLastId();
if (!empty($data['default'])) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$customer_id . "'");
}
return $address_id;
}
public function editAddress($address_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "address SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', company = '" . $this->db->escape($data['company']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', postcode = '" . $this->db->escape($data['postcode']) . "', city = '" . $this->db->escape($data['city']) . "', zone_id = '" . (int)$data['zone_id'] . "', country_id = '" . (int)$data['country_id'] . "', custom_field = '" . $this->db->escape(isset($data['custom_field']['address']) ? json_encode($data['custom_field']['address']) : '') . "' WHERE address_id = '" . (int)$address_id . "' AND customer_id = '" . (int)$this->customer->getId() . "'");
if (!empty($data['default'])) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
}
public function deleteAddress($address_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "address WHERE address_id = '" . (int)$address_id . "' AND customer_id = '" . (int)$this->customer->getId() . "'");
$default_query = $this->db->query("SELECT address_id FROM " . DB_PREFIX . "customer WHERE address_id = '" . (int)$address_id . "' AND customer_id = '" . (int)$this->customer->getId() . "'");
if ($default_query->num_rows) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = 0 WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
}
public function getAddress($address_id) {
$address_query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "address WHERE address_id = '" . (int)$address_id . "' AND customer_id = '" . (int)$this->customer->getId() . "'");
if ($address_query->num_rows) {
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$address_query->row['country_id'] . "'");
if ($country_query->num_rows) {
$country = $country_query->row['name'];
$iso_code_2 = $country_query->row['iso_code_2'];
$iso_code_3 = $country_query->row['iso_code_3'];
$address_format = $country_query->row['address_format'];
} else {
$country = '';
$iso_code_2 = '';
$iso_code_3 = '';
$address_format = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$address_query->row['zone_id'] . "'");
if ($zone_query->num_rows) {
$zone = $zone_query->row['name'];
$zone_code = $zone_query->row['code'];
} else {
$zone = '';
$zone_code = '';
}
$address_data = array(
'address_id' => $address_query->row['address_id'],
'firstname' => $address_query->row['firstname'],
'lastname' => $address_query->row['lastname'],
'company' => $address_query->row['company'],
'address_1' => $address_query->row['address_1'],
'address_2' => $address_query->row['address_2'],
'postcode' => $address_query->row['postcode'],
'city' => $address_query->row['city'],
'zone_id' => $address_query->row['zone_id'],
'zone' => $zone,
'zone_code' => $zone_code,
'country_id' => $address_query->row['country_id'],
'country' => $country,
'iso_code_2' => $iso_code_2,
'iso_code_3' => $iso_code_3,
'address_format' => $address_format,
'custom_field' => json_decode($address_query->row['custom_field'], true)
);
return $address_data;
} else {
return false;
}
}
public function getAddresses() {
$address_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int)$this->customer->getId() . "'");
foreach ($query->rows as $result) {
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$result['country_id'] . "'");
if ($country_query->num_rows) {
$country = $country_query->row['name'];
$iso_code_2 = $country_query->row['iso_code_2'];
$iso_code_3 = $country_query->row['iso_code_3'];
$address_format = $country_query->row['address_format'];
} else {
$country = '';
$iso_code_2 = '';
$iso_code_3 = '';
$address_format = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$result['zone_id'] . "'");
if ($zone_query->num_rows) {
$zone = $zone_query->row['name'];
$zone_code = $zone_query->row['code'];
} else {
$zone = '';
$zone_code = '';
}
$address_data[$result['address_id']] = array(
'address_id' => $result['address_id'],
'firstname' => $result['firstname'],
'lastname' => $result['lastname'],
'company' => $result['company'],
'address_1' => $result['address_1'],
'address_2' => $result['address_2'],
'postcode' => $result['postcode'],
'city' => $result['city'],
'zone_id' => $result['zone_id'],
'zone' => $zone,
'zone_code' => $zone_code,
'country_id' => $result['country_id'],
'country' => $country,
'iso_code_2' => $iso_code_2,
'iso_code_3' => $iso_code_3,
'address_format' => $address_format,
'custom_field' => json_decode($result['custom_field'], true)
);
}
return $address_data;
}
public function getTotalAddresses() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int)$this->customer->getId() . "'");
return $query->row['total'];
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
class ModelAccountApi extends Model {
public function login($username, $key) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api` WHERE `username` = '" . $this->db->escape($username) . "' AND `key` = '" . $this->db->escape($key) . "' AND `status` = '1'");
return $query->row;
}
public function addApiSession($api_id, $session_id, $ip) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "api_session` SET `api_id` = '" . (int)$api_id . "', `session_id` = '" . $this->db->escape($session_id) . "', `ip` = '" . $this->db->escape($ip) . "', `date_added` = NOW(), `date_modified` = NOW()");
return $this->db->getLastId();
}
public function getApiIps($api_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api_ip` WHERE `api_id` = '" . (int)$api_id . "'");
return $query->rows;
}
}
@@ -0,0 +1,47 @@
<?php
class ModelAccountCustomField extends Model {
public function getCustomField($custom_field_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "custom_field` cf LEFT JOIN `" . DB_PREFIX . "custom_field_description` cfd ON (cf.custom_field_id = cfd.custom_field_id) WHERE cf.status = '1' AND cf.custom_field_id = '" . (int)$custom_field_id . "' AND cfd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row;
}
public function getCustomFields($customer_group_id = 0) {
$custom_field_data = array();
if (!$customer_group_id) {
$custom_field_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "custom_field` cf LEFT JOIN `" . DB_PREFIX . "custom_field_description` cfd ON (cf.custom_field_id = cfd.custom_field_id) WHERE cf.status = '1' AND cfd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND cf.status = '1' ORDER BY cf.sort_order ASC");
} else {
$custom_field_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "custom_field_customer_group` cfcg LEFT JOIN `" . DB_PREFIX . "custom_field` cf ON (cfcg.custom_field_id = cf.custom_field_id) LEFT JOIN `" . DB_PREFIX . "custom_field_description` cfd ON (cf.custom_field_id = cfd.custom_field_id) WHERE cf.status = '1' AND cfd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND cfcg.customer_group_id = '" . (int)$customer_group_id . "' ORDER BY cf.sort_order ASC");
}
foreach ($custom_field_query->rows as $custom_field) {
$custom_field_value_data = array();
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') {
$custom_field_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_value cfv LEFT JOIN " . DB_PREFIX . "custom_field_value_description cfvd ON (cfv.custom_field_value_id = cfvd.custom_field_value_id) WHERE cfv.custom_field_id = '" . (int)$custom_field['custom_field_id'] . "' AND cfvd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY cfv.sort_order ASC");
foreach ($custom_field_value_query->rows as $custom_field_value) {
$custom_field_value_data[] = array(
'custom_field_value_id' => $custom_field_value['custom_field_value_id'],
'name' => $custom_field_value['name']
);
}
}
$custom_field_data[] = array(
'custom_field_id' => $custom_field['custom_field_id'],
'custom_field_value' => $custom_field_value_data,
'name' => $custom_field['name'],
'type' => $custom_field['type'],
'value' => $custom_field['value'],
'validation' => $custom_field['validation'],
'location' => $custom_field['location'],
'required' => empty($custom_field['required']) || $custom_field['required'] == 0 ? false : true,
'sort_order' => $custom_field['sort_order']
);
}
return $custom_field_data;
}
}
+152
View File
@@ -0,0 +1,152 @@
<?php
class ModelAccountCustomer extends Model {
public function addCustomer($data) {
if (isset($data['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($data['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $data['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$customer_group_id . "', store_id = '" . (int)$this->config->get('config_store_id') . "', language_id = '" . (int)$this->config->get('config_language_id') . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']['account']) ? json_encode($data['custom_field']['account']) : '') . "', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', status = '" . (int)!$customer_group_info['approval'] . "', date_added = NOW()");
$customer_id = $this->db->getLastId();
if ($customer_group_info['approval']) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "customer_approval` SET customer_id = '" . (int)$customer_id . "', type = 'customer', date_added = NOW()");
}
return $customer_id;
}
public function editCustomer($customer_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']['account']) ? json_encode($data['custom_field']['account']) : '') . "' WHERE customer_id = '" . (int)$customer_id . "'");
}
public function editPassword($email, $password) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($password)))) . "', code = '' WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
}
public function editAddressId($customer_id, $address_id) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$customer_id . "'");
}
public function editCode($email, $code) {
$this->db->query("UPDATE `" . DB_PREFIX . "customer` SET code = '" . $this->db->escape($code) . "' WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
}
public function editNewsletter($newsletter) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET newsletter = '" . (int)$newsletter . "' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
public function getCustomer($customer_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
return $query->row;
}
public function getCustomerByEmail($email) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
return $query->row;
}
public function getCustomerByCode($code) {
$query = $this->db->query("SELECT customer_id, firstname, lastname, email FROM `" . DB_PREFIX . "customer` WHERE code = '" . $this->db->escape($code) . "' AND code != ''");
return $query->row;
}
public function getCustomerByToken($token) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE token = '" . $this->db->escape($token) . "' AND token != ''");
$this->db->query("UPDATE " . DB_PREFIX . "customer SET token = ''");
return $query->row;
}
public function getTotalCustomersByEmail($email) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
return $query->row['total'];
}
public function addTransaction($customer_id, $description, $amount = '', $order_id = 0) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_transaction SET customer_id = '" . (int)$customer_id . "', order_id = '" . (float)$order_id . "', description = '" . $this->db->escape($description) . "', amount = '" . (float)$amount . "', date_added = NOW()");
}
public function deleteTransactionByOrderId($order_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'");
}
public function getTransactionTotal($customer_id) {
$query = $this->db->query("SELECT SUM(amount) AS total FROM " . DB_PREFIX . "customer_transaction WHERE customer_id = '" . (int)$customer_id . "'");
return $query->row['total'];
}
public function getTotalTransactionsByOrderId($order_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'");
return $query->row['total'];
}
public function getRewardTotal($customer_id) {
$query = $this->db->query("SELECT SUM(points) AS total FROM " . DB_PREFIX . "customer_reward WHERE customer_id = '" . (int)$customer_id . "'");
return $query->row['total'];
}
public function getIps($customer_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_ip` WHERE customer_id = '" . (int)$customer_id . "'");
return $query->rows;
}
public function addLoginAttempt($email) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_login WHERE email = '" . $this->db->escape(utf8_strtolower((string)$email)) . "' AND ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "'");
if (!$query->num_rows) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_login SET email = '" . $this->db->escape(utf8_strtolower((string)$email)) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', total = 1, date_added = '" . $this->db->escape(date('Y-m-d H:i:s')) . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "'");
} else {
$this->db->query("UPDATE " . DB_PREFIX . "customer_login SET total = (total + 1), date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE customer_login_id = '" . (int)$query->row['customer_login_id'] . "'");
}
}
public function getLoginAttempts($email) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_login` WHERE email = '" . $this->db->escape(utf8_strtolower($email)) . "'");
return $query->row;
}
public function deleteLoginAttempts($email) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_login` WHERE email = '" . $this->db->escape(utf8_strtolower($email)) . "'");
}
public function addAffiliate($customer_id, $data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_affiliate SET `customer_id` = '" . (int)$customer_id . "', `company` = '" . $this->db->escape($data['company']) . "', `website` = '" . $this->db->escape($data['website']) . "', `tracking` = '" . $this->db->escape(token(64)) . "', `commission` = '" . (float)$this->config->get('config_affiliate_commission') . "', `tax` = '" . $this->db->escape($data['tax']) . "', `payment` = '" . $this->db->escape($data['payment']) . "', `cheque` = '" . $this->db->escape($data['cheque']) . "', `paypal` = '" . $this->db->escape($data['paypal']) . "', `bank_name` = '" . $this->db->escape($data['bank_name']) . "', `bank_branch_number` = '" . $this->db->escape($data['bank_branch_number']) . "', `bank_swift_code` = '" . $this->db->escape($data['bank_swift_code']) . "', `bank_account_name` = '" . $this->db->escape($data['bank_account_name']) . "', `bank_account_number` = '" . $this->db->escape($data['bank_account_number']) . "', `status` = '" . (int)!$this->config->get('config_affiliate_approval') . "'");
if ($this->config->get('config_affiliate_approval')) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "customer_approval` SET customer_id = '" . (int)$customer_id . "', type = 'affiliate', date_added = NOW()");
}
}
public function editAffiliate($customer_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "customer_affiliate SET `company` = '" . $this->db->escape($data['company']) . "', `website` = '" . $this->db->escape($data['website']) . "', `commission` = '" . (float)$this->config->get('config_affiliate_commission') . "', `tax` = '" . $this->db->escape($data['tax']) . "', `payment` = '" . $this->db->escape($data['payment']) . "', `cheque` = '" . $this->db->escape($data['cheque']) . "', `paypal` = '" . $this->db->escape($data['paypal']) . "', `bank_name` = '" . $this->db->escape($data['bank_name']) . "', `bank_branch_number` = '" . $this->db->escape($data['bank_branch_number']) . "', `bank_swift_code` = '" . $this->db->escape($data['bank_swift_code']) . "', `bank_account_name` = '" . $this->db->escape($data['bank_account_name']) . "', `bank_account_number` = '" . $this->db->escape($data['bank_account_number']) . "' WHERE `customer_id` = '" . (int)$customer_id . "'");
}
public function getAffiliate($customer_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_affiliate` WHERE `customer_id` = '" . (int)$customer_id . "'");
return $query->row;
}
public function getAffiliateByTracking($tracking) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_affiliate` WHERE `tracking` = '" . $this->db->escape($tracking) . "'");
return $query->row;
}
}
@@ -0,0 +1,14 @@
<?php
class ModelAccountCustomerGroup extends Model {
public function getCustomerGroup($customer_group_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer_group cg LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (cg.customer_group_id = cgd.customer_group_id) WHERE cg.customer_group_id = '" . (int)$customer_group_id . "' AND cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row;
}
public function getCustomerGroups() {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_group cg LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (cg.customer_group_id = cgd.customer_group_id) WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY cg.sort_order ASC, cgd.name ASC");
return $query->rows;
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
class ModelAccountDownload extends Model {
public function getDownload($download_id) {
$implode = array();
$order_statuses = $this->config->get('config_complete_status');
foreach ($order_statuses as $order_status_id) {
$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
}
if ($implode) {
$query = $this->db->query("SELECT d.filename, d.mask FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) LEFT JOIN " . DB_PREFIX . "download d ON (p2d.download_id = d.download_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND (" . implode(" OR ", $implode) . ") AND d.download_id = '" . (int)$download_id . "'");
return $query->row;
} else {
return;
}
}
public function getDownloads($start = 0, $limit = 20) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 20;
}
$implode = array();
$order_statuses = $this->config->get('config_complete_status');
foreach ($order_statuses as $order_status_id) {
$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
}
if ($implode) {
$query = $this->db->query("SELECT DISTINCT op.order_product_id, d.download_id, o.order_id, o.date_added, dd.name, d.filename FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) LEFT JOIN " . DB_PREFIX . "download d ON (p2d.download_id = d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND (" . implode(" OR ", $implode) . ") ORDER BY o.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
} else {
return array();
}
}
public function getTotalDownloads() {
$implode = array();
$order_statuses = $this->config->get('config_complete_status');
foreach ($order_statuses as $order_status_id) {
$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
}
if ($implode) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) LEFT JOIN " . DB_PREFIX . "product_to_download p2d ON (op.product_id = p2d.product_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND (" . implode(" OR ", $implode) . ")");
return $query->row['total'];
} else {
return 0;
}
}
}
+170
View File
@@ -0,0 +1,170 @@
<?php
class ModelAccountOrder extends Model {
public function getOrder($order_id) {
$order_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$order_id . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND customer_id != '0' AND order_status_id > '0'");
if ($order_query->num_rows) {
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'");
if ($country_query->num_rows) {
$payment_iso_code_2 = $country_query->row['iso_code_2'];
$payment_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$payment_iso_code_2 = '';
$payment_iso_code_3 = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'");
if ($zone_query->num_rows) {
$payment_zone_code = $zone_query->row['code'];
} else {
$payment_zone_code = '';
}
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'");
if ($country_query->num_rows) {
$shipping_iso_code_2 = $country_query->row['iso_code_2'];
$shipping_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$shipping_iso_code_2 = '';
$shipping_iso_code_3 = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'");
if ($zone_query->num_rows) {
$shipping_zone_code = $zone_query->row['code'];
} else {
$shipping_zone_code = '';
}
return array(
'order_id' => $order_query->row['order_id'],
'invoice_no' => $order_query->row['invoice_no'],
'invoice_prefix' => $order_query->row['invoice_prefix'],
'store_id' => $order_query->row['store_id'],
'store_name' => $order_query->row['store_name'],
'store_url' => $order_query->row['store_url'],
'customer_id' => $order_query->row['customer_id'],
'firstname' => $order_query->row['firstname'],
'lastname' => $order_query->row['lastname'],
'telephone' => $order_query->row['telephone'],
'email' => $order_query->row['email'],
'payment_firstname' => $order_query->row['payment_firstname'],
'payment_lastname' => $order_query->row['payment_lastname'],
'payment_company' => $order_query->row['payment_company'],
'payment_address_1' => $order_query->row['payment_address_1'],
'payment_address_2' => $order_query->row['payment_address_2'],
'payment_postcode' => $order_query->row['payment_postcode'],
'payment_city' => $order_query->row['payment_city'],
'payment_zone_id' => $order_query->row['payment_zone_id'],
'payment_zone' => $order_query->row['payment_zone'],
'payment_zone_code' => $payment_zone_code,
'payment_country_id' => $order_query->row['payment_country_id'],
'payment_country' => $order_query->row['payment_country'],
'payment_iso_code_2' => $payment_iso_code_2,
'payment_iso_code_3' => $payment_iso_code_3,
'payment_address_format' => $order_query->row['payment_address_format'],
'payment_method' => $order_query->row['payment_method'],
'shipping_firstname' => $order_query->row['shipping_firstname'],
'shipping_lastname' => $order_query->row['shipping_lastname'],
'shipping_company' => $order_query->row['shipping_company'],
'shipping_address_1' => $order_query->row['shipping_address_1'],
'shipping_address_2' => $order_query->row['shipping_address_2'],
'shipping_postcode' => $order_query->row['shipping_postcode'],
'shipping_city' => $order_query->row['shipping_city'],
'shipping_zone_id' => $order_query->row['shipping_zone_id'],
'shipping_zone' => $order_query->row['shipping_zone'],
'shipping_zone_code' => $shipping_zone_code,
'shipping_country_id' => $order_query->row['shipping_country_id'],
'shipping_country' => $order_query->row['shipping_country'],
'shipping_iso_code_2' => $shipping_iso_code_2,
'shipping_iso_code_3' => $shipping_iso_code_3,
'shipping_address_format' => $order_query->row['shipping_address_format'],
'shipping_method' => $order_query->row['shipping_method'],
'comment' => $order_query->row['comment'],
'total' => $order_query->row['total'],
'order_status_id' => $order_query->row['order_status_id'],
'language_id' => $order_query->row['language_id'],
'currency_id' => $order_query->row['currency_id'],
'currency_code' => $order_query->row['currency_code'],
'currency_value' => $order_query->row['currency_value'],
'date_modified' => $order_query->row['date_modified'],
'date_added' => $order_query->row['date_added'],
'ip' => $order_query->row['ip']
);
} else {
return false;
}
}
public function getOrders($start = 0, $limit = 20) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 1;
}
$query = $this->db->query("SELECT o.order_id, o.firstname, o.lastname, os.name as status, o.date_added, o.total, o.currency_code, o.currency_value FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id) WHERE o.customer_id = '" . (int)$this->customer->getId() . "' AND o.order_status_id > '0' AND o.store_id = '" . (int)$this->config->get('config_store_id') . "' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.order_id DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
}
public function getOrderProduct($order_id, $order_product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
return $query->row;
}
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
public function getOrderOptions($order_id, $order_product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
return $query->rows;
}
public function getOrderVouchers($order_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_voucher` WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
public function getOrderTotals($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order");
return $query->rows;
}
public function getOrderHistories($order_id) {
$query = $this->db->query("SELECT date_added, os.name AS status, oh.comment, oh.notify FROM " . DB_PREFIX . "order_history oh LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id WHERE oh.order_id = '" . (int)$order_id . "' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY oh.date_added");
return $query->rows;
}
public function getTotalOrders() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` o WHERE customer_id = '" . (int)$this->customer->getId() . "' AND o.order_status_id > '0' AND o.store_id = '" . (int)$this->config->get('config_store_id') . "'");
return $query->row['total'];
}
public function getTotalOrderProductsByOrderId($order_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
return $query->row['total'];
}
public function getTotalOrderVouchersByOrderId($order_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order_voucher` WHERE order_id = '" . (int)$order_id . "'");
return $query->row['total'];
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
class ModelAccountRecurring extends Model {
public function getOrderRecurring($order_recurring_id) {
$query = $this->db->query("SELECT `or`.*,`o`.`payment_method`,`o`.`payment_code`,`o`.`currency_code` FROM `" . DB_PREFIX . "order_recurring` `or` LEFT JOIN `" . DB_PREFIX . "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `or`.`order_recurring_id` = '" . (int)$order_recurring_id . "' AND `o`.`customer_id` = '" . (int)$this->customer->getId() . "'");
return $query->row;
}
public function getOrderRecurrings($start = 0, $limit = 20) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 1;
}
$query = $this->db->query("SELECT `or`.*,`o`.`payment_method`,`o`.`currency_id`,`o`.`currency_value` FROM `" . DB_PREFIX . "order_recurring` `or` LEFT JOIN `" . DB_PREFIX . "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `o`.`customer_id` = '" . (int)$this->customer->getId() . "' ORDER BY `o`.`order_id` DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
}
public function getOrderRecurringByReference($reference) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_recurring` WHERE `reference` = '" . $this->db->escape($reference) . "'");
return $query->row;
}
public function getOrderRecurringTransactions($order_recurring_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_recurring_transaction` WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'");
return $query->rows;
}
public function getTotalOrderRecurrings() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order_recurring` `or` LEFT JOIN `" . DB_PREFIX . "order` `o` ON `or`.`order_id` = `o`.`order_id` WHERE `o`.`customer_id` = '" . (int)$this->customer->getId() . "'");
return $query->row['total'];
}
public function addOrderRecurringTransaction($order_recurring_id, $type) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$order_recurring_id . "', `date_added` = NOW(), `type` = '" . (int)$type . "'");
}
public function editOrderRecurringStatus($order_recurring_id, $status) {
$this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = '" . (int)$status . "' WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'");
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
class ModelAccountReturn extends Model {
public function addReturn($data) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "return` SET order_id = '" . (int)$data['order_id'] . "', product_id = '" . (int)$data['product_id'] . "', customer_id = '" . (int)$this->customer->getId() . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', product = '" . $this->db->escape($data['product']) . "', model = '" . $this->db->escape($data['model']) . "', quantity = '" . (int)$data['quantity'] . "', opened = '" . (int)$data['opened'] . "', return_reason_id = '" . (int)$data['return_reason_id'] . "', return_status_id = '" . (int)$this->config->get('config_return_status_id') . "', comment = '" . $this->db->escape($data['comment']) . "', date_ordered = '" . $this->db->escape($data['date_ordered']) . "', date_added = NOW(), date_modified = NOW()");
return $this->db->getLastId();
}
public function getReturn($return_id) {
$query = $this->db->query("SELECT r.return_id, r.order_id, r.firstname, r.lastname, r.email, r.telephone, r.product, r.model, r.quantity, r.opened, (SELECT rr.name FROM " . DB_PREFIX . "return_reason rr WHERE rr.return_reason_id = r.return_reason_id AND rr.language_id = '" . (int)$this->config->get('config_language_id') . "') AS reason, (SELECT ra.name FROM " . DB_PREFIX . "return_action ra WHERE ra.return_action_id = r.return_action_id AND ra.language_id = '" . (int)$this->config->get('config_language_id') . "') AS action, (SELECT rs.name FROM " . DB_PREFIX . "return_status rs WHERE rs.return_status_id = r.return_status_id AND rs.language_id = '" . (int)$this->config->get('config_language_id') . "') AS status, r.comment, r.date_ordered, r.date_added, r.date_modified FROM `" . DB_PREFIX . "return` r WHERE r.return_id = '" . (int)$return_id . "' AND r.customer_id = '" . $this->customer->getId() . "'");
return $query->row;
}
public function getReturns($start = 0, $limit = 20) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 20;
}
$query = $this->db->query("SELECT r.return_id, r.order_id, r.firstname, r.lastname, rs.name as status, r.date_added FROM `" . DB_PREFIX . "return` r LEFT JOIN " . DB_PREFIX . "return_status rs ON (r.return_status_id = rs.return_status_id) WHERE r.customer_id = '" . (int)$this->customer->getId() . "' AND rs.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY r.return_id DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
}
public function getTotalReturns() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "return`WHERE customer_id = '" . $this->customer->getId() . "'");
return $query->row['total'];
}
public function getReturnHistories($return_id) {
$query = $this->db->query("SELECT rh.date_added, rs.name AS status, rh.comment FROM " . DB_PREFIX . "return_history rh LEFT JOIN " . DB_PREFIX . "return_status rs ON rh.return_status_id = rs.return_status_id WHERE rh.return_id = '" . (int)$return_id . "' AND rs.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY rh.date_added ASC");
return $query->rows;
}
}
+56
View File
@@ -0,0 +1,56 @@
<?php
class ModelAccountReward extends Model {
public function getRewards($data = array()) {
$sql = "SELECT * FROM `" . DB_PREFIX . "customer_reward` WHERE customer_id = '" . (int)$this->customer->getId() . "'";
$sort_data = array(
'points',
'description',
'date_added'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY date_added";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getTotalRewards() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_reward` WHERE customer_id = '" . (int)$this->customer->getId() . "'");
return $query->row['total'];
}
public function getTotalPoints() {
$query = $this->db->query("SELECT SUM(points) AS total FROM `" . DB_PREFIX . "customer_reward` WHERE customer_id = '" . (int)$this->customer->getId() . "' GROUP BY customer_id");
if ($query->num_rows) {
return $query->row['total'];
} else {
return 0;
}
}
}
+6
View File
@@ -0,0 +1,6 @@
<?php
class ModelAccountSearch extends Model {
public function addSearch($data) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "customer_search` SET `store_id` = '" . (int)$this->config->get('config_store_id') . "', `language_id` = '" . (int)$this->config->get('config_language_id') . "', `customer_id` = '" . (int)$data['customer_id'] . "', `keyword` = '" . $this->db->escape($data['keyword']) . "', `category_id` = '" . (int)$data['category_id'] . "', `sub_category` = '" . (int)$data['sub_category'] . "', `description` = '" . (int)$data['description'] . "', `products` = '" . (int)$data['products'] . "', `ip` = '" . $this->db->escape($data['ip']) . "', `date_added` = NOW()");
}
}
@@ -0,0 +1,56 @@
<?php
class ModelAccountTransaction extends Model {
public function getTransactions($data = array()) {
$sql = "SELECT * FROM `" . DB_PREFIX . "customer_transaction` WHERE customer_id = '" . (int)$this->customer->getId() . "'";
$sort_data = array(
'amount',
'description',
'date_added'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY date_added";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getTotalTransactions() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_transaction` WHERE customer_id = '" . (int)$this->customer->getId() . "'");
return $query->row['total'];
}
public function getTotalAmount() {
$query = $this->db->query("SELECT SUM(amount) AS total FROM `" . DB_PREFIX . "customer_transaction` WHERE customer_id = '" . (int)$this->customer->getId() . "' GROUP BY customer_id");
if ($query->num_rows) {
return $query->row['total'];
} else {
return 0;
}
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
class ModelAccountWishlist extends Model {
public function addWishlist($product_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "' AND product_id = '" . (int)$product_id . "'");
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_wishlist SET customer_id = '" . (int)$this->customer->getId() . "', product_id = '" . (int)$product_id . "', date_added = NOW()");
}
public function deleteWishlist($product_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "' AND product_id = '" . (int)$product_id . "'");
}
public function getWishlist() {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "'");
return $query->rows;
}
public function getTotalWishlist() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "'");
return $query->row['total'];
}
}
+437
View File
@@ -0,0 +1,437 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ModelBlogArticle extends Model {
public function updateViewed($article_id) {
$this->db->query("UPDATE " . DB_PREFIX . "article SET viewed = (viewed + 1) WHERE article_id = '" . (int)$article_id . "'");
}
public function getArticle($article_id) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review_article r1 WHERE r1.article_id = p.article_id AND r1.status = '1' GROUP BY r1.article_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review_article r2 WHERE r2.article_id = p.article_id AND r2.status = '1' GROUP BY r2.article_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id) WHERE p.article_id = '" . (int)$article_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return array(
'meta_title' => $query->row['meta_title'],
'noindex' => $query->row['noindex'],
'meta_h1' => $query->row['meta_h1'],
'article_id' => $query->row['article_id'],
'name' => $query->row['name'],
'description' => $query->row['description'],
'meta_description' => $query->row['meta_description'],
'meta_keyword' => $query->row['meta_keyword'],
'image' => $query->row['image'],
'rating' => round($query->row['rating']),
'reviews' => $query->row['reviews'],
'sort_order' => $query->row['sort_order'],
'article_review' => $query->row['article_review'],
'status' => $query->row['status'],
'gstatus' => $query->row['gstatus'],
'date_added' => $query->row['date_added'],
'date_modified' => $query->row['date_modified'],
'viewed' => $query->row['viewed']
);
} else {
return false;
}
}
public function getArticles($data = array()) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$cache = 'article.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$customer_group_id . '.' . md5(http_build_query($data));
$article_data = $this->cache->get($cache);
if (!$article_data) {
$sql = "SELECT p.article_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review_article r1 WHERE r1.article_id = p.article_id AND r1.status = '1' GROUP BY r1.article_id) AS rating FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id)";
if (!empty($data['filter_blog_category_id'])) {
$sql .= " LEFT JOIN " . DB_PREFIX . "article_to_blog_category a2c ON (p.article_id = a2c.article_id)";
}
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
if (!empty($data['filter_name']) || !empty($data['filter_tag'])) {
$sql .= " AND (";
if (!empty($data['filter_name'])) {
if (!empty($data['filter_description'])) {
$sql .= "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%' OR MATCH(pd.description) AGAINST('" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "')";
} else {
$sql .= "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
}
}
if (!empty($data['filter_name']) && !empty($data['filter_tag'])) {
$sql .= " OR ";
}
if (!empty($data['filter_tag'])) {
$sql .= "MATCH(pd.tag) AGAINST('" . $this->db->escape(utf8_strtolower($data['filter_tag'])) . "')";
}
$sql .= ")";
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
}
if (!empty($data['filter_blog_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$implode_data = array();
$implode_data[] = (int)$data['filter_blog_category_id'];
$this->load->model('blog/category');
$categories = $this->model_blog_category->getCategoriesByParentId($data['filter_blog_category_id']);
foreach ($categories as $blog_category_id) {
$implode_data[] = (int)$blog_category_id;
}
$sql .= " AND a2c.blog_category_id IN (" . implode(', ', $implode_data) . ")";
} else {
$sql .= " AND a2c.blog_category_id = '" . (int)$data['filter_blog_category_id'] . "'";
}
}
$sql .= " GROUP BY p.article_id";
$sort_data = array(
'pd.name',
//OCSTORE.COM
'p.viewed',
//OCSTORE.COM
'rating',
'p.sort_order',
'p.date_added'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model' || $data['sort'] == 'p.date_added') {
$sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
} else {
$sql .= " ORDER BY " . $data['sort'];
}
} else {
$sql .= " ORDER BY p.sort_order";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(pd.name) DESC";
} else {
$sql .= " ASC, LCASE(pd.name) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$article_data = array();
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$article_data[$result['article_id']] = $this->getArticle($result['article_id']);
}
$this->cache->set($cache, $article_data);
}
return $article_data;
}
public function getLatestArticles($limit) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$cache = 'article.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit;
$article_data = $this->cache->get($cache);
if (!$article_data) {
$query = $this->db->query("SELECT p.article_id FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$article_data[$result['article_id']] = $this->getArticle($result['article_id']);
}
$this->cache->set($cache, $article_data);
}
return $article_data;
}
public function getPopularArticles($limit) {
$article_data = array();
$query = $this->db->query("SELECT p.article_id FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$article_data[$result['article_id']] = $this->getArticle($result['article_id']);
}
return $article_data;
}
public function getArticleImages($article_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_image WHERE article_id = '" . (int)$article_id . "' ORDER BY sort_order ASC");
return $query->rows;
}
public function getArticleRelated($article_id) {
$article_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related pr LEFT JOIN " . DB_PREFIX . "article p ON (pr.related_id = p.article_id) LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id) WHERE pr.article_id = '" . (int)$article_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
foreach ($query->rows as $result) {
$article_data[$result['related_id']] = $this->getArticle($result['related_id']);
}
return $article_data;
}
public function getArticleRelatedByProduct($data) {
$article_data = array();
$this->load->model('blog/article');
$sql = "SELECT * FROM " . DB_PREFIX . "product_related_article np LEFT JOIN " . DB_PREFIX . "article p ON (np.article_id = p.article_id) LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id) WHERE np.product_id = '" . (int)$data['product_id'] . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT " . (int)$data['limit'];
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$article_data[$result['article_id']] = $this->model_blog_article->getArticle($result['article_id']);
}
return $article_data;
}
//category manuf
public function getArticleRelatedByCategory($data) {
$article_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related_wb pr LEFT JOIN " . DB_PREFIX . "article p ON (pr.article_id = p.article_id) LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id) WHERE pr.category_id = '" . (int)$data['category_id'] . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT " . (int)$data['limit']);
foreach ($query->rows as $result) {
$article_data[$result['article_id']] = $this->getArticle($result['article_id']);
}
return $article_data;
}
public function getArticleRelatedByManufacturer($data) {
$article_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related_mn pr LEFT JOIN " . DB_PREFIX . "article p ON (pr.article_id = p.article_id) LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id) WHERE pr.manufacturer_id = '" . (int)$data['manufacturer_id'] . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT " . (int)$data['limit']);
foreach ($query->rows as $result) {
$article_data[$result['article_id']] = $this->getArticle($result['article_id']);
}
return $article_data;
}
//category manuf
public function getArticleRelatedProduct($article_id) {
$product_data = array();
$this->load->model('catalog/product');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related_product np LEFT JOIN " . DB_PREFIX . "product p ON (np.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE np.article_id = '" . (int)$article_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
return $product_data;
}
public function getArticleLayoutId($article_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_layout WHERE article_id = '" . (int)$article_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return $query->row['layout_id'];
} else {
return $this->config->get('config_layout_article');
}
}
public function getCategories($article_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_blog_category WHERE article_id = '" . (int)$article_id . "'");
return $query->rows;
}
public function getDownloads($article_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_download pd LEFT JOIN " . DB_PREFIX . "download d ON(pd.download_id=d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON(pd.download_id=dd.download_id) WHERE article_id = '" . (int)$article_id . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id')."'");
return $query->rows;
}
public function getDownload($article_id, $download_id) {
$download="";
if($download_id!=0)$download=" AND d.download_id=".(int)$download_id;
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_download pd LEFT JOIN " . DB_PREFIX . "download d ON(pd.download_id=d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON(pd.download_id=dd.download_id) WHERE article_id = '" . (int)$article_id . "' ".$download." AND dd.language_id = '" . (int)$this->config->get('config_language_id')."'");
return $query->row;
}
public function getTotalArticles($data = array()) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$cache = md5(http_build_query($data));
$article_data = $this->cache->get('article.total.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$customer_group_id . '.' . $cache);
$article_data = [];
if (!$article_data) {
$sql = "SELECT COUNT(DISTINCT p.article_id) AS total FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) LEFT JOIN " . DB_PREFIX . "article_to_store p2s ON (p.article_id = p2s.article_id)";
if (!empty($data['filter_blog_category_id'])) {
$sql .= " LEFT JOIN " . DB_PREFIX . "article_to_blog_category a2c ON (p.article_id = a2c.article_id)";
}
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
if (!empty($data['filter_name']) || !empty($data['filter_tag'])) {
$sql .= " AND (";
if (!empty($data['filter_name'])) {
if (!empty($data['filter_description'])) {
$sql .= "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%' OR MATCH(pd.description) AGAINST('" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "')";
} else {
$sql .= "LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
}
}
if (!empty($data['filter_name']) && !empty($data['filter_tag'])) {
$sql .= " OR ";
}
if (!empty($data['filter_tag'])) {
$sql .= "MATCH(pd.tag) AGAINST('" . $this->db->escape(utf8_strtolower($data['filter_tag'])) . "')";
}
$sql .= ")";
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
}
if (!empty($data['filter_blog_category_id'])) {
if (!empty($data['filter_sub_blog_category'])) {
$implode_data = array();
$implode_data[] = (int)$data['filter_blog_category_id'];
$this->load->model('blog/category');
$categories = $this->model_blog_category->getCategoriesByParentId($data['filter_category_id']);
foreach ($categories as $blog_category_id) {
$implode_data[] = (int)$blog_category_id;
}
$sql .= " AND a2c.blog_category_id IN (" . implode(', ', $implode_data) . ")";
} else {
$sql .= " AND a2c.blog_category_id = '" . (int)$data['filter_blog_category_id'] . "'";
}
}
$query = $this->db->query($sql);
$article_data = $query->row['total'];
$this->cache->set('article.total.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$customer_group_id . '.' . $cache, $article_data);
}
return $article_data;
}
}
?>
+59
View File
@@ -0,0 +1,59 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ModelBlogCategory extends Model {
public function getCategory($blog_category_id) {
return $this->getCategories((int)$blog_category_id, 'by_id');
}
public function getCategories($id = 0, $type = 'by_parent') {
static $data = null;
if ($data === null) {
$data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category c LEFT JOIN " . DB_PREFIX . "blog_category_description cd ON (c.blog_category_id = cd.blog_category_id) LEFT JOIN " . DB_PREFIX . "blog_category_to_store c2s ON (c.blog_category_id = c2s.blog_category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1' ORDER BY c.parent_id, c.sort_order, cd.name");
foreach ($query->rows as $row) {
$data['by_id'][$row['blog_category_id']] = $row;
$data['by_parent'][$row['parent_id']][] = $row;
}
}
return ((isset($data[$type]) && isset($data[$type][$id])) ? $data[$type][$id] : array());
}
public function getCategoriesByParentId($blog_category_id) {
$category_data = array();
$categories = $this->getCategories((int)$blog_category_id);
foreach ($categories as $category) {
$category_data[] = $category['blog_category_id'];
$children = $this->getCategoriesByParentId($category['blog_category_id']);
if ($children) {
$category_data = array_merge($children, $category_data);
}
}
return $category_data;
}
public function getCategoryLayoutId($blog_category_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category_to_layout WHERE blog_category_id = '" . (int)$blog_category_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return $query->row['layout_id'];
} else {
return $this->config->get('config_layout_category');
}
}
public function getTotalCategoriesByCategoryId($parent_id = 0) {
return count($this->getCategories((int)$parent_id));
}
}
?>
+74
View File
@@ -0,0 +1,74 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ModelBlogReview extends Model {
public function addReview($article_id, $data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "review_article SET author = '" . $this->db->escape($data['name']) . "', customer_id = '" . (int)$this->customer->getId() . "', article_id = '" . (int)$article_id . "', text = '" . $this->db->escape($data['text']) . "', rating = '" . (int)$data['rating'] . "', date_added = NOW()");
$review_id = $this->db->getLastId();
if ($this->config->get('configblog_review_mail')) {
$this->load->language('blog/mail/review');
$this->load->model('blog/article');
$article_info = $this->model_blog_article->getArticle($article_id);
$subject = sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$message = $this->language->get('text_waiting') . "\n";
$message .= sprintf($this->language->get('text_article'), html_entity_decode($article_info['name'], ENT_QUOTES, 'UTF-8')) . "\n";
$message .= sprintf($this->language->get('text_reviewer'), html_entity_decode($data['name'], ENT_QUOTES, 'UTF-8')) . "\n";
$message .= sprintf($this->language->get('text_rating'), $data['rating']) . "\n";
$message .= $this->language->get('text_review') . "\n";
$message .= html_entity_decode($data['text'], ENT_QUOTES, 'UTF-8') . "\n\n";
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$mail->setSubject($subject);
$mail->setText($message);
$mail->send();
// Send to additional alert emails
$emails = explode(',', $this->config->get('config_alert_email'));
foreach ($emails as $email) {
if ($email && preg_match('/^[^\@]+@.*.[a-z]{2,15}$/i', $email)) {
$mail->setTo($email);
$mail->send();
}
}
}
}
public function getReviewsByArticleId($article_id, $start = 0, $limit = 20) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 20;
}
$query = $this->db->query("SELECT r.review_article_id, r.author, r.rating, r.text, p.article_id, pd.name, p.image, r.date_added FROM " . DB_PREFIX . "review_article r LEFT JOIN " . DB_PREFIX . "article p ON (r.article_id = p.article_id) LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) WHERE p.article_id = '" . (int)$article_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY r.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
}
public function getTotalReviewsByArticleId($article_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review_article r LEFT JOIN " . DB_PREFIX . "article p ON (r.article_id = p.article_id) LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) WHERE p.article_id = '" . (int)$article_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row['total'];
}
}
+69
View File
@@ -0,0 +1,69 @@
<?php
class ModelCatalogCategory extends Model {
public function getCategory($category_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.category_id = '" . (int)$category_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'");
return $query->row;
}
public function getCategories($parent_id = 0) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1' ORDER BY c.sort_order, LCASE(cd.name)");
return $query->rows;
}
public function getCategoryFilters($category_id) {
$implode = array();
$query = $this->db->query("SELECT filter_id FROM " . DB_PREFIX . "category_filter WHERE category_id = '" . (int)$category_id . "'");
foreach ($query->rows as $result) {
$implode[] = (int)$result['filter_id'];
}
$filter_group_data = array();
if ($implode) {
$filter_group_query = $this->db->query("SELECT DISTINCT f.filter_group_id, fgd.name, fg.sort_order FROM " . DB_PREFIX . "filter f LEFT JOIN " . DB_PREFIX . "filter_group fg ON (f.filter_group_id = fg.filter_group_id) LEFT JOIN " . DB_PREFIX . "filter_group_description fgd ON (fg.filter_group_id = fgd.filter_group_id) WHERE f.filter_id IN (" . implode(',', $implode) . ") AND fgd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY f.filter_group_id ORDER BY fg.sort_order, LCASE(fgd.name)");
foreach ($filter_group_query->rows as $filter_group) {
$filter_data = array();
$filter_query = $this->db->query("SELECT DISTINCT f.filter_id, fd.name FROM " . DB_PREFIX . "filter f LEFT JOIN " . DB_PREFIX . "filter_description fd ON (f.filter_id = fd.filter_id) WHERE f.filter_id IN (" . implode(',', $implode) . ") AND f.filter_group_id = '" . (int)$filter_group['filter_group_id'] . "' AND fd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY f.sort_order, LCASE(fd.name)");
foreach ($filter_query->rows as $filter) {
$filter_data[] = array(
'filter_id' => $filter['filter_id'],
'name' => $filter['name']
);
}
if ($filter_data) {
$filter_group_data[] = array(
'filter_group_id' => $filter_group['filter_group_id'],
'name' => $filter_group['name'],
'filter' => $filter_data
);
}
}
}
return $filter_group_data;
}
public function getCategoryLayoutId($category_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_to_layout WHERE category_id = '" . (int)$category_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return (int)$query->row['layout_id'];
} else {
return 0;
}
}
public function getTotalCategoriesByCategoryId($parent_id = 0) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'");
return $query->row['total'];
}
}
+256
View File
@@ -0,0 +1,256 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ModelCatalogCms extends Model {
private $NOW;
public function __construct($registry) {
$this->NOW = date('Y-m-d H:i') . ':00';
parent::__construct($registry);
}
public function getProductRelatedByCategory($data) {
$product_data = array();
$this->load->model('catalog/product');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_wb pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.category_id = '" . (int)$data['category_id'] . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT " . (int)$data['limit']);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
return $product_data;
}
public function getProductRelatedByManufacturer($data) {
$product_data = array();
$this->load->model('catalog/product');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_mn pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.manufacturer_id = '" . (int)$data['manufacturer_id'] . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT " . (int)$data['limit']);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
return $product_data;
}
public function getBestSeller($data = array()) {
$product_data = array();
$sort_data = array(
'op.name',
'p.model',
'p.price',
'rating',
'total'
);
$sql="SELECT op.product_id, SUM(op.quantity) AS total,(SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = op.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id";
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
$sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
} else {
$sql .= " ORDER BY " . $data['sort'];
}
} else {
$sql .= " ORDER BY p.sort_order";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(op.name) DESC";
} else {
$sql .= " ASC, LCASE(op.name) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
return $product_data;
}
public function getTotalBestSeller() {
$query = $this->db->query("SELECT COUNT(DISTINCT op.product_id) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if (isset($query->row['total'])) {
return $query->row['total'];
} else {
return 0;
}
}
public function getLatest($data = array()) {
$this->load->model('catalog/product');
$NOW = date('Y-m-d H:i') . ':00';
$sql = "SELECT * FROM (SELECT p.product_id, p.sort_order, p.model, pd.name, p.quantity, p.price, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < '" . $NOW . "') AND (pd2.date_end = '0000-00-00' OR pd2.date_end > '" . $NOW . "')) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ((ps.date_start = '0000-00-00' OR ps.date_start < '" . $NOW . "') AND (ps.date_end = '0000-00-00' OR ps.date_end > '" . $NOW . "')) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.status = '1' AND p.date_available <= '" . $NOW . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY p.product_id ORDER BY p.date_added DESC, LCASE(pd.name) DESC";
$sql .= " LIMIT 0," . (int)$data['max'];
$sql .= ") p ORDER BY ";
$sort_data = array(
'pd.name',
'quantity',
'ps.price',
'rating',
'p.sort_order',
'p.model'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name') {
$sql .= " LCASE('name')";
} elseif ($data['sort'] == 'ps.price') {
$sql .= " (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
} else {
$sql .= " " . $data['sort'];
}
} else {
$sql .= " sort_order";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(name) DESC";
} else {
$sql .= " ASC, LCASE(name) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
return $product_data;
}
public function getMostViewed($data = array()) {
$this->load->model('catalog/product');
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$product_data = $this->cache->get('product.mostviewed.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'). '.' . $customer_group_id . '.' . (int)$data['limit']);
$product_data = null;
if (!$product_data) {
$product_data = array();
$sql = "SELECT * FROM (SELECT p.product_id,
(SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id
AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2
WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "'
AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < '" . $this->NOW . "')
AND (pd2.date_end = '0000-00-00' OR pd2.date_end > '" . $this->NOW . "')) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount,
(SELECT price FROM " . DB_PREFIX . "product_special ps
WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "'
AND ((ps.date_start = '0000-00-00' OR ps.date_start < '" . $this->NOW . "') AND (ps.date_end = '0000-00-00' OR ps.date_end > '" . $this->NOW . "'))
ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, p.sort_order, p.viewed, p.price, p.model";
$sql .= " FROM " . DB_PREFIX . "product p
LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)
WHERE p.status = '1' AND p.date_available <= '" . $this->NOW . "'
AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'
GROUP BY p.product_id ORDER by p.viewed DESC LIMIT 0, " . (int)$data['max'];
$sql .= ") p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id AND pd.language_id = '". (int)$this->config->get('config_language_id') ."') ORDER BY ";
$sort_data = array(
'pd.name',
'quantity',
'ps.price',
'rating',
'p.sort_order',
'p.model',
'p.viewed'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name') {
$sql .= " LCASE('pd.name')";
} elseif ($data['sort'] == 'ps.price') {
$sql .= " (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
} else {
$sql .= " " . $data['sort'];
}
} else {
$sql .= " p.sort_order";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(name) DESC";
} else {
$sql .= " ASC, LCASE(name) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
$this->cache->set('product.mostviewed.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'). '.' . $customer_group_id . '.' . (int)$data['limit'], $product_data);
}
return $product_data;
}
}
?>
@@ -0,0 +1,24 @@
<?php
class ModelCatalogInformation extends Model {
public function getInformation($information_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.information_id = '" . (int)$information_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");
return $query->row;
}
public function getInformations() {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' ORDER BY i.sort_order, LCASE(id.title) ASC");
return $query->rows;
}
public function getInformationLayoutId($information_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_layout WHERE information_id = '" . (int)$information_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return (int)$query->row['layout_id'];
} else {
return 0;
}
}
}
@@ -0,0 +1,72 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ModelCatalogManufacturer extends Model {
public function getManufacturerLayoutId($manufacturer_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer_to_layout WHERE manufacturer_id = '" . (int)$manufacturer_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return $query->row['layout_id'];
} else {
return 0;
}
}
public function getManufacturer($manufacturer_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "manufacturer m LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON (m.manufacturer_id = md.manufacturer_id) LEFT JOIN " . DB_PREFIX . "manufacturer_to_store m2s ON (m.manufacturer_id = m2s.manufacturer_id) WHERE m.manufacturer_id = '" . (int)$manufacturer_id . "' AND md.language_id = '" . (int)$this->config->get('config_language_id') . "' AND m2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
return $query->row;
}
public function getManufacturers($data = array()) {
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "manufacturer m LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON (m.manufacturer_id = md.manufacturer_id) LEFT JOIN " . DB_PREFIX . "manufacturer_to_store m2s ON (m.manufacturer_id = m2s.manufacturer_id) WHERE m2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND md.language_id = '" . (int)$this->config->get('config_language_id') . "'";
$sort_data = array(
'name',
'sort_order'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY name";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
} else {
$manufacturer_data = $this->cache->get('manufacturer.' . (int)$this->config->get('config_store_id') . '.' . (int)$this->config->get('config_language_id'));
if (!$manufacturer_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer m LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON (m.manufacturer_id = md.manufacturer_id) LEFT JOIN " . DB_PREFIX . "manufacturer_to_store m2s ON (m.manufacturer_id = m2s.manufacturer_id) WHERE m2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND md.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
$manufacturer_data = $query->rows;
$this->cache->set('manufacturer.' . (int)$this->config->get('config_store_id') . '.' . (int)$this->config->get('config_language_id'), $manufacturer_data);
}
return $manufacturer_data;
}
}
}
+546
View File
@@ -0,0 +1,546 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ModelCatalogProduct extends Model {
public function updateViewed($product_id) {
$this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'");
}
public function getProduct($product_id) {
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, p.price_2, p.price_3, p.noindex AS noindex, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return array(
'product_id' => $query->row['product_id'],
'name' => $query->row['name'],
'description' => $query->row['description'],
'meta_title' => $query->row['meta_title'],
'noindex' => $query->row['noindex'],
'meta_h1' => $query->row['meta_h1'],
'meta_description' => $query->row['meta_description'],
'meta_keyword' => $query->row['meta_keyword'],
'tag' => $query->row['tag'],
'model' => $query->row['model'],
'sku' => $query->row['sku'],
'upc' => $query->row['upc'],
'ean' => $query->row['ean'],
'jan' => $query->row['jan'],
'isbn' => $query->row['isbn'],
'mpn' => $query->row['mpn'],
'location' => $query->row['location'],
'quantity' => $query->row['quantity'],
'stock_status' => $query->row['stock_status'],
'image' => $query->row['image'],
'manufacturer_id' => $query->row['manufacturer_id'],
'manufacturer' => $query->row['manufacturer'],
'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']),
'price_2' => $query->row['price_2'],
'price_3' => $query->row['price_3'],
'special' => $query->row['special'],
'reward' => $query->row['reward'],
'points' => $query->row['points'],
'tax_class_id' => $query->row['tax_class_id'],
'date_available' => $query->row['date_available'],
'weight' => $query->row['weight'],
'weight_class_id' => $query->row['weight_class_id'],
'length' => $query->row['length'],
'width' => $query->row['width'],
'height' => $query->row['height'],
'length_class_id' => $query->row['length_class_id'],
'subtract' => $query->row['subtract'],
'rating' => round($query->row['rating']),
'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0,
'minimum' => $query->row['minimum'],
'sort_order' => $query->row['sort_order'],
'status' => $query->row['status'],
'date_added' => $query->row['date_added'],
'date_modified' => $query->row['date_modified'],
'viewed' => $query->row['viewed']
);
} else {
return false;
}
}
public function getProducts($data = array()) {
$sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "product_to_category p2c";
}
if (!empty($data['filter_filter'])) {
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)";
} else {
$sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)";
}
} else {
$sql .= " FROM " . DB_PREFIX . "product p";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'";
} else {
$sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'";
}
if (!empty($data['filter_filter'])) {
$implode = array();
$filters = explode(',', $data['filter_filter']);
foreach ($filters as $filter_id) {
$implode[] = (int)$filter_id;
}
$sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")";
}
}
if (!empty($data['filter_name']) || !empty($data['filter_tag'])) {
$sql .= " AND (";
if (!empty($data['filter_name'])) {
$implode = array();
$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name'])));
foreach ($words as $word) {
$implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'";
}
if ($implode) {
$sql .= " " . implode(" AND ", $implode) . "";
}
if (!empty($data['filter_description'])) {
$sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
}
if (!empty($data['filter_name']) && !empty($data['filter_tag'])) {
$sql .= " OR ";
}
if (!empty($data['filter_tag'])) {
$implode = array();
$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag'])));
foreach ($words as $word) {
$implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'";
}
if ($implode) {
$sql .= " " . implode(" AND ", $implode) . "";
}
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
$sql .= ")";
}
if (!empty($data['filter_manufacturer_id'])) {
$sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'";
}
$sql .= " GROUP BY p.product_id";
$sort_data = array(
'pd.name',
'p.model',
'p.quantity',
'p.price',
'rating',
'p.sort_order',
'p.date_added'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
$sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
} elseif ($data['sort'] == 'p.price') {
$sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
} else {
$sql .= " ORDER BY " . $data['sort'];
}
} else {
$sql .= " ORDER BY p.sort_order";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(pd.name) DESC";
} else {
$sql .= " ASC, LCASE(pd.name) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$product_data = array();
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
}
return $product_data;
}
public function getProductSpecials($data = array()) {
$sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id";
$sort_data = array(
'pd.name',
'p.model',
'ps.price',
'rating',
'p.sort_order'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
$sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
} else {
$sql .= " ORDER BY " . $data['sort'];
}
} else {
$sql .= " ORDER BY p.sort_order";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(pd.name) DESC";
} else {
$sql .= " ASC, LCASE(pd.name) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$product_data = array();
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
}
return $product_data;
}
public function getLatestProducts($limit) {
$product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);
if (!$product_data) {
$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
}
$this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
}
return $product_data;
}
public function getPopularProducts($limit) {
$product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);
if (!$product_data) {
$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
}
$this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
}
return $product_data;
}
public function getBestSellerProducts($limit) {
$product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);
if (!$product_data) {
$product_data = array();
$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
}
$this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
}
return $product_data;
}
public function getProductAttributes($product_id) {
$product_attribute_group_data = array();
$product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name");
foreach ($product_attribute_group_query->rows as $product_attribute_group) {
$product_attribute_data = array();
$product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name");
foreach ($product_attribute_query->rows as $product_attribute) {
$product_attribute_data[] = array(
'attribute_id' => $product_attribute['attribute_id'],
'name' => $product_attribute['name'],
'text' => $product_attribute['text']
);
}
$product_attribute_group_data[] = array(
'attribute_group_id' => $product_attribute_group['attribute_group_id'],
'name' => $product_attribute_group['name'],
'attribute' => $product_attribute_data
);
}
return $product_attribute_group_data;
}
public function getProductOptions($product_id) {
$product_option_data = array();
$product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order");
foreach ($product_option_query->rows as $product_option) {
$product_option_value_data = array();
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order");
foreach ($product_option_value_query->rows as $product_option_value) {
$product_option_value_data[] = array(
'product_option_value_id' => $product_option_value['product_option_value_id'],
'option_value_id' => $product_option_value['option_value_id'],
'name' => $product_option_value['name'],
'image' => $product_option_value['image'],
'quantity' => $product_option_value['quantity'],
'subtract' => $product_option_value['subtract'],
'price' => $product_option_value['price'],
'price_prefix' => $product_option_value['price_prefix'],
'weight' => $product_option_value['weight'],
'weight_prefix' => $product_option_value['weight_prefix']
);
}
$product_option_data[] = array(
'product_option_id' => $product_option['product_option_id'],
'product_option_value' => $product_option_value_data,
'option_id' => $product_option['option_id'],
'name' => $product_option['name'],
'type' => $product_option['type'],
'value' => $product_option['value'],
'required' => $product_option['required']
);
}
return $product_option_data;
}
public function getProductDiscounts($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC");
return $query->rows;
}
public function getProductImages($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC");
return $query->rows;
}
public function getProductRelated($product_id) {
$product_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
foreach ($query->rows as $result) {
$product_data[$result['related_id']] = $this->getProduct($result['related_id']);
}
return $product_data;
}
public function getProductLayoutId($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return (int)$query->row['layout_id'];
} else {
return 0;
}
}
public function getCategories($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
return $query->rows;
}
public function getTotalProducts($data = array()) {
$sql = "SELECT COUNT(DISTINCT p.product_id) AS total";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "product_to_category p2c";
}
if (!empty($data['filter_filter'])) {
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)";
} else {
$sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)";
}
} else {
$sql .= " FROM " . DB_PREFIX . "product p";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'";
} else {
$sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'";
}
if (!empty($data['filter_filter'])) {
$implode = array();
$filters = explode(',', $data['filter_filter']);
foreach ($filters as $filter_id) {
$implode[] = (int)$filter_id;
}
$sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")";
}
}
if (!empty($data['filter_name']) || !empty($data['filter_tag'])) {
$sql .= " AND (";
if (!empty($data['filter_name'])) {
$implode = array();
$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name'])));
foreach ($words as $word) {
$implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'";
}
if ($implode) {
$sql .= " " . implode(" AND ", $implode) . "";
}
if (!empty($data['filter_description'])) {
$sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
}
if (!empty($data['filter_name']) && !empty($data['filter_tag'])) {
$sql .= " OR ";
}
if (!empty($data['filter_tag'])) {
$implode = array();
$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag'])));
foreach ($words as $word) {
$implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'";
}
if ($implode) {
$sql .= " " . implode(" AND ", $implode) . "";
}
}
if (!empty($data['filter_name'])) {
$sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
$sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
}
$sql .= ")";
}
if (!empty($data['filter_manufacturer_id'])) {
$sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'";
}
$query = $this->db->query($sql);
return $query->row['total'];
}
public function getProfile($product_id, $recurring_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'");
return $query->row;
}
public function getProfiles($product_id) {
$query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC");
return $query->rows;
}
public function getTotalProductSpecials() {
$query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))");
if (isset($query->row['total'])) {
return $query->row['total'];
} else {
return 0;
}
}
}
+69
View File
@@ -0,0 +1,69 @@
<?php
class ModelCatalogReview extends Model {
public function addReview($product_id, $data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "review SET author = '" . $this->db->escape($data['name']) . "', customer_id = '" . (int)$this->customer->getId() . "', product_id = '" . (int)$product_id . "', text = '" . $this->db->escape($data['text']) . "', rating = '" . (int)$data['rating'] . "', date_added = NOW()");
$review_id = $this->db->getLastId();
if (in_array('review', (array)$this->config->get('config_mail_alert'))) {
$this->load->language('mail/review');
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($product_id);
$subject = sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$message = $this->language->get('text_waiting') . "\n";
$message .= sprintf($this->language->get('text_product'), html_entity_decode($product_info['name'], ENT_QUOTES, 'UTF-8')) . "\n";
$message .= sprintf($this->language->get('text_reviewer'), html_entity_decode($data['name'], ENT_QUOTES, 'UTF-8')) . "\n";
$message .= sprintf($this->language->get('text_rating'), $data['rating']) . "\n";
$message .= $this->language->get('text_review') . "\n";
$message .= html_entity_decode($data['text'], ENT_QUOTES, 'UTF-8') . "\n\n";
$mail = new Mail($this->config->get('config_mail_engine'));
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$mail->setSubject($subject);
$mail->setText($message);
$mail->send();
// Send to additional alert emails
$emails = explode(',', $this->config->get('config_mail_alert_email'));
foreach ($emails as $email) {
if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
$mail->setTo($email);
$mail->send();
}
}
}
}
public function getReviewsByProductId($product_id, $start = 0, $limit = 20) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 20;
}
$query = $this->db->query("SELECT r.review_id, r.author, r.rating, r.text, p.product_id, pd.name, p.price, p.image, r.date_added FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY r.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
}
public function getTotalReviewsByProductId($product_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product p ON (r.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND p.date_available <= NOW() AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row['total'];
}
}
@@ -0,0 +1,8 @@
<?php
class ModelCheckoutMarketing extends Model {
public function getMarketingByCode($code) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "marketing WHERE code = '" . $this->db->escape($code) . "'");
return $query->row;
}
}
+385
View File
@@ -0,0 +1,385 @@
<?php
class ModelCheckoutOrder extends Model {
public function addOrder($data) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '') . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_custom_field = '" . $this->db->escape(isset($data['payment_custom_field']) ? json_encode($data['payment_custom_field']) : '') . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_custom_field = '" . $this->db->escape(isset($data['shipping_custom_field']) ? json_encode($data['shipping_custom_field']) : '') . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', marketing_id = '" . (int)$data['marketing_id'] . "', tracking = '" . $this->db->escape($data['tracking']) . "', language_id = '" . (int)$data['language_id'] . "', currency_id = '" . (int)$data['currency_id'] . "', currency_code = '" . $this->db->escape($data['currency_code']) . "', currency_value = '" . (float)$data['currency_value'] . "', ip = '" . $this->db->escape($data['ip']) . "', forwarded_ip = '" . $this->db->escape($data['forwarded_ip']) . "', user_agent = '" . $this->db->escape($data['user_agent']) . "', accept_language = '" . $this->db->escape($data['accept_language']) . "', date_added = NOW(), date_modified = NOW()");
$order_id = $this->db->getLastId();
// Products
if (isset($data['products'])) {
foreach ($data['products'] as $product) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', quantity = '" . (int)$product['quantity'] . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', reward = '" . (int)$product['reward'] . "'");
$order_product_id = $this->db->getLastId();
foreach ($product['option'] as $option) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_option SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', product_option_id = '" . (int)$option['product_option_id'] . "', product_option_value_id = '" . (int)$option['product_option_value_id'] . "', name = '" . $this->db->escape($option['name']) . "', `value` = '" . $this->db->escape($option['value']) . "', `type` = '" . $this->db->escape($option['type']) . "'");
}
}
}
// Gift Voucher
$this->load->model('extension/total/voucher');
// Vouchers
if (isset($data['vouchers'])) {
foreach ($data['vouchers'] as $voucher) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_voucher SET order_id = '" . (int)$order_id . "', description = '" . $this->db->escape($voucher['description']) . "', code = '" . $this->db->escape($voucher['code']) . "', from_name = '" . $this->db->escape($voucher['from_name']) . "', from_email = '" . $this->db->escape($voucher['from_email']) . "', to_name = '" . $this->db->escape($voucher['to_name']) . "', to_email = '" . $this->db->escape($voucher['to_email']) . "', voucher_theme_id = '" . (int)$voucher['voucher_theme_id'] . "', message = '" . $this->db->escape($voucher['message']) . "', amount = '" . (float)$voucher['amount'] . "'");
$order_voucher_id = $this->db->getLastId();
$voucher_id = $this->model_extension_total_voucher->addVoucher($order_id, $voucher);
$this->db->query("UPDATE " . DB_PREFIX . "order_voucher SET voucher_id = '" . (int)$voucher_id . "' WHERE order_voucher_id = '" . (int)$order_voucher_id . "'");
}
}
// Totals
if (isset($data['totals'])) {
foreach ($data['totals'] as $total) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_total SET order_id = '" . (int)$order_id . "', code = '" . $this->db->escape($total['code']) . "', title = '" . $this->db->escape($total['title']) . "', `value` = '" . (float)$total['value'] . "', sort_order = '" . (int)$total['sort_order'] . "'");
}
}
return $order_id;
}
public function editOrder($order_id, $data) {
// Void the order first
$this->addOrderHistory($order_id, 0);
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(json_encode($data['custom_field'])) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_custom_field = '" . $this->db->escape(json_encode($data['payment_custom_field'])) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_custom_field = '" . $this->db->escape(json_encode($data['shipping_custom_field'])) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "'");
// Products
if (isset($data['products'])) {
foreach ($data['products'] as $product) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', quantity = '" . (int)$product['quantity'] . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', reward = '" . (int)$product['reward'] . "'");
$order_product_id = $this->db->getLastId();
foreach ($product['option'] as $option) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_option SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', product_option_id = '" . (int)$option['product_option_id'] . "', product_option_value_id = '" . (int)$option['product_option_value_id'] . "', name = '" . $this->db->escape($option['name']) . "', `value` = '" . $this->db->escape($option['value']) . "', `type` = '" . $this->db->escape($option['type']) . "'");
}
}
}
// Gift Voucher
$this->load->model('extension/total/voucher');
$this->model_extension_total_voucher->disableVoucher($order_id);
// Vouchers
$this->db->query("DELETE FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int)$order_id . "'");
if (isset($data['vouchers'])) {
foreach ($data['vouchers'] as $voucher) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_voucher SET order_id = '" . (int)$order_id . "', description = '" . $this->db->escape($voucher['description']) . "', code = '" . $this->db->escape($voucher['code']) . "', from_name = '" . $this->db->escape($voucher['from_name']) . "', from_email = '" . $this->db->escape($voucher['from_email']) . "', to_name = '" . $this->db->escape($voucher['to_name']) . "', to_email = '" . $this->db->escape($voucher['to_email']) . "', voucher_theme_id = '" . (int)$voucher['voucher_theme_id'] . "', message = '" . $this->db->escape($voucher['message']) . "', amount = '" . (float)$voucher['amount'] . "'");
$order_voucher_id = $this->db->getLastId();
$voucher_id = $this->model_extension_total_voucher->addVoucher($order_id, $voucher);
$this->db->query("UPDATE " . DB_PREFIX . "order_voucher SET voucher_id = '" . (int)$voucher_id . "' WHERE order_voucher_id = '" . (int)$order_voucher_id . "'");
}
}
// Totals
$this->db->query("DELETE FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "'");
if (isset($data['totals'])) {
foreach ($data['totals'] as $total) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_total SET order_id = '" . (int)$order_id . "', code = '" . $this->db->escape($total['code']) . "', title = '" . $this->db->escape($total['title']) . "', `value` = '" . (float)$total['value'] . "', sort_order = '" . (int)$total['sort_order'] . "'");
}
}
}
public function deleteOrder($order_id) {
// Void the order first
$this->addOrderHistory($order_id, 0);
$this->db->query("DELETE FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_product` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_option` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_voucher` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_history` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE `or`, ort FROM `" . DB_PREFIX . "order_recurring` `or`, `" . DB_PREFIX . "order_recurring_transaction` `ort` WHERE order_id = '" . (int)$order_id . "' AND ort.order_recurring_id = `or`.order_recurring_id");
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_transaction` WHERE order_id = '" . (int)$order_id . "'");
// Gift Voucher
$this->load->model('extension/total/voucher');
$this->model_extension_total_voucher->disableVoucher($order_id);
}
public function getOrder($order_id) {
$order_query = $this->db->query("SELECT *, (SELECT os.name FROM `" . DB_PREFIX . "order_status` os WHERE os.order_status_id = o.order_status_id AND os.language_id = o.language_id) AS order_status FROM `" . DB_PREFIX . "order` o WHERE o.order_id = '" . (int)$order_id . "'");
if ($order_query->num_rows) {
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'");
if ($country_query->num_rows) {
$payment_iso_code_2 = $country_query->row['iso_code_2'];
$payment_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$payment_iso_code_2 = '';
$payment_iso_code_3 = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'");
if ($zone_query->num_rows) {
$payment_zone_code = $zone_query->row['code'];
} else {
$payment_zone_code = '';
}
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'");
if ($country_query->num_rows) {
$shipping_iso_code_2 = $country_query->row['iso_code_2'];
$shipping_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$shipping_iso_code_2 = '';
$shipping_iso_code_3 = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'");
if ($zone_query->num_rows) {
$shipping_zone_code = $zone_query->row['code'];
} else {
$shipping_zone_code = '';
}
$this->load->model('localisation/language');
$language_info = $this->model_localisation_language->getLanguage($order_query->row['language_id']);
if ($language_info) {
$language_code = $language_info['code'];
} else {
$language_code = $this->config->get('config_language');
}
return array(
'order_id' => $order_query->row['order_id'],
'invoice_no' => $order_query->row['invoice_no'],
'invoice_prefix' => $order_query->row['invoice_prefix'],
'store_id' => $order_query->row['store_id'],
'store_name' => $order_query->row['store_name'],
'store_url' => $order_query->row['store_url'],
'customer_id' => $order_query->row['customer_id'],
'firstname' => $order_query->row['firstname'],
'lastname' => $order_query->row['lastname'],
'email' => $order_query->row['email'],
'telephone' => $order_query->row['telephone'],
'custom_field' => json_decode($order_query->row['custom_field'], true),
'payment_firstname' => $order_query->row['payment_firstname'],
'payment_lastname' => $order_query->row['payment_lastname'],
'payment_company' => $order_query->row['payment_company'],
'payment_address_1' => $order_query->row['payment_address_1'],
'payment_address_2' => $order_query->row['payment_address_2'],
'payment_postcode' => $order_query->row['payment_postcode'],
'payment_city' => $order_query->row['payment_city'],
'payment_zone_id' => $order_query->row['payment_zone_id'],
'payment_zone' => $order_query->row['payment_zone'],
'payment_zone_code' => $payment_zone_code,
'payment_country_id' => $order_query->row['payment_country_id'],
'payment_country' => $order_query->row['payment_country'],
'payment_iso_code_2' => $payment_iso_code_2,
'payment_iso_code_3' => $payment_iso_code_3,
'payment_address_format' => $order_query->row['payment_address_format'],
'payment_custom_field' => json_decode($order_query->row['payment_custom_field'], true),
'payment_method' => $order_query->row['payment_method'],
'payment_code' => $order_query->row['payment_code'],
'shipping_firstname' => $order_query->row['shipping_firstname'],
'shipping_lastname' => $order_query->row['shipping_lastname'],
'shipping_company' => $order_query->row['shipping_company'],
'shipping_address_1' => $order_query->row['shipping_address_1'],
'shipping_address_2' => $order_query->row['shipping_address_2'],
'shipping_postcode' => $order_query->row['shipping_postcode'],
'shipping_city' => $order_query->row['shipping_city'],
'shipping_zone_id' => $order_query->row['shipping_zone_id'],
'shipping_zone' => $order_query->row['shipping_zone'],
'shipping_zone_code' => $shipping_zone_code,
'shipping_country_id' => $order_query->row['shipping_country_id'],
'shipping_country' => $order_query->row['shipping_country'],
'shipping_iso_code_2' => $shipping_iso_code_2,
'shipping_iso_code_3' => $shipping_iso_code_3,
'shipping_address_format' => $order_query->row['shipping_address_format'],
'shipping_custom_field' => json_decode($order_query->row['shipping_custom_field'], true),
'shipping_method' => $order_query->row['shipping_method'],
'shipping_code' => $order_query->row['shipping_code'],
'comment' => $order_query->row['comment'],
'total' => $order_query->row['total'],
'order_status_id' => $order_query->row['order_status_id'],
'order_status' => $order_query->row['order_status'],
'affiliate_id' => $order_query->row['affiliate_id'],
'commission' => $order_query->row['commission'],
'language_id' => $order_query->row['language_id'],
'language_code' => $language_code,
'currency_id' => $order_query->row['currency_id'],
'currency_code' => $order_query->row['currency_code'],
'currency_value' => $order_query->row['currency_value'],
'ip' => $order_query->row['ip'],
'forwarded_ip' => $order_query->row['forwarded_ip'],
'user_agent' => $order_query->row['user_agent'],
'accept_language' => $order_query->row['accept_language'],
'date_added' => $order_query->row['date_added'],
'date_modified' => $order_query->row['date_modified']
);
} else {
return false;
}
}
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
public function getOrderOptions($order_id, $order_product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
return $query->rows;
}
public function getOrderVouchers($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
public function getOrderTotals($order_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order ASC");
return $query->rows;
}
public function addOrderHistory($order_id, $order_status_id, $comment = '', $notify = false, $override = false) {
$order_info = $this->getOrder($order_id);
if ($order_info) {
// Fraud Detection
$this->load->model('account/customer');
$customer_info = $this->model_account_customer->getCustomer($order_info['customer_id']);
if ($customer_info && $customer_info['safe']) {
$safe = true;
} else {
$safe = false;
}
// Only do the fraud check if the customer is not on the safe list and the order status is changing into the complete or process order status
if (!$safe && !$override && in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
// Anti-Fraud
$this->load->model('setting/extension');
$extensions = $this->model_setting_extension->getExtensions('fraud');
foreach ($extensions as $extension) {
if ($this->config->get('fraud_' . $extension['code'] . '_status')) {
$this->load->model('extension/fraud/' . $extension['code']);
if (property_exists($this->{'model_extension_fraud_' . $extension['code']}, 'check')) {
$fraud_status_id = $this->{'model_extension_fraud_' . $extension['code']}->check($order_info);
if ($fraud_status_id) {
$order_status_id = $fraud_status_id;
}
}
}
}
}
// If current order status is not processing or complete but new status is processing or complete then commence completing the order
if (!in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
// Redeem coupon, vouchers and reward points
$order_totals = $this->getOrderTotals($order_id);
foreach ($order_totals as $order_total) {
$this->load->model('extension/total/' . $order_total['code']);
if (property_exists($this->{'model_extension_total_' . $order_total['code']}, 'confirm')) {
// Confirm coupon, vouchers and reward points
$fraud_status_id = $this->{'model_extension_total_' . $order_total['code']}->confirm($order_info, $order_total);
// If the balance on the coupon, vouchers and reward points is not enough to cover the transaction or has already been used then the fraud order status is returned.
if ($fraud_status_id) {
$order_status_id = $fraud_status_id;
}
}
}
// Stock subtraction
$order_products = $this->getOrderProducts($order_id);
foreach ($order_products as $order_product) {
$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");
$order_options = $this->getOrderOptions($order_id, $order_product['order_product_id']);
foreach ($order_options as $order_option) {
$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_option_value_id = '" . (int)$order_option['product_option_value_id'] . "' AND subtract = '1'");
}
}
// Add commission if sale is linked to affiliate referral.
if ($order_info['affiliate_id'] && $this->config->get('config_affiliate_auto')) {
$this->load->model('account/customer');
if (!$this->model_account_customer->getTotalTransactionsByOrderId($order_id)) {
$this->model_account_customer->addTransaction($order_info['affiliate_id'], $this->language->get('text_order_id') . ' #' . $order_id, $order_info['commission'], $order_id);
}
}
}
// Update the DB with the new statuses
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int)$order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()");
// If old order status is the processing or complete status but new status is not then commence restock, and remove coupon, voucher and reward history
if (in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && !in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
// Restock
$order_products = $this->getOrderProducts($order_id);
foreach($order_products as $order_product) {
$this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");
$order_options = $this->getOrderOptions($order_id, $order_product['order_product_id']);
foreach ($order_options as $order_option) {
$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity + " . (int)$order_product['quantity'] . ") WHERE product_option_value_id = '" . (int)$order_option['product_option_value_id'] . "' AND subtract = '1'");
}
}
// Remove coupon, vouchers and reward points history
$order_totals = $this->getOrderTotals($order_id);
foreach ($order_totals as $order_total) {
$this->load->model('extension/total/' . $order_total['code']);
if (property_exists($this->{'model_extension_total_' . $order_total['code']}, 'unconfirm')) {
$this->{'model_extension_total_' . $order_total['code']}->unconfirm($order_id);
}
}
// Remove commission if sale is linked to affiliate referral.
if ($order_info['affiliate_id']) {
$this->load->model('account/customer');
$this->model_account_customer->deleteTransactionByOrderId($order_id);
}
}
$this->cache->delete('product');
}
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
class ModelCheckoutRecurring extends Model {
public function addRecurring($order_id, $description, $data) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring` SET `order_id` = '" . (int)$order_id . "', `date_added` = NOW(), `status` = 6, `product_id` = '" . (int)$data['product_id'] . "', `product_name` = '" . $this->db->escape($data['name']) . "', `product_quantity` = '" . $this->db->escape($data['quantity']) . "', `recurring_id` = '" . (int)$data['recurring']['recurring_id'] . "', `recurring_name` = '" . $this->db->escape($data['name']) . "', `recurring_description` = '" . $this->db->escape($description) . "', `recurring_frequency` = '" . $this->db->escape($data['recurring']['frequency']) . "', `recurring_cycle` = '" . (int)$data['recurring']['cycle'] . "', `recurring_duration` = '" . (int)$data['recurring']['duration'] . "', `recurring_price` = '" . (float)$data['recurring']['price'] . "', `trial` = '" . (int)$data['recurring']['trial'] . "', `trial_frequency` = '" . $this->db->escape($data['recurring']['trial_frequency']) . "', `trial_cycle` = '" . (int)$data['recurring']['trial_cycle'] . "', `trial_duration` = '" . (int)$data['recurring']['trial_duration'] . "', `trial_price` = '" . (float)$data['recurring']['trial_price'] . "', `reference` = ''");
return $this->db->getLastId();
}
public function editReference($order_recurring_id, $reference) {
$this->db->query("UPDATE " . DB_PREFIX . "order_recurring SET reference = '" . $this->db->escape($reference) . "' WHERE order_recurring_id = '" . (int)$order_recurring_id . "'");
if ($this->db->countAffected() > 0) {
return true;
} else {
return false;
}
}
}
+7
View File
@@ -0,0 +1,7 @@
<?php
class ModelDesignBanner extends Model {
public function getBanner($banner_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner b LEFT JOIN " . DB_PREFIX . "banner_image bi ON (b.banner_id = bi.banner_id) WHERE b.banner_id = '" . (int)$banner_id . "' AND b.status = '1' AND bi.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY bi.sort_order ASC");
return $query->rows;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
class ModelDesignLayout extends Model {
public function getLayout($route) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_route WHERE '" . $this->db->escape($route) . "' LIKE route AND store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY route DESC LIMIT 1");
if ($query->num_rows) {
return (int)$query->row['layout_id'];
} else {
return 0;
}
}
public function getLayoutModules($layout_id, $position) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "' AND position = '" . $this->db->escape($position) . "' ORDER BY sort_order");
return $query->rows;
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
class ModelDesignTheme extends Model {
public function getTheme($route, $theme) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "theme WHERE store_id = '" . (int)$this->config->get('config_store_id') . "' AND theme = '" . $this->db->escape($theme) . "' AND route = '" . $this->db->escape($route) . "'");
return $query->row;
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
class ModelDesignTranslation extends Model {
public function getTranslations($route) {
$language_code = !empty($this->session->data['language']) ? $this->session->data['language'] : $this->config->get('config_language');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "translation WHERE store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "' AND (route = '" . $this->db->escape($route) . "' OR route = '" . $this->db->escape($language_code) . "')");
return $query->rows;
}
}
@@ -0,0 +1,141 @@
<?php
class ModelExtensionAdvertiseGoogle extends Model {
public function getHumanReadableCategory($product_id, $store_id) {
$this->load->config('googleshopping/googleshopping');
$google_category_result = $this->db->query("SELECT google_product_category FROM `" . DB_PREFIX . "googleshopping_product` pag WHERE pag.product_id = " . (int)$product_id . " AND pag.store_id = " . (int)$store_id);
if ($google_category_result->num_rows > 0) {
$google_category_id = $google_category_result->row['google_product_category'];
$google_categories = $this->config->get('advertise_google_google_product_categories');
if (!empty($google_category_id) && isset($google_categories[$google_category_id])) {
return $google_categories[$google_category_id];
}
}
$oc_category_result = $this->db->query("SELECT c.category_id FROM `" . DB_PREFIX . "product_to_category` p2c LEFT JOIN `" . DB_PREFIX . "category` c ON (c.category_id = p2c.category_id) WHERE p2c.product_id=" . (int)$product_id . " LIMIT 0,1");
if ($oc_category_result->num_rows > 0) {
return $this->getHumanReadableOpenCartCategory((int)$oc_category_result->row['category_id']);
}
return "";
}
public function getHumanReadableOpenCartCategory($category_id) {
$sql = "SELECT GROUP_CONCAT(cd.name ORDER BY cp.level SEPARATOR ' &gt; ') AS path FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "category_description cd ON (cp.path_id = cd.category_id) WHERE cd.language_id=" . (int)$this->config->get('config_language_id') . " AND cp.category_id=" . (int)$category_id;
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->row['path'];
}
return "";
}
public function getSizeAndColorOptionMap($product_id, $store_id) {
$color_id = $this->getOptionId($product_id, $store_id, 'color');
$size_id = $this->getOptionId($product_id, $store_id, 'size');
$groups = $this->googleshopping->getGroups($product_id, $this->config->get('config_language_id'), $color_id, $size_id);
$colors = $this->googleshopping->getProductOptionValueNames($product_id, $this->config->get('config_language_id'), $color_id);
$sizes = $this->googleshopping->getProductOptionValueNames($product_id, $this->config->get('config_language_id'), $size_id);
$map = array(
'groups' => $groups,
'colors' => count($colors) > 1 ? $colors : null,
'sizes' => count($sizes) > 1 ? $sizes : null,
);
return $map;
}
public function getCoupon($order_id) {
$sql = "SELECT c.code FROM `" . DB_PREFIX . "coupon_history` ch LEFT JOIN `" . DB_PREFIX . "coupon` c ON (c.coupon_id = ch.coupon_id) WHERE ch.order_id=" . (int)$order_id;
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return $result->row['code'];
}
return null;
}
public function getRemarketingProductIds($products, $store_id) {
$ecomm_prodid = array();
foreach ($products as $product) {
if (null !== $id = $this->getRemarketingProductId($product, $store_id)) {
$ecomm_prodid[] = $id;
}
}
return $ecomm_prodid;
}
public function getRemarketingItems($products, $store_id) {
$items = array();
foreach ($products as $product) {
if (null !== $id = $this->getRemarketingProductId($product, $store_id)) {
$items[] = array(
'google_business_vertical' => 'retail',
'id' => (string)$id,
'name' => (string)$product['name'],
'quantity' => (int)$product['quantity']
);
}
}
return $items;
}
protected function getRemarketingProductId($product, $store_id) {
$option_map = $this->getSizeAndColorOptionMap($product['product_id'], $store_id);
$found_color = "";
$found_size = "";
foreach ($product['option'] as $option) {
if (is_array($option_map['colors'])) {
foreach ($option_map['colors'] as $product_option_value_id => $color) {
if ($option['product_option_value_id'] == $product_option_value_id) {
$found_color = $color;
}
}
}
if (is_array($option_map['sizes'])) {
foreach ($option_map['sizes'] as $product_option_value_id => $size) {
if ($option['product_option_value_id'] == $product_option_value_id) {
$found_size = $size;
}
}
}
}
foreach ($option_map['groups'] as $id => $group) {
if ($group['color'] === $found_color && $group['size'] === $found_size) {
return $id;
}
}
return null;
}
protected function getOptionId($product_id, $store_id, $type) {
$sql = "SELECT pag." . $type . " FROM `" . DB_PREFIX . "googleshopping_product` pag WHERE product_id=" . (int)$product_id . " AND store_id=" . (int)$store_id;
$result = $this->db->query($sql);
if ($result->num_rows > 0) {
return (int)$result->row[$type];
}
return 0;
}
}
@@ -0,0 +1,14 @@
<?php
class ModelExtensionFeedGoogleBase extends Model {
public function getCategories() {
$query = $this->db->query("SELECT google_base_category_id, (SELECT name FROM `" . DB_PREFIX . "google_base_category` gbc WHERE gbc.google_base_category_id = gbc2c.google_base_category_id) AS google_base_category, category_id, (SELECT name FROM `" . DB_PREFIX . "category_description` cd WHERE cd.category_id = gbc2c.category_id AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS category FROM `" . DB_PREFIX . "google_base_category_to_category` gbc2c ORDER BY google_base_category ASC");
return $query->rows;
}
public function getTotalCategories() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "google_base_category_to_category`");
return $query->row['total'];
}
}
@@ -0,0 +1,49 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ModelExtensionFeedYandexMarket extends Model {
public function getCategory() {
$query = $this->db->query("SELECT cd.name, c.category_id, c.parent_id FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1' AND c.sort_order <> '-1'");
return $query->rows;
}
public function getProduct($allowed_categories, $allowed_manufacturers, $out_of_stock_id, $vendor_required = true, $bus_image = true, $bus_image_quantity = '9', $bus_main_category = true, $bus_quantity_status = false) {
$sql = "SELECT p2c.category_id, p.product_id, p.model, p.sku, p.upc, p.ean, p.jan, p.isbn, p.mpn, p.location, p.quantity, p.stock_status_id, p.image, p.tax_class_id, pd.name, pd.description, pd.meta_title, pd.meta_description, pd.meta_keyword, pd.meta_h1,";
if ((int)$bus_image_quantity > '1') {
$sql .= " (SELECT SUBSTRING_INDEX(GROUP_CONCAT(pi.image ORDER BY pi.image SEPARATOR ','), ',', " . ((int)$bus_image_quantity <= "10" ? (int)$bus_image_quantity - 1 : "9") . ") FROM " . DB_PREFIX . "product_image pi WHERE pi.product_id = p2c.product_id) AS images,";
}
$sql .= " m.name AS manufacturer, IFNULL(ps.price, p.price) AS price FROM " . DB_PREFIX . "product_to_category AS p2c JOIN " . DB_PREFIX . "product AS p ON (p.product_id = p2c.product_id) " . ($vendor_required ? '' : 'LEFT ') . "JOIN " . DB_PREFIX . "manufacturer AS m ON (m.manufacturer_id = p.manufacturer_id) LEFT JOIN " . DB_PREFIX . "product_description AS pd ON (pd.product_id = p2c.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store AS p2s ON (p2s.product_id = p2c.product_id) LEFT JOIN " . DB_PREFIX . "product_special AS ps ON (ps.product_id = p2c.product_id) AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ps.date_start < NOW() AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())";
if (!empty($allowed_categories)) {
$sql .= " WHERE p2c.category_id IN (" . $this->db->escape($allowed_categories) . ")";
} else {
$sql .= " WHERE p2c.category_id";
}
if (!empty($bus_main_category)) {
$sql .= " AND p2c.main_category = '1'";
}
if (!empty($allowed_manufacturers)) {
$sql .= " AND m.manufacturer_id IN (" . $this->db->escape($allowed_manufacturers) . ")";
}
$sql .= " AND p.status = '1'";
if (!empty($bus_image)) {
$sql .= " AND p.image != ''";
}
$sql .= " AND p.date_available <= NOW() AND (p.quantity " . (!empty($bus_quantity_status) ? '>=' : '>') . " '0' OR p.stock_status_id != '" . (int)$out_of_stock_id . "') AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
$sql .= " GROUP BY p2c.product_id";
$query = $this->db->query($sql);
return $query->rows;
}
}
@@ -0,0 +1,15 @@
<?php
class ModelExtensionFeedYandexTurbo extends Model {
public function getCategories() {
$query = $this->db->query("SELECT cd.name, c.category_id, c.parent_id FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1' AND c.sort_order <> '-1'");
return $query->rows;
}
public function getProducts() {
$sql = "SELECT p.*, pd.name, pd.description, p2c.category_id, IFNULL(ps.price, p.price) AS price FROM " . DB_PREFIX . "product p JOIN " . DB_PREFIX . "product_to_category AS p2c ON (p.product_id = p2c.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "product_special ps ON (p.product_id = ps.product_id) AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ps.date_start < NOW() AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()) WHERE p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.date_available <= NOW() AND p.status = '1' GROUP BY p.product_id";
$query = $this->db->query($sql);
return $query->rows;
}
}
@@ -0,0 +1,163 @@
<?php
class ModelExtensionFraudFraudLabsPro extends Model {
public function check($data) {
// Do not perform fraud check if FraudLabs Pro is disabled or API key is not provided.
if (!$this->config->get('fraud_fraudlabspro_status') ||!$this->config->get('fraud_fraudlabspro_key')) {
return;
}
$risk_score = 0;
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraudlabspro` WHERE order_id = '" . (int)$data['order_id'] . "'");
// Do not call FraudLabs Pro API if order is already screened.
if ($query->num_rows) {
return;
}
$ip = $data['ip'];
// Detect client IP is store is behind CloudFlare protection.
if(isset($_SERVER['HTTP_CF_CONNECTING_IP']) && filter_var($_SERVER['HTTP_CF_CONNECTING_IP'], FILTER_VALIDATE_IP)){
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
// Get real client IP is they are behind proxy server.
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
// Overwrite client IP if simulate IP is provided.
if (filter_var($this->config->get('fraud_fraudlabspro_simulate_ip'), FILTER_VALIDATE_IP)) {
$ip = $this->config->get('fraud_fraudlabspro_simulate_ip');
}
$request['key'] = $this->config->get('fraud_fraudlabspro_key');
$request['ip'] = $ip;
$request['first_name'] = $data['firstname'];
$request['last_name'] = $data['lastname'];
$request['bill_city'] = $data['payment_city'];
$request['bill_state'] = $data['payment_zone'];
$request['bill_country'] = $data['payment_iso_code_2'];
$request['bill_zip_code'] = $data['payment_postcode'];
$request['email_domain'] = utf8_substr(strrchr($data['email'], '@'), 1);
$request['user_phone'] = $data['telephone'];
if ($data['shipping_method']) {
$request['ship_addr'] = $data['shipping_address_1'];
$request['ship_city'] = $data['shipping_city'];
$request['ship_state'] = $data['shipping_zone'];
$request['ship_zip_code'] = $data['shipping_postcode'];
$request['ship_country'] = $data['shipping_iso_code_2'];
}
$request['email'] = $data['email'];
$request['email_hash'] = $this->hashIt($data['email']);
$request['amount'] = $this->currency->format($data['total'], $data['currency_code'], $data['currency_value'], false);
$request['quantity'] = 1;
$request['currency'] = $data['currency_code'];
$request['payment_mode'] = $data['payment_code'];
$request['user_order_id'] = $data['order_id'];
$request['flp_checksum'] = (isset($_COOKIE['flp_checksum'])) ? $_COOKIE['flp_checksum'] : '';
$request['format'] = 'json';
$request['source'] = 'opencart';
$request['source_version'] = '2.1.0.2';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.fraudlabspro.com/v1/order/screen?' . http_build_query($request));
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
$response = curl_exec($curl);
curl_close($curl);
$risk_score = 0;
if (is_null($json = json_decode($response)) === FALSE) {
$this->db->query("REPLACE INTO `" . DB_PREFIX . "fraudlabspro` SET order_id = '" . (int)$data['order_id'] . "',
is_country_match = '" . $this->db->escape($json->is_country_match) . "',
is_high_risk_country = '" . $this->db->escape($json->is_high_risk_country) . "',
distance_in_km = '" . $this->db->escape($json->distance_in_km) . "',
distance_in_mile = '" . $this->db->escape($json->distance_in_mile) . "',
ip_country = '" . $this->db->escape($json->ip_country) . "',
ip_region = '" . $this->db->escape($json->ip_region) . "',
ip_city = '" . $this->db->escape($json->ip_city) . "',
ip_continent = '" . $this->db->escape($json->ip_continent) . "',
ip_latitude = '" . $this->db->escape($json->ip_latitude) . "',
ip_longitude = '" . $this->db->escape($json->ip_longitude) . "',
ip_timezone = '" . $this->db->escape($json->ip_timezone) . "',
ip_elevation = '" . $this->db->escape($json->ip_elevation) . "',
ip_domain = '" . $this->db->escape($json->ip_domain) . "',
ip_mobile_mnc = '" . $this->db->escape($json->ip_mobile_mnc) . "',
ip_mobile_mcc = '" . $this->db->escape($json->ip_mobile_mcc) . "',
ip_mobile_brand = '" . $this->db->escape($json->ip_mobile_brand) . "',
ip_netspeed = '" . $this->db->escape($json->ip_netspeed) . "',
ip_isp_name = '" . $this->db->escape($json->ip_isp_name) . "',
ip_usage_type = '" . $this->db->escape($json->ip_usage_type) . "',
is_free_email = '" . $this->db->escape($json->is_free_email) . "',
is_new_domain_name = '" . $this->db->escape($json->is_new_domain_name) . "',
is_proxy_ip_address = '" . $this->db->escape($json->is_proxy_ip_address) . "',
is_bin_found = '" . $this->db->escape($json->is_bin_found) . "',
is_bin_country_match = '" . $this->db->escape($json->is_bin_country_match) . "',
is_bin_name_match = '" . $this->db->escape($json->is_bin_name_match) . "',
is_bin_phone_match = '" . $this->db->escape($json->is_bin_phone_match) . "',
is_bin_prepaid = '" . $this->db->escape($json->is_bin_prepaid) . "',
is_address_ship_forward = '" . $this->db->escape($json->is_address_ship_forward) . "',
is_bill_ship_city_match = '" . $this->db->escape($json->is_bill_ship_city_match) . "',
is_bill_ship_state_match = '" . $this->db->escape($json->is_bill_ship_state_match) . "',
is_bill_ship_country_match = '" . $this->db->escape($json->is_bill_ship_country_match) . "',
is_bill_ship_postal_match = '" . $this->db->escape($json->is_bill_ship_postal_match) . "',
is_ip_blacklist = '" . $this->db->escape($json->is_ip_blacklist) . "',
is_email_blacklist = '" . $this->db->escape($json->is_email_blacklist) . "',
is_credit_card_blacklist = '" . $this->db->escape($json->is_credit_card_blacklist) . "',
is_device_blacklist = '" . $this->db->escape($json->is_device_blacklist) . "',
is_user_blacklist = '" . $this->db->escape($json->is_user_blacklist) . "',
fraudlabspro_score = '" . $this->db->escape($json->fraudlabspro_score) . "',
fraudlabspro_distribution = '" . $this->db->escape($json->fraudlabspro_distribution) . "',
fraudlabspro_status = '" . $this->db->escape($json->fraudlabspro_status) . "',
fraudlabspro_id = '" . $this->db->escape($json->fraudlabspro_id) . "',
fraudlabspro_error = '" . $this->db->escape($json->fraudlabspro_error_code) . "',
fraudlabspro_message = '" . $this->db->escape($json->fraudlabspro_message) . "',
fraudlabspro_credits = '" . $this->db->escape($json->fraudlabspro_credits) . "',
api_key = '" . $this->config->get('fraud_fraudlabspro_key') . "',
ip_address = '" . $ip . "'"
);
$risk_score = (int)$json->fraudlabspro_score;
}
// Do not perform any action if error found
if ($json->fraudlabspro_error_code) {
return;
}
if ($risk_score > $this->config->get('fraud_fraudlabspro_score')) {
return $this->config->get('fraud_fraudlabspro_order_status_id');
}
if ($json->fraudlabspro_status == 'REVIEW') {
return $this->config->get('fraud_fraudlabspro_review_status_id');
}
if ($json->fraudlabspro_status == 'APPROVE') {
return $this->config->get('fraud_fraudlabspro_approve_status_id');
}
if ($json->fraudlabspro_status == 'REJECT') {
return $this->config->get('fraud_fraudlabspro_reject_status_id');
}
}
private function hashIt($s) {
$hash = 'fraudlabspro_' . $s;
for ($i = 0; $i < 65536; $i++)
$hash = sha1('fraudlabspro_' . $hash);
return $hash;
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
class ModelExtensionFraudIp extends Model {
public function check($order_info) {
$this->load->model('account/customer');
$status = false;
if ($order_info['customer_id']) {
$results = $this->model_account_customer->getIps($order_info['customer_id']);
foreach ($results as $result) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraud_ip` WHERE ip = '" . $this->db->escape($result['ip']) . "'");
if ($query->num_rows) {
$status = true;
break;
}
}
} else {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraud_ip` WHERE ip = '" . $this->db->escape($order_info['ip']) . "'");
if ($query->num_rows) {
$status = true;
}
}
if ($status) {
return $this->config->get('fraud_ip_order_status_id');
}
}
}
@@ -0,0 +1,380 @@
<?php
class ModelExtensionFraudMaxMind extends Model {
public function check($order_info) {
$risk_score = 0;
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "maxmind` WHERE order_id = '" . (int)$order_info['order_id'] . "'");
if ($query->num_rows) {
$risk_score = $query->row['risk_score'];
} else {
/*
maxmind api
http://www.maxmind.com/app/ccv
paypal api
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables
*/
$request = 'i=' . urlencode($order_info['ip']);
$request .= '&city=' . urlencode($order_info['payment_city']);
$request .= '&region=' . urlencode($order_info['payment_zone']);
$request .= '&postal=' . urlencode($order_info['payment_postcode']);
$request .= '&country=' . urlencode($order_info['payment_country']);
$request .= '&domain=' . urlencode(utf8_substr(strrchr($order_info['email'], '@'), 1));
$request .= '&custPhone=' . urlencode($order_info['telephone']);
$request .= '&license_key=' . urlencode($this->config->get('fraud_maxmind_key'));
if ($order_info['shipping_method']) {
$request .= '&shipAddr=' . urlencode($order_info['shipping_address_1']);
$request .= '&shipCity=' . urlencode($order_info['shipping_city']);
$request .= '&shipRegion=' . urlencode($order_info['shipping_zone']);
$request .= '&shipPostal=' . urlencode($order_info['shipping_postcode']);
$request .= '&shipCountry=' . urlencode($order_info['shipping_country']);
}
$request .= '&user_agent=' . urlencode($order_info['user_agent']);
$request .= '&forwardedIP=' . urlencode($order_info['forwarded_ip']);
$request .= '&emailMD5=' . urlencode(md5(utf8_strtolower($order_info['email'])));
//$request .= '&passwordMD5=' . urlencode($order_info['password']);
$request .= '&accept_language=' . urlencode($order_info['accept_language']);
$request .= '&order_amount=' . urlencode($this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false));
$request .= '&order_currency=' . urlencode($order_info['currency_code']);
$curl = curl_init('https://minfraud1.maxmind.com/app/ccv2r');
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($curl);
curl_close($curl);
$risk_score = 0;
if ($response) {
$order_id = $order_info['order_id'];
$customer_id = $order_info['customer_id'];
$response_info = array();
$parts = explode(';', $response);
foreach ($parts as $part) {
list($key, $value) = explode('=', $part);
$response_info[$key] = $value;
}
if (isset($response_info['countryMatch'])) {
$country_match = $response_info['countryMatch'];
} else {
$country_match = '';
}
if (isset($response_info['countryCode'])) {
$country_code = $response_info['countryCode'];
} else {
$country_code = '';
}
if (isset($response_info['highRiskCountry'])) {
$high_risk_country = $response_info['highRiskCountry'];
} else {
$high_risk_country = '';
}
if (isset($response_info['distance'])) {
$distance = $response_info['distance'];
} else {
$distance = '';
}
if (isset($response_info['ip_region'])) {
$ip_region = $response_info['ip_region'];
} else {
$ip_region = '';
}
if (isset($response_info['ip_city'])) {
$ip_city = $response_info['ip_city'];
} else {
$ip_city = '';
}
if (isset($response_info['ip_latitude'])) {
$ip_latitude = $response_info['ip_latitude'];
} else {
$ip_latitude = '';
}
if (isset($response_info['ip_longitude'])) {
$ip_longitude = $response_info['ip_longitude'];
} else {
$ip_longitude = '';
}
if (isset($response_info['ip_isp'])) {
$ip_isp = $response_info['ip_isp'];
} else {
$ip_isp = '';
}
if (isset($response_info['ip_org'])) {
$ip_org = $response_info['ip_org'];
} else {
$ip_org = '';
}
if (isset($response_info['ip_asnum'])) {
$ip_asnum = $response_info['ip_asnum'];
} else {
$ip_asnum = '';
}
if (isset($response_info['ip_userType'])) {
$ip_user_type = $response_info['ip_userType'];
} else {
$ip_user_type = '';
}
if (isset($response_info['ip_countryConf'])) {
$ip_country_confidence = $response_info['ip_countryConf'];
} else {
$ip_country_confidence = '';
}
if (isset($response_info['ip_regionConf'])) {
$ip_region_confidence = $response_info['ip_regionConf'];
} else {
$ip_region_confidence = '';
}
if (isset($response_info['ip_cityConf'])) {
$ip_city_confidence = $response_info['ip_cityConf'];
} else {
$ip_city_confidence = '';
}
if (isset($response_info['ip_postalConf'])) {
$ip_postal_confidence = $response_info['ip_postalConf'];
} else {
$ip_postal_confidence = '';
}
if (isset($response_info['ip_postalCode'])) {
$ip_postal_code = $response_info['ip_postalCode'];
} else {
$ip_postal_code = '';
}
if (isset($response_info['ip_accuracyRadius'])) {
$ip_accuracy_radius = $response_info['ip_accuracyRadius'];
} else {
$ip_accuracy_radius = '';
}
if (isset($response_info['ip_netSpeedCell'])) {
$ip_net_speed_cell = $response_info['ip_netSpeedCell'];
} else {
$ip_net_speed_cell = '';
}
if (isset($response_info['ip_metroCode'])) {
$ip_metro_code = $response_info['ip_metroCode'];
} else {
$ip_metro_code = '';
}
if (isset($response_info['ip_areaCode'])) {
$ip_area_code = $response_info['ip_areaCode'];
} else {
$ip_area_code = '';
}
if (isset($response_info['ip_timeZone'])) {
$ip_time_zone = $response_info['ip_timeZone'];
} else {
$ip_time_zone = '';
}
if (isset($response_info['ip_regionName'])) {
$ip_region_name = $response_info['ip_regionName'];
} else {
$ip_region_name = '';
}
if (isset($response_info['ip_domain'])) {
$ip_domain = $response_info['ip_domain'];
} else {
$ip_domain = '';
}
if (isset($response_info['ip_countryName'])) {
$ip_country_name = $response_info['ip_countryName'];
} else {
$ip_country_name = '';
}
if (isset($response_info['ip_continentCode'])) {
$ip_continent_code = $response_info['ip_continentCode'];
} else {
$ip_continent_code = '';
}
if (isset($response_info['ip_corporateProxy'])) {
$ip_corporate_proxy = $response_info['ip_corporateProxy'];
} else {
$ip_corporate_proxy = '';
}
if (isset($response_info['anonymousProxy'])) {
$anonymous_proxy = $response_info['anonymousProxy'];
} else {
$anonymous_proxy = '';
}
if (isset($response_info['proxyScore'])) {
$proxy_score = $response_info['proxyScore'];
} else {
$proxy_score = '';
}
if (isset($response_info['isTransProxy'])) {
$is_trans_proxy = $response_info['isTransProxy'];
} else {
$is_trans_proxy = '';
}
if (isset($response_info['freeMail'])) {
$free_mail = $response_info['freeMail'];
} else {
$free_mail = '';
}
if (isset($response_info['carderEmail'])) {
$carder_email = $response_info['carderEmail'];
} else {
$carder_email = '';
}
if (isset($response_info['highRiskUsername'])) {
$high_risk_username = $response_info['highRiskUsername'];
} else {
$high_risk_username = '';
}
if (isset($response_info['highRiskPassword'])) {
$high_risk_password = $response_info['highRiskPassword'];
} else {
$high_risk_password = '';
}
if (isset($response_info['binMatch'])) {
$bin_match = $response_info['binMatch'];
} else {
$bin_match = '';
}
if (isset($response_info['binCountry'])) {
$bin_country = $response_info['binCountry'];
} else {
$bin_country = '';
}
if (isset($response_info['binNameMatch'])) {
$bin_name_match = $response_info['binNameMatch'];
} else {
$bin_name_match = '';
}
if (isset($response_info['binName'])) {
$bin_name = $response_info['binName'];
} else {
$bin_name = '';
}
if (isset($response_info['binPhoneMatch'])) {
$bin_phone_match = $response_info['binPhoneMatch'];
} else {
$bin_phone_match = '';
}
if (isset($response_info['binPhone'])) {
$bin_phone = $response_info['binPhone'];
} else {
$bin_phone = '';
}
if (isset($response_info['custPhoneInBillingLoc'])) {
$customer_phone_in_billing_location = $response_info['custPhoneInBillingLoc'];
} else {
$customer_phone_in_billing_location = '';
}
if (isset($response_info['shipForward'])) {
$ship_forward = $response_info['shipForward'];
} else {
$ship_forward = '';
}
if (isset($response_info['cityPostalMatch'])) {
$city_postal_match = $response_info['cityPostalMatch'];
} else {
$city_postal_match = '';
}
if (isset($response_info['shipCityPostalMatch'])) {
$ship_city_postal_match = $response_info['shipCityPostalMatch'];
} else {
$ship_city_postal_match = '';
}
if (isset($response_info['score'])) {
$score = $response_info['score'];
} else {
$score = '';
}
if (isset($response_info['explanation'])) {
$explanation = $response_info['explanation'];
} else {
$explanation = '';
}
if (isset($response_info['riskScore'])) {
$risk_score = $response_info['riskScore'];
} else {
$risk_score = '';
}
if (isset($response_info['queriesRemaining'])) {
$queries_remaining = $response_info['queriesRemaining'];
} else {
$queries_remaining = '';
}
if (isset($response_info['maxmindID'])) {
$maxmind_id = $response_info['maxmindID'];
} else {
$maxmind_id = '';
}
if (isset($response_info['err'])) {
$error = $response_info['err'];
} else {
$error = '';
}
$this->db->query("INSERT INTO `" . DB_PREFIX . "maxmind` SET order_id = '" . (int)$order_id . "', customer_id = '" . (int)$customer_id . "', country_match = '" . $this->db->escape($country_match) . "', country_code = '" . $this->db->escape($country_code) . "', high_risk_country = '" . $this->db->escape($high_risk_country) . "', distance = '" . (int)$distance . "', ip_region = '" . $this->db->escape($ip_region) . "', ip_city = '" . $this->db->escape($ip_city) . "', ip_latitude = '" . $this->db->escape($ip_latitude) . "', ip_longitude = '" . $this->db->escape($ip_longitude) . "', ip_isp = '" . $this->db->escape($ip_isp) . "', ip_org = '" . $this->db->escape($ip_org) . "', ip_asnum = '" . (int)$ip_asnum . "', ip_user_type = '" . $this->db->escape($ip_user_type) . "', ip_country_confidence = '" . $this->db->escape($ip_country_confidence) . "', ip_region_confidence = '" . $this->db->escape($ip_region_confidence) . "', ip_city_confidence = '" . $this->db->escape($ip_city_confidence) . "', ip_postal_confidence = '" . $this->db->escape($ip_postal_confidence) . "', ip_postal_code = '" . $this->db->escape($ip_postal_code) . "', ip_accuracy_radius = '" . (int)$ip_accuracy_radius . "', ip_net_speed_cell = '" . $this->db->escape($ip_net_speed_cell) . "', ip_metro_code = '" . (int)$ip_metro_code . "', ip_area_code = '" . (int)$ip_area_code . "', ip_time_zone = '" . $this->db->escape($ip_time_zone) . "', ip_region_name = '" . $this->db->escape($ip_region_name) . "', ip_domain = '" . $this->db->escape($ip_domain) . "', ip_country_name = '" . $this->db->escape($ip_country_name) . "', ip_continent_code = '" . $this->db->escape($ip_continent_code) . "', ip_corporate_proxy = '" . $this->db->escape($ip_corporate_proxy) . "', anonymous_proxy = '" . $this->db->escape($anonymous_proxy) . "', proxy_score = '" . (float)$proxy_score . "', is_trans_proxy = '" . $this->db->escape($is_trans_proxy) . "', free_mail = '" . $this->db->escape($free_mail) . "', carder_email = '" . $this->db->escape($carder_email) . "', high_risk_username = '" . $this->db->escape($high_risk_username) . "', high_risk_password = '" . $this->db->escape($high_risk_password) . "', bin_match = '" . $this->db->escape($bin_match) . "', bin_country = '" . $this->db->escape($bin_country) . "', bin_name_match = '" . $this->db->escape($bin_name_match) . "', bin_name = '" . $this->db->escape($bin_name) . "', bin_phone_match = '" . $this->db->escape($bin_phone_match) . "', bin_phone = '" . $this->db->escape($bin_phone) . "', customer_phone_in_billing_location = '" . $this->db->escape($customer_phone_in_billing_location) . "', ship_forward = '" . $this->db->escape($ship_forward) . "', city_postal_match = '" . $this->db->escape($city_postal_match) . "', ship_city_postal_match = '" . $this->db->escape($ship_city_postal_match) . "', score = '" . (float)$score . "', explanation = '" . $this->db->escape($explanation) . "', risk_score = '" . (float)$risk_score . "', queries_remaining = '" . (int)$queries_remaining . "', maxmind_id = '" . $this->db->escape($maxmind_id) . "', error = '" . $this->db->escape($error) . "', date_added = NOW()");
}
}
if ($risk_score > $this->config->get('fraud_maxmind_score') && $this->config->get('fraud_maxmind_key')) {
return $this->config->get('maxmind_order_status_id');
}
}
}
@@ -0,0 +1,11 @@
<?php
class ModelExtensionModuleCallback extends Model {
public function addCallback($data) {
$query = $this->db->query("INSERT INTO " . DB_PREFIX . "callback SET name = '" . $this->db->escape($data['name']) . "', telephone = '" . $this->db->escape($data['phone']) . "', date_added = NOW(), date_modified = NOW(), status_id = '0', comment = '" . $this->db->escape($data['comment']) . "'");
return $this->db->getLastId();
}
}
?>
@@ -0,0 +1,83 @@
<?php
class ModelExtensionModuleLbcomment extends Model {
public function addComment($blog_id, $data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_comment SET author = '" . $this->db->escape($data['name']) . "', customer_id = '" . (int)$this->customer->getId() . "', blog_id = '" . (int)$blog_id . "', text = '" . $this->db->escape($data['text']) . "', rating = 0, date_added = NOW()");
$comment_id = $this->db->getLastId();
if (in_array('comment', (array)$this->config->get('config_mail_alert'))) {
$this->load->language('mail/review');
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($blog_id);
$subject = sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$message = $this->language->get('text_waiting') . "\n";
$message .= sprintf($this->language->get('text_product'), html_entity_decode($product_info['name'], ENT_QUOTES, 'UTF-8')) . "\n";
$message .= sprintf($this->language->get('text_reviewer'), html_entity_decode($data['name'], ENT_QUOTES, 'UTF-8')) . "\n";
$message .= sprintf($this->language->get('text_rating'), $data['rating']) . "\n";
$message .= $this->language->get('text_review') . "\n";
$message .= html_entity_decode($data['text'], ENT_QUOTES, 'UTF-8') . "\n\n";
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$mail->setSubject($subject);
$mail->setText($message);
$mail->send();
// Send to additional alert emails
$emails = explode(',', $this->config->get('config_alert_email'));
foreach ($emails as $email) {
if ($email && preg_match($this->config->get('config_mail_regexp'), $email)) {
$mail->setTo($email);
$mail->send();
}
}
}
}
public function getCommentsByBlogId($blog_id, $start = 0, $limit = 20) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 20;
}
$sql = "SELECT r.comment_id, r.author, r.rating, r.text, p.blog_id, pd.title, r.date_added FROM " . DB_PREFIX . "lightshop_blog_comment r LEFT JOIN " . DB_PREFIX . "lightshop_blog p ON (r.blog_id = p.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_description pd ON (p.blog_id = pd.blog_id) WHERE p.blog_id = '" . (int)$blog_id . "'";
if (!$this->config->get('theme_lightshop_blog_rev_moder')) {
$sql .= " AND r.status = '1' ";
}
$sql .= " AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY r.date_added DESC LIMIT " . (int)$start . "," . (int)$limit . "";
//var_dump($sql);
$query = $this->db->query($sql);
return $query->rows;
}
public function getTotalCommentsByBlogId($blog_id) {
if ($this->config->get('theme_lightshop_blog_rev_moder')) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog_comment r LEFT JOIN " . DB_PREFIX . "lightshop_blog p ON (r.blog_id = p.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_description pd ON (p.blog_id = pd.blog_id) WHERE p.blog_id = '" . (int)$blog_id . "' AND p.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
}else{
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog_comment r LEFT JOIN " . DB_PREFIX . "lightshop_blog p ON (r.blog_id = p.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_description pd ON (p.blog_id = pd.blog_id) WHERE p.blog_id = '" . (int)$blog_id . "' AND p.status = '1' AND r.status = '1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
}
return $query->row['total'];
}
}
@@ -0,0 +1,430 @@
<?php //004fb
if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');if(function_exists('dl')){@dl($__ln);}if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}if(function_exists('dl')){@dl($__ln);}}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo("Site error: the ".(php_sapi_name()=='cli'?'ionCube':'<a href="http://www.ioncube.com">ionCube</a>')." PHP Loader needs to be installed. This is a widely used PHP extension for running ionCube protected PHP code, website security and malware blocking.\n\nPlease visit ".(php_sapi_name()=='cli'?'get-loader.ioncube.com':'<a href="http://get-loader.ioncube.com">get-loader.ioncube.com</a>')." for install assistance.\n\n");exit(199);
?>
HR+cP+0L28muXF6ZnGgTh/QqaLSxZ4QSaeF+MAkuDEoAXGoYYYw+hBDBc+0Vifyhf/4r1x2SMv2T
sIMsm8Rj92ZujHtuToiClpjjbXNTweW5ZY5CrJkNCAzrYOBUuuv9jXSjQ4GdPcvNp2J2CKxPeHY2
19fbtrD1lorCgXeV3j2CabHlfG3sM9t7bSr8az08R0iH+HvfunuXMeR0nuXMi5FH/sjLoqfrSvEb
i+BJ7MftRRm97bKrTVzFftMJWARdV4vp0+Jt4eXGI5PEJENOLXXCwldsIp9dfEG/NaQ7GBxSu/3a
Dl41//X/0TV55MH7QFATtic+Cz7RdfPRV/9zY5W17tEckt0x+Dg1nZ4UkxUFp6pcC4JuY9+SsRRf
a6NP2AzYeZxJ0x7Ky7Zi7dQsXHA6qsZxe2zAimyiTfT9dpWoYWWA08MWY3dhYknagQKnbIBdtyDG
rzHsN19LjsXLiRZJpdjl8uIeF/SVo3gSloUZAljeNb8isiR8AlGHgNXK6nEyI7tM4Aowy4WiPTlz
HJe7HjVJbZ1l9knu2U9dkFDmCO0tH1291WljGcDJsSv4YCggGw3mlvopG9VQXYg4gr38RL/ZMGQs
IJ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huhfq
Dm==
@@ -0,0 +1,204 @@
<?php
class ModelExtensionModuleLightshopblog extends Model {
public function updateViewed($blog_id) {
$this->db->query("UPDATE " . DB_PREFIX . "lightshop_blog SET viewed = (viewed + 1) WHERE blog_id = '" . (int)$blog_id . "'");
}
public function getBlog($blog_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "lightshop_blog i LEFT JOIN " . DB_PREFIX . "lightshop_blog_description id ON (i.blog_id = id.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_store i2s ON (i.blog_id = i2s.blog_id) WHERE i.blog_id = '" . (int)$blog_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");
return $query->row;
}
public function getBlogs($data) {
$sql = "SELECT * ";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " FROM " . DB_PREFIX . "lightshopcat_blog_path cp LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_category p2c ON (cp.category_id = p2c.category_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "lightshop_blog_to_category p2c";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "lightshop_blog i ON (p2c.blog_id = i.blog_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "lightshop_blog i";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "lightshop_blog_description id ON (i.blog_id = id.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_tag bt ON (i.blog_id = bt.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_store i2s ON (i.blog_id = i2s.blog_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' ";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'";
} else {
$sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'";
}
}
if (!empty($data['filtertag'])) {
$sql .= " AND bt.tag = '" . $this->db->escape($data['filtertag']) . "'";
}
if (!empty($data['filter_name'])) {
$sql .= " AND id.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}
$sql .= " GROUP BY i.blog_id ORDER BY i.date_added DESC LIMIT ".(int)$data['start'].",".(int)$data['limit']."";
$query = $this->db->query($sql);
return $query->rows;
}
public function getBlogsTotal() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog WHERE status = '1'");
return $query->row['total'];
}
public function getBlogLayoutId($blog_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_to_layout WHERE blog_id = '" . (int)$blog_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return $query->row['layout_id'];
} else {
return 0;
}
}
public function isModuleSet() {
$isSet = false;
$query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "lightshop_blog'");
if($query->num_rows){
$isSet = true;
}
return $isSet;
}
public function getBlogRelated($blog_id) {
$product_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_related pr LEFT JOIN " . DB_PREFIX . "lightshop_blog p ON (pr.blog_id = p.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_store p2s ON (p.blog_id = p2s.blog_id) WHERE pr.blog_id = '" . (int)$blog_id . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
$querys = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "lightshop_key'");
if($querys->num_rows){$queryss = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_key WHERE 1");}
foreach ($query->rows as $result) {
$product_data[$result['related_id']] = $result['related_id'];
}
if(!isset($queryss->row['value']) || !$queryss->row['value']){$product_data = array();}
return $product_data;
}
public function getBlogRelatedProd($blog_id) {
$product_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_related_prod pr LEFT JOIN " . DB_PREFIX . "lightshop_blog p ON (pr.blog_id = p.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_store p2s ON (p.blog_id = p2s.blog_id) WHERE pr.blog_id = '" . (int)$blog_id . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
$querys = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "lightshop_key'");
if($querys->num_rows){$queryss = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_key WHERE 1");}
foreach ($query->rows as $result) {
$product_data[$result['related_id']] = $result['related_id'];
}
if(!isset($queryss->row['value']) || !$queryss->row['value']){$product_data = array();}
return $product_data;
}
public function getTotalBlogs($data = array()) {
$sql = "SELECT COUNT(DISTINCT p.blog_id) AS total";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " FROM " . DB_PREFIX . "lightshopcat_blog_path cp LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_category p2c ON (cp.category_id = p2c.category_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "lightshop_blog_to_category p2c";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "lightshop_blog p ON (p2c.blog_id = p.blog_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "lightshop_blog p";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "lightshop_blog_description pd ON (p.blog_id = pd.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_tag bt ON (p.blog_id = bt.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_store p2s ON (p.blog_id = p2s.blog_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'";
} else {
$sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'";
}
}
if (!empty($data['filtertag'])) {
$sql .= " AND bt.tag = '" . $this->db->escape($data['filtertag']) . "'";
}
$query = $this->db->query($sql);
$total = 0;
if(isset($query->row['total'])){
$total = $query->row['total'];
}
return $total;
}
public function getBlogsTag($data) {
$sql = "SELECT *,COUNT(i.blog_id) as total ";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " FROM " . DB_PREFIX . "lightshopcat_blog_path cp LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_category p2c ON (cp.category_id = p2c.category_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "lightshop_blog_to_category p2c";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "lightshop_blog i ON (p2c.blog_id = i.blog_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "lightshop_blog i";
}
$sql .= " LEFT JOIN " . DB_PREFIX . "lightshop_blog_tag bt ON (i.blog_id = bt.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_store i2s ON (i.blog_id = i2s.blog_id) WHERE bt.language_id = '" . (int)$this->config->get('config_language_id') . "' AND bt.tag IS NOT NULL AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' ";
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'";
} else {
$sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'";
}
}
$sql .= " GROUP BY bt.tag ORDER BY total DESC LIMIT ".(int)$data['start'].",".(int)$data['limit']."";
$query = $this->db->query($sql);
return $query->rows;
}
public function getBlogTag($blog_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_tag WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' AND blog_id = '" . (int)$blog_id . "'");
return $query->rows;
}
public function getBlogCat($blog_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_to_category b2c LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cbd ON (b2c.category_id = cbd.category_id ) WHERE cbd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND b2c.blog_id= '" . (int)$blog_id . "'");
return $query->row;
}
public function getTotalReviewsByBlogId($blog_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog_comment c LEFT JOIN " . DB_PREFIX . "lightshop_blog b ON (c.blog_id = b.blog_id) WHERE b.blog_id = '" . (int)$blog_id . "' AND c.status = '1'");
return $query->row['total'];
}
}
@@ -0,0 +1,128 @@
<?php
class ModelExtensionModuleLightshopcatblog extends Model {
public function getBlogCategory($blogcategory_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "lightshopcat_blog c LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.category_id = '" . (int)$blogcategory_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'");
return $query->row;
}
public function getBlogCategories($parent_id = 0) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog c LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1' ORDER BY c.sort_order, LCASE(cd.name)");
return $query->rows;
}
public function getBlogCategoryFilters($blogcategory_id) {
$implode = array();
$query = $this->db->query("SELECT filter_id FROM " . DB_PREFIX . "lightshopcat_blog_filter WHERE category_id = '" . (int)$blogcategory_id . "'");
foreach ($query->rows as $result) {
$implode[] = (int)$result['filter_id'];
}
$filter_group_data = array();
if ($implode) {
$filter_group_query = $this->db->query("SELECT DISTINCT f.filter_group_id, fgd.name, fg.sort_order FROM " . DB_PREFIX . "filter f LEFT JOIN " . DB_PREFIX . "filter_group fg ON (f.filter_group_id = fg.filter_group_id) LEFT JOIN " . DB_PREFIX . "filter_group_description fgd ON (fg.filter_group_id = fgd.filter_group_id) WHERE f.filter_id IN (" . implode(',', $implode) . ") AND fgd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY f.filter_group_id ORDER BY fg.sort_order, LCASE(fgd.name)");
foreach ($filter_group_query->rows as $filter_group) {
$filter_data = array();
$filter_query = $this->db->query("SELECT DISTINCT f.filter_id, fd.name FROM " . DB_PREFIX . "filter f LEFT JOIN " . DB_PREFIX . "filter_description fd ON (f.filter_id = fd.filter_id) WHERE f.filter_id IN (" . implode(',', $implode) . ") AND f.filter_group_id = '" . (int)$filter_group['filter_group_id'] . "' AND fd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY f.sort_order, LCASE(fd.name)");
foreach ($filter_query->rows as $filter) {
$filter_data[] = array(
'filter_id' => $filter['filter_id'],
'name' => $filter['name']
);
}
if ($filter_data) {
$filter_group_data[] = array(
'filter_group_id' => $filter_group['filter_group_id'],
'name' => $filter_group['name'],
'filter' => $filter_data
);
}
}
}
return $filter_group_data;
}
public function getBlogCategoryLayoutId($blogcategory_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog_to_layout WHERE category_id = '" . (int)$blogcategory_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return $query->row['layout_id'];
} else {
return 0;
}
}
public function getBlogsTotalByCategoryId($category_id = 0) {
if ($category_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog b LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_store b2s ON (b.blog_id = b2s.blog_id) LEFT JOIN " . DB_PREFIX . "lightshop_blog_to_category b2c ON (b.blog_id = b2c.blog_id) WHERE b2c.category_id = '" . (int)$category_id . "' AND b2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND b.status = '1'");
}else{
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog WHERE status = '1'");
}
return $query->row['total'];
}
public function getBlogTotalCategoriesByCategoryId($parent_id = 0) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshopcat_blog c LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'");
return $query->row['total'];
}
public function getPathByBlog($blog_id) {
$blog_id = (int)$blog_id;
if ($blog_id < 1) return false;
static $path = null;
$query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "lightshop_blog_to_category WHERE blog_id = '" . $blog_id . "' ORDER BY main_category DESC LIMIT 1");
$path[$blog_id] = $this->getPathByCategory($query->num_rows ? (int)$query->row['category_id'] : 0);
return $path[$blog_id];
}
private function getPathByCategory($category_id) {
$category_id = (int)$category_id;
if ($category_id < 1) return false;
static $path = null;
$max_level = 10;
$sql = "SELECT CONCAT_WS('_'";
for ($i = $max_level-1; $i >= 0; --$i) {
$sql .= ",t$i.category_id";
}
$sql .= ") AS path FROM " . DB_PREFIX . "lightshopcat_blog t0";
for ($i = 1; $i < $max_level; ++$i) {
$sql .= " LEFT JOIN " . DB_PREFIX . "lightshopcat_blog t$i ON (t$i.category_id = t" . ($i-1) . ".parent_id)";
}
$sql .= " WHERE t0.category_id = '" . $category_id . "'";
$query = $this->db->query($sql);
$path[$category_id] = $query->num_rows ? $query->row['path'] : false;
return $path[$category_id];
}
public function isModuleSet() {
$isSet = false;
$query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "lightshopcat_blog'");
if($query->num_rows){
$isSet = true;
}
return $isSet;
}
}
@@ -0,0 +1,48 @@
<?php
class ModelExtensionModuleLightshopnews extends Model {
public function getNews($news_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "lightshop_news i LEFT JOIN " . DB_PREFIX . "lightshop_news_description id ON (i.news_id = id.news_id) LEFT JOIN " . DB_PREFIX . "lightshop_news_to_store i2s ON (i.news_id = i2s.news_id) WHERE i.news_id = '" . (int)$news_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");
return $query->row;
}
public function getNewss($data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news i LEFT JOIN " . DB_PREFIX . "lightshop_news_description id ON (i.news_id = id.news_id) LEFT JOIN " . DB_PREFIX . "lightshop_news_to_store i2s ON (i.news_id = i2s.news_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' ORDER BY i.date_added DESC LIMIT ".(int)$data['start'].",".(int)$data['limit']."");
return $query->rows;
}
public function getNewssTotal() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_news WHERE status = '1'");
return $query->row['total'];
}
public function getNewsLayoutId($news_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news_to_layout WHERE news_id = '" . (int)$news_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return $query->row['layout_id'];
} else {
return 0;
}
}
public function isModuleSet() {
$isSet = false;
$query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "lightshop_news'");
if($query->num_rows){
$isSet = true;
}
return $isSet;
}
public function getProductRelated($news_id) {
$product_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.news_id = '" . (int)$news_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
foreach ($query->rows as $result) {
$product_data[$result['related_id']] = $result['related_id'];
}
return $product_data;
}
}
@@ -0,0 +1,38 @@
<?php
class ModelExtensionModuleLightshopsubscribe extends Model {
public function addSubscribe($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "subscribe SET email = '" . $this->db->escape($data['email']) . "', status = '" . (int) $data['status'] . "'");
}
public function editSubscribe($data) {
$this->db->query("UPDATE " . DB_PREFIX . "subscribe SET status = '" . (int) $data['status'] . "' WHERE email = '" . $this->db->escape($data['email']) . "'");
}
public function getSubscribers() {
$query = $this->db->query("SELECT email FROM " . DB_PREFIX . "subscribe WHERE status = '0'");
return $query->rows;
}
public function checkEmail($email) {
$query = $this->db->query("SELECT email FROM " . DB_PREFIX . "subscribe WHERE email ='" . $this->db->escape($email) . "'");
return isset($query->row['email']) ? $query->row['email'] : 0;
}
public function getAuthDescription($language_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "subscribe_auth_description WHERE language_id='" .(int)$language_id . "'");
return isset($query->row['subscribe_authorization']) ? $query->row['subscribe_authorization'] : '';
}
public function getEmailDescription($language_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "subscribe_email_description WHERE language_id='" . (int)$language_id . "'");
return isset($query->row['subscribe_descriptions']) ? $query->row['subscribe_descriptions'] : '';
}
}
?>
@@ -0,0 +1,33 @@
<?php
class ModelExtensionPaymentCOD extends Model {
public function getMethod($address, $total) {
$this->load->language('extension/payment/cod');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_cod_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if ($this->config->get('payment_cod_total') > 0 && $this->config->get('payment_cod_total') > $total) {
$status = false;
} elseif (!$this->cart->hasShipping()) {
$status = false;
} elseif (!$this->config->get('payment_cod_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}
$method_data = array();
if ($status) {
$method_data = array(
'code' => 'cod',
'title' => $this->language->get('text_title'),
'terms' => '',
'sort_order' => $this->config->get('payment_cod_sort_order')
);
}
return $method_data;
}
}
@@ -0,0 +1,40 @@
<?php
class ModelExtensionShippingFlat extends Model {
function getQuote($address) {
$this->load->language('extension/shipping/flat');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('shipping_flat_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if (!$this->config->get('shipping_flat_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}
$method_data = array();
if ($status) {
$quote_data = array();
$quote_data['flat'] = array(
'code' => 'flat.flat',
'title' => $this->language->get('text_description'),
'cost' => $this->config->get('shipping_flat_cost'),
'tax_class_id' => $this->config->get('shipping_flat_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($this->config->get('shipping_flat_cost'), $this->config->get('shipping_flat_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency'])
);
$method_data = array(
'code' => 'flat',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('shipping_flat_sort_order'),
'error' => false
);
}
return $method_data;
}
}
@@ -0,0 +1,242 @@
<?php
class ModelExtensionTotalCoupon extends Model {
public function getCoupon($code) {
$status = true;
$coupon_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon` WHERE code = '" . $this->db->escape($code) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND status = '1'");
if ($coupon_query->num_rows) {
if ($coupon_query->row['total'] > $this->cart->getSubTotal()) {
$status = false;
}
$coupon_total = $this->getTotalCouponHistoriesByCoupon($code);
if ($coupon_query->row['uses_total'] > 0 && ($coupon_total >= $coupon_query->row['uses_total'])) {
$status = false;
}
if ($coupon_query->row['logged'] && !$this->customer->getId()) {
$status = false;
}
if ($this->customer->getId()) {
$customer_total = $this->getTotalCouponHistoriesByCustomerId($code, $this->customer->getId());
if ($coupon_query->row['uses_customer'] > 0 && ($customer_total >= $coupon_query->row['uses_customer'])) {
$status = false;
}
}
// Products
$coupon_product_data = array();
$coupon_product_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon_product` WHERE coupon_id = '" . (int)$coupon_query->row['coupon_id'] . "'");
foreach ($coupon_product_query->rows as $product) {
$coupon_product_data[] = $product['product_id'];
}
// Categories
$coupon_category_data = array();
$coupon_category_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon_category` cc LEFT JOIN `" . DB_PREFIX . "category_path` cp ON (cc.category_id = cp.path_id) WHERE cc.coupon_id = '" . (int)$coupon_query->row['coupon_id'] . "'");
foreach ($coupon_category_query->rows as $category) {
$coupon_category_data[] = $category['category_id'];
}
$product_data = array();
if ($coupon_product_data || $coupon_category_data) {
foreach ($this->cart->getProducts() as $product) {
if (in_array($product['product_id'], $coupon_product_data)) {
$product_data[] = $product['product_id'];
continue;
}
foreach ($coupon_category_data as $category_id) {
$coupon_category_query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "product_to_category` WHERE `product_id` = '" . (int)$product['product_id'] . "' AND category_id = '" . (int)$category_id . "'");
if ($coupon_category_query->row['total']) {
$product_data[] = $product['product_id'];
continue;
}
}
}
if (!$product_data) {
$status = false;
}
}
} else {
$status = false;
}
if ($status) {
return array(
'coupon_id' => $coupon_query->row['coupon_id'],
'code' => $coupon_query->row['code'],
'name' => $coupon_query->row['name'],
'type' => $coupon_query->row['type'],
'discount' => $coupon_query->row['discount'],
'shipping' => $coupon_query->row['shipping'],
'total' => $coupon_query->row['total'],
'product' => $product_data,
'date_start' => $coupon_query->row['date_start'],
'date_end' => $coupon_query->row['date_end'],
'uses_total' => $coupon_query->row['uses_total'],
'uses_customer' => $coupon_query->row['uses_customer'],
'status' => $coupon_query->row['status'],
'date_added' => $coupon_query->row['date_added']
);
}
}
public function getTotal($total) {
if (isset($this->session->data['coupon'])) {
$this->load->language('extension/total/coupon', 'coupon');
$coupon_info = $this->getCoupon($this->session->data['coupon']);
if ($coupon_info) {
$discount_total = 0;
if (!$coupon_info['product']) {
$sub_total = $this->cart->getSubTotal();
} else {
$sub_total = 0;
foreach ($this->cart->getProducts() as $product) {
if (in_array($product['product_id'], $coupon_info['product'])) {
$sub_total += $product['total'];
}
}
}
if ($coupon_info['type'] == 'F') {
$coupon_info['discount'] = min($coupon_info['discount'], $sub_total);
}
foreach ($this->cart->getProducts() as $product) {
$discount = 0;
if (!$coupon_info['product']) {
$status = true;
} else {
$status = in_array($product['product_id'], $coupon_info['product']);
}
if ($status) {
if ($coupon_info['type'] == 'F') {
$discount = $coupon_info['discount'] * ($product['total'] / $sub_total);
} elseif ($coupon_info['type'] == 'P') {
$discount = $product['total'] / 100 * $coupon_info['discount'];
}
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$total['taxes'][$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
$discount_total += $discount;
}
if ($coupon_info['shipping'] && isset($this->session->data['shipping_method'])) {
if (!empty($this->session->data['shipping_method']['tax_class_id'])) {
$tax_rates = $this->tax->getRates($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$total['taxes'][$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
$discount_total += $this->session->data['shipping_method']['cost'];
}
// If discount greater than total
if ($discount_total > $total['total']) {
$discount_total = $total['total'];
}
if ($discount_total > 0) {
$total['totals'][] = array(
'code' => 'coupon',
'title' => sprintf($this->language->get('coupon')->get('text_coupon'), $this->session->data['coupon']),
'value' => -$discount_total,
'sort_order' => $this->config->get('total_coupon_sort_order')
);
$total['total'] -= $discount_total;
}
}
}
}
public function confirm($order_info, $order_total) {
$code = '';
$start = strpos($order_total['title'], '(') + 1;
$end = strrpos($order_total['title'], ')');
if ($start && $end) {
$code = substr($order_total['title'], $start, $end - $start);
}
if ($code) {
$status = true;
$coupon_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon` WHERE code = '" . $this->db->escape($code) . "' AND status = '1'");
if ($coupon_query->num_rows) {
$coupon_total = $this->getTotalCouponHistoriesByCoupon($code);
if ($coupon_query->row['uses_total'] > 0 && ($coupon_total >= $coupon_query->row['uses_total'])) {
$status = false;
}
if ($order_info['customer_id']) {
$customer_total = $this->getTotalCouponHistoriesByCustomerId($code, $order_info['customer_id']);
if ($coupon_query->row['uses_customer'] > 0 && ($customer_total >= $coupon_query->row['uses_customer'])) {
$status = false;
}
}
} else {
$status = false;
}
if ($status) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "coupon_history` SET coupon_id = '" . (int)$coupon_query->row['coupon_id'] . "', order_id = '" . (int)$order_info['order_id'] . "', customer_id = '" . (int)$order_info['customer_id'] . "', amount = '" . (float)$order_total['value'] . "', date_added = NOW()");
} else {
return $this->config->get('config_fraud_status_id');
}
}
}
public function unconfirm($order_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "coupon_history` WHERE order_id = '" . (int)$order_id . "'");
}
public function getTotalCouponHistoriesByCoupon($coupon) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "coupon_history` ch LEFT JOIN `" . DB_PREFIX . "coupon` c ON (ch.coupon_id = c.coupon_id) WHERE c.code = '" . $this->db->escape($coupon) . "'");
return $query->row['total'];
}
public function getTotalCouponHistoriesByCustomerId($coupon, $customer_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "coupon_history` ch LEFT JOIN `" . DB_PREFIX . "coupon` c ON (ch.coupon_id = c.coupon_id) WHERE c.code = '" . $this->db->escape($coupon) . "' AND ch.customer_id = '" . (int)$customer_id . "'");
return $query->row['total'];
}
}
@@ -0,0 +1,35 @@
<?php
class ModelExtensionTotalCredit extends Model {
public function getTotal($total) {
$this->load->language('extension/total/credit');
$balance = $this->customer->getBalance();
if ((float)$balance) {
$credit = min($balance, $total['total']);
if ((float)$credit > 0) {
$total['totals'][] = array(
'code' => 'credit',
'title' => $this->language->get('text_credit'),
'value' => -$credit,
'sort_order' => $this->config->get('total_credit_sort_order')
);
$total['total'] -= $credit;
}
}
}
public function confirm($order_info, $order_total) {
$this->load->language('extension/total/credit');
if ($order_info['customer_id']) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_transaction SET customer_id = '" . (int)$order_info['customer_id'] . "', order_id = '" . (int)$order_info['order_id'] . "', description = '" . $this->db->escape(sprintf($this->language->get('text_order_id'), (int)$order_info['order_id'])) . "', amount = '" . (float)$order_total['value'] . "', date_added = NOW()");
}
}
public function unconfirm($order_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'");
}
}
@@ -0,0 +1,29 @@
<?php
class ModelExtensionTotalHandling extends Model {
public function getTotal($total) {
if (($this->cart->getSubTotal() > $this->config->get('total_handling_total')) && ($this->cart->getSubTotal() > 0) && ($this->cart->hasDownload() == false) && $this->cart->hasShipping() == true) {
$this->load->language('extension/total/handling');
$total['totals'][] = array(
'code' => 'handling',
'title' => $this->language->get('text_handling'),
'value' => $this->config->get('total_handling_fee'),
'sort_order' => $this->config->get('total_handling_sort_order')
);
if ($this->config->get('total_handling_tax_class_id')) {
$tax_rates = $this->tax->getRates($this->config->get('total_handling_fee'), $this->config->get('total_handling_tax_class_id'));
foreach ($tax_rates as $tax_rate) {
if (!isset($total['taxes'][$tax_rate['tax_rate_id']])) {
$total['taxes'][$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$total['taxes'][$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total['total'] += $this->config->get('total_handling_fee');
}
}
}
@@ -0,0 +1,52 @@
<?php
class ModelExtensionTotalLightshopsets extends Model {
public function getTotal($total) {
$this->load->language('extension/total/lightshopsets');
$this->load->model('extension/module/lightshop');
$setids = array();
if (isset($this->session->data['lightshopsetid']) && $this->session->data['lightshopsetid']) {
$setids = $this->session->data['lightshopsetid'];
}
$cartProducts = array();
foreach ($this->cart->getProducts() as $product) {
$cartProducts[$product['product_id']]['quantity'] = $product['quantity'];
$cartProducts[$product['product_id']]['price'] = $product['price'];
}
foreach ($setids as $setid) {
$lightshopsets = $this->model_extension_module_lightshop->getSetDiscount($total,$setid,$cartProducts);
if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $voucher) {
$lightshopsets += $voucher['amount'];
}
}
if ($lightshopsets['discount']) {
$setInfo = $this->model_extension_module_lightshop->getSetInfo($setid);
$total['totals'][] = array(
'code' => 'lightshopsets',
'title' => $this->language->get('text_lightshopsets').' - '.$setInfo['title'],
'value' => -$lightshopsets['discount'],
'sort_order' => $this->config->get('total_lightshopsets_sort_order')
);
$total['total'] -= $lightshopsets['discount'];
$cartProducts = $lightshopsets['cartproducts'];
}
}
}
}
@@ -0,0 +1,29 @@
<?php
class ModelExtensionTotalLowOrderFee extends Model {
public function getTotal($total) {
if ($this->cart->getSubTotal() && ($this->cart->getSubTotal() < $this->config->get('total_low_order_fee_total'))) {
$this->load->language('extension/total/low_order_fee');
$total['totals'][] = array(
'code' => 'low_order_fee',
'title' => $this->language->get('text_low_order_fee'),
'value' => $this->config->get('total_low_order_fee_fee'),
'sort_order' => $this->config->get('total_low_order_fee_sort_order')
);
if ($this->config->get('total_low_order_fee_tax_class_id')) {
$tax_rates = $this->tax->getRates($this->config->get('total_low_order_fee_fee'), $this->config->get('total_low_order_fee_tax_class_id'));
foreach ($tax_rates as $tax_rate) {
if (!isset($total['taxes'][$tax_rate['tax_rate_id']])) {
$total['taxes'][$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$total['taxes'][$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total['total'] += $this->config->get('total_low_order_fee_fee');
}
}
}
@@ -0,0 +1,78 @@
<?php
class ModelExtensionTotalReward extends Model {
public function getTotal($total) {
if (isset($this->session->data['reward'])) {
$this->load->language('extension/total/reward', 'reward');
$points = $this->customer->getRewardPoints();
if ($this->session->data['reward'] <= $points) {
$discount_total = 0;
$points_total = 0;
foreach ($this->cart->getProducts() as $product) {
if ($product['points']) {
$points_total += $product['points'];
}
}
$points = min($points, $points_total);
foreach ($this->cart->getProducts() as $product) {
$discount = 0;
if ($product['points']) {
$discount = $product['total'] * ($this->session->data['reward'] / $points_total);
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$total['taxes'][$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
$discount_total += $discount;
}
$total['totals'][] = array(
'code' => 'reward',
'title' => sprintf($this->language->get('reward')->get('text_reward'), $this->session->data['reward']),
'value' => -$discount_total,
'sort_order' => $this->config->get('total_reward_sort_order')
);
$total['total'] -= $discount_total;
}
}
}
public function confirm($order_info, $order_total) {
$this->load->language('extension/total/reward');
$points = 0;
$start = strpos($order_total['title'], '(') + 1;
$end = strrpos($order_total['title'], ')');
if ($start && $end) {
$points = substr($order_total['title'], $start, $end - $start);
}
$this->load->model('account/customer');
if ($this->model_account_customer->getRewardTotal($order_info['customer_id']) >= $points) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$order_info['customer_id'] . "', order_id = '" . (int)$order_info['order_id'] . "', description = '" . $this->db->escape(sprintf($this->language->get('text_order_id'), (int)$order_info['order_id'])) . "', points = '" . (float)-$points . "', date_added = NOW()");
} else {
return $this->config->get('config_fraud_status_id');
}
}
public function unconfirm($order_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_reward WHERE order_id = '" . (int)$order_id . "' AND points < 0");
}
}
@@ -0,0 +1,27 @@
<?php
class ModelExtensionTotalShipping extends Model {
public function getTotal($total) {
if ($this->cart->hasShipping() && isset($this->session->data['shipping_method'])) {
$total['totals'][] = array(
'code' => 'shipping',
'title' => $this->session->data['shipping_method']['title'],
'value' => $this->session->data['shipping_method']['cost'],
'sort_order' => $this->config->get('total_shipping_sort_order')
);
if ($this->session->data['shipping_method']['tax_class_id']) {
$tax_rates = $this->tax->getRates($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if (!isset($total['taxes'][$tax_rate['tax_rate_id']])) {
$total['taxes'][$tax_rate['tax_rate_id']] = $tax_rate['amount'];
} else {
$total['taxes'][$tax_rate['tax_rate_id']] += $tax_rate['amount'];
}
}
}
$total['total'] += $this->session->data['shipping_method']['cost'];
}
}
}
@@ -0,0 +1,23 @@
<?php
class ModelExtensionTotalSubTotal extends Model {
public function getTotal($total) {
$this->load->language('extension/total/sub_total');
$sub_total = $this->cart->getSubTotal();
if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $voucher) {
$sub_total += $voucher['amount'];
}
}
$total['totals'][] = array(
'code' => 'sub_total',
'title' => $this->language->get('text_sub_total'),
'value' => $sub_total,
'sort_order' => $this->config->get('total_sub_total_sort_order')
);
$total['total'] += $sub_total;
}
}
@@ -0,0 +1,17 @@
<?php
class ModelExtensionTotalTax extends Model {
public function getTotal($total) {
foreach ($total['taxes'] as $key => $value) {
if ($value > 0) {
$total['totals'][] = array(
'code' => 'tax',
'title' => $this->tax->getRateName($key),
'value' => $value,
'sort_order' => $this->config->get('total_tax_sort_order')
);
$total['total'] += $value;
}
}
}
}
@@ -0,0 +1,13 @@
<?php
class ModelExtensionTotalTotal extends Model {
public function getTotal($total) {
$this->load->language('extension/total/total');
$total['totals'][] = array(
'code' => 'total',
'title' => $this->language->get('text_total'),
'value' => max(0, $total['total']),
'sort_order' => $this->config->get('total_total_sort_order')
);
}
}
@@ -0,0 +1,124 @@
<?php
class ModelExtensionTotalVoucher extends Model {
public function addVoucher($order_id, $data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "voucher SET order_id = '" . (int)$order_id . "', code = '" . $this->db->escape($data['code']) . "', from_name = '" . $this->db->escape($data['from_name']) . "', from_email = '" . $this->db->escape($data['from_email']) . "', to_name = '" . $this->db->escape($data['to_name']) . "', to_email = '" . $this->db->escape($data['to_email']) . "', voucher_theme_id = '" . (int)$data['voucher_theme_id'] . "', message = '" . $this->db->escape($data['message']) . "', amount = '" . (float)$data['amount'] . "', status = '1', date_added = NOW()");
return $this->db->getLastId();
}
public function disableVoucher($order_id) {
$this->db->query("UPDATE " . DB_PREFIX . "voucher SET status = '0' WHERE order_id = '" . (int)$order_id . "'");
}
public function getVoucher($code) {
$status = true;
$voucher_query = $this->db->query("SELECT *, vtd.name AS theme FROM " . DB_PREFIX . "voucher v LEFT JOIN " . DB_PREFIX . "voucher_theme vt ON (v.voucher_theme_id = vt.voucher_theme_id) LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE v.code = '" . $this->db->escape($code) . "' AND vtd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND v.status = '1'");
if ($voucher_query->num_rows) {
if ($voucher_query->row['order_id']) {
$implode = array();
foreach ($this->config->get('config_complete_status') as $order_status_id) {
$implode[] = "'" . (int)$order_status_id . "'";
}
$order_query = $this->db->query("SELECT order_id FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$voucher_query->row['order_id'] . "' AND order_status_id IN(" . implode(",", $implode) . ")");
if (!$order_query->num_rows) {
$status = false;
}
$order_voucher_query = $this->db->query("SELECT order_voucher_id FROM `" . DB_PREFIX . "order_voucher` WHERE order_id = '" . (int)$voucher_query->row['order_id'] . "' AND voucher_id = '" . (int)$voucher_query->row['voucher_id'] . "'");
if (!$order_voucher_query->num_rows) {
$status = false;
}
}
$voucher_history_query = $this->db->query("SELECT SUM(amount) AS total FROM `" . DB_PREFIX . "voucher_history` vh WHERE vh.voucher_id = '" . (int)$voucher_query->row['voucher_id'] . "' GROUP BY vh.voucher_id");
if ($voucher_history_query->num_rows) {
$amount = $voucher_query->row['amount'] + $voucher_history_query->row['total'];
} else {
$amount = $voucher_query->row['amount'];
}
if ($amount <= 0) {
$status = false;
}
} else {
$status = false;
}
if ($status) {
return array(
'voucher_id' => $voucher_query->row['voucher_id'],
'code' => $voucher_query->row['code'],
'from_name' => $voucher_query->row['from_name'],
'from_email' => $voucher_query->row['from_email'],
'to_name' => $voucher_query->row['to_name'],
'to_email' => $voucher_query->row['to_email'],
'voucher_theme_id' => $voucher_query->row['voucher_theme_id'],
'theme' => $voucher_query->row['theme'],
'message' => $voucher_query->row['message'],
'image' => $voucher_query->row['image'],
'amount' => $amount,
'status' => $voucher_query->row['status'],
'date_added' => $voucher_query->row['date_added']
);
}
}
public function getTotal($total) {
if (isset($this->session->data['voucher'])) {
$this->load->language('extension/total/voucher', 'voucher');
$voucher_info = $this->getVoucher($this->session->data['voucher']);
if ($voucher_info) {
$amount = min($voucher_info['amount'], $total['total']);
if ($amount > 0) {
$total['totals'][] = array(
'code' => 'voucher',
'title' => sprintf($this->language->get('voucher')->get('text_voucher'), $this->session->data['voucher']),
'value' => -$amount,
'sort_order' => $this->config->get('total_voucher_sort_order')
);
$total['total'] -= $amount;
} else {
unset($this->session->data['voucher']);
}
} else {
unset($this->session->data['voucher']);
}
}
}
public function confirm($order_info, $order_total) {
$code = '';
$start = strpos($order_total['title'], '(') + 1;
$end = strrpos($order_total['title'], ')');
if ($start && $end) {
$code = substr($order_total['title'], $start, $end - $start);
}
if ($code) {
$voucher_info = $this->getVoucher($code);
if ($voucher_info) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "voucher_history` SET voucher_id = '" . (int)$voucher_info['voucher_id'] . "', order_id = '" . (int)$order_info['order_id'] . "', amount = '" . (float)$order_total['value'] . "', date_added = NOW()");
} else {
return $this->config->get('config_fraud_status_id');
}
}
}
public function unconfirm($order_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "voucher_history` WHERE order_id = '" . (int)$order_id . "'");
}
}
@@ -0,0 +1,48 @@
<?php
class ModelExtensionTotalVoucherTheme extends Model {
public function getVoucherTheme($voucher_theme_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vt.voucher_theme_id = '" . (int)$voucher_theme_id . "' AND vtd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row;
}
public function getVoucherThemes($data = array()) {
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vtd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.name";
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
} else {
$voucher_theme_data = $this->cache->get('voucher_theme.' . (int)$this->config->get('config_language_id'));
if (!$voucher_theme_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vtd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.name");
$voucher_theme_data = $query->rows;
$this->cache->set('voucher_theme.' . (int)$this->config->get('config_language_id'), $voucher_theme_data);
}
return $voucher_theme_data;
}
}
}
@@ -0,0 +1,22 @@
<?php
class ModelLocalisationCountry extends Model {
public function getCountry($country_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$country_id . "' AND status = '1'");
return $query->row;
}
public function getCountries() {
$country_data = $this->cache->get('country.catalog');
if (!$country_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE status = '1' ORDER BY name ASC");
$country_data = $query->rows;
$this->cache->set('country.catalog', $country_data);
}
return $country_data;
}
}
@@ -0,0 +1,36 @@
<?php
class ModelLocalisationCurrency extends Model {
public function getCurrencyByCode($currency) {
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "currency` WHERE `code` = '" . $this->db->escape($currency) . "'");
return $query->row;
}
public function getCurrencies() {
$currency_data = $this->cache->get('currency');
if (!$currency_data) {
$currency_data = array();
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "currency` WHERE `status` = '1' ORDER BY `title` ASC");
foreach ($query->rows as $result) {
$currency_data[$result['code']] = array(
'currency_id' => $result['currency_id'],
'title' => $result['title'],
'code' => $result['code'],
'symbol_left' => $result['symbol_left'],
'symbol_right' => $result['symbol_right'],
'decimal_place' => $result['decimal_place'],
'value' => $result['value'],
'status' => $result['status'],
'date_modified' => $result['date_modified']
);
}
$this->cache->set('currency', $currency_data);
}
return $currency_data;
}
}
@@ -0,0 +1,35 @@
<?php
class ModelLocalisationLanguage extends Model {
public function getLanguage($language_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language WHERE language_id = '" . (int)$language_id . "'");
return $query->row;
}
public function getLanguages() {
$language_data = $this->cache->get('catalog.language');
if (!$language_data) {
$language_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language WHERE status = '1' ORDER BY sort_order, name");
foreach ($query->rows as $result) {
$language_data[$result['code']] = array(
'language_id' => $result['language_id'],
'name' => $result['name'],
'code' => $result['code'],
'locale' => $result['locale'],
'image' => $result['image'],
'directory' => $result['directory'],
'sort_order' => $result['sort_order'],
'status' => $result['status']
);
}
$this->cache->set('catalog.language', $language_data);
}
return $language_data;
}
}
@@ -0,0 +1,8 @@
<?php
class ModelLocalisationLocation extends Model {
public function getLocation($location_id) {
$query = $this->db->query("SELECT location_id, name, address, geocode, telephone, fax, image, open, comment FROM " . DB_PREFIX . "location WHERE location_id = '" . (int)$location_id . "'");
return $query->row;
}
}
@@ -0,0 +1,22 @@
<?php
class ModelLocalisationOrderStatus extends Model {
public function getOrderStatus($order_status_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row;
}
public function getOrderStatuses() {
$order_status_data = $this->cache->get('order_status.' . (int)$this->config->get('config_language_id'));
if (!$order_status_data) {
$query = $this->db->query("SELECT order_status_id, name FROM " . DB_PREFIX . "order_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
$order_status_data = $query->rows;
$this->cache->set('order_status.' . (int)$this->config->get('config_language_id'), $order_status_data);
}
return $order_status_data;
}
}
@@ -0,0 +1,44 @@
<?php
class ModelLocalisationReturnReason extends Model {
public function getReturnReasons($data = array()) {
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "return_reason WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'";
$sql .= " ORDER BY name";
if (isset($data['return']) && ($data['return'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
} else {
$return_reason_data = $this->cache->get('return_reason.' . (int)$this->config->get('config_language_id'));
if (!$return_reason_data) {
$query = $this->db->query("SELECT return_reason_id, name FROM " . DB_PREFIX . "return_reason WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
$return_reason_data = $query->rows;
$this->cache->set('return_reason.' . (int)$this->config->get('config_language_id'), $return_reason_data);
}
return $return_reason_data;
}
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
class ModelLocalisationZone extends Model {
public function getZone($zone_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE zone_id = '" . (int)$zone_id . "' AND status = '1'");
return $query->row;
}
public function getZonesByCountryId($country_id) {
$zone_data = $this->cache->get('zone.' . (int)$country_id);
if (!$zone_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "' AND status = '1' ORDER BY name");
$zone_data = $query->rows;
$this->cache->set('zone.' . (int)$country_id, $zone_data);
}
return $zone_data;
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
class ModelReportStatistics extends Model {
public function getStatistics() {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "statistics");
return $query->rows;
}
public function getValue($code) {
$query = $this->db->query("SELECT value FROM " . DB_PREFIX . "statistics WHERE `code` = '" . $this->db->escape($code) . "'");
if ($query->num_rows) {
return $query->row['value'];
} else {
return null;
}
}
public function addValue($code, $value) {
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = (`value` + '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
}
public function removeValue($code, $value) {
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = (`value` - '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
}
public function editValue($code, $value) {
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = '" . (float)$value . "' WHERE `code` = '" . $this->db->escape($code) . "'");
}
}
+223
View File
@@ -0,0 +1,223 @@
<?php
class ModelServiceService extends Model {
public function updateViewed($service_id) {
$this->db->query("UPDATE " . DB_PREFIX . "service SET viewed = (viewed + 1) WHERE service_id = '" . (int)$service_id . "'");
}
public function getService($service_id) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, p.sort_order FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_description pd ON (p.service_id = pd.service_id) LEFT JOIN " . DB_PREFIX . "service_to_store p2s ON (p.service_id = p2s.service_id) WHERE p.service_id = '" . (int)$service_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return array(
'meta_title' => $query->row['meta_title'],
'noindex' => $query->row['noindex'],
'meta_h1' => $query->row['meta_h1'],
'service_id' => $query->row['service_id'],
'name' => $query->row['name'],
'description' => $query->row['description'],
'meta_description' => $query->row['meta_description'],
'meta_keyword' => $query->row['meta_keyword'],
'image' => $query->row['image'],
'sort_order' => $query->row['sort_order'],
'status' => $query->row['status'],
'date_added' => $query->row['date_added'],
'date_modified' => $query->row['date_modified'],
'viewed' => $query->row['viewed']
);
} else {
return false;
}
}
public function getServices($data = array()) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$cache = 'service.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$customer_group_id . '.' . md5(http_build_query($data));
$service_data = $this->cache->get($cache);
if (!$service_data) {
$sql = "SELECT p.service_id FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_description pd ON (p.service_id = pd.service_id) LEFT JOIN " . DB_PREFIX . "service_to_store p2s ON (p.service_id = p2s.service_id)";
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
$sql .= " GROUP BY p.service_id";
$sort_data = array(
'pd.name',
'p.viewed',
'p.sort_order',
'p.date_added'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.date_added') {
$sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
} else {
$sql .= " ORDER BY " . $data['sort'];
}
} else {
$sql .= " ORDER BY p.sort_order";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(pd.name) DESC";
} else {
$sql .= " ASC, LCASE(pd.name) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$service_data = array();
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$service_data[$result['service_id']] = $this->getService($result['service_id']);
}
$this->cache->set($cache, $service_data);
}
return $service_data;
}
public function getLatestServices($limit) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$cache = 'service.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit;
$service_data = $this->cache->get($cache);
if (!$service_data) {
$query = $this->db->query("SELECT p.service_id FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_to_store p2s ON (p.service_id = p2s.service_id) WHERE p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$service_data[$result['service_id']] = $this->getService($result['service_id']);
}
$this->cache->set($cache, $service_data);
}
return $service_data;
}
public function getPopularServices($limit) {
$service_data = array();
$query = $this->db->query("SELECT p.service_id FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_to_store p2s ON (p.service_id = p2s.service_id) WHERE p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$service_data[$result['service_id']] = $this->getService($result['service_id']);
}
return $service_data;
}
public function getServiceImages($service_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_image WHERE service_id = '" . (int)$service_id . "' ORDER BY sort_order ASC");
return $query->rows;
}
public function getServiceRelated($service_id) {
$service_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_related pr LEFT JOIN " . DB_PREFIX . "service p ON (pr.related_id = p.service_id) LEFT JOIN " . DB_PREFIX . "service_to_store p2s ON (p.service_id = p2s.service_id) WHERE pr.service_id = '" . (int)$service_id . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
foreach ($query->rows as $result) {
$service_data[$result['related_id']] = $this->getService($result['related_id']);
}
return $service_data;
}
public function getServiceRelatedProduct($service_id) {
$product_data = array();
$this->load->model('catalog/product');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_related_product np LEFT JOIN " . DB_PREFIX . "product p ON (np.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE np.service_id = '" . (int)$service_id . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
return $product_data;
}
public function getServiceLayoutId($service_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_to_layout WHERE service_id = '" . (int)$service_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return $query->row['layout_id'];
} else {
return $this->config->get('config_layout_service');
}
}
public function getDownloads($service_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_to_download pd LEFT JOIN " . DB_PREFIX . "download d ON(pd.download_id=d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON(pd.download_id=dd.download_id) WHERE service_id = '" . (int)$service_id . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id')."'");
return $query->rows;
}
public function getDownload($service_id, $download_id) {
$download="";
if($download_id!=0)$download=" AND d.download_id=".(int)$download_id;
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_to_download pd LEFT JOIN " . DB_PREFIX . "download d ON(pd.download_id=d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON(pd.download_id=dd.download_id) WHERE service_id = '" . (int)$service_id . "' ".$download." AND dd.language_id = '" . (int)$this->config->get('config_language_id')."'");
return $query->row;
}
public function getTotalServices($data = array()) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$cache = md5(http_build_query($data));
$service_data = $this->cache->get('service.total.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$customer_group_id . '.' . $cache);
$service_data = [];
if (!$service_data) {
$sql = "SELECT COUNT(DISTINCT p.service_id) AS total FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_description pd ON (p.service_id = pd.service_id) LEFT JOIN " . DB_PREFIX . "service_to_store p2s ON (p.service_id = p2s.service_id)";
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
$query = $this->db->query($sql);
$service_data = $query->row['total'];
$this->cache->set('service.total.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$customer_group_id . '.' . $cache, $service_data);
}
return $service_data;
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
class ModelSettingApi extends Model {
public function login($username, $key) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "api a LEFT JOIN " . DB_PREFIX . "api_ip `ai` ON (a.api_id = ai.api_id) WHERE a.username = '" . $this->db->escape($username) . "' AND a.key = '" . $this->db->escape($key) . "'");
return $query->row;
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
class ModelSettingEvent extends Model {
function getEvents() {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "event` WHERE `trigger` LIKE 'catalog/%' AND status = '1' ORDER BY `sort_order` ASC");
return $query->rows;
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
class ModelSettingExtension extends Model {
public function getExtensions($type) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "extension WHERE `type` = '" . $this->db->escape($type) . "'");
return $query->rows;
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
class ModelSettingModule extends Model {
public function getModule($module_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "module WHERE module_id = '" . (int)$module_id . "'");
if ($query->row) {
return json_decode($query->row['setting'], true);
} else {
return array();
}
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
class ModelSettingSetting extends Model {
public function getSetting($code, $store_id = 0) {
$data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
foreach ($query->rows as $result) {
if (!$result['serialized']) {
$data[$result['key']] = $result['value'];
} else {
$data[$result['key']] = json_decode($result['value'], true);
}
}
return $data;
}
public function getSettingValue($key, $store_id = 0) {
$query = $this->db->query("SELECT value FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$store_id . "' AND `key` = '" . $this->db->escape($key) . "'");
if ($query->num_rows) {
return $query->row['value'];
} else {
return null;
}
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
class ModelSettingStore extends Model {
public function getStores() {
$store_data = $this->cache->get('store');
if (!$store_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "store ORDER BY url");
$store_data = $query->rows;
$this->cache->set('store', $store_data);
}
return $store_data;
}
}
+50
View File
@@ -0,0 +1,50 @@
<?php
class ModelToolImage extends Model {
public function resize($filename, $width, $height) {
if (!is_file(DIR_IMAGE . $filename) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != str_replace('\\', '/', DIR_IMAGE)) {
return;
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$image_old = $filename;
$image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.' . $extension;
if (!is_file(DIR_IMAGE . $image_new) || (filemtime(DIR_IMAGE . $image_old) > filemtime(DIR_IMAGE . $image_new))) {
list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);
if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) {
return DIR_IMAGE . $image_old;
}
$path = '';
$directories = explode('/', dirname($image_new));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $image_old);
//$image->resize($width, $height);
$image->cropsize($width, $height);
$image->save(DIR_IMAGE . $image_new);
} else {
copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new);
}
}
$image_new = str_replace(' ', '%20', $image_new); // fix bug when attach image on email (gmail.com). it is automatic changing space " " to +
if ($this->request->server['HTTPS']) {
return $this->config->get('config_ssl') . 'image/' . $image_new;
} else {
return $this->config->get('config_url') . 'image/' . $image_new;
}
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
class ModelToolOnline extends Model {
public function addOnline($ip, $customer_id, $url, $referer) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_online` WHERE date_added < '" . date('Y-m-d H:i:s', strtotime('-1 hour')) . "'");
$this->db->query("REPLACE INTO `" . DB_PREFIX . "customer_online` SET `ip` = '" . $this->db->escape($ip) . "', `customer_id` = '" . (int)$customer_id . "', `url` = '" . $this->db->escape($url) . "', `referer` = '" . $this->db->escape($referer) . "', `date_added` = '" . $this->db->escape(date('Y-m-d H:i:s')) . "'");
}
}
+119
View File
@@ -0,0 +1,119 @@
<?php
class ModelToolSitemap extends Model {
private function getPathByCategory($category_id) {
$category_id = (int)$category_id;
if($category_id < 1) return false;
$max_level = 10;
$sql = "SELECT CONCAT_WS('_'";
for($i = $max_level - 1; $i >= 0; --$i) {
$sql .= ",t$i.category_id";
}
$sql .= ") AS path FROM " . DB_PREFIX . "category t0";
for($i = 1; $i < $max_level; ++$i) {
$sql .= " LEFT JOIN " . DB_PREFIX . "category t$i ON (t$i.category_id = t" . ($i - 1) . ".parent_id)";
}
$sql .= " WHERE t0.category_id = '" . $category_id . "'";
$query = $this->db->query($sql);
return $query->num_rows ? $query->row['path'] : false;
}
public function getProducts() {
$product_data = $this->cache->get('product.sitemap.' . (int)$this->config->get('config_store_id'));
if(!$product_data) {
//cache for seo_pro
$category_path = array();
$query = $this->db->query("SELECT c.category_id FROM " . DB_PREFIX . "category c WHERE c.status = '1'");
foreach($query->rows as $row) {
$category_path[$row['category_id']] = $this->getPathByCategory($row['category_id']);
}
$category_path[0] = false;
$this->cache->set('category.seopath', $category_path);
$product_path = array();
$query = $this->db->query("SELECT p.product_id, date(GREATEST(p.date_added, p.date_modified)) as 'date'," .
" (SELECT category_id FROM " . DB_PREFIX . "product_to_category p2c WHERE p2c.product_id = p.product_id ORDER BY category_id DESC LIMIT 1) as category_id" .
" FROM " . DB_PREFIX . "product p" .
" LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)" .
" WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"
);
foreach($query->rows as $row) {
if(isset($category_path[$row['category_id']])) {
$product_path[$row['product_id']] = $category_path[$row['category_id']];
} else {
$product_path[$row['product_id']] = 0;
$category_path[$row['category_id']] = false;
}
}
$this->cache->set('product.seopath', $product_path);
$product_data = $query->rows;
$this->cache->set('product.sitemap.' . (int)$this->config->get('config_store_id'), $product_data);
}
return $product_data;
}
public function getAllCategories() {
$category_data = $this->cache->get('category.sitemap.' . (int)$this->config->get('config_store_id'));
if(!$category_data || !is_array($category_data)) {
$query = $this->db->query("SELECT c.category_id, c.parent_id, date(GREATEST(c.date_added, c.date_modified)) as 'date' FROM " . DB_PREFIX . "category c" .
" LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id)" .
" WHERE c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'");
$category_data = array();
foreach($query->rows as $row) {
$category_data[$row['parent_id']][$row['category_id']] = $row;
}
$this->cache->set('category.sitemap.' . (int)$this->config->get('config_store_id'), $category_data);
}
return $category_data;
}
public function getManufacturers() {
$manufacturer_data = $this->cache->get('manufacturer.sitemap.' . (int)$this->config->get('config_store_id'));
if(!$manufacturer_data) {
$query = $this->db->query("SELECT m.manufacturer_id FROM " . DB_PREFIX . "manufacturer m" .
" LEFT JOIN " . DB_PREFIX . "manufacturer_to_store m2s ON (m.manufacturer_id = m2s.manufacturer_id)" .
" WHERE m2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
$manufacturer_data = $query->rows;
$this->cache->set('manufacturer.sitemap.' . (int)$this->config->get('config_store_id'), $manufacturer_data);
}
return $manufacturer_data;
}
public function getInformations() {
$informations_data = $this->cache->get('information.sitemap.' . (int)$this->config->get('config_store_id'));
if(!$informations_data) {
$query = $this->db->query("SELECT i.information_id FROM " . DB_PREFIX . "information i" .
" LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id)" .
" WHERE i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' AND i.sort_order <> '-1'");
$informations_data = $query->rows;
$this->cache->set('information.sitemap.' . (int)$this->config->get('config_store_id'), $informations_data);
}
return $informations_data;
}
}
?>
+16
View File
@@ -0,0 +1,16 @@
<?php
class ModelToolUpload extends Model {
public function addUpload($name, $filename) {
$code = sha1(uniqid(mt_rand(), true));
$this->db->query("INSERT INTO `" . DB_PREFIX . "upload` SET `name` = '" . $this->db->escape($name) . "', `filename` = '" . $this->db->escape($filename) . "', `code` = '" . $this->db->escape($code) . "', `date_added` = NOW()");
return $code;
}
public function getUploadByCode($code) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "upload` WHERE code = '" . $this->db->escape($code) . "'");
return $query->row;
}
}