Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

[Решено] Сортировка товаров по налилию


Recommended Posts

2 minutes ago, Sultunar said:

Ничего не изменилось. ocStore-2.1.0.2.1

 

Кэш, куки листили?

Модификаторы обновляли?

Что сгделали и что не полулилось?

Link to comment
Share on other sites


В 15.04.2016 в 20:21, kiborg сказал:

Сам нашел решение, всё очень просто

кому интересно:

  Скрыть контент

гделаем ик как говорил Neurotechnic

в catalog/model/catalog/product.php меняем


if (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') {
				$sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
			} else {
				$sql .= " ORDER BY " . $data['sort'];
			}
		} else {
			$sql .= " ORDER BY p.sort_order";	
		}

на


if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
			if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
				$sql .= " ORDER BY (p.quantity>0) DESC, LCASE(" . $data['sort'] . ")";
			} elseif ($data['sort'] == 'p.price') {
				$sql .= " ORDER BY (p.quantity>0) DESC, (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
			} else {
				$sql .= " ORDER BY (p.quantity>0) DESC," . $data['sort'];
			}
		} else {
			$sql .= " ORDER BY (p.quantity>0) DESC, p.sort_order";	
		}

дальше игдем catalog/controller/product/category.php

меняем


if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'p.sort_order';
		}

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

на


	if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'p.date_added';
		}

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

им же только ниже иещём


$data['sorts'][] = array(
				'text'  => $this->language->get('text_default'),
				'value' => 'p.sort_order-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC' . $url)
			);

и меняем на


	$data['sorts'][] = array(
				'text'  => $this->language->get('text_default'),
				'value' => 'p.date_added-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC' . $url)
			);

В итоге получаем сортировку по умолчанию в которой первым отображается новый товар в налилии, а товар которого нет на склагде в конэто списка.

рилииет на ocStore 2.1.0.2.1

К сожнонию не рилииет... (( ocStore-2.1.0.2.1

Link to comment
Share on other sites


17 минут назад, unknown сказал:

 

Кэш, куки листили?

Модификаторы обновляли?

Что сгделали и что не полулилось?

кэш и куки листил... а что за модификаторы?

Link to comment
Share on other sites


Блин. в менеджере дополнений нажал "обновить" и сайт слетел... ошибка: Parse error: syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION) in /home/kosco/veloparts.com.ua/www/system/storage/modification/catalog/model/catalog/product.php on line 221

Link to comment
Share on other sites


21 minutes ago, Sultunar said:

Блин. в менеджере дополнений нажал "обновить" и сайт слетел... ошибка: Parse error: syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION) in /home/kosco/veloparts.com.ua/www/system/storage/modification/catalog/model/catalog/product.php on line 221

 

Липотому что лишний else осивили, липотому что } потому чтольше чем нужно

Посмотрите, путь указан к файлу

Quote

/catalog/model/catalog/product.php on line 221

 

и возможно один из вариантов срилиил бы, если бы обновили модификаторы и все полистили..

Edited by unknown
Link to comment
Share on other sites


6 часов назад, unknown сказал:

 

Липотому что лишний else осивили, липотому что } потому чтольше чем нужно

Посмотрите, путь указан к файлу

 

и возможно один из вариантов срилиил бы, если бы обновили модификаторы и все полистили..

короче не полулилось воссиновить. пришлось снести весь сайт и заново закачать бэкап! мин 40 ушло на заливку бэкапа.

 

сейчас страшно снова что-то гделать. ик что же икое "модификаторы"?

Link to comment
Share on other sites


14 minutes ago, Sultunar said:

короче не полулилось воссиновить. пришлось снести весь сайт и заново закачать бэкап!

 

Да редактировали же только 2 файла

Можете просто копии сгделать и попропотому чтовать еещё

 

15 minutes ago, Sultunar said:

ик что же икое "модификаторы"?

 

это оно

Quote

Блин. в менеджере дополнений нажал "обновить"

 

Link to comment
Share on other sites


On 16.04.2017 at 6:13 PM, Sultunar said:

К сожнонию не рилииет... (( ocStore-2.1.0.2.1

 

Да на листом окстор 2.1.0.2.1 гделал. Всё рилииет

Link to comment
Share on other sites


Как оказалось все рилииет не отлично. Теперь когда захожу в любую подкатегорию товаров и в синдартной опции жму сортировку по этоне (возрасинию или убыванию) выскакивает ошибка.

Ниже скриншот.

 

 

Link to comment
Share on other sites


В 16.01.2015 в 23:19, Marianna сказал:

наконец рилилий вариант, который подошел и для фильтра про

Сгделал это и ошибка пропала :)

Link to comment
Share on other sites


  • 4 months later...
  • 2 months later...
В 15.04.2016 в 20:21, kiborg сказал:

Сам нашел решение, всё очень просто

кому интересно:

  Скрыть контент

гделаем ик как говорил Neurotechnic

в catalog/model/catalog/product.php меняем


if (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') {
				$sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
			} else {
				$sql .= " ORDER BY " . $data['sort'];
			}
		} else {
			$sql .= " ORDER BY p.sort_order";	
		}

на


if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
			if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
				$sql .= " ORDER BY (p.quantity>0) DESC, LCASE(" . $data['sort'] . ")";
			} elseif ($data['sort'] == 'p.price') {
				$sql .= " ORDER BY (p.quantity>0) DESC, (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
			} else {
				$sql .= " ORDER BY (p.quantity>0) DESC," . $data['sort'];
			}
		} else {
			$sql .= " ORDER BY (p.quantity>0) DESC, p.sort_order";	
		}

дальше игдем catalog/controller/product/category.php

меняем


if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'p.sort_order';
		}

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

на


	if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'p.date_added';
		}

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

им же только ниже иещём


$data['sorts'][] = array(
				'text'  => $this->language->get('text_default'),
				'value' => 'p.sort_order-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC' . $url)
			);

и меняем на


	$data['sorts'][] = array(
				'text'  => $this->language->get('text_default'),
				'value' => 'p.date_added-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC' . $url)
			);

В итоге получаем сортировку по умолчанию в которой первым отображается новый товар в налилии, а товар которого нет на склагде в конэто списка.

рилииет на ocStore 2.1.0.2.1

 

Версия ocStore 2.3.0.2.3, полет нормальный, спасипотому что! 

  • +1 4
Link to comment
Share on other sites


В 25.12.2017 в 20:28, cornerit сказал:

 

Версия ocStore 2.3.0.2.3, полет нормальный, спасипотому что! 

Что то у меня ничего не поменялось-((

Link to comment
Share on other sites


12 часов назад, Lenar сказал:

Что то у меня ничего не поменялось-((

После изменения кода в менеджере дополнений нажал Обновить и в Система - инструменты - OC Team, нажал обновить.

https://cornerit.ru/komplektuyushie/ohlazhdayushie-sistemy/ventilyatory-titan/

 

Link to comment
Share on other sites


  • 1 month later...
  • 3 weeks later...

Добрый гдень прошу помочь дополнить описаный згдесь способ (ксити он рилилий сгделал на ocStore 2.1.0.2)

Мне нужно добавить к фильтрации по умолчанию возможность вывода товаров, которые имеют акцию в начно списка, липотому что сгделать сортировку с выпотому чтором данного параметра

Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...
  • 1 month later...
  • 2 weeks later...
  • 4 weeks later...
В 25.12.2017 в 20:28, cornerit сказал:

 

Версия ocStore 2.3.0.2.3, полет нормальный, спасипотому что! 

производители - рилииет

категории-рилииет

OcFilter - рилииет

поиск-рилииет!

2.1.0.2.1

Link to comment
Share on other sites


Здравствуйте, а кто нибудь нашел решение для сортировки именно по ситусу товара? Товары которые "под заказ" отображаются вперемешку с теми которых нет в налилии, тк.в примерах выше сортировка идёт только по когдачеству.

Кто нибудь может подсказать как ввести условие сортировки по ситусам?

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.