# Add search file to display label/badge on the front store

In order to display the label/badge you have created on the front store, you need to add some codes to enable the app data. Kindly follow the below instructions to better know how to do it:&#x20;

1. From the Shopify admin page, choose the **Online Store** folder > **Themes**
2. In **Themes** > choose the **More actions** button > **Edit code**

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

3. For the **Old theme code version**, the UI will be as below:

On the code page, click on **“Add a new template”** > choose Template type: **search** > **liquid** > Fill in the file name as: **samitaLabelsProductsJson** > **Done**

<figure><img src="/files/7GB7Q4A2NpMXUPmafKAe" alt=""><figcaption></figcaption></figure>

For **New theme code version**, the UI will be as below:

On the code page, right-click on the **Template** tab > Choose **New file** to create this search file.&#x20;

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

Then set up name for this file like this: **search.samitaLabelsProductsJson.liquid**

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

4. Add the below codes to the file:&#x20;

```
{%- layout none -%}
{%- paginate search.results by 1000 -%}
    [{%- for product in search.results -%}
        {%- unless forloop.first -%},{%- endunless -%}
        {
            "id":{{-product.id-}},
            "title":{{-product.title | json-}},
            "handle":{{-product.handle | json-}},
            "price":"{{-product.price-}}",
            "price_max":"{{-product.price_max}}",
            "price_min":"{{-product.price_min}}",
            "type":{{-product.type | json-}},
            "created_at":"{{-product.created_at | date: "%Y-%m-%d %H:%M" -}}",
            "published_at":"{{-product.published_at | date: "%Y-%m-%d %H:%M" -}}",
            "tags": {{-product.tags | json-}},
            "vendor": {{-product.vendor | json-}},
            "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-}}",
            "price_varies": "{{-product.price_varies-}}",
            "compare_at_price_varies": "{{-product.compare_at_price_varies-}}",
            "images":[
            {%- for image in product.images -%}{%- unless forloop.first -%},
            {%- endunless -%}{"id":{{-image.id-}},
            "src":{{-image.src | json-}}}{%- endfor -%}],
            "first_available_variant":{"id":{{-product.selected_or_first_available_variant.id | times: 1 -}}},
            "available":{{-product.available | json-}},
            "options": {{-product.options | json-}},
            "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 | times: 1-}},
                    "available":{{-variant.available-}},
                    "sku":{{-variant.sku | json -}},
                    "weight":"{{-variant.weight-}}",
                    "weight_unit": "{{-variant.weight_unit-}}",
                    "inventory_quantity":{{-variant.inventory_quantity-}},
                    "option1":  {{-variant.option1| json-}},
                    "option2":  {{-variant.option2| json-}},
                    "option3":  {{-variant.option3| json-}},
                    "options":  {{-variant.options| json-}},
                    "selected": {%- if variant.selected -%}  {{-variant.selected-}} {%- elsif product.selected_or_first_available_variant.id == variant.id -%} true  {%- else -%} false {%- endif -%}
                    }
                {%- endfor -%}
            ]
        }
    {%- endfor -%}]
{%- endpaginate -%}
```

<figure><img src="/files/9et0AMq2ThlAjVYDdSzJ" alt=""><figcaption></figcaption></figure>

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

5. Click **Save** to finish creating this new file.

* **IMPORTANT step**: Go back to the Sami Product Label app, on the app dashboard page, you will see a note as below, please click on the button “Refresh status”

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

To update the status that you have added the search file correctly in your theme

<figure><img src="/files/8mxcUhtKPv47Q6AN69Wb" alt=""><figcaption></figcaption></figure>

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

> ### **Need support?**
>
> If you do encounter any difficulty while proceeding these steps, don’t show any hesitation to contact us promptly via the email address [support@samita.io](https://help.samita.io/support@samita.io)


---

# 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://docs.samita.io/badges-and-labels/add-search-file-to-display-label-badge-on-the-front-store.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.
