> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Visual merchandising tool

> Learn how to use the visual merchandising tool in the Algolia AI Search & Discovery app.

export const SearchQuery = () => <Tooltip tip="The text users enter into a search box. In the Search API, this corresponds to the query parameter. A search query is often used with filters, facets, and other parameters, but these aren't part of the query text itself.">
    search query
  </Tooltip>;

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

export const Filter = () => <Tooltip tip="A filter is a condition that limits which records Algolia returns. Filters often use one or more facet-value pairs, such as brand:Apple AND color:red. You can also filter by numeric values, dates, tags, booleans, or geographic constraints." cta="Filtering" href="/doc/guides/managing-results/refine-results/faceting">
    filter
  </Tooltip>;

The Merchandising tool helps shop owners actively promote (or demote) items for specific search queries or collections.
With the Merchandising tool, you can influence results and boost certain products in specific search contexts:

* Promote high-performing products for popular searches
* Add related items to searches with no results

The Merchandising tool uses Algolia's [Rules](/doc/guides/managing-results/rules/rules-overview).
Rules are *if-then* statements that let you to assign actions to specific triggers.
For example, *if* a user types "dress", *then* promote the item "Red satin dress".

## How you can influence search results

For a given <SearchQuery />, the Merchandising tool lets you:

* **Pin a product.** Assign an absolute position to a product.
* **Hide a product.** Remove the product from the search results.
* **Promote a product.** Move the product higher in the search results.
* **Demote a product.** Move the product lower in the search results.
* **Add a product.** Using the search box, add a product that wouldn't be on the first page of the results otherwise.
  The item is assigned to the first available (not pinned) position.

## How the Merchandising tool works

When you modify the results for a search query using the Merchandising tool,
it creates a new rule.
Each rule represents a single query and can contain multiple actions—you can promote,
demote, pin, or hide as many objects as needed.

You can view these rules in the [Algolia dashboard](https://dashboard.algolia.com/rules/).
Rules created by the Merchandising tool follow the naming pattern `shopify-merchandising-<query>`.

Changes made in the Merchandising tool are sent to Algolia.
However, rules created directly in the Algolia dashboard **aren't synced back** to the Merchandising tool.
Similarly, don't delete rules created in the Merchandising tool in the Algolia dashboard.
This can cause unexpected behavior.

The Merchandising tool only applies changes to the first page of the search results.
The number of results shown is determined by the **Number of Products shown** setting in the InstantSearch configuration,
under **Search Options** in your app.

## Create a new rule

1. Open the **Merchandising tool** tab and click **Create your first query rule**.

   <img src="https://mintcdn.com/algolia/TTlnKswkCK2YkCpC/doc/integration/shopify/going-further/7-create-qr.jpeg?fit=max&auto=format&n=TTlnKswkCK2YkCpC&q=85&s=96be06ce36fe0089edf3cc8cadc481dd" alt="Screenshot of the 'Merchandising tool' page showing the 'Create your first query rule' button and a 'No query rule currently active' message." width="1918" height="719" data-path="doc/integration/shopify/going-further/7-create-qr.jpeg" />

2. Type a search query you want to assign actions to, and click **Search**.
   You can change the order of the results.

   <img src="https://mintcdn.com/algolia/TTlnKswkCK2YkCpC/doc/integration/shopify/going-further/8-merchandising.jpeg?fit=max&auto=format&n=TTlnKswkCK2YkCpC&q=85&s=9c96eb1c1100b495bfb13071f4153352" alt="Screenshot of the 'Merchandising tool' page with 'watch' in the 'Targeted query' field and a 'Search' button." width="1918" height="800" data-path="doc/integration/shopify/going-further/8-merchandising.jpeg" />

## Promote or demote products

Use the arrow buttons to adjust the desired position of a product: up or down.

<img src="https://mintcdn.com/algolia/TTlnKswkCK2YkCpC/doc/integration/shopify/going-further/9-pinned.jpeg?fit=max&auto=format&n=TTlnKswkCK2YkCpC&q=85&s=09883495552380de7eb1e5c0b0021831" alt="Screenshot of the 'Merchandising tool' page showing gift card products with 'Pin here,' 'Unpin,' and 'Hide' buttons, and a 'Pinned here' label." width="1920" height="938" data-path="doc/integration/shopify/going-further/9-pinned.jpeg" />

## Pin a product which is outside search results

In the following example, the search query "watch" returns video games.

<img src="https://mintcdn.com/algolia/aEHwQtyVTByx4c7q/doc/integration/shopify/going-further/10-result.jpeg?fit=max&auto=format&n=aEHwQtyVTByx4c7q&q=85&s=5dd2d0d6bfd5f2a0bc0cf5a2b1fb08aa" alt="Screenshot of a 'Visual merchandising tool' page showing search results for the query 'watch,' with options to 'Pin here' or 'Hide' each product." width="1278" height="1052" data-path="doc/integration/shopify/going-further/10-result.jpeg" />

To show wrist watches instead:

1. Click **Add another product to pin** and search for the item you want to promote.

   <img src="https://mintcdn.com/algolia/aEHwQtyVTByx4c7q/doc/integration/shopify/going-further/11-autocomplete.jpeg?fit=max&auto=format&n=aEHwQtyVTByx4c7q&q=85&s=8a3d48ffce8ab0def9bd4bb15d0402e1" alt="Search for the product you want to pin to this query" width="1318" height="1052" data-path="doc/integration/shopify/going-further/11-autocomplete.jpeg" />

2. The items are pinned to the first available (not pinned) position. Other pinned items aren't impacted.

   <img src="https://mintcdn.com/algolia/aEHwQtyVTByx4c7q/doc/integration/shopify/going-further/12-pinned-item.jpeg?fit=max&auto=format&n=aEHwQtyVTByx4c7q&q=85&s=750d3445c26f65f3563b51a8db808c45" alt="Screenshot of a visual merchandising tool showing a product pinned in search results with a 'Pinned here' label and 'Unpin' and 'Hide' buttons." width="1029" height="862" data-path="doc/integration/shopify/going-further/12-pinned-item.jpeg" />

## Hide a product from search results

To hide a product from your search results,
select an item and click **Hide**.
The item won't appear in your search results and is listed at the bottom of the page under **Items hidden from search results**.
If you want to return a hidden product to your search result, select it and click **Add to results**.
The item will be restored to either its initial position—if no other product has been pinned to it—or to the next available position.

## Make pinned items filterable

By default, pinned items show up in the search results even if they don't match an applied <Filter />.
You can change this behavior by selecting **Pinned items must match active filters to be displayed** in the **Merchandising tool > Merchandising settings** section.

For example, if you pinned a red item that's on sale, but users filter on blue items, this setting ensures that only blue items appear (discarding your pinned red item).

<img src="https://mintcdn.com/algolia/aEHwQtyVTByx4c7q/doc/integration/shopify/going-further/21-filter-pinned-items.jpeg?fit=max&auto=format&n=aEHwQtyVTByx4c7q&q=85&s=1eac4091df4aae18fe5f05b3bf377377" alt="Screenshot of a 'Merchandising settings' section with a checked option 'Pinned items must match active filters to be displayed' and a 'Save' button." width="1982" height="580" data-path="doc/integration/shopify/going-further/21-filter-pinned-items.jpeg" />

### Widget updates

The InstantSearch widget was updated to support this new feature for merchandised collections.

<Info>
  You can find the latest version in [`algolia_instant_search.js.liquid`](https://shopify.algolia.com/shopify/assets/javascripts/v4/algolia_instant_search.js.liquid).
</Info>

```diff JavaScript icon=code theme={"system"}
@@ -177,17 +177,11 @@
     // targeting collection pages
     if (collectionPage) {
       // Collection page merchandising:
-      // send rulesContext for promoted results only if no filters active
-      if (
-        !hasRefinements(searchFunctionHelper, instant.facets.list) &&
-        Number(page) === 0
-      ) {
         // If we are on a collection page, `collectionRulesContextValue` is defined
         if (collectionRulesContextValue) {
           searchFunctionHelper.setQueryParameter('ruleContexts', [
             collectionRulesContextValue.toString(),
           ]);
         }
       } else {
          searchFunctionHelper.setQueryParameter('ruleContexts', []);
       }
```

## Collection merchandising in the Algolia dashboard (Visual Editor)

You can also merchandise your collections with the **Visual Editor** in the Algolia dashboard.

<Check>
  Enable the [collection search page](/doc/integration/shopify/advanced-customization/collection-search-page) feature to merchandise collections.
</Check>

### Create a new Rule with the Visual Editor

1. Go to the [**Rules**](https://dashboard.algolia.com/rules/) section in the Algolia dashboard and select the <Index /> to which you want to add a rule.
2. Select either **Create your first Rule** or **New Rule** and select **Visual Editor**.

   <img src="https://mintcdn.com/algolia/aEHwQtyVTByx4c7q/doc/integration/shopify/going-further/23-add-new-rule.jpeg?fit=max&auto=format&n=aEHwQtyVTByx4c7q&q=85&s=6cc03426e2ba1c343309935b488c4aa4" alt="Screenshot of a drop-down menu showing 'Visual Editor' and 'Manual Editor' options in a rules management interface." width="1280" height="720" data-path="doc/integration/shopify/going-further/23-add-new-rule.jpeg" />

### Set the collection context

1. In the Visual Editor, click **Set a search query**.
2. In the menu next to **Your search**, select **is** and leave the following input field empty.
3. In **Add a context (optional)**, add a collection handle.
   To trigger a Rule when a user lands on a collection page, the search query must be empty and the context must be equal to your collection handle.

   <img src="https://mintcdn.com/algolia/TTlnKswkCK2YkCpC/doc/integration/shopify/going-further/24-search-context.jpeg?fit=max&auto=format&n=TTlnKswkCK2YkCpC&q=85&s=c72ad62cdf8f12585048c41d0415055a" alt="Screenshot of a visual merchandising tool with 'bright-shirts' entered in the context field." width="1846" height="1480" data-path="doc/integration/shopify/going-further/24-search-context.jpeg" />

The collection handle is the last part of your collection page's URL.
You can also find it when editing your collection's "website SEO" in the Algolia AI Search & Discovery app's settings.
For example, if the URL of the collection "Bright Shirts" is `mystore.myshopify.com/collections/bright-shirts`,
then its collection handle is `bright-shirts`.

### Filter the results on a particular collection

To display only the products of a specific collection,
click **Filter results** in the **What do you want to do?** section.
In the **Category** section, you can either choose to filter on:

* `collection_ids`: an array of the collection IDs the product belongs to
* `collections`: an array of the collection *handles* the product belongs to

Filtering on the `collection_ids` attribute is more robust,
as changes to the collection ID are less likely.

<img src="https://mintcdn.com/algolia/TTlnKswkCK2YkCpC/doc/integration/shopify/going-further/25-filter-on-collection.jpeg?fit=max&auto=format&n=TTlnKswkCK2YkCpC&q=85&s=d6721abe732bf9c5218ee82a477ec924" alt="Filter the search results on that particular collection" width="1842" height="1358" data-path="doc/integration/shopify/going-further/25-filter-on-collection.jpeg" />

<Tip>
  You can find the `collection_id` in the URL, when editing your collection in Shopify.
  For example, if the URL of the collection edition page is `mystore.myshopify.com/admin/collections/187530641539`,
  then its ID is `187530641539`.
</Tip>

### Pin or hide your products

Move the items at the position you want them to appear in the collection page and hide the ones you don't want to show.
Save your selection by clicking **Review and Publish**.

<img src="https://mintcdn.com/algolia/TTlnKswkCK2YkCpC/doc/integration/shopify/going-further/26-pin-and-hide-items.jpeg?fit=max&auto=format&n=TTlnKswkCK2YkCpC&q=85&s=d5bef3a5dbf11790ecec224461158582" alt="Promote and hide the items the way you want them to appear" width="3550" height="1830" data-path="doc/integration/shopify/going-further/26-pin-and-hide-items.jpeg" />

**If you want to use the Algolia dashboard to merchandise a collection, the rule condition must be an empty query and the context must be the collection handle.**
