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

# Google Merchant Center

> Formato XML do feed Google Shopping, campos obrigatórios e validação.

## Visão Geral

O feed Google retorna um documento XML RSS 2.0 com atributos de produto do Google Merchant Center (namespace `g:`). Envie esta URL diretamente no Google Merchant Center como fetch agendado.

## URL do Feed

```
GET /api/v1/feeds/google
```

Adicione esta URL no Google Merchant Center em **Produtos → Feeds → URL de busca**.

## Formato XML

```xml theme={null}
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
  <channel>
    <title>Nome da Sua Loja</title>
    <link>https://sualoja.com.br</link>
    <description>Feed de produtos</description>
    <item>
      <g:id>SKU-001</g:id>
      <g:title>Camiseta de Algodão Azul</g:title>
      <g:description>100% algodão, pré-encolhido, disponível em P-GG</g:description>
      <g:link>https://sualoja.com.br/produtos/camiseta-azul</g:link>
      <g:image_link>https://cdn.sualoja.com.br/camiseta-azul.jpg</g:image_link>
      <g:availability>in stock</g:availability>
      <g:price>29.99 BRL</g:price>
      <g:brand>SuaMarca</g:brand>
      <g:condition>new</g:condition>
      <g:google_product_category>Roupas e Acessórios &gt; Roupas</g:google_product_category>
    </item>
  </channel>
</rss>
```

## Campos Obrigatórios

| Campo            | Descrição                                   |
| ---------------- | ------------------------------------------- |
| `g:id`           | Identificador único do produto (SKU)        |
| `g:title`        | Nome do produto (máx. 150 chars)            |
| `g:description`  | Descrição do produto (máx. 5000 chars)      |
| `g:link`         | URL da página do produto                    |
| `g:image_link`   | URL da imagem principal                     |
| `g:availability` | `in stock`, `out of stock` ou `preorder`    |
| `g:price`        | Preço com código de moeda (ex: `29.99 BRL`) |
| `g:brand`        | Nome da marca                               |
| `g:condition`    | `new`, `used` ou `refurbished`              |

## Solicitando o Feed

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://app.alana.shopping/api/v1/feeds/google" \
    -H "X-API-Key: sk_live_sua_chave_api" \
    -o feed-google.xml
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    "https://app.alana.shopping/api/v1/feeds/google",
    { headers: { "X-API-Key": "sk_live_sua_chave_api" } }
  );
  const xml = await res.text();
  ```

  ```python Python theme={null}
  import requests

  res = requests.get(
      "https://app.alana.shopping/api/v1/feeds/google",
      headers={"X-API-Key": "sk_live_sua_chave_api"},
  )
  with open("feed-google.xml", "wb") as f:
      f.write(res.content)
  ```
</CodeGroup>

## Endpoint de Validação

Verifique seu feed em busca de violações de políticas do Google antes de enviar:

```
GET /api/v1/feeds/google/validate
```

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://app.alana.shopping/api/v1/feeds/google/validate" \
    -H "X-API-Key: sk_live_sua_chave_api"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    "https://app.alana.shopping/api/v1/feeds/google/validate",
    { headers: { "X-API-Key": "sk_live_sua_chave_api" } }
  );
  const report = await res.json();
  console.log(report.errors, report.warnings);
  ```

  ```python Python theme={null}
  import requests

  res = requests.get(
      "https://app.alana.shopping/api/v1/feeds/google/validate",
      headers={"X-API-Key": "sk_live_sua_chave_api"},
  )
  report = res.json()
  print(report["errors"], report["warnings"])
  ```
</CodeGroup>

## Erros Comuns

| Erro                                  | Causa                     | Solução                              |
| ------------------------------------- | ------------------------- | ------------------------------------ |
| `Missing required attribute: g:brand` | Produto sem marca         | Adicione a marca ao produto no Alana |
| `Invalid price format`                | Preço sem código de moeda | Inclua a moeda no campo de preço     |
| `Image URL not accessible`            | Imagem retorna 404        | Atualize a URL da imagem do produto  |
| `Title too long`                      | Título excede 150 chars   | Reduza o título do produto           |
