# Виды сортировки

В модуле используются и зарезервированы следующие виды сортировки:

{% code fullWidth="true" %}

```php
$sorting = Core_Array::getGet('sorting', 0, 'int');
```

{% endcode %}

* `?sorting=1` - Цена по возврастанию (absolute\_price ASC)
* `?sorting=2` - Цена по убыванию (absolute\_price DESC)
* `?sorting=3` - Название товара по возврастанию (shop\_items.name ASC)
* `?sorting=4` - Название товара по убыванию (shop\_items.name DESC)
* `?sorting=5` - Дата создания товара по возврастанию (shop\_items.datetime ASC)
* `?sorting=6` - Дата создания товара по убыванию (shop\_items.datetime DESC)
* `?sorting=7` - Просмотры товара по возврастанию (shop\_items.showed ASC)
* `?sorting=8` - Просмотры товара по убыванию (shop\_items.showed DESC)

### Добавение своих сортировок через ->orderBy()

<pre class="language-php" data-full-width="true"><code class="lang-php">// !!!! Сортировка всегда идет после setFilterConditions !!!!
<strong>// по умолчанию ASC, стирает все предыдущие сортировки
</strong>// по наличию основного товара да = 0|нет = 1
$Shop_Controller_Show->orderBy('in_stock');

// по наличию основного товара и его модификаций да = 0|нет = 1
$Shop_Controller_Show->orderBy('in_stock_modification');

// по цене
$Shop_Controller_Show->orderBy('price'); // или absolute_price

// по доп. свойству
$Shop_Controller_Show->orderBy('property_123');

// НЕ стирает все предыдущие сортировки ->noClearOrderBy(), по умол. FALSE
// будет сортировка in_stock + sorting + shop_items.name
$Shop_Controller_Show
    ->orderBy('in_stock') // первая сортировка по умочланию очищает пред. сортировки
    ->noClearOrderBy(TRUE) // выкл. очистку последующих сортировок
    ->orderBy('sorting', 'ASC')
    ->orderBy('shop_items.name', 'ASC')
    ->noClearOrderBy(FALSE); // снова вкл. очистку послед. сортировок
    
</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.morozovpimnev.ru/asmp_filter/vidy-sortirovki.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
