Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Сортировка товаров по цене


mylifeyd
 Share

Recommended Posts

Добрый день!

Прошу помощи в решении одной проблемы, может ранее кто сталкивался.

Суть: не актуальным/распроданным товарам присваиваю цену 0, что бы сместить их в конец списка категории.

Проблема получается с сортировкой "от дешевых к дорогим" и на оборот.

Есть ли вариант указать условие, что бы подсчет от меньшего к большему начинался с 1 или 2 к примеру ?

Код  - контроллера категории

 

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

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

 

Link to comment
Share on other sites


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

-------->

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

 

Link to comment
Share on other sites

6 hours ago, spectre said:

там в сортировке сначала должно быть price = 0 а потом все остальное, тогда при любой сортировке этот товар будет в конце

 

Можно по подробнее, как это указать ? Заранее большое спасибо!

 

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

 

Link to comment
Share on other sites


16 hours ago, spectre said:

Это в model , там где getProducts

Нашел строчку, не понимаю, что с ней сделать.

Если поможете, большой респект, если нет, буду искать исполнителей.

 

Quote

$results = $this->model_catalog_product->getProducts($filter_data);

 

Но, все равно спасибо!

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.