Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * @ https://EasyToYou.eu - IonCube v10 Decoder Online
- * @ PHP 5.6
- * @ Decoder version: 1.0.4
- * @ Release: 02/06/2020
- *
- * @ ZendGuard Decoder PHP 5.6
- */
- class ModelExtensionModuleYumenu extends Model
- {
- public function getCategory($category_id)
- {
- return $this->getCategories((int) $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 c.parent_id, c.category_id, c.sort_order, c.image, cd.name 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' ORDER BY c.parent_id, c.sort_order, cd.name");
- foreach ($query->rows as $row) {
- $data["by_id"][$row["category_id"]] = $row;
- $data["by_parent"][$row["parent_id"]][] = $row;
- }
- }
- return isset($data[$type]) && isset($data[$type][$id]) ? $data[$type][$id] : array();
- }
- public function getCategoriesList()
- {
- $result = $this->cache->get("yum.categories.list." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $query = $this->db->query("SELECT c.category_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' ORDER BY c.parent_id, c.sort_order, cd.name");
- foreach ($query->rows as $category) {
- $result[] = $category["category_id"];
- }
- $this->cache->set("yum.categories.list." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getCategoriesInfo()
- {
- $result = $this->cache->get("yum.categories.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $ids = $this->getCategoriesList();
- foreach ($ids as $id) {
- $result[$id] = $this->getCategory($id);
- }
- $this->cache->set("yum.categories.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function buildSelectedTree(array $ids)
- {
- $result = array();
- foreach ($ids as $item_id) {
- $item = $this->getCategory($item_id);
- if ($item) {
- $result[$item["category_id"]] = $item;
- }
- }
- $root = array();
- foreach ($result as $id => $item) {
- $parent = in_array($item["parent_id"], $ids) ? $item["parent_id"] : "0";
- $result[$parent]["children"][$id] =& $result[$id];
- if (!$parent) {
- $root[$id] =& $result[$id];
- }
- }
- return $root;
- }
- public function getCategoriesPath()
- {
- $result = $this->cache->get("yum.categories.path." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $ids_array = $this->getCategoriesList();
- $ids = array_merge(array(0), $ids_array);
- foreach ($ids as $id) {
- $result[$id] = $this->getPath($id);
- }
- $this->cache->set("yum.categories.path." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getPath($category_id)
- {
- $result = array();
- $category_info = $this->getCategory($category_id);
- if ($category_info) {
- $result[] = $category_info["category_id"];
- if ($category_info["parent_id"] != 0) {
- $parent = $this->getPath($category_info["parent_id"]);
- if ($parent) {
- $result = array_merge($parent, $result);
- }
- }
- }
- return $result;
- }
- public function getCategoriesChildren()
- {
- $result = $this->cache->get("yum.categories.children." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $ids_array = $this->getCategoriesList();
- $ids = array_merge(array(0), $ids_array);
- foreach ($ids as $id) {
- $result[$id] = $this->getChildren($id);
- }
- $this->cache->set("yum.categories.children." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getChildren($parent_id)
- {
- $result = array();
- $categories = $this->getCategories($parent_id);
- if ($categories) {
- foreach ($categories as $category) {
- $result[] = $category["category_id"];
- $children = $this->getChildren($category["category_id"]);
- if ($children) {
- $result = array_merge($children, $result);
- }
- }
- }
- return $result;
- }
- public function getNotEmptyCategories()
- {
- $result = $this->cache->get("yum.categories.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $query = $this->db->query("SELECT pc.category_id FROM " . DB_PREFIX . "product_to_category pc LEFT JOIN " . DB_PREFIX . "product p ON (pc.product_id = p.product_id) WHERE p.status = '1'");
- if ($query->num_rows) {
- foreach ($query->rows as $row) {
- $result[] = $row["category_id"];
- }
- }
- $this->cache->set("yum.categories.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getMainCategory()
- {
- $result = $this->cache->get("yum.categories.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category");
- if ($query->num_rows) {
- if (isset($query->row["main_category"])) {
- foreach ($query->rows as $row) {
- $result[$row["product_id"]]["all"][] = $row["category_id"];
- if ($row["main_category"] == "1") {
- $result[$row["product_id"]]["main"] = $row["category_id"];
- }
- }
- } else {
- foreach ($query->rows as $row) {
- $result[$row["product_id"]]["all"][] = $row["category_id"];
- }
- }
- }
- $this->cache->set("yum.categories.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getManufacturer($manufacturer_id)
- {
- return $this->getManufacturers($manufacturer_id);
- }
- public function getManufacturers($id = 0)
- {
- static $data = NULL;
- if ($data === NULL) {
- $data = array();
- $query = $this->db->query("SELECT m.manufacturer_id, m.sort_order, md.name, m.image FROM " . DB_PREFIX . "manufacturer m LEFT JOIN " . DB_PREFIX . "manufacturer_to_store m2s ON (m.manufacturer_id = m2s.manufacturer_id) LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON (m.manufacturer_id = md.manufacturer_id) WHERE md.language_id = '" . (int) $this->config->get("config_language_id") . "' AND m2s.store_id = '" . (int) $this->config->get("config_store_id") . "' ORDER BY m.sort_order, m.name");
- foreach ($query->rows as $row) {
- $data[$row["manufacturer_id"]] = $row;
- }
- }
- return isset($data[$id]) ? $data[$id] : $data;
- }
- public function getManufacturersInfo()
- {
- $result = $this->cache->get("yum.brands.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $manufacturers = $this->getManufacturers();
- foreach ($manufacturers as $manufacturer) {
- $result[$manufacturer["manufacturer_id"]] = $manufacturer;
- }
- $this->cache->set("yum.brands.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getProductManufacturer()
- {
- $result = $this->cache->get("yum.brands.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $query = $this->db->query("SELECT p.manufacturer_id, p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p2s.store_id = '" . (int) $this->config->get("config_store_id") . "' AND p.status = '1'");
- if ($query->num_rows) {
- foreach ($query->rows as $row) {
- $result[$row["product_id"]] = $row["manufacturer_id"];
- }
- }
- $this->cache->set("yum.brands.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getNotEmptyManufacturers()
- {
- $result = $this->cache->get("yum.brands.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $query = $this->db->query("SELECT manufacturer_id FROM " . DB_PREFIX . "product WHERE status = '1'");
- if ($query->num_rows) {
- foreach ($query->rows as $row) {
- $result[] = $row["manufacturer_id"];
- }
- }
- $this->cache->set("yum.brands.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getInformation($information_id)
- {
- return $this->getInformations($information_id);
- }
- public function getInformations($id = 0)
- {
- static $data = NULL;
- if ($data === NULL) {
- $data = array();
- $query = $this->db->query("SELECT i.information_id, i.sort_order, id.title 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");
- foreach ($query->rows as $row) {
- $data[$row["information_id"]] = $row;
- }
- }
- return isset($data[$id]) ? $data[$id] : $data;
- }
- public function getInformationsInfo()
- {
- $result = $this->cache->get("yum.informations.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $informations = $this->getInformations();
- foreach ($informations as $information) {
- $result[$information["information_id"]] = $information;
- }
- $this->cache->set("yum.informations.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getProduct($product_id)
- {
- return $this->getProducts($product_id);
- }
- public function getProducts($id = 0)
- {
- static $data = NULL;
- if ($data === NULL) {
- $data = array();
- $query = $this->db->query("SELECT DISTINCT p.product_id, p.manufacturer_id, p.image, p.price, p.tax_class_id, pd.name AS name, (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, 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) 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") . "'");
- foreach ($query->rows as $row) {
- $data[$row["product_id"]] = $row;
- }
- }
- return isset($data[$id]) ? $data[$id] : $data;
- }
- public function getProductsInfo()
- {
- $result = $this->cache->get("yum.products.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $products = $this->getProducts();
- foreach ($products as $product) {
- $result[$product["product_id"]] = $product;
- }
- $this->cache->set("yum.products.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- public function getItems()
- {
- $result = $this->cache->get("yum.custom.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
- if (!$result) {
- $result = array();
- $query = $this->db->query("SELECT module_id, items FROM " . DB_PREFIX . "yumenu");
- if ($query->num_rows) {
- foreach ($query->rows as $row) {
- $result[$row["module_id"]] = $row["items"];
- }
- }
- $this->cache->set("yum.custom.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
- }
- return $result;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment