> For the complete documentation index, see [llms.txt](https://docs.nosto.com/shopware-6/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nosto.com/shopware-6/getting-started/guides/sorting.md).

# Sorting

### 1. Core Sorting Behaviour by Shopware Version

#### ≤ Shopware 6.6.9

| Area            | Behaviour                                                                                                                                                                                                      |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Admin panel** | <p>• One unified sorting configuration covers both category listings <em>and</em> search results.<br>• The <em>Top Results</em> (<code>score</code>) option is <strong>not</strong> visible/selectable.</p>    |
| **Storefront**  | <p><strong>Category pages</strong> – <em>Top Results</em> is absent from the dropdown.<br><strong>Search results</strong> – <em>Top Results</em> is hard-coded as the default and visible in the dropdown.</p> |

<figure><img src="/files/dghjcpwBJsTwYBIlTcXu" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/H3dC4lqfceeCjZzXmQph" alt=""><figcaption></figcaption></figure>

***

#### ≥ Shopware 6.6.10

| Area            | Behaviour                                                                                                                                                                                                                                                                                |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Admin panel** | <p>• Sorting settings are split: one for <strong>categories</strong>, one for <strong>search</strong>.<br>• <em>Top Results</em> appears <strong>only</strong> in <strong>Search</strong> sorting.<br>• <em>Top Results</em> is still absent from <strong>Category</strong> sorting.</p> |
| **Storefront**  | <p><strong>Category pages</strong> – <em>Top Results</em> still not shown.<br><strong>Search results</strong> – <em>Top Results</em> remains hard-coded as default.</p>                                                                                                                  |

<figure><img src="/files/zsWFVIY5NFDOmLeYjYhf" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/SGHewPWZUmaV6Es1CD8a" alt=""><figcaption></figcaption></figure>

<br>

***

### 2. What the Nosto Plugin Adds

| Property  | Value                                                       | Purpose                           |
| --------- | ----------------------------------------------------------- | --------------------------------- |
| **Label** | *Recommendation*                                            | Human-readable name               |
| **Key**   | `nosto-recommendation`                                      | Technical identifier              |
| **Usage** | May be set as default in **both** category and search pages | Personalised relevance-based sort |

***

### 3. Plugin Lifecycle & Fallback Logic

#### ✔️ Install

* Adds *Recommendation* if it does not yet exist.

#### ❌ Uninstall

* Removes *Recommendation*.
* **Fallbacks** if *Recommendation* was the default:

| Shopware Version | Area(s)        | Action                                                                           |
| ---------------- | -------------- | -------------------------------------------------------------------------------- |
| ≤ 6.6.9          | Unified config | Pick first active, unlocked option with highest priority                         |
| ≥ 6.6.10         | Category       | Same as above                                                                    |
|                  | Search         | Use *Top Results* if present; otherwise first active, unlocked, highest-priority |

#### 🚫 Deactivate

* Marks *Recommendation* as inactive (`active = 0`).
* Applies the same fallback rules as **Uninstall**.

#### ✔️ Activate

* Sets `active = 1` for *Recommendation* without touching existing defaults.

***

### 4. Storefront Visibility Logic

“Why don’t I see both *Top Results* and *Recommendation*?”

Only **one** relevance-based option is shown to avoid duplication.

| Condition                      | Visible in Dropdown    | Hidden                |
| ------------------------------ | ---------------------- | --------------------- |
| *Top Results* is default       | *Top Results*          | Recommendation        |
| *Recommendation* is default    | Recommendation         | Top Results           |
| Neither is default             | Higher-priority option | Lower-priority option |
| Same priority, neither default | Recommendation         | Top Results           |

> **Rule of thumb:** *Recommendation* replaces *Top Results* when its priority is **≥** the priority of *Top Results*.

***

#### If Nosto Services Are Inactive

*Recommendation* is suppressed in the storefront—but still remains configured in Admin.\
Customers then see whichever active option has the highest priority instead.

***

### 5. Shopware Handling of Sortings Without Criteria

If a sorting option contains **no criteria**, Shopware runs the listing **without** an `ORDER BY` clause. MySQL then applies a nondeterministic order (effectively by ID). Shopware mitigates this by appending a fallback sort on product ID.

***

### 6. Managing Sorting Options in the Backend

#### Changing Priority

1. **Settings → Catalogue → Product Sorting**
2. Drag options or adjust the **Priority** column.

<figure><img src="/files/6375o9ehq4FaGyc7q3lM" alt=""><figcaption></figcaption></figure>

*Higher numbers = higher dropdown position.*\
\&#xNAN;*Avoid giving two options the exact same priority.*

#### Creating a New Option

1. Click **Add option**.<br>

   <figure><img src="/files/M68nlyuZIJ5AeQyDORKR" alt=""><figcaption></figcaption></figure>
2. Fill in **Name**, **Technical name**, set **Active**, and add criteria.<br>

   <figure><img src="/files/fMwPDpB5iOcwiAb8WIEN" alt=""><figcaption></figcaption></figure>
3. For each criterion define **Order** *(ASC/DESC)* and \**Priority*.<br>

   <figure><img src="/files/zRCxEB2IbI7u4mYtW4V1" alt=""><figcaption></figcaption></figure>

***

### 7. Using a Custom Field as Sorting Criteria

1. Create the custom field in **Shopware Backend → Settings → Custom fields** and attach it to products.<br>

   <figure><img src="/files/ijxEm09vl8iz4dxoFlik" alt=""><figcaption></figcaption></figure>
2. Back in **Product Sorting**, pick the custom field from the **Name** dropdown.<br>

   <figure><img src="/files/ME9a7zllXWmdsuh0kn5K" alt=""><figcaption></figcaption></figure>
3. In **Settings → Extensions → Nosto**, add the same custom field.<br>

   <figure><img src="/files/FPSqB6i7vYhRHrigkbJP" alt=""><figcaption></figcaption></figure>
4. Run a **Full Product Sync**.
5. In the Nosto account:\
   **Product Experience Cloud → Search → Settings → Indexed fields → + Add attribute**.<br>

   <figure><img src="/files/BXEAB5xKUgJCOfGbweUr" alt=""><figcaption></figcaption></figure>
6. Save. Indexing runs every 6 hours—changes may take time to appear.<br>

   <figure><img src="/files/wRq2W04Jf3unHMJ05DFu" alt=""><figcaption></figcaption></figure>
