> For the complete documentation index, see [llms.txt](https://partners.tray.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://partners.tray.com.br/themes/construindo-seu-template/referencias/funcoes/brands.md).

# Brands()

A função **`Brands()`** retorna as marcas cadastradas no Painel Administrativo da loja.

{% hint style="info" %}
**Disponível para uso em todas as páginas.**

**Saiba mais sobre como gerenciar marcas acessando:** [Marcas e Fabricantes](https://basedeconhecimento.tray.com.br/hc/pt-br/articles/6734137851931-Marcas-e-Fabricantes)
{% endhint %}

### Argumentos disponíveis

Essa função sempre retornará um array de dados com todas as marcas e através dele é possível acessar alguns atributos utilizando os argumentos abaixo. Devido ao retorno ser um array é possível utilizar um índice determinado ou iterar em um laço de repetição.

| Atributos              | Característica               |
| ---------------------- | ---------------------------- |
| `{{ brands[0].id }}`   | Identificador único da marca |
| `{{ brands[0].name }}` | Nome da marca                |
| `{{ brands[0].slug }}` | Final da url da marca        |

## Como Usar

Abaixo alguns exemplos de como utilizar a função `Brands()`.

### Para Exibir Todas as Marcas

No código HTML deve ser atribuída a função `Brands()` a uma variável e em seguida iniciar um loop que exibe o nome de cada marca, como o exemplo abaixo.

{% code title="Input" %}

```html
<ul>
  {% set brands = Brands() %}
  {% for brand in brands %}
    <li>{{ brand.name }}</li>
  {% endfor %}
</ul>
```

{% endcode %}

{% code title="Output" %}

```html
<ul>
    <li>Marca A</li>
    <li>Marca C</li>
    <li>Marca D</li>
    <li>Marca E</li>
    <li>Marca F</li>
    <li>Marca G</li>
    <li>Marca H</li>
</ul>
```

{% endcode %}

### Para exibir acima de 30 marcas

No código HTML deve ser atribuída a função `Brands()` a uma variável e em seguida iniciar um loop que exibe o nome de cada marca, como o exemplo abaixo.

```twig
De:{% set brands = Brands() %} 
Para:{% set brands = Brands({ "no_paging":1 }) %}    
```

### Para buscar por determinada Marca ou ID

{% code title="Input" %}

```html
{# busca a marca Tray #}
<ul>
  {% set brandTray = Brands( { "brand": "Tray" } ) %}
  {% for brand in brandTray %}
    <li>{{ brand.name }}</li>
  {% endfor %}
</ul>

{# busca o id 10 #}
<ul>
  {% set brands = Brands( { "id": "10" } ) %}
  {% for brand in brands %}
    <li>{{ brand.id }}</li>
  {% endfor %}
</ul>    
```

{% endcode %}

{% code title="Output" %}

```html
<ul>
    <li>Tray</li>
</ul>

<ul>
    <li>10</li>
</ul>
```

{% endcode %}

### Para exibir todas as marcas em ordem decrescente

Todas as marcas ordenadas por ID decrescente.

{% code title="Input" %}

```html
<ul>
 {% set brands = Brands({ "order": { "id": "desc" }}) %}
 {% for brand in brands %}
   <li><span>{{ brand.id }}</span><span>{{ brand.name }}</span></li>
 {% endfor %}
</ul>    
```

{% endcode %}

{% code title="Output" %}

```html
<ul>
   <li><span>5</span><span>Marca E</span></li>
   <li><span>4</span><span>Marca D</span></li>
   <li><span>3</span><span>Marca C</span></li>
   <li><span>2</span><span>Marca B</span></li>
   <li><span>1</span><span>Marca A</span></li>
</ul>
```

{% endcode %}

Você também pode utilizar nosso snippet de menu de marcas. Para saber mais acesse [Menu de Marcas](/themes/construindo-seu-template/referencias/componentes/menu-de-marcas.md)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://partners.tray.com.br/themes/construindo-seu-template/referencias/funcoes/brands.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
