> For the complete documentation index, see [llms.txt](https://developer.vario-software.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.vario-software.de/cookbook/onlineshops-and-marketplaces-app/project-structure/your-first-shop-app.md).

# Your First Shop App

This tutorial walks through the shop-specific setup: creating a sales channel, registering webhooks, and defining EAV groups. It assumes you already have a working VARIO Cloud app.

## 1. Set Up the Migration

The migration runs on first install. It creates the sales channel backend, a default channel, EAV groups, and webhooks.

```javascript
// api/services/maintenance/install/migrations/1/index.js
const MigratorErp = require('vario-app-framework/backend/utils/migrator.js');

const eavGroupShop = require('./static/erp/eav-groups/myShop.json');

const handle = async function ()
{
  const migratorErp = new MigratorErp('migration1');

  // ERP-level: EAV groups for article listings
  await migratorErp.setMigration('eavStructureErp', async (methods) =>
  {
    await methods.createEavGroup(eavGroupShop);
  });

  // ERP-level: sales channel
  await migratorErp.setMigration('salesChannel', async (methods) =>
  {
    const backend = await methods.createSalesChannelBackend('My Shop', ['ECOMMERCE']);
    await methods.createSalesChannel(backend, 'My Shop', '', 'ECOMMERCE');
    await methods.activateSalesChannelBackend(backend);
  });

  // ERP-level: webhooks
  await migratorErp.setMigration('webhooks', async (methods) =>
  {
    await methods.registerWebhook(
      'sales_channel.create',
      '/api/webhooks/sales_channel.create',
    );
    await methods.registerWebhook(
      'sales_channel.delete',
      '/api/webhooks/sales_channel.delete',
    );
  });

  // App-level: cron webhooks (destinationOwner = 'APP')
  await migratorErp.setMigration('cronWebhooks', async (methods) =>
  {
    await methods.registerWebhook(
      'ORDER_IMPORT',
      '/api/cron-webhooks/ORDER_IMPORT',
      'APP',
    );
    await methods.registerWebhook(
      'PROCESS_QUEUES',
      '/api/cron-webhooks/PROCESS_QUEUES',
      'APP',
    );
  });
};

module.exports = { handle };
```

{% hint style="info" %}
Use `MigratorErp` (from `vario-app-framework`) for ERP-level operations like sales channels, EAV groups, and webhooks.
{% endhint %}

## 2. Define the Shop EAV Group

Adds custom fields to article listings to store the external platform ID.

```json
// static/erp/eav-groups/myShop.json
{
  "key": "myShop",
  "label": "My Shop",
  "description": "My Shop",
  "entities": ["article_listing"],
  "attributes": [
    {
      "key": "id",
      "label": "External ID",
      "type": "TEXT",
      "viewMode": "EDITABLE",
      "active": true,
      "fulltextField": false,
      "searchIndex": true,
      "position": 1
    }
  ]
}
```

## 3. Query Articles via VQL

Use VQL to fetch article data including your custom fields:

```javascript
const ErpApi = require('vario-app-framework/backend/api/ErpApi.js');

const { salesChannel } = getContext();

const { data } = await ErpApi.vql({
  statement: `
    SELECT
        --v:result{displayname='id'}
      id,
        --v:result{displayname='articleNumber'}
      articleNumber,
        --v:result{displayname='name'}
      listings.descriptions.name,
        --v:result{displayname='externalId'}
      listings.custom.myShop.id
    FROM article.shopListing
    WHERE listings.salesChannel.id = '${salesChannel}'
  `,
  limit: 100,
});
```

## Next Steps

* [Core Concepts](/cookbook/onlineshops-and-marketplaces-app/core-concepts.md) — sales channels, webhooks, data flow, and queue processing
* [Integrations](/cookbook/onlineshops-and-marketplaces-app/integrations.md) — inbound and outbound sync patterns
* [Configuration](/cookbook/onlineshops-and-marketplaces-app/configuration.md) — per-channel parameters and transfer toggles


---

# 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://developer.vario-software.de/cookbook/onlineshops-and-marketplaces-app/project-structure/your-first-shop-app.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.
