From 2aba593aa333e9f3c47cb8fbd9f225fd24720b2b Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 31 May 2026 11:17:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B8=D1=81=D0=BA=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/store/controller/common/header.php | 1 + public/store/controller/product/search.php | 98 ++++++- .../store/language/ru-ru/product/search.php | 15 +- public/store/model/catalog/product.php | 193 ++++++------ .../view/theme/dominik/assets/css/main.css | 193 ++++++++++++ .../view/theme/dominik/assets/js/script.js | 53 +++- .../theme/dominik/template/common/header.twig | 5 + .../dominik/template/product/search.twig | 275 +++++------------- 8 files changed, 509 insertions(+), 324 deletions(-) diff --git a/public/store/controller/common/header.php b/public/store/controller/common/header.php index fff97bd..7801e2b 100644 --- a/public/store/controller/common/header.php +++ b/public/store/controller/common/header.php @@ -90,6 +90,7 @@ foreach(['name','email','telephone','address','open', 'comment'] as $item){ $data['shopping_cart'] = $this->url->link('checkout/cart'); $data['checkout'] = $this->url->link('checkout/checkout', '', true); $data['contact'] = $this->url->link('information/contact'); + $data['search_url'] = $this->url->link('product/search'); $data['telephone'] = $this->config->get('config_telephone'); $data['language'] = $this->load->controller('common/language'); diff --git a/public/store/controller/product/search.php b/public/store/controller/product/search.php index 7825bdd..610e59a 100644 --- a/public/store/controller/product/search.php +++ b/public/store/controller/product/search.php @@ -1,14 +1,100 @@ load->model('catalog/category'); + $this->load->language('product/search'); + $this->load->model('catalog/product'); + $this->load->model('tool/image'); - $categories = $this->model_catalog_category->getCategories(0); + $search = isset($this->request->get['search']) ? trim((string)$this->request->get['search']) : ''; + $search = utf8_substr($search, 0, 120); + $page = isset($this->request->get['page']) ? max(1, (int)$this->request->get['page']) : 1; + $limit = (int)$this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'); - if ($categories) { - $this->response->redirect($this->url->link('product/category', 'path=' . $categories[0]['category_id'])); - } else { - $this->response->redirect($this->url->link('common/home')); + if ($limit < 1) { + $limit = 12; } + + $this->document->setTitle($search ? sprintf($this->language->get('heading_results'), $search) : $this->language->get('heading_title')); + $this->document->setRobots('noindex,follow'); + + $data['breadcrumbs'] = array( + array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/home') + ), + array( + 'text' => $this->language->get('heading_title'), + 'href' => $this->url->link('product/search') + ) + ); + + $data['heading_title'] = $this->language->get('heading_title'); + $data['text_search_eyebrow'] = $this->language->get('text_search_eyebrow'); + $data['text_search_hint'] = $this->language->get('text_search_hint'); + $data['text_search_results'] = $this->language->get('text_search_results'); + $data['text_search_for'] = $this->language->get('text_search_for'); + $data['text_found'] = $this->language->get('text_found'); + $data['text_start_search'] = $this->language->get('text_start_search'); + $data['text_search_note'] = $this->language->get('text_search_note'); + $data['text_empty'] = $this->language->get('text_empty'); + $data['text_empty_hint'] = $this->language->get('text_empty_hint'); + $data['text_keyword'] = $this->language->get('text_keyword'); + $data['entry_search'] = $this->language->get('entry_search'); + $data['button_search'] = $this->language->get('button_search'); + $data['price_prefix'] = $this->language->get('price_prefix'); + $data['search'] = $search; + $data['search_url'] = $this->url->link('product/search'); + $data['products'] = array(); + $data['product_total'] = 0; + $data['pagination'] = ''; + $data['results'] = ''; + + if ($search !== '') { + $filter_data = array( + 'filter_name' => $search, + 'sort' => 'relevance', + 'order' => 'DESC', + 'start' => ($page - 1) * $limit, + 'limit' => $limit + ); + + $data['product_total'] = $this->model_catalog_product->getTotalProducts($filter_data); + $results = $this->model_catalog_product->getProducts($filter_data); + + foreach ($results as $result) { + $image = $this->model_tool_image->resize($result['image'] ? $result['image'] : 'placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height')); + $product_images = $this->model_catalog_product->getProductImages($result['product_id']); + $additional_image = $product_images ? $this->model_tool_image->resize($product_images[0]['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height')) : false; + + $data['products'][] = array( + 'product_id' => $result['product_id'], + 'thumb' => $image, + 'additional_thumb' => $additional_image, + 'price_n' => $result['price'], + 'price_2' => $this->currency->format($this->tax->calculate($result['price_2'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), + 'price_2_n' => $result['price_2'], + 'price_3' => $this->currency->format($this->tax->calculate($result['price_3'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), + 'name' => $result['name'], + 'min_price' => $this->currency->format($this->tax->calculate(min(array($result['price'], $result['price_2'])), $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), + 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) + ); + } + + $pagination = new Pagination(); + $pagination->total = $data['product_total']; + $pagination->page = $page; + $pagination->limit = $limit; + $pagination->url = $this->url->link('product/search', 'search=' . rawurlencode($search) . '&page={page}'); + + $data['pagination'] = $pagination->render(); + $data['results'] = sprintf($this->language->get('text_pagination'), ($data['product_total']) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($data['product_total'] - $limit)) ? $data['product_total'] : ((($page - 1) * $limit) + $limit), $data['product_total'], ceil($data['product_total'] / $limit)); + } + + $data['content_top'] = $this->load->controller('common/content_top'); + $data['content_bottom'] = $this->load->controller('common/content_bottom'); + $data['footer'] = $this->load->controller('common/footer'); + $data['header'] = $this->load->controller('common/header'); + + $this->response->setOutput($this->load->view('product/search', $data)); } } diff --git a/public/store/language/ru-ru/product/search.php b/public/store/language/ru-ru/product/search.php index f38d870..75bf479 100644 --- a/public/store/language/ru-ru/product/search.php +++ b/public/store/language/ru-ru/product/search.php @@ -4,14 +4,23 @@ // Heading $_['heading_title'] = 'Поиск'; +$_['heading_results'] = 'Поиск: %s'; $_['heading_tag'] = 'По тегу - '; // Text $_['text_search'] = 'Товары, соответствующие критериям поиска'; -$_['text_keyword'] = 'Ключевые слова'; +$_['text_keyword'] = 'Название, модель или характеристика'; +$_['text_search_eyebrow'] = 'Каталог Dominik'; +$_['text_search_hint'] = 'Найдите нужную модель по названию, артикулу или характеристикам.'; +$_['text_search_results'] = 'Результаты поиска'; +$_['text_search_for'] = 'По запросу «%s»'; +$_['text_found'] = 'Найдено товаров: %d'; +$_['text_start_search'] = 'Что будем искать?'; +$_['text_search_note'] = 'Например: кружево, длинный рукав или название модели.'; +$_['text_empty_hint'] = 'Попробуйте изменить запрос: сократить его или проверить написание.'; $_['text_category'] = 'Все категории'; $_['text_sub_category'] = 'Поиск в подкатегориях'; -$_['text_empty'] = 'Нет товаров, которые соответствуют критериям поиска.'; +$_['text_empty'] = 'По вашему запросу ничего не найдено'; $_['text_quantity'] = 'Кол-во:'; $_['text_manufacturer'] = 'Производитель:'; $_['text_model'] = 'Код Товара:'; @@ -35,4 +44,4 @@ $_['text_benefits'] = 'Преимущества:'; // Entry $_['entry_search'] = 'Поиск'; -$_['entry_description'] = 'Искать в описании товаров'; \ No newline at end of file +$_['entry_description'] = 'Искать в описании товаров'; diff --git a/public/store/model/catalog/product.php b/public/store/model/catalog/product.php index 92c29dc..61664fe 100644 --- a/public/store/model/catalog/product.php +++ b/public/store/model/catalog/product.php @@ -74,6 +74,10 @@ class ModelCatalogProduct extends Model { $sql = 'SELECT p.product_id, (SELECT AVG(rating) AS total FROM ' . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int) $this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (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"; + if (!empty($data['filter_name'])) { + $sql .= ', ' . $this->getSearchRelevanceSql($data['filter_name']) . ' AS relevance'; + } + if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= ' FROM ' . DB_PREFIX . 'category_path cp LEFT JOIN ' . DB_PREFIX . 'product_to_category p2c ON (cp.category_id = p2c.category_id)'; @@ -112,57 +116,7 @@ class ModelCatalogProduct extends Model } } - if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { - $sql .= ' AND ('; - - if (!empty($data['filter_name'])) { - $implode = array(); - - $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); - - foreach ($words as $word) { - $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; - } - - if ($implode) { - $sql .= ' ' . implode(' AND ', $implode) . ''; - } - - if (!empty($data['filter_description'])) { - $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; - } - } - - if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { - $sql .= ' OR '; - } - - if (!empty($data['filter_tag'])) { - $implode = array(); - - $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); - - foreach ($words as $word) { - $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; - } - - if ($implode) { - $sql .= ' ' . implode(' AND ', $implode) . ''; - } - } - - if (!empty($data['filter_name'])) { - $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - } - - $sql .= ')'; - } + $sql .= $this->getSearchConditionSql($data); if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int) $data['filter_manufacturer_id'] . "'"; @@ -177,10 +131,13 @@ class ModelCatalogProduct extends Model 'p.price', 'rating', 'p.sort_order', - 'p.date_added' + 'p.date_added', + 'relevance' ); - if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { + if (isset($data['sort']) && $data['sort'] == 'relevance' && !empty($data['filter_name'])) { + $sql .= ' ORDER BY relevance'; + } elseif (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= ' ORDER BY LCASE(' . $data['sort'] . ')'; } elseif ($data['sort'] == 'p.price') { @@ -501,57 +458,7 @@ class ModelCatalogProduct extends Model } } - if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { - $sql .= ' AND ('; - - if (!empty($data['filter_name'])) { - $implode = array(); - - $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); - - foreach ($words as $word) { - $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; - } - - if ($implode) { - $sql .= ' ' . implode(' AND ', $implode) . ''; - } - - if (!empty($data['filter_description'])) { - $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; - } - } - - if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { - $sql .= ' OR '; - } - - if (!empty($data['filter_tag'])) { - $implode = array(); - - $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); - - foreach ($words as $word) { - $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; - } - - if ($implode) { - $sql .= ' ' . implode(' AND ', $implode) . ''; - } - } - - if (!empty($data['filter_name'])) { - $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; - } - - $sql .= ')'; - } + $sql .= $this->getSearchConditionSql($data); if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int) $data['filter_manufacturer_id'] . "'"; @@ -562,6 +469,84 @@ class ModelCatalogProduct extends Model return $query->row['total']; } + private function getSearchConditionSql($data) + { + $groups = array(); + + if (!empty($data['filter_name'])) { + $conditions = array(); + + foreach ($this->getSearchWords($data['filter_name']) as $word) { + $word = $this->db->escape($word); + $matches = array( + "pd.name LIKE '%" . $word . "%'", + "p.model LIKE '%" . $word . "%'", + "p.sku LIKE '%" . $word . "%'", + "p.upc LIKE '%" . $word . "%'", + "p.ean LIKE '%" . $word . "%'", + "p.jan LIKE '%" . $word . "%'", + "p.isbn LIKE '%" . $word . "%'", + "p.mpn LIKE '%" . $word . "%'", + $this->getAttributeMatchSql($word) + ); + + if (!empty($data['filter_description'])) { + $matches[] = "pd.description LIKE '%" . $word . "%'"; + } + + $conditions[] = '(' . implode(' OR ', $matches) . ')'; + } + + if ($conditions) { + $groups[] = '(' . implode(' AND ', $conditions) . ')'; + } + } + + if (!empty($data['filter_tag'])) { + $conditions = array(); + + foreach ($this->getSearchWords($data['filter_tag']) as $word) { + $conditions[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; + } + + if ($conditions) { + $groups[] = '(' . implode(' AND ', $conditions) . ')'; + } + } + + return $groups ? ' AND (' . implode(' OR ', $groups) . ')' : ''; + } + + private function getSearchRelevanceSql($search) + { + $search = utf8_strtolower(trim(preg_replace('/\s+/', ' ', $search))); + $escaped_search = $this->db->escape($search); + $sql = "(CASE WHEN LCASE(pd.name) = '" . $escaped_search . "' THEN 120 WHEN LCASE(pd.name) LIKE '" . $escaped_search . "%' THEN 80 WHEN LCASE(pd.name) LIKE '%" . $escaped_search . "%' THEN 50 ELSE 0 END"; + $sql .= " + CASE WHEN LCASE(p.model) = '" . $escaped_search . "' THEN 110 WHEN LCASE(p.model) LIKE '" . $escaped_search . "%' THEN 70 WHEN LCASE(p.model) LIKE '%" . $escaped_search . "%' THEN 40 ELSE 0 END"; + $sql .= " + CASE WHEN LCASE(p.sku) = '" . $escaped_search . "' OR LCASE(p.upc) = '" . $escaped_search . "' OR LCASE(p.ean) = '" . $escaped_search . "' OR LCASE(p.jan) = '" . $escaped_search . "' OR LCASE(p.isbn) = '" . $escaped_search . "' OR LCASE(p.mpn) = '" . $escaped_search . "' THEN 90 ELSE 0 END"; + + foreach ($this->getSearchWords($search) as $word) { + $word = $this->db->escape($word); + $sql .= " + CASE WHEN pd.name LIKE '%" . $word . "%' THEN 14 ELSE 0 END"; + $sql .= " + CASE WHEN p.model LIKE '%" . $word . "%' THEN 10 ELSE 0 END"; + $sql .= ' + CASE WHEN ' . $this->getAttributeMatchSql($word) . ' THEN 5 ELSE 0 END'; + } + + return $sql . ')'; + } + + private function getAttributeMatchSql($word) + { + $language_id = (int) $this->config->get('config_language_id'); + + return 'EXISTS (SELECT 1 FROM ' . DB_PREFIX . 'product_attribute pa LEFT JOIN ' . DB_PREFIX . "attribute_description ad ON (pa.attribute_id = ad.attribute_id AND ad.language_id = '" . $language_id . "') WHERE pa.product_id = p.product_id AND pa.language_id = '" . $language_id . "' AND (pa.text LIKE '%" . $word . "%' OR ad.name LIKE '%" . $word . "%'))"; + } + + private function getSearchWords($search) + { + return array_filter(explode(' ', trim(preg_replace('/\s+/', ' ', $search))), 'strlen'); + } + public function getProfile($product_id, $recurring_id) { $query = $this->db->query('SELECT * FROM ' . DB_PREFIX . 'recurring r JOIN ' . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int) $product_id . "') WHERE pr.recurring_id = '" . (int) $recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int) $this->config->get('config_customer_group_id') . "'"); diff --git a/public/store/view/theme/dominik/assets/css/main.css b/public/store/view/theme/dominik/assets/css/main.css index 75e1bff..a733937 100644 --- a/public/store/view/theme/dominik/assets/css/main.css +++ b/public/store/view/theme/dominik/assets/css/main.css @@ -97,6 +97,15 @@ header .menu li a { header .menu svg{ } +.header-search__icon, +a:hover .header-search__icon, +a:hover .header-search__icon path { + fill: none !important; +} +a:hover .header-search__icon circle, +a:hover .header-search__icon path { + stroke: var(--color-secondary); +} header .menu>li:first-child { padding-left: 0; @@ -475,6 +484,190 @@ section{ border-color: #000 } +.search-modal__body { + padding: 42px 46px 48px; +} +.search-modal__intro { + max-width: 560px; + margin-bottom: 28px; +} +.search-modal__eyebrow, +.search-page__eyebrow { + display: block; + color: var(--color-dark-gray); + font-size: 11px; + letter-spacing: 0.18em; + line-height: 1.4; + text-transform: uppercase; +} +.search-modal__intro h2 { + margin: 9px 0 8px; + color: #14142b; + font-size: clamp(30px, 4vw, 43px); + font-weight: 400; + line-height: 1.08; +} +.search-modal__intro p { + margin: 0; + color: rgba(20, 20, 43, 0.68); +} +.search-modal__field, +.search-page__form { + display: flex; + border-bottom: 1px solid #14142b; +} +.search-modal__field input, +.search-page__form input { + width: 100%; + padding: 13px 0; + border: 0; + background: transparent; + color: #14142b; + font: inherit; + font-size: 18px; + outline: 0; +} +.search-modal__field button, +.search-page__form button { + display: inline-flex; + flex: 0 0 auto; + gap: 9px; + align-items: center; + padding: 12px 0 12px 18px; + border: 0; + background: transparent; + color: #14142b; + font: inherit; + text-transform: uppercase; +} +.search-modal__field button:hover, +.search-page__form button:hover { + color: var(--color-dark-gray); +} + +.search-page { + min-height: 62vh; + color: #14142b; +} +.search-page__hero { + padding: 34px 0 54px; + background: linear-gradient(180deg, #f8f6f5 0, #fff 100%); +} +.search-page__breadcrumb { + display: flex; + flex-wrap: wrap; + gap: 4px; + padding: 0; + margin: 0 0 42px; + list-style: none; + color: rgba(20, 20, 43, 0.58); + font-size: 14px; +} +.search-page__breadcrumb span { + margin-left: 4px; +} +.search-page__intro { + max-width: 760px; +} +.search-page__intro h1 { + margin: 10px 0 12px; + font-size: clamp(44px, 6.3vw, 88px); + font-weight: 400; + line-height: 1; +} +.search-page__intro p { + margin: 0; + color: rgba(20, 20, 43, 0.68); + font-size: 18px; + line-height: 1.55; +} +.search-page__form { + max-width: 920px; + margin-top: 37px; +} +.search-page__form input { + padding: 17px 0; + font-size: 21px; +} +.search-page__results { + padding: 12px 0 76px; +} +.search-page__summary { + display: flex; + gap: 20px; + align-items: end; + justify-content: space-between; + padding: 28px 0 32px; +} +.search-page__summary h2 { + margin: 8px 0 0; + font-size: clamp(26px, 3vw, 38px); + font-weight: 400; + line-height: 1.15; +} +.search-page__count { + color: rgba(20, 20, 43, 0.58); + white-space: nowrap; +} +.search-page__pagination { + display: flex; + gap: 20px; + align-items: center; + justify-content: space-between; + padding-top: 32px; +} +.search-page__empty { + max-width: 740px; + padding: 52px 0 24px; +} +.search-page__empty h2 { + margin: 0 0 12px; + font-size: clamp(27px, 3vw, 40px); + font-weight: 400; +} +.search-page__empty p { + margin: 0; + color: rgba(20, 20, 43, 0.68); + font-size: 18px; + line-height: 1.55; +} +@media (max-width: 767px) { + .search-modal__body { + padding: 38px 24px 32px; + } + .search-modal__field input, + .search-page__form input { + font-size: 16px; + } + .search-page__hero { + padding: 24px 0 38px; + } + .search-page__breadcrumb { + margin-bottom: 29px; + } + .search-page__intro h1 { + font-size: 50px; + } + .search-page__intro p, + .search-page__empty p { + font-size: 16px; + } + .search-page__form { + margin-top: 27px; + } + .search-page__form button span { + display: none; + } + .search-page__summary, + .search-page__pagination { + display: block; + } + .search-page__count, + .search-page__pagination > div + div { + margin-top: 12px; + } +} + .fav-btn { position: absolute; top: 20px; diff --git a/public/store/view/theme/dominik/assets/js/script.js b/public/store/view/theme/dominik/assets/js/script.js index ca54a3c..42d766d 100644 --- a/public/store/view/theme/dominik/assets/js/script.js +++ b/public/store/view/theme/dominik/assets/js/script.js @@ -1,5 +1,54 @@ - -function NextPage(page, elem, btn){ +function submitProductSearch(form) { + var input = $(form).find('input[name="search"]'); + var search = $.trim(input.val()); + + if (!search) { + input.trigger('focus'); + return false; + } + + var url = $(form).data('search-url'); + var separator = url.indexOf('?') === -1 ? '?' : '&'; + + window.location.href = url + separator + 'search=' + encodeURIComponent(search); + + return false; +} + +function openSearch(el) { + var form = $('
').addClass('search-modal__form').attr('data-search-url', $(el).data('search-url')); + var intro = $('
').append( + 'Каталог Dominik', + '

Найти платье

', + '

Введите название, модель или характеристику.

' + ); + var field = $('
').append( + '', + '' + ); + + form.append(intro, field); + form.on('submit', function() { + return submitProductSearch(this); + }); + + modal.create({ + modal: form, + width: 760, + class: { + 'modal-body': 'search-modal__body' + }, + callback: { + show: function() { + setTimeout(function() { + form.find('input[name="search"]').trigger('focus'); + }, 200); + } + } + }); +} + +function NextPage(page, elem, btn){ console.log(page); /*if(elem){ diff --git a/public/store/view/theme/dominik/template/common/header.twig b/public/store/view/theme/dominik/template/common/header.twig index 6623bf6..6c28c5a 100644 --- a/public/store/view/theme/dominik/template/common/header.twig +++ b/public/store/view/theme/dominik/template/common/header.twig @@ -82,6 +82,11 @@
+ + +{{ content_bottom }} +{{ footer }}