Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions upload/admin/controller/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public function edit() {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_search'])) {
$url .= '&filter_search=' . urlencode(html_entity_decode($this->request->get['filter_search'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
Expand Down Expand Up @@ -208,6 +212,10 @@ public function delete() {
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_search'])) {
$url .= '&filter_search=' . urlencode(html_entity_decode($this->request->get['filter_search'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
Expand Down Expand Up @@ -294,6 +302,10 @@ public function copy() {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_search'])) {
$url .= '&filter_search=' . urlencode(html_entity_decode($this->request->get['filter_search'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
Expand Down Expand Up @@ -366,6 +378,12 @@ protected function getList() {
$filter_name = '';
}

if (isset($this->request->get['filter_search'])) {
$filter_search = $this->request->get['filter_search'];
} else {
$filter_search = '';
}

if (isset($this->request->get['filter_model'])) {
$filter_model = $this->request->get['filter_model'];
} else {
Expand Down Expand Up @@ -523,6 +541,10 @@ protected function getList() {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_search'])) {
$url .= '&filter_search=' . urlencode(html_entity_decode($this->request->get['filter_search'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
Expand Down Expand Up @@ -600,6 +622,7 @@ protected function getList() {

$filter_data = array(
'filter_name' => $filter_name,
'filter_search' => $filter_search,
'filter_model' => $filter_model,
'filter_price' => $filter_price,
'filter_price_min'=> $filter_price_min,
Expand Down Expand Up @@ -686,6 +709,10 @@ protected function getList() {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_search'])) {
$url .= '&filter_search=' . urlencode(html_entity_decode($this->request->get['filter_search'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
Expand Down Expand Up @@ -757,6 +784,10 @@ protected function getList() {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_search'])) {
$url .= '&filter_search=' . urlencode(html_entity_decode($this->request->get['filter_search'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
Expand Down Expand Up @@ -823,6 +854,7 @@ protected function getList() {
$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($product_total - $this->config->get('config_limit_admin'))) ? $product_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $product_total, ceil($product_total / $this->config->get('config_limit_admin')));

$data['filter_name'] = $filter_name;
$data['filter_search'] = $filter_search;
$data['filter_model'] = $filter_model;
$data['filter_price'] = $filter_price;
$data['filter_price_min'] = $filter_price_min;
Expand Down Expand Up @@ -893,6 +925,10 @@ protected function getForm() {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_search'])) {
$url .= '&filter_search=' . urlencode(html_entity_decode($this->request->get['filter_search'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_model'])) {
$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
}
Expand Down
1 change: 1 addition & 0 deletions upload/admin/language/en-gb/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$_['column_status'] = 'Status';
$_['column_noindex'] = 'Index';
$_['column_action'] = 'Action';
$_ ['entry_search'] = 'Search';
$_['entry_name'] = 'Product Name';
$_['entry_description'] = 'Description';
$_['entry_meta_title'] = 'Meta Tag Title';
Expand Down
1 change: 1 addition & 0 deletions upload/admin/language/ru-ru/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$_['column_status'] = 'Статус';
$_['column_noindex'] = 'Индексация';
$_['column_action'] = 'Действие';
$_['entry_search'] = 'Поиск';
$_['entry_name'] = 'Название товара';
$_['entry_description'] = 'Описание';
$_['entry_description_mini'] = '';
Expand Down
86 changes: 86 additions & 0 deletions upload/admin/model/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,49 @@ public function getProducts($data = array()) {
$sql .= " AND pd.name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}

if (!empty($data['filter_search'])) {
$sql .= " AND (";

$implode = [];

$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_search'])));

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_search']) . "%'";
}

$sql .= " OR ";

$implode = [];

$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_search'])));

foreach ($words as $word) {
$implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'";
}

if ($implode) {
$sql .= " " . implode(" AND ", $implode) . "";
}

$sql .= " OR LCASE(p.model) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.upc) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.ean) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.jan) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.isbn) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.mpn) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= ")";
}

if (!empty($data['filter_model'])) {
$sql .= " AND p.model LIKE '%" . $this->db->escape($data['filter_model']) . "%'";
}
Expand Down Expand Up @@ -789,6 +832,49 @@ public function getTotalProducts($data = array()) {
$sql .= " AND pd.name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
}

if (!empty($data['filter_search'])) {
$sql .= " AND (";

$implode = [];

$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_search'])));

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_search']) . "%'";
}

$sql .= " OR ";

$implode = [];

$words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_search'])));

foreach ($words as $word) {
$implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'";
}

if ($implode) {
$sql .= " " . implode(" AND ", $implode) . "";
}

$sql .= " OR LCASE(p.model) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.upc) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.ean) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.jan) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.isbn) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= " OR LCASE(p.mpn) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_search'])) . "%'";
$sql .= ")";
}

if (!empty($data['filter_model'])) {
$sql .= " AND p.model LIKE '%" . $this->db->escape($data['filter_model']) . "%'";
}
Expand Down
24 changes: 22 additions & 2 deletions upload/admin/view/template/catalog/product_list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
<h3 class="panel-title"><i class="fa fa-filter"></i> {{ text_filter }}</h3>
</div>
<div class="panel-body">
<div class="form-group">
<label class="control-label" for="input-search">{{ entry_search }}</label>
<div class="input-group">
<input type="text" name="filter_search" value="{{ filter_search }}" placeholder="{{ entry_search }}" id="input-search" class="form-control" />
<div class="input-group-btn">
<button type="button" id="button-clear-input-search" class="btn btn-default"><i class="fa fa-times"></i></button>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label" for="input-name">{{ entry_name }}</label>
<div class="input-group">
Expand Down Expand Up @@ -269,6 +278,12 @@
url += '&filter_name=' + encodeURIComponent(filter_name);
}

var filter_search = $('input[name=\'filter_search\']').val();

if (filter_search) {
url += '&filter_search=' + encodeURIComponent(filter_search);
}

var filter_model = $('input[name=\'filter_model\']').val();

if (filter_model) {
Expand Down Expand Up @@ -297,7 +312,7 @@

if (filter_quantity_max) {
url += '&filter_quantity_max=' + encodeURIComponent(filter_quantity_max);
}
}

var filter_status = $('select[name=\'filter_status\']').val();

Expand Down Expand Up @@ -341,7 +356,12 @@
$('button[form=\'form-product\']').on('click', function(e) {
$('#form-product').attr('action', $(this).attr('formaction'));
});


$('#button-clear-input-search').on('click',function(){
$('input[name=\'filter_search\']').val('');
$('#button-filter').trigger('click');
});

$('input[name=\'filter_name\']').autocomplete({
'source': function(request, response) {
$.ajax({
Expand Down