Advertisement
Guest User

Untitled

a guest
Nov 17th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.13 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class ModelToolNeoSeoExchange1c extends NeoSeoModel
  15. {
  16. private $categories_to_1c = [];
  17. private $categories_parents = [];
  18. private $hasCategoryPath = false;
  19. private $hasRelatedImages = false;
  20. private $hasManufacturerDescription = false;
  21. private $hasManufacturerDescriptionName = false;
  22. private $hasManufacturerName = false;
  23. private $hasRelatedOptionsVariantProductId = false;
  24. private $hasAttributeProductSortorder = false;
  25. private $hasProductMultycurr = false;
  26. private $properties1c = [];
  27. private $properties1cLng = [];
  28. private $properties1c_values = [];
  29. private $properties1c_valuesLng = [];
  30. private $options1c = [];
  31. private $option_1c_values_array = [];
  32. private $option_1c_values = [];
  33. private $stockStatusesByName = [];
  34. private $languages = [];
  35. private $languageCodes = [];
  36. private $category_links = [];
  37. private $attribute_links = [];
  38. private $warehouses = [];
  39. private $warehouses_name = [];
  40. private $hasOcFilter;
  41. private $thirdOpencart;
  42. private $hasNaclad;
  43. private $hasNeoSeoFilter;
  44. private $hasNeoSeoWarehouse;
  45. private $hasModuleNMP;
  46. private $getAllProducts = false;
  47. private $use_filter = '';
  48. private $journal_labels = [];
  49. private $attribute_labels = [];
  50. static public $REPL = [
  51. 'search' => ["\n", "\r", "\t"],
  52. 'replace' => ['[~nl~]', '[~nr~]', '[~nt~]']
  53. ];
  54. private $decimal_sep = '.';
  55. private $system_decimal_sep = '.';
  56. private $hasOptionsPro = false;
  57. private $hasMultiStore = false;
  58. private $customerGroups = [];
  59. private $hasOptionsCombinations = false;
  60. private $octFilterAttribute = [];
  61. private $attribute_routing_download_files = [];
  62. private $hasCpriceModule = false;
  63. private $productDescriptionFieldsList = [];
  64. private $relatedoptions_variant_to_option_id = [];
  65. private $option_not_requered_name_list = [];
  66. private $product_tags_agree_languages = [];
  67.  
  68. public function __construct($registry)
  69. {
  70. parent::__construct($registry);
  71. $this->_moduleSysName = 'neoseo_exchange1c';
  72. $this->_logFile = $this->_moduleSysName() . '.log';
  73. $this->debug = $this->config->get($this->_moduleSysName() . '_debug') == 1;
  74. $sql = 'show tables like \'' . DB_PREFIX . 'ocfilter_option\'';
  75. $query = $this->query($sql);
  76. $this->hasOcFilter = false;
  77. $this->OcFilterVersion = 'old';
  78. $this->hasOcFilter = 0 < $query->num_rows;
  79.  
  80. if (!$this->hasOcFilter) {
  81. $sql = 'show tables like \'' . DB_PREFIX . 'ocfilter_filter\'';
  82. $query = $this->query($sql);
  83. $this->OcFilterVersion = 'new';
  84. $this->hasOcFilter = 0 < $query->num_rows;
  85. }
  86.  
  87. $sql = 'show tables like \'' . DB_PREFIX . 'seo_url\'';
  88. $query = $this->query($sql);
  89. $this->thirdOpencart = 0 < $query->num_rows;
  90. $sql = 'show tables like \'' . DB_PREFIX . 'naclad\'';
  91. $query = $this->query($sql);
  92. $this->hasNaclad = 0 < $query->num_rows;
  93. $sql = 'SHOW TABLES LIKE \'' . DB_PREFIX . 'filter_option\'';
  94. $query = $this->db->query($sql);
  95. $this->hasNeoSeoFilter = 0 < $query->num_rows;
  96. $sql = 'SHOW TABLES LIKE \'' . DB_PREFIX . 'warehouse\'';
  97. $query = $this->db->query($sql);
  98. $this->hasNeoSeoWarehouse = 0 < $query->num_rows;
  99. $sql = 'SHOW TABLES LIKE \'' . DB_PREFIX . 'product_filter\'';
  100. $query = $this->db->query($sql);
  101. $this->hasFilter = 0 < $query->num_rows;
  102. $sql = 'show tables like \'' . DB_PREFIX . 'category_path\'';
  103. $query = $this->query($sql);
  104. $this->hasCategoryPath = 0 < $query->num_rows;
  105. $sql = 'show tables like \'' . DB_PREFIX . 'relatedoptions_variant_product\'';
  106. $query = $this->query($sql);
  107. $this->hasRelatedoptions = 0 < $query->num_rows;
  108. $sql = 'show tables like \'' . DB_PREFIX . 'product_option_pro_to_product\'';
  109. $query = $this->query($sql);
  110. $this->hasOptionsPro = 0 < $query->num_rows;
  111. $sql = 'show tables like \'' . DB_PREFIX . 'multistore\'';
  112. $query = $this->query($sql);
  113. $this->hasMultiStore = 0 < $query->num_rows;
  114. $sql = 'show tables like \'' . DB_PREFIX . 'poip_option_image\'';
  115. $query = $this->query($sql);
  116. $this->hasRelatedImages = 0 < $query->num_rows;
  117. $sql = 'show tables like \'' . DB_PREFIX . 'product_options_combinations\'';
  118. $query = $this->query($sql);
  119. $this->hasOptionsCombinations = 0 < $query->num_rows;
  120.  
  121. if (!$this->hasOptionsCombinations) {
  122. $this->debug('Сообщение для разработчика: Модуль Комбинации опций не установлен. Использование комбинаций опций не возможно.');
  123. }
  124.  
  125. $sql = 'show tables like \'' . DB_PREFIX . 'product_multycurr\'';
  126. $query = $this->query($sql);
  127. $this->hasProductMultycurr = 0 < $query->num_rows;
  128. $sql = 'show tables like \'' . DB_PREFIX . 'manufacturer_description\'';
  129. $query = $this->query($sql);
  130. $this->hasManufacturerDescription = 0 < $query->num_rows;
  131.  
  132. if ($this->hasManufacturerDescription) {
  133. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'manufacturer_description` LIKE \'name\';';
  134. $query = $this->query($sql);
  135. $this->hasManufacturerDescriptionName = 0 < $query->num_rows;
  136. }
  137. else {
  138. $this->hasManufacturerDescriptionName = false;
  139. }
  140.  
  141. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'product_option_value` LIKE \'image\';';
  142. $query = $this->query($sql);
  143. $this->hasOptionValueImage = 0 < $query->num_rows;
  144. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'product_option_value` LIKE \'more_image\';';
  145. $query = $this->query($sql);
  146. $this->hasOptionValueMoreImage = 0 < $query->num_rows;
  147. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'order` LIKE \'date_of_payment\';';
  148. $query = $this->query($sql);
  149. $this->hasDateOfPayment = 0 < $query->num_rows;
  150. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'product_attribute` LIKE \'sort_order\';';
  151. $query = $this->query($sql);
  152. $this->hasAttributeProductSortorder = 0 < $query->num_rows;
  153. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'order_product` LIKE \'status\';';
  154. $query = $this->query($sql);
  155. $this->hasOrderProductStatus = 0 < $query->num_rows;
  156. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'manufacturer` LIKE \'name\';';
  157. $query = $this->query($sql);
  158. $this->hasManufacturerName = 0 < $query->num_rows;
  159. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'product_to_category` LIKE \'main_category\';';
  160. $query = $this->query($sql);
  161. $this->main_category = 0 < $query->num_rows;
  162. $sql = 'SHOW TABLES LIKE \'' . DB_PREFIX . 'hpmodel_links\'';
  163. $query = $this->db->query($sql);
  164. $this->hasModuleNMP = 0 < $query->num_rows;
  165. if ($this->hasRelatedoptions && $this->config->get('neoseo_exchange1c_use_related_options')) {
  166. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'relatedoptions_variant_product` LIKE \'relatedoptions_variant_product_id\';';
  167. $query = $this->query($sql);
  168. $this->hasRelatedOptionsVariantProductId = 0 < $query->num_rows;
  169. }
  170. else {
  171. $this->debug('Сообщение для разработчика. Таблица `' . DB_PREFIX . 'relatedoptions_variant_product` не была найдена. Использование связных опций не возможно.');
  172. }
  173.  
  174. $search_option_for_sku = $this->config->get($this->_moduleSysName . '_search_option_for_sku');
  175. $option_field_sku = $this->config->get($this->_moduleSysName . '_option_field_sku');
  176. $this->sku = 0;
  177. $this->sku_field = '';
  178.  
  179. if ($search_option_for_sku == 1) {
  180. if ($this->config->get($this->_moduleSysName . '_use_related_options') && $this->hasRelatedoptions) {
  181. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'relatedoptions` LIKE \'' . $option_field_sku . '\';';
  182. $tablename = 'relatedoptions';
  183. }
  184. else {
  185. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'product_option_value` LIKE \'' . $option_field_sku . '\';';
  186. $tablename = 'product_option_value';
  187. }
  188.  
  189. $query = $this->query($sql);
  190. $this->sku = 0 < $query->num_rows;
  191. if ($this->sku || $this->hasOptionsPro || $this->hasOptionsCombinations) {
  192. $this->sku_field = $option_field_sku;
  193. }
  194. else {
  195. $this->debug('Поле ' . $option_field_sku . ' не найдено в таблице ' . DB_PREFIX . ($tablename . '. Поиск опций по артикулу не возможен.'));
  196. }
  197. }
  198.  
  199. $option_field_ean = $this->config->get($this->_moduleSysName . '_option_field_ean');
  200. $this->option_ean_field = '';
  201. $this->option_ean = 0;
  202. $tablename = '';
  203. $this->relatedoptions_has_ean = 0;
  204. $this->product_option_value_has_ean = 0;
  205.  
  206. if ($option_field_ean) {
  207. if ($this->config->get($this->_moduleSysName . '_use_related_options') && $this->hasRelatedoptions) {
  208. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'relatedoptions` LIKE \'' . $option_field_ean . '\';';
  209. $tablename = 'relatedoptions';
  210. }
  211. else {
  212. $sql = 'SHOW COLUMNS FROM `' . DB_PREFIX . 'product_option_value` LIKE \'' . $option_field_ean . '\';';
  213. $tablename = 'product_option_value';
  214. }
  215.  
  216. $query = $this->query($sql);
  217. $this->option_ean = 0 < $query->num_rows;
  218.  
  219. if ($this->option_ean) {
  220. $this->option_ean_field = $option_field_ean;
  221.  
  222. if ($tablename == 'product_option_value') {
  223. $this->product_option_value_has_ean = 1;
  224. }
  225. else if ($tablename == 'relatedoptions') {
  226. $this->relatedoptions_has_ean = 1;
  227. }
  228. }
  229. else {
  230. $this->debug('Поле ' . $option_field_ean . ' не найдено в таблице ' . DB_PREFIX . ($tablename . '. Штрих код для опции не будет присвоен'));
  231. }
  232. }
  233.  
  234. $sql = 'SELECT stock_status_id, name FROM `' . DB_PREFIX . 'stock_status` WHERE language_id = ' . (int) $this->config->get('config_language_id') . ';';
  235.  
  236. foreach ($this->query($sql)->rows as $row) {
  237. $this->stockStatusesByName[utf8_strtolower($row['name'])] = $row['stock_status_id'];
  238. }
  239.  
  240. $this->log('Статусы в магазине ' . print_r($this->stockStatusesByName, true));
  241. $sql = 'SELECT language_id, code FROM `' . DB_PREFIX . 'language`;';
  242.  
  243. foreach ($this->query($sql)->rows as $row) {
  244. $this->languages[$row['code']] = (int) $row['language_id'];
  245. $this->languageCodes[$row['code']] = $row['language_id'];
  246. }
  247.  
  248. $links = [];
  249.  
  250. foreach (explode("\n", $this->config->get('neoseo_exchange1c_category_links')) as $line) {
  251. $line = trim($line);
  252.  
  253. if ($line == '') {
  254. continue;
  255. }
  256.  
  257. $parts = explode(':', $line);
  258.  
  259. if (count($parts) != 2) {
  260. $this->debug('Некорректная настройка связей категорий: ' . $line);
  261. continue;
  262. }
  263.  
  264. $category_1c = $this->normalizeCategoryName($parts[0]);
  265. $category_names = [];
  266.  
  267. foreach (explode(';', $parts[1]) as $name) {
  268. $name = $this->normalizeCategoryName($name);
  269. $category_id = $this->obf_7ujsqOQtJS4o6WmuJanwJ3rJCWtZE($name);
  270.  
  271. if (!$category_id) {
  272. $this->debug('Некорректная настройка связей категорий: категория \'' . $name . '\' не найдена в базе');
  273. continue;
  274. }
  275.  
  276. $category_names[] = $category_id;
  277. }
  278.  
  279. if (0 < count($category_names)) {
  280. $links[$category_1c] = $category_names;
  281. }
  282. }
  283.  
  284. $this->category_links = $links;
  285.  
  286. if (0 < count($this->category_links)) {
  287. }
  288.  
  289. foreach (explode("\n", $this->config->get('neoseo_exchange1c_attribute_links')) as $line) {
  290. $line = trim($line);
  291.  
  292. if ($line == '') {
  293. continue;
  294. }
  295.  
  296. $parts = explode(':', $line);
  297.  
  298. if (count($parts) != 2) {
  299. $this->debug('Некорректная настройка связей атрибутов: ' . $line);
  300. continue;
  301. }
  302.  
  303. $this->attribute_links[trim($parts[0])] = trim($parts[1]);
  304. }
  305.  
  306. if (0 < count($this->attribute_links)) {
  307. $this->debug('Таблица связей для атрибутов: ' . print_r($this->attribute_links, true));
  308. }
  309.  
  310. $attribute_labels = [];
  311.  
  312. if ($this->config->get('neoseo_exchange1c_attribute_label')) {
  313. foreach (explode("\n", $this->config->get('neoseo_exchange1c_attribute_label')) as $line) {
  314. $line = trim($line);
  315. ..........................................................................
  316. .......................................
  317. .................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement