Guest User

Untitled

a guest
Jul 14th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.70 KB | None | 0 0
  1. <?php
  2. /*
  3. * @ https://EasyToYou.eu - IonCube v10 Decoder Online
  4. * @ PHP 5.6
  5. * @ Decoder version: 1.0.4
  6. * @ Release: 02/06/2020
  7. *
  8. * @ ZendGuard Decoder PHP 5.6
  9. */
  10.  
  11. class ModelExtensionModuleYumenu extends Model
  12. {
  13. public function getCategory($category_id)
  14. {
  15. return $this->getCategories((int) $category_id, "by_id");
  16. }
  17. public function getCategories($id = 0, $type = "by_parent")
  18. {
  19. static $data = NULL;
  20. if ($data === NULL) {
  21. $data = array();
  22. $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");
  23. foreach ($query->rows as $row) {
  24. $data["by_id"][$row["category_id"]] = $row;
  25. $data["by_parent"][$row["parent_id"]][] = $row;
  26. }
  27. }
  28. return isset($data[$type]) && isset($data[$type][$id]) ? $data[$type][$id] : array();
  29. }
  30. public function getCategoriesList()
  31. {
  32. $result = $this->cache->get("yum.categories.list." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  33. if (!$result) {
  34. $result = array();
  35. $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");
  36. foreach ($query->rows as $category) {
  37. $result[] = $category["category_id"];
  38. }
  39. $this->cache->set("yum.categories.list." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  40. }
  41. return $result;
  42. }
  43. public function getCategoriesInfo()
  44. {
  45. $result = $this->cache->get("yum.categories.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  46. if (!$result) {
  47. $result = array();
  48. $ids = $this->getCategoriesList();
  49. foreach ($ids as $id) {
  50. $result[$id] = $this->getCategory($id);
  51. }
  52. $this->cache->set("yum.categories.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  53. }
  54. return $result;
  55. }
  56. public function buildSelectedTree(array $ids)
  57. {
  58. $result = array();
  59. foreach ($ids as $item_id) {
  60. $item = $this->getCategory($item_id);
  61. if ($item) {
  62. $result[$item["category_id"]] = $item;
  63. }
  64. }
  65. $root = array();
  66. foreach ($result as $id => $item) {
  67. $parent = in_array($item["parent_id"], $ids) ? $item["parent_id"] : "0";
  68. $result[$parent]["children"][$id] =& $result[$id];
  69. if (!$parent) {
  70. $root[$id] =& $result[$id];
  71. }
  72. }
  73. return $root;
  74. }
  75. public function getCategoriesPath()
  76. {
  77. $result = $this->cache->get("yum.categories.path." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  78. if (!$result) {
  79. $result = array();
  80. $ids_array = $this->getCategoriesList();
  81. $ids = array_merge(array(0), $ids_array);
  82. foreach ($ids as $id) {
  83. $result[$id] = $this->getPath($id);
  84. }
  85. $this->cache->set("yum.categories.path." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  86. }
  87. return $result;
  88. }
  89. public function getPath($category_id)
  90. {
  91. $result = array();
  92. $category_info = $this->getCategory($category_id);
  93. if ($category_info) {
  94. $result[] = $category_info["category_id"];
  95. if ($category_info["parent_id"] != 0) {
  96. $parent = $this->getPath($category_info["parent_id"]);
  97. if ($parent) {
  98. $result = array_merge($parent, $result);
  99. }
  100. }
  101. }
  102. return $result;
  103. }
  104. public function getCategoriesChildren()
  105. {
  106. $result = $this->cache->get("yum.categories.children." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  107. if (!$result) {
  108. $result = array();
  109. $ids_array = $this->getCategoriesList();
  110. $ids = array_merge(array(0), $ids_array);
  111. foreach ($ids as $id) {
  112. $result[$id] = $this->getChildren($id);
  113. }
  114. $this->cache->set("yum.categories.children." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  115. }
  116. return $result;
  117. }
  118. public function getChildren($parent_id)
  119. {
  120. $result = array();
  121. $categories = $this->getCategories($parent_id);
  122. if ($categories) {
  123. foreach ($categories as $category) {
  124. $result[] = $category["category_id"];
  125. $children = $this->getChildren($category["category_id"]);
  126. if ($children) {
  127. $result = array_merge($children, $result);
  128. }
  129. }
  130. }
  131. return $result;
  132. }
  133. public function getNotEmptyCategories()
  134. {
  135. $result = $this->cache->get("yum.categories.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  136. if (!$result) {
  137. $result = array();
  138. $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'");
  139. if ($query->num_rows) {
  140. foreach ($query->rows as $row) {
  141. $result[] = $row["category_id"];
  142. }
  143. }
  144. $this->cache->set("yum.categories.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  145. }
  146. return $result;
  147. }
  148. public function getMainCategory()
  149. {
  150. $result = $this->cache->get("yum.categories.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  151. if (!$result) {
  152. $result = array();
  153. $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category");
  154. if ($query->num_rows) {
  155. if (isset($query->row["main_category"])) {
  156. foreach ($query->rows as $row) {
  157. $result[$row["product_id"]]["all"][] = $row["category_id"];
  158. if ($row["main_category"] == "1") {
  159. $result[$row["product_id"]]["main"] = $row["category_id"];
  160. }
  161. }
  162. } else {
  163. foreach ($query->rows as $row) {
  164. $result[$row["product_id"]]["all"][] = $row["category_id"];
  165. }
  166. }
  167. }
  168. $this->cache->set("yum.categories.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  169. }
  170. return $result;
  171. }
  172. public function getManufacturer($manufacturer_id)
  173. {
  174. return $this->getManufacturers($manufacturer_id);
  175. }
  176. public function getManufacturers($id = 0)
  177. {
  178. static $data = NULL;
  179. if ($data === NULL) {
  180. $data = array();
  181. $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");
  182. foreach ($query->rows as $row) {
  183. $data[$row["manufacturer_id"]] = $row;
  184. }
  185. }
  186. return isset($data[$id]) ? $data[$id] : $data;
  187. }
  188. public function getManufacturersInfo()
  189. {
  190. $result = $this->cache->get("yum.brands.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  191. if (!$result) {
  192. $result = array();
  193. $manufacturers = $this->getManufacturers();
  194. foreach ($manufacturers as $manufacturer) {
  195. $result[$manufacturer["manufacturer_id"]] = $manufacturer;
  196. }
  197. $this->cache->set("yum.brands.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  198. }
  199. return $result;
  200. }
  201. public function getProductManufacturer()
  202. {
  203. $result = $this->cache->get("yum.brands.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  204. if (!$result) {
  205. $result = array();
  206. $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'");
  207. if ($query->num_rows) {
  208. foreach ($query->rows as $row) {
  209. $result[$row["product_id"]] = $row["manufacturer_id"];
  210. }
  211. }
  212. $this->cache->set("yum.brands.connections." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  213. }
  214. return $result;
  215. }
  216. public function getNotEmptyManufacturers()
  217. {
  218. $result = $this->cache->get("yum.brands.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  219. if (!$result) {
  220. $result = array();
  221. $query = $this->db->query("SELECT manufacturer_id FROM " . DB_PREFIX . "product WHERE status = '1'");
  222. if ($query->num_rows) {
  223. foreach ($query->rows as $row) {
  224. $result[] = $row["manufacturer_id"];
  225. }
  226. }
  227. $this->cache->set("yum.brands.notempty." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  228. }
  229. return $result;
  230. }
  231. public function getInformation($information_id)
  232. {
  233. return $this->getInformations($information_id);
  234. }
  235. public function getInformations($id = 0)
  236. {
  237. static $data = NULL;
  238. if ($data === NULL) {
  239. $data = array();
  240. $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");
  241. foreach ($query->rows as $row) {
  242. $data[$row["information_id"]] = $row;
  243. }
  244. }
  245. return isset($data[$id]) ? $data[$id] : $data;
  246. }
  247. public function getInformationsInfo()
  248. {
  249. $result = $this->cache->get("yum.informations.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  250. if (!$result) {
  251. $result = array();
  252. $informations = $this->getInformations();
  253. foreach ($informations as $information) {
  254. $result[$information["information_id"]] = $information;
  255. }
  256. $this->cache->set("yum.informations.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  257. }
  258. return $result;
  259. }
  260. public function getProduct($product_id)
  261. {
  262. return $this->getProducts($product_id);
  263. }
  264. public function getProducts($id = 0)
  265. {
  266. static $data = NULL;
  267. if ($data === NULL) {
  268. $data = array();
  269. $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") . "'");
  270. foreach ($query->rows as $row) {
  271. $data[$row["product_id"]] = $row;
  272. }
  273. }
  274. return isset($data[$id]) ? $data[$id] : $data;
  275. }
  276. public function getProductsInfo()
  277. {
  278. $result = $this->cache->get("yum.products.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  279. if (!$result) {
  280. $result = array();
  281. $products = $this->getProducts();
  282. foreach ($products as $product) {
  283. $result[$product["product_id"]] = $product;
  284. }
  285. $this->cache->set("yum.products.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  286. }
  287. return $result;
  288. }
  289. public function getItems()
  290. {
  291. $result = $this->cache->get("yum.custom.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"));
  292. if (!$result) {
  293. $result = array();
  294. $query = $this->db->query("SELECT module_id, items FROM " . DB_PREFIX . "yumenu");
  295. if ($query->num_rows) {
  296. foreach ($query->rows as $row) {
  297. $result[$row["module_id"]] = $row["items"];
  298. }
  299. }
  300. $this->cache->set("yum.custom.info." . (int) $this->config->get("config_language_id") . "." . (int) $this->config->get("config_store_id"), $result);
  301. }
  302. return $result;
  303. }
  304. }
  305.  
  306. ?>
Advertisement
Add Comment
Please, Sign In to add comment