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

# Collection search page

> Enable InstantSearch on your Shopify collection pages

export const Records = () => <Tooltip tip="A record is a searchable object in an Algolia index. Each record consists of named attributes." cta="Algolia records" href="/doc/guides/sending-and-managing-data/prepare-your-data#algolia-records">
    records
  </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 Facet = () => <Tooltip tip="An attribute in your records that lets users filter or group results (for example, by color, brand, or price)." cta="Faceting" href="/doc/guides/managing-results/refine-results/faceting">
    facet
  </Tooltip>;

<Info>
  Shopify apps can't modify theme code directly.
  To integrate Autocomplete and InstantSearch,
  use the Algolia AI Search & Discovery app's **App Embed** and **App Blocks**.

  For more information, see:

  * [Manual theme configuration](/doc/integration/shopify/getting-started/quick-start#manual-theme-configuration)
  * [Shopify Algolia configuration](/doc/integration/shopify/sending-and-managing-data/algolia-config)
</Info>

With the Algolia AI Search & Discovery app for Shopify,
you can enhance your collection pages with real-time search.

**Collection search pages** list products from a [collection](https://help.shopify.com/en/manual/products/collections).
Usually, they have URLs with the following pattern: `/collection/<collection-name>`.

<Info>
  When you modify a collection, all products from the collection are reindexed.
  Enabling the collection search feature increases the number of [indexing operations](https://support.algolia.com/hc/en-us/articles/18138875086865).
</Info>

## All products

Shopify automatically creates a page at the URL `/collections/all` that lists all your products.
To enable InstantSearch on this [collection list](/doc/integration/shopify/getting-started/quick-start#enable-instantsearch) page,
you must [create a collection](https://help.shopify.com/en/manual/products/collections) called `all` in the Shopify Admin.

## Turn on Algolia on collection pages

To enable Algolia on your collections,
go to the **Collection pages** tab and click **Enable**.

<img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/1-enabling-collection-pages.jpeg?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=221196f325505616c54a5c661d6af0e0" alt="The Collection pages enable screen in the Shopify admin" width="1964" height="1226" data-path="doc/integration/shopify/advanced-customization/1-enabling-collection-pages.jpeg" />

Once the feature is enabled, all your products and collections will be reindexed to ensure that all required data is available.

<img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/2-collection-pages-reindexing.jpeg?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=4cffa35d6880798403fae126ecea0440" alt="The Collection pages reindexing screen in the Shopify admin" width="1952" height="1028" data-path="doc/integration/shopify/advanced-customization/2-collection-pages-reindexing.jpeg" />

Once the reindexing is done, InstantSearch will be enabled on your Collection pages.
You can now configure how it behaves.

## Configure Algolia on collection pages

<img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/3-collection-pages-display-settings.jpeg?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=fc9387be49b27c642cd78f49c991aad1" alt="The Collection pages display settings in the Shopify admin" width="1938" height="388" data-path="doc/integration/shopify/advanced-customization/3-collection-pages-display-settings.jpeg" />

### Enable InstantSearch on collection pages

1. Add the [Algolia Search App Embed](/doc/integration/shopify/getting-started/quick-start#enable-instantsearch) to your theme.
2. Add [Algolia App Blocks](/doc/integration/shopify/getting-started/quick-start#enable-autocomplete). App Embed must be enabled before the App Block will work.

### Products to be displayed

The number of products to show per page for your collections.

### Sort orders

In this section, you can choose which sort orders you want to activate for your collections, how you want to call them, and which ones you want to display first.

<img src="https://mintcdn.com/algolia/lcM1kQMHTdqMvYi4/doc/integration/shopify/advanced-customization/4-collection-pages-sort-orders.jpeg?fit=max&auto=format&n=lcM1kQMHTdqMvYi4&q=85&s=422bd92b62b70bebc6c2be264a6c8425" alt="The Collection pages sort orders settings in the Shopify admin" width="968" height="427" data-path="doc/integration/shopify/advanced-customization/4-collection-pages-sort-orders.jpeg" />

Each sort order uses a [replica](/doc/guides/managing-results/refine-results/sorting/in-depth/replicas) of your main <Index />.
The replica's type—set in **Search options > Sort orders** determines its impact on your record count.
Standard replicas duplicate the <Records /> from your main index.
Virtual replicas don't add to your record count.
Results are ordered by [relevant sorting](/doc/guides/managing-results/refine-results/sorting/in-depth/relevant-sort/).

**Make sure that an increased record count won't exceed your [plan's quota](https://www.algolia.com/pricing/)**.

<Warning>
  **Search options** and **Collection Pages** share replicas for the same sort orders.
  If the same sort order is active in both places,
  changing its type in **Search options** also changes it in **Collection Pages**.
  This can change sorting on collection pages.
</Warning>

For more information, see [Sorting](/doc/guides/managing-results/refine-results/sorting).

<Info>
  On collection pages, the manual order defined in the Shopify admin don't apply.
  To customize the order, you can use the [visual merchandising tool](/doc/integration/shopify/going-further/merchandising-tool).
</Info>

### Facets

In this section, choose each <Facet /> to activate for your collections, what you want to call it, and its display order.

<img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/5-collection-pages-facets.jpeg?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=195cc522956942e85dc72b843f4b599f" alt="The Collection pages facets settings in the Shopify admin" width="1938" height="826" data-path="doc/integration/shopify/advanced-customization/5-collection-pages-facets.jpeg" />

Facets are primarily used to refine searches.
For more information, see [Filtering](/doc/guides/managing-results/refine-results/filtering).

### Configure with Merchandising Studio

By default the Shopify category pages use the `collection_ids` attribute as a [category page identifier](/doc/guides/solutions/ecommerce/browse/tutorials/category-pages#implementation-steps).

To create a more accessible interface to merchandise your categories,
change the category page identifier to `collections`.

<Steps>
  <Step title="Add a facet">
    Add a custom facet called `collections` in the Algolia app for Shopify and set it as hidden and searchable.

    <img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/13-collection-add-facet.png?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=e0810dd405407a9e0f40de279320eeaa" alt="collection add facets settings in the Shopify admin" width="1272" height="1424" data-path="doc/integration/shopify/advanced-customization/13-collection-add-facet.png" />

    <img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/14-collection-edit-facet.png?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=3e8b29d2e82c5506db58e25e8c9a7f39" alt="The Collection edit facets settings in the Shopify admin" width="976" height="850" data-path="doc/integration/shopify/advanced-customization/14-collection-edit-facet.png" />
  </Step>

  <Step title="Change the category page identifier">
    You can configure the category page identifier on your Merchandising studio settings.
    To do this, go to **Merchandising Studio > Settings > Category Page Identifiers** and change the category page identifier to `collections`.

    <img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/15-collection-category-page-identifier.png?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=4ad87672bdd298cd392fa29457b69e27" alt="The Collection category page identifier configuration" width="1980" height="1734" data-path="doc/integration/shopify/advanced-customization/15-collection-category-page-identifier.png" />
  </Step>

  <Step title="Change your frontend code">
    Add a [custom hook](/doc/integration/shopify/building-search-ui/frontend-custom-events#add-custom-hooks) to your Shopify theme to update the search filter using the [`beforeInstantSearchFiltersString`](/doc/integration/shopify/building-search-ui/instantsearch-hooks#beforeinstantsearchfiltersstring) hook:

    ```js JavaScript icon=code theme={"system"}
    document.addEventListener("algolia.hooks.initialize", function () {
      algoliaShopify.hooks.registerHook(
        "beforeInstantSearchFiltersString",
        function (defaultFilter) {
          if (defaultFilter && defaultFilter.includes("collection_ids")) {
            const collectionIDFilterRegex = /collection_ids:"\w+"/g;
            const matches = window.location.pathname.match(
              /\/collections\/([^/]+)/i,
            );
            const collectionHandle =
              matches && matches.length === 2 ? matches[1] : null;

            if (collectionHandle) {
              return defaultFilter.replace(
                collectionIDFilterRegex,
                "collections:" + collectionHandle,
              );
            }
          }

          return defaultFilter;
        },
      );
    });
    ```

    Now, you should the this filter applied on your collection pages.

    <img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/16-collection-page-network.png?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=be4aed9e22b0bb120820b541e1925f44" alt="Screenshot of a search results page with 'filters: collections:under-5' highlighted in the developer tools payload." width="3386" height="1644" data-path="doc/integration/shopify/advanced-customization/16-collection-page-network.png" />
  </Step>
</Steps>

## Turn off Algolia on collection pages

<img src="https://mintcdn.com/algolia/IBpvqiDfc9oOPDK9/doc/integration/shopify/advanced-customization/6-collection-pages-disable.jpeg?fit=max&auto=format&n=IBpvqiDfc9oOPDK9&q=85&s=83dc83640ae3e17110d0f4f752109c6f" alt="The Collection pages facets settings in the Shopify admin" width="1938" height="452" data-path="doc/integration/shopify/advanced-customization/6-collection-pages-disable.jpeg" />

To turn off Algolia on Collection pages,
go to the bottom of the page and click **Disable**.
Your collection pages revert to their default layout,
and InstantSearch no longer shows up.
