| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- <?xml version="1.0" encoding="utf-8"?>
- <modification>
- <name>Links to marketplaces</name>
- <code>links2marketplaces</code>
- <version>1.0.0</version>
- <date>05.08.2024</date>
- <author>Kuzmichev Ruslan</author>
- <link>http://kuzmichev.pw</link>
- <file path="admin/controller/catalog/product.php">
- <operation>
- <search>
- <![CDATA[
- if (isset($this->error['name'])) {
- ]]>
- </search>
- <add position="before">
- <![CDATA[
- $data['module_links_to_marketplaces_status'] = $this->config->get('module_links_to_marketplaces_status');
- $data['module_links_to_marketplaces'] = $this->config->get('module_links_to_marketplaces');
- if (isset($this->error['url_ozon'])) {
- $data['error_url_ozon'] = $this->error['url_ozon'];
- } else {
- $data['error_url_ozon'] = array();
- }
- if (isset($this->error['url_wildberries'])) {
- $data['error_url_wildberries'] = $this->error['url_wildberries'];
- } else {
- $data['error_url_wildberries'] = array();
- }
- if (isset($this->error['url_yandex_market'])) {
- $data['error_url_yandex_market'] = $this->error['url_yandex_market'];
- } else {
- $data['error_url_yandex_market'] = array();
- }
- if (isset($this->error['url_megamarket'])) {
- $data['error_url_megamarket'] = $this->error['url_megamarket'];
- } else {
- $data['error_url_megamarket'] = array();
- }
- ]]>
- </add>
- </operation>
- <operation>
- <search>
- <![CDATA[
- if (isset($this->request->post['model'])) {
- ]]>
- </search>
- <add position="before">
- <![CDATA[
- if (isset($this->request->post['url_ozon'])) {
- $data['url_ozon'] = $this->request->post['url_ozon'];
- } elseif (!empty($product_info)) {
- $data['url_ozon'] = $product_info['url_ozon'];
- } else {
- $data['url_ozon'] = '';
- }
- if (isset($this->request->post['url_wildberries'])) {
- $data['url_wildberries'] = $this->request->post['url_wildberries'];
- } elseif (!empty($product_info)) {
- $data['url_wildberries'] = $product_info['url_wildberries'];
- } else {
- $data['url_wildberries'] = '';
- }
- if (isset($this->request->post['url_yandex_market'])) {
- $data['url_yandex_market'] = $this->request->post['url_yandex_market'];
- } elseif (!empty($product_info)) {
- $data['url_yandex_market'] = $product_info['url_yandex_market'];
- } else {
- $data['url_yandex_market'] = '';
- }
- if (isset($this->request->post['url_megamarket'])) {
- $data['url_megamarket'] = $this->request->post['url_megamarket'];
- } elseif (!empty($product_info)) {
- $data['url_megamarket'] = $product_info['url_megamarket'];
- } else {
- $data['url_megamarket'] = '';
- }
- ]]>
- </add>
- </operation>
- <operation>
- <search>
- <![CDATA[
- if ($this->error && !isset($this->error['warning'])) {
- ]]>
- </search>
- <add position="before">
- <![CDATA[
- $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#!:.?+=&%@!\-\/])*)?/';
- if (!empty($this->request->post['url_ozon']) && !preg_match($url_pattern, $this->request->post['url_ozon'])) {
- $this->error['url_ozon'] = $this->language->get('error_invalid_url');
- }
- if (!empty($this->request->post['url_wildberries']) && !preg_match($url_pattern, $this->request->post['url_wildberries'])) {
- $this->error['url_wildberries'] = $this->language->get('error_invalid_url');
- }
- if (!empty($this->request->post['url_yandex_market']) && !preg_match($url_pattern, $this->request->post['url_yandex_market'])) {
- $this->error['url_yandex_market'] = $this->language->get('error_invalid_url');
- }
- if (!empty($this->request->post['url_megamarket']) && !preg_match($url_pattern, $this->request->post['url_megamarket'])) {
- $this->error['url_megamarket'] = $this->language->get('error_invalid_url');
- }
- ]]>
- </add>
- </operation>
- </file>
- <file path="admin/model/catalog/product.php">
- <operation>
- <search>
- <![CDATA[
- if (isset($data['image'])) {
- ]]>
- </search>
- <add position="before">
- <![CDATA[
- if (isset($data['url_ozon']) || isset($data['url_wildberries']) || isset($data['url_yandex_market']) || isset($data['url_megamarket'])) {
- $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 . "'");
- }
- ]]>
- </add>
- </operation>
- </file>
- <file path="admin/view/template/catalog/product_form.twig">
- <operation>
- <search>
- <![CDATA[
- <div class="tab-pane" id="tab-links">
- ]]>
- </search>
- <add position="before" offset="1">
- <![CDATA[
- {% if module_links_to_marketplaces_status %}
- {% 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 %}
- <fieldset>
- <legend>{{ entry_links_to_marketplace }}</legend>
- {% if module_links_to_marketplaces.ozon.show %}
- <div class="form-group">
- <label class="col-sm-2 control-label" for="input-url-ozon">{{ entry_ozon }}</label>
- <div class="col-sm-10">
- <input type="url" name="url_ozon" value="{{ url_ozon }}" placeholder="{{ entry_ozon }}" id="input-url-ozon" class="form-control" />
- {% if error_url_ozon %}
- <div class="text-danger">{{ error_url_ozon }}</div>
- {% endif %}
- </div>
- </div>
- {% endif %}
- {% if module_links_to_marketplaces.wildberries.show %}
- <div class="form-group">
- <label class="col-sm-2 control-label" for="input-url-wildberries">{{ entry_wildberries }}</label>
- <div class="col-sm-10">
- <input type="url" name="url_wildberries" value="{{ url_wildberries }}" placeholder="{{ entry_wildberries }}" id="input-url-wildberries" class="form-control" />
- {% if error_url_wildberries %}
- <div class="text-danger">{{ error_url_wildberries }}</div>
- {% endif %}
- </div>
- </div>
- {% endif %}
- {% if module_links_to_marketplaces.yandex_market.show %}
- <div class="form-group">
- <label class="col-sm-2 control-label" for="input-url-yandex-market">{{ entry_yandex_market }}</label>
- <div class="col-sm-10">
- <input type="url" name="url_yandex_market" value="{{ url_yandex_market }}" placeholder="{{ entry_yandex_market }}" id="input-url-yandex-market" class="form-control" />
- {% if error_url_yandex_market %}
- <div class="text-danger">{{ error_url_yandex_market }}</div>
- {% endif %}
- </div>
- </div>
- {% endif %}
- {% if module_links_to_marketplaces.megamarket.show %}
- <div class="form-group">
- <label class="col-sm-2 control-label" for="input-url-megamarket">{{ entry_megamarket }}</label>
- <div class="col-sm-10">
- <input type="url" name="url_megamarket" value="{{ url_megamarket }}" placeholder="{{ entry_megamarket }}" id="input-url-megamarket" class="form-control" />
- {% if error_url_megamarket %}
- <div class="text-danger">{{ error_url_megamarket }}</div>
- {% endif %}
- </div>
- </div>
- {% endif %}
- </fieldset>
- {% endif %}
- {% endif %}
- ]]>
- </add>
- </operation>
- </file>
- <file path="admin/language/en-gb/catalog/product.php">
- <operation>
- <search>
- <![CDATA[
- <?php
- ]]>
- </search>
- <add position="after">
- <![CDATA[
- $_['entry_links_to_marketplace'] = 'Links to marketplaces';
- $_['entry_ozon'] = 'Ozon';
- $_['entry_wildberries'] = 'Wildberries';
- $_['entry_yandex_market'] = 'Yandex.Market';
- $_['entry_megamarket'] = 'Megamarket';
- $_['error_invalid_url'] = 'Invalid url';
- ]]>
- </add>
- </operation>
- </file>
- <file path="catalog/controller/product/product.php">
- <operation>
- <search>
- <![CDATA[
- $data['column_left'] = $this->load->controller('common/column_left');
- ]]>
- </search>
- <add position="before">
- <![CDATA[
- $this->document->addStyle('catalog/view/theme/default/stylesheet/links_to_marketplaces.css');
- ]]>
- </add>
- </operation>
- <operation>
- <search>
- <![CDATA[
- $this->response->setOutput($this->load->view('product/product', $data));
- ]]>
- </search>
- <add position="before">
- <![CDATA[
- $data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);
- $data['url_ozon'] = !empty($product_info['url_ozon']) ? $product_info['url_ozon'] : '';
- $data['url_wildberries'] = !empty($product_info['url_wildberries']) ? $product_info['url_wildberries'] : '';
- $data['url_yandex_market'] = !empty($product_info['url_yandex_market']) ? $product_info['url_yandex_market'] : '';
- $data['url_megamarket'] = !empty($product_info['url_megamarket']) ? $product_info['url_megamarket'] : '';
- $data['module_links_to_marketplaces_status'] = $this->config->get('module_links_to_marketplaces_status');
- $data['module_links_to_marketplaces'] = $this->config->get('module_links_to_marketplaces');
- if (!empty($data['module_links_to_marketplaces']) && count($data['module_links_to_marketplaces'])) {
- foreach($data['module_links_to_marketplaces'] as $key => $linkData) {
- if (!empty($data['module_links_to_marketplaces'][$key]['image'])) {
- $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']);
- } else {
- $data['module_links_to_marketplaces'][$key]['thumb'] = $data['placeholder'];
- }
- }
- }
- ]]>
- </add>
- </operation>
- </file>
- <file path="admin/language/ru-ru/catalog/product.php">
- <operation>
- <search>
- <![CDATA[
- <?php
- ]]>
- </search>
- <add position="after">
- <![CDATA[
- $_['entry_links_to_marketplace'] = 'Ссылки на маркетплейсы';
- $_['entry_ozon'] = 'Ozon';
- $_['entry_wildberries'] = 'Wildberries';
- $_['entry_yandex_market'] = 'Yandex.Market';
- $_['entry_megamarket'] = 'Megamarket';
- $_['error_invalid_url'] = 'Некорректная ссылка';
- ]]>
- </add>
- </operation>
- </file>
- <file path="catalog/model/catalog/product.php">
- <operation>
- <search>
- <![CDATA[
- 'date_modified' => $query->row['date_modified'],
- ]]>
- </search>
- <add position="after">
- <![CDATA[
- 'url_ozon' => $query->row['url_ozon'],
- 'url_wildberries' => $query->row['url_wildberries'],
- 'url_yandex_market' => $query->row['url_yandex_market'],
- 'url_megamarket' => $query->row['url_megamarket'],
- ]]>
- </add>
- </operation>
- </file>
- <file path="catalog/view/theme/*/template/product/product.twig">
- <operation>
- <search>
- <![CDATA[
- <ul class="nav nav-tabs">
- ]]>
- </search>
- <add position="before">
- <![CDATA[
- {% if module_links_to_marketplaces_status %}
- {% 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 %}
- <div class="marketplaces">
- {% if module_links_to_marketplaces.ozon.show and url_ozon %}
- <div class="marketplaces__item">
- <a href="{{ url_ozon }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.ozon.thumb }}" alt="" /></a>
- </div>
- {% endif %}
- {% if module_links_to_marketplaces.wildberries.show and url_wildberries %}
- <div class="marketplaces__item">
- <a href="{{ url_wildberries }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.wildberries.thumb }}" alt="" /></a>
- </div>
- {% endif %}
- {% if module_links_to_marketplaces.yandex_market.show and url_yandex_market %}
- <div class="marketplaces__item">
- <a href="{{ url_yandex_market }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.yandex_market.thumb }}" alt="" /></a>
- </div>
- {% endif %}
- {% if module_links_to_marketplaces.megamarket.show and url_megamarket %}
- <div class="marketplaces__item">
- <a href="{{ url_megamarket }}" target="_blank" class="marketplaces__link"><img src="{{ module_links_to_marketplaces.megamarket.thumb }}" alt="" /></a>
- </div>
- {% endif %}
- </div>
- {% endif %}
- {% endif %}
- ]]>
- </add>
- </operation>
- </file>
- </modification>
|