install.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <modification>
  3. <name>Links to marketplaces</name>
  4. <code>links2marketplaces</code>
  5. <version>1.0.0</version>
  6. <date>05.08.2024</date>
  7. <author>Kuzmichev Ruslan</author>
  8. <link>http://kuzmichev.pw</link>
  9. <file path="admin/controller/catalog/product.php">
  10. <operation>
  11. <search>
  12. <![CDATA[
  13. if (isset($this->error['name'])) {
  14. ]]>
  15. </search>
  16. <add position="before">
  17. <![CDATA[
  18. $data['module_links_to_marketplaces_status'] = $this->config->get('module_links_to_marketplaces_status');
  19. $data['module_links_to_marketplaces'] = $this->config->get('module_links_to_marketplaces');
  20. if (isset($this->error['url_ozon'])) {
  21. $data['error_url_ozon'] = $this->error['url_ozon'];
  22. } else {
  23. $data['error_url_ozon'] = array();
  24. }
  25. if (isset($this->error['url_wildberries'])) {
  26. $data['error_url_wildberries'] = $this->error['url_wildberries'];
  27. } else {
  28. $data['error_url_wildberries'] = array();
  29. }
  30. if (isset($this->error['url_yandex_market'])) {
  31. $data['error_url_yandex_market'] = $this->error['url_yandex_market'];
  32. } else {
  33. $data['error_url_yandex_market'] = array();
  34. }
  35. if (isset($this->error['url_megamarket'])) {
  36. $data['error_url_megamarket'] = $this->error['url_megamarket'];
  37. } else {
  38. $data['error_url_megamarket'] = array();
  39. }
  40. ]]>
  41. </add>
  42. </operation>
  43. <operation>
  44. <search>
  45. <![CDATA[
  46. if (isset($this->request->post['model'])) {
  47. ]]>
  48. </search>
  49. <add position="before">
  50. <![CDATA[
  51. if (isset($this->request->post['url_ozon'])) {
  52. $data['url_ozon'] = $this->request->post['url_ozon'];
  53. } elseif (!empty($product_info)) {
  54. $data['url_ozon'] = $product_info['url_ozon'];
  55. } else {
  56. $data['url_ozon'] = '';
  57. }
  58. if (isset($this->request->post['url_wildberries'])) {
  59. $data['url_wildberries'] = $this->request->post['url_wildberries'];
  60. } elseif (!empty($product_info)) {
  61. $data['url_wildberries'] = $product_info['url_wildberries'];
  62. } else {
  63. $data['url_wildberries'] = '';
  64. }
  65. if (isset($this->request->post['url_yandex_market'])) {
  66. $data['url_yandex_market'] = $this->request->post['url_yandex_market'];
  67. } elseif (!empty($product_info)) {
  68. $data['url_yandex_market'] = $product_info['url_yandex_market'];
  69. } else {
  70. $data['url_yandex_market'] = '';
  71. }
  72. if (isset($this->request->post['url_megamarket'])) {
  73. $data['url_megamarket'] = $this->request->post['url_megamarket'];
  74. } elseif (!empty($product_info)) {
  75. $data['url_megamarket'] = $product_info['url_megamarket'];
  76. } else {
  77. $data['url_megamarket'] = '';
  78. }
  79. ]]>
  80. </add>
  81. </operation>
  82. <operation>
  83. <search>
  84. <![CDATA[
  85. if ($this->error && !isset($this->error['warning'])) {
  86. ]]>
  87. </search>
  88. <add position="before">
  89. <![CDATA[
  90. $url_pattern = '/^((ftp|http|https):\/\/)?(www\.)?([A-Za-zА-Яа-я0-9]{1}[A-Za-zА-Яа-я0-9\-]*\.?)*\.{1}[A-Za-zА-Яа-я0-9-]{2,8}(\/([\w#!:.?+=&%@!\-\/])*)?/';
  91. if (!empty($this->request->post['url_ozon']) && !preg_match($url_pattern, $this->request->post['url_ozon'])) {
  92. $this->error['url_ozon'] = $this->language->get('error_invalid_url');
  93. }
  94. if (!empty($this->request->post['url_wildberries']) && !preg_match($url_pattern, $this->request->post['url_wildberries'])) {
  95. $this->error['url_wildberries'] = $this->language->get('error_invalid_url');
  96. }
  97. if (!empty($this->request->post['url_yandex_market']) && !preg_match($url_pattern, $this->request->post['url_yandex_market'])) {
  98. $this->error['url_yandex_market'] = $this->language->get('error_invalid_url');
  99. }
  100. if (!empty($this->request->post['url_megamarket']) && !preg_match($url_pattern, $this->request->post['url_megamarket'])) {
  101. $this->error['url_megamarket'] = $this->language->get('error_invalid_url');
  102. }
  103. ]]>
  104. </add>
  105. </operation>
  106. </file>
  107. <file path="admin/model/catalog/product.php">
  108. <operation>
  109. <search>
  110. <![CDATA[
  111. if (isset($data['image'])) {
  112. ]]>
  113. </search>
  114. <add position="before">
  115. <![CDATA[
  116. if (isset($data['url_ozon']) || isset($data['url_wildberries']) || isset($data['url_yandex_market']) || isset($data['url_megamarket'])) {
  117. $this->db->query("UPDATE ". DB_PREFIX . "product SET url_ozon = '" . $this->db->escape($data['url_ozon']) . "', url_wildberries = '" . $this->db->escape($data['url_wildberries']) . "', url_yandex_market = '" . $this->db->escape($data['url_yandex_market']) . "', url_megamarket = '" . $this->db->escape($data['url_megamarket']) . "' WHERE product_id = '" . (int)$product_id . "'");
  118. }
  119. ]]>
  120. </add>
  121. </operation>
  122. </file>
  123. <file path="admin/view/template/catalog/product_form.twig">
  124. <operation>
  125. <search>
  126. <![CDATA[
  127. <div class="tab-pane" id="tab-links">
  128. ]]>
  129. </search>
  130. <add position="before" offset="1">
  131. <![CDATA[
  132. {% if module_links_to_marketplaces_status %}
  133. {% if module_links_to_marketplaces.ozon.show or module_links_to_marketplaces.wildberries.show or module_links_to_marketplaces.yandex_market.show or module_links_to_marketplaces.megamarket.show %}
  134. <fieldset>
  135. <legend>{{ entry_links_to_marketplace }}</legend>
  136. {% if module_links_to_marketplaces.ozon.show %}
  137. <div class="form-group">
  138. <label class="col-sm-2 control-label" for="input-url-ozon">{{ entry_ozon }}</label>
  139. <div class="col-sm-10">
  140. <input type="url" name="url_ozon" value="{{ url_ozon }}" placeholder="{{ entry_ozon }}" id="input-url-ozon" class="form-control" />
  141. {% if error_url_ozon %}
  142. <div class="text-danger">{{ error_url_ozon }}</div>
  143. {% endif %}
  144. </div>
  145. </div>
  146. {% endif %}
  147. {% if module_links_to_marketplaces.wildberries.show %}
  148. <div class="form-group">
  149. <label class="col-sm-2 control-label" for="input-url-wildberries">{{ entry_wildberries }}</label>
  150. <div class="col-sm-10">
  151. <input type="url" name="url_wildberries" value="{{ url_wildberries }}" placeholder="{{ entry_wildberries }}" id="input-url-wildberries" class="form-control" />
  152. {% if error_url_wildberries %}
  153. <div class="text-danger">{{ error_url_wildberries }}</div>
  154. {% endif %}
  155. </div>
  156. </div>
  157. {% endif %}
  158. {% if module_links_to_marketplaces.yandex_market.show %}
  159. <div class="form-group">
  160. <label class="col-sm-2 control-label" for="input-url-yandex-market">{{ entry_yandex_market }}</label>
  161. <div class="col-sm-10">
  162. <input type="url" name="url_yandex_market" value="{{ url_yandex_market }}" placeholder="{{ entry_yandex_market }}" id="input-url-yandex-market" class="form-control" />
  163. {% if error_url_yandex_market %}
  164. <div class="text-danger">{{ error_url_yandex_market }}</div>
  165. {% endif %}
  166. </div>
  167. </div>
  168. {% endif %}
  169. {% if module_links_to_marketplaces.megamarket.show %}
  170. <div class="form-group">
  171. <label class="col-sm-2 control-label" for="input-url-megamarket">{{ entry_megamarket }}</label>
  172. <div class="col-sm-10">
  173. <input type="url" name="url_megamarket" value="{{ url_megamarket }}" placeholder="{{ entry_megamarket }}" id="input-url-megamarket" class="form-control" />
  174. {% if error_url_megamarket %}
  175. <div class="text-danger">{{ error_url_megamarket }}</div>
  176. {% endif %}
  177. </div>
  178. </div>
  179. {% endif %}
  180. </fieldset>
  181. {% endif %}
  182. {% endif %}
  183. ]]>
  184. </add>
  185. </operation>
  186. </file>
  187. <file path="admin/language/en-gb/catalog/product.php">
  188. <operation>
  189. <search>
  190. <![CDATA[
  191. <?php
  192. ]]>
  193. </search>
  194. <add position="after">
  195. <![CDATA[
  196. $_['entry_links_to_marketplace'] = 'Links to marketplaces';
  197. $_['entry_ozon'] = 'Ozon';
  198. $_['entry_wildberries'] = 'Wildberries';
  199. $_['entry_yandex_market'] = 'Yandex.Market';
  200. $_['entry_megamarket'] = 'Megamarket';
  201. $_['error_invalid_url'] = 'Invalid url';
  202. ]]>
  203. </add>
  204. </operation>
  205. </file>
  206. <file path="catalog/controller/product/product.php">
  207. <operation>
  208. <search>
  209. <![CDATA[
  210. $data['column_left'] = $this->load->controller('common/column_left');
  211. ]]>
  212. </search>
  213. <add position="before">
  214. <![CDATA[
  215. $this->document->addStyle('catalog/view/theme/default/stylesheet/links_to_marketplaces.css');
  216. ]]>
  217. </add>
  218. </operation>
  219. <operation>
  220. <search>
  221. <![CDATA[
  222. $this->response->setOutput($this->load->view('product/product', $data));
  223. ]]>
  224. </search>
  225. <add position="before">
  226. <![CDATA[
  227. $data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);
  228. $data['url_ozon'] = !empty($product_info['url_ozon']) ? $product_info['url_ozon'] : '';
  229. $data['url_wildberries'] = !empty($product_info['url_wildberries']) ? $product_info['url_wildberries'] : '';
  230. $data['url_yandex_market'] = !empty($product_info['url_yandex_market']) ? $product_info['url_yandex_market'] : '';
  231. $data['url_megamarket'] = !empty($product_info['url_megamarket']) ? $product_info['url_megamarket'] : '';
  232. $data['module_links_to_marketplaces_status'] = $this->config->get('module_links_to_marketplaces_status');
  233. $data['module_links_to_marketplaces'] = $this->config->get('module_links_to_marketplaces');
  234. if (!empty($data['module_links_to_marketplaces']) && count($data['module_links_to_marketplaces'])) {
  235. foreach($data['module_links_to_marketplaces'] as $key => $linkData) {
  236. if (!empty($data['module_links_to_marketplaces'][$key]['image'])) {
  237. $data['module_links_to_marketplaces'][$key]['thumb'] = $this->model_tool_image->resize($data['module_links_to_marketplaces'][$key]['image'], $data['module_links_to_marketplaces']['icon']['width'], $data['module_links_to_marketplaces']['icon']['height']);
  238. } else {
  239. $data['module_links_to_marketplaces'][$key]['thumb'] = $data['placeholder'];
  240. }
  241. }
  242. }
  243. ]]>
  244. </add>
  245. </operation>
  246. </file>
  247. <file path="admin/language/ru-ru/catalog/product.php">
  248. <operation>
  249. <search>
  250. <![CDATA[
  251. <?php
  252. ]]>
  253. </search>
  254. <add position="after">
  255. <![CDATA[
  256. $_['entry_links_to_marketplace'] = 'Ссылки на маркетплейсы';
  257. $_['entry_ozon'] = 'Ozon';
  258. $_['entry_wildberries'] = 'Wildberries';
  259. $_['entry_yandex_market'] = 'Yandex.Market';
  260. $_['entry_megamarket'] = 'Megamarket';
  261. $_['error_invalid_url'] = 'Некорректная ссылка';
  262. ]]>
  263. </add>
  264. </operation>
  265. </file>
  266. <file path="catalog/model/catalog/product.php">
  267. <operation>
  268. <search>
  269. <![CDATA[
  270. 'date_modified' => $query->row['date_modified'],
  271. ]]>
  272. </search>
  273. <add position="after">
  274. <![CDATA[
  275. 'url_ozon' => $query->row['url_ozon'],
  276. 'url_wildberries' => $query->row['url_wildberries'],
  277. 'url_yandex_market' => $query->row['url_yandex_market'],
  278. 'url_megamarket' => $query->row['url_megamarket'],
  279. ]]>
  280. </add>
  281. </operation>
  282. </file>
  283. <file path="catalog/view/theme/*/template/product/product.twig">
  284. <operation>
  285. <search>
  286. <![CDATA[
  287. <ul class="nav nav-tabs">
  288. ]]>
  289. </search>
  290. <add position="before">
  291. <![CDATA[
  292. {% if module_links_to_marketplaces_status %}
  293. {% if module_links_to_marketplaces.ozon.show or module_links_to_marketplaces.wildberries.show or module_links_to_marketplaces.yandex_market.show or module_links_to_marketplaces.megamarket.show %}
  294. <div class="marketplaces">
  295. {% if module_links_to_marketplaces.ozon.show and url_ozon %}
  296. <div class="marketplaces__item">
  297. <a href="{{ url_ozon }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.ozon.thumb }}" alt="" /></a>
  298. </div>
  299. {% endif %}
  300. {% if module_links_to_marketplaces.wildberries.show and url_wildberries %}
  301. <div class="marketplaces__item">
  302. <a href="{{ url_wildberries }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.wildberries.thumb }}" alt="" /></a>
  303. </div>
  304. {% endif %}
  305. {% if module_links_to_marketplaces.yandex_market.show and url_yandex_market %}
  306. <div class="marketplaces__item">
  307. <a href="{{ url_yandex_market }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.yandex_market.thumb }}" alt="" /></a>
  308. </div>
  309. {% endif %}
  310. {% if module_links_to_marketplaces.megamarket.show and url_megamarket %}
  311. <div class="marketplaces__item">
  312. <a href="{{ url_megamarket }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.megamarket.thumb }}" alt="" /></a>
  313. </div>
  314. {% endif %}
  315. </div>
  316. {% endif %}
  317. {% endif %}
  318. ]]>
  319. </add>
  320. </operation>
  321. </file>
  322. </modification>