> For the complete documentation index, see [llms.txt](https://docs.samita.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.samita.io/samita-wholesale-b2b/mandatory-steps/add-search-file-to-enable-app-data-in-your-theme.md).

# Add search file to enable app data in your theme

Add a Liquid search template so the app can read product data directly from your theme.

For the app to read product data from your theme, you need to manually add one search file. This page shows you exactly what to create and what code to paste in.

## Steps to manage

{% stepper %}
{% step %}

### Open your theme code editor

From the Shopify admin, go to **Online Store > Themes**, then choose **More actions > Edit code**.

<figure><img src="https://1875078098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcI28ZFsoFjOa0T0AsCVi%2Fuploads%2Fgit-blob-60879858a6cd429b4589d93377c9e6e735f16889%2Fimage%20(322).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create the search file

Right-click the **Templates** tab and choose **New file** to create this search file.

<figure><img src="https://1875078098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcI28ZFsoFjOa0T0AsCVi%2Fuploads%2Fgit-blob-ae275309bb9bdbbb791cbbece579333244499d09%2Fimage%20(454).png?alt=media" alt=""><figcaption></figcaption></figure>

Name the file exactly: **search.samitaWSProductsJson.liquid**

<figure><img src="https://1875078098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcI28ZFsoFjOa0T0AsCVi%2Fuploads%2Fgit-blob-f81527a374af6af0f8d8e0d1971bebc33837c5a9%2Fimage%20(455).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Paste in the code

Copy the code below into the new file exactly as shown.

```
{%- layout none -%}
{%- paginate search.results by 250 -%}
    [{%- for product in search.results -%}
        {%- unless forloop.first -%},{%- endunless -%}
        {
            "id":{{-product.id-}},
            "title":{{-product.title | json-}},
            "handle":"{{-product.handle-}}",
            "price":"{{-product.price-}}",
            "price_max":"{{-product.price_max}}",
            "price_min":"{{-product.price_min}}",
            "product_type":"{{-product.product_type-}}",
            "created_at":"{{-product.created_at-}}",
            "published_at":"{{-product.published_at-}}",
            "tags": {{-product.tags | json-}},
            "vendor": "{{-product.vendor-}}",
            "featured_image":"{{-product.featured_image-}}",
            "url":"{{-product.url-}}",
            "collections":{{-product.collections | map: 'id' | json-}},
            "compare_at_price":"{{-product.compare_at_price-}}",
            "compare_at_price_max": "{{-product.compare_at_price_max-}}",
            "compare_at_price_min": "{{-product.compare_at_price_min-}}",
            "options": {{-product.options | json-}},
            "options_with_values": {{-product.options_with_values | json-}},
            "images":[
            {%- for image in product.images -%}{%- unless forloop.first -%},
            {%- endunless -%}
            {
                "id":{{-image.id-}},
                "src":{{-image.src | json-}},
                "variant_ids":{{-image.variants | json-}}
            }
            {%- endfor -%}
            ],
            "first_available_variant":{"id":{{product.selected_or_first_available_variant.id}}},
            "available":{{-product.available-}},
            "variants":[
                {%- for variant in product.variants -%}{%- unless forloop.first -%},
                    {%- endunless -%}
                    {
                    "id":{{-variant.id-}},
                    "title":{{-variant.title | json}},
                    "name":{{-variant.name | json}},
                    "price":{{-variant.price-}},
                    "compare_at_price":"{{-variant.compare_at_price-}}",
                    "available":{{-variant.available-}},
                    "vendor": "{{-variant.vendor-}}",
                    "sku":{{-variant.sku | json -}},
                    "weight":"{{-variant.weight-}}",
                    "image_id": "{{-variant.image_id-}}",
                    "weight_unit": "{{-variant.weight_unit-}}",
                    "option1":  {{-variant.option1| json-}},
                    "option2":  {{-variant.option2| json-}},
                    "option3":  {{-variant.option3| json-}},
                    "options":  {{-variant.options| json-}},
                    "inventory_quantity":{{-variant.inventory_quantity-}},
                    "inventory_policy": {{-variant.inventory_policy | json -}}
                    }
                {%- endfor -%}
            ]
        }
    {%- endfor -%}]
{%- endpaginate -%}
```

<figure><img src="https://1875078098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcI28ZFsoFjOa0T0AsCVi%2Fuploads%2Fgit-blob-794069b2374129d8384a6acad422cbb4a9659580%2Fimage%20(324).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1875078098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcI28ZFsoFjOa0T0AsCVi%2Fuploads%2Fgit-blob-9bbc4fcdb6d91f3dc0dc95e69de1793a775bd049%2Fimage%20(456).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Save the file

Click **Save** to finish creating the file.
{% endstep %}
{% endstepper %}

## Tutorial video

{% embed url="<https://www.youtube.com/watch?v=AThxMwLRvBo>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.samita.io/samita-wholesale-b2b/mandatory-steps/add-search-file-to-enable-app-data-in-your-theme.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
