Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/admin-sdk/api-reference/base-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ In this example, the base options are passed on the same object as the method-sp
import { notification } from '@shopware-ag/meteor-admin-sdk';

notification.dispatch({
title: 'Product report ready',
message: 'Your product report is ready',
/* ... base options ... */
});
Expand Down Expand Up @@ -62,14 +63,15 @@ Pass the `privileges` array to any SDK method that supports base options:
import { notification, ui } from '@shopware-ag/meteor-admin-sdk';

notification.dispatch({
title: 'Product report ready',
message: 'Your product report is ready',
privileges: [
'product:read',
],
});

ui.actionButton.add({
action: 'generate-report',
name: 'generate-report',
entity: 'product',
view: 'detail',
label: 'Generate Report',
Expand Down
38 changes: 19 additions & 19 deletions docs/admin-sdk/api-reference/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ No parameters needed.
Promise<{
languageId: string;
systemLanguageId: string;
}>;
}>
```

#### Example value
Expand Down Expand Up @@ -98,7 +98,7 @@ No parameters needed.
#### Return value

```ts
Promise<"development" | "production" | "testing">;
Promise<"development" | "production" | "testing">
```

#### Example value
Expand Down Expand Up @@ -127,7 +127,7 @@ No parameters needed.
Promise<{
locale: string;
fallbackLocale: string;
}>;
}>
```

#### Example value
Expand Down Expand Up @@ -195,7 +195,7 @@ No parameters needed.
Promise<{
systemCurrencyId: string;
systemCurrencyISOCode: string;
}>;
}>
```

#### Example value
Expand Down Expand Up @@ -224,7 +224,7 @@ No parameters needed.
#### Return value

```ts
string;
string
```

#### Example value
Expand All @@ -233,14 +233,14 @@ string;
"6.4.0.0";
```

## compareShopwareVersion()
## compareIsShopwareVersion()

Compares the current Shopware version against a target version. The current Shopware version is always the left-hand side of the comparison — so `context.compareShopwareVersion('>=', '7.0.0')` reads as "is the current Shopware version equal to or greater than 7.0.0?"
Compares the current Shopware version against a target version. The current Shopware version is always the left-hand side of the comparison — so `context.compareIsShopwareVersion('>=', '7.0.0')` reads as "is the current Shopware version equal to or greater than 7.0.0?"

#### Usage

```ts
const isRightVersion = await context.compareShopwareVersion(">=", "7.0.0");
const isRightVersion = await context.compareIsShopwareVersion(">=", "7.0.0");
```

#### Parameters
Expand All @@ -253,15 +253,15 @@ const isRightVersion = await context.compareShopwareVersion(">=", "7.0.0");
The function supports both Shopware's four-digit version number and semver versions. The following calls are equivalent:

```ts
await context.compareShopwareVersion(">=", "6.6.4.0");
await context.compareIsShopwareVersion(">=", "6.6.4.0");

await context.compareShopwareVersion(">=", "6.4.0");
await context.compareIsShopwareVersion(">=", "6.4.0");
```

#### Return value

```ts
boolean;
boolean
```

#### Example value
Expand Down Expand Up @@ -294,7 +294,7 @@ Promise<{
version: string;
type: "app" | "plugin";
privileges: privileges;
}>;
}>
```

#### Example value
Expand All @@ -303,10 +303,10 @@ Promise<{
{
name: 'my-extension',
version: '1.2.3',
type: 'app'
type: 'app',
privileges: {
read: [ 'product', 'customer' ],
write: [ 'product' ],
update: [ 'product' ],
additional: [ 'system.cache_clear' ]
}
}
Expand Down Expand Up @@ -349,7 +349,7 @@ Promise<{
title: string;
type: string;
username: string;
}>;
}>
```

#### Example value
Expand Down Expand Up @@ -390,7 +390,7 @@ No parameters needed.
#### Return value

```ts
Promise<string>;
Promise<string>
```

This function returns a Promise that resolves to a string representing the user's timezone.
Expand Down Expand Up @@ -428,7 +428,7 @@ Promise<{
id: string;
locationId: string;
}>;
}>;
}>
```

#### Example value
Expand Down Expand Up @@ -465,7 +465,7 @@ No parameters needed.
#### Return value

```ts
Promise<string>;
Promise<string | null>
```

## can()
Expand All @@ -489,5 +489,5 @@ const isAllowed: boolean = await context.can("product:read");
#### Return value

```ts
boolean;
boolean
```
27 changes: 25 additions & 2 deletions docs/admin-sdk/api-reference/data/repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,18 @@ Clones an existing entity
```ts
const exampleRepository = data.repository('your_entity');

const clonedEntityId = await exampleRepository.clone('theEntityIdToClone');
const clonedEntityId = await exampleRepository.clone(
'theEntityIdToClone',
yourApiContext
);
```

#### Parameters
| Name | Required | Default | Description |
| :--------- | :------- | :------ | :--------------------------------------------- |
| `entityId` | true | | The entity id which should be cloned |
| `context` | false | {} | Change the [request context](#request-context) |
| `context` | true | | Change the [request context](#request-context) |
| `behavior` | false | | Configure the [clone behavior](#clone-behavior) |

#### Return value
This method returns the id of the cloned entity.
Expand Down Expand Up @@ -250,3 +254,22 @@ const exampleContext = {
liveVersionId: 'yourLiveVersionId'
}
```

### Clone Behavior
You can optionally change the clone behavior of the request. The clone behavior controls how the entity is duplicated on the server.

Use `overwrites` to replace values in the cloned entity before it is written, for example to set a different name or other field values on the copy.

Use `cloneChildren` to control whether child entities are cloned as well. This value defaults to `true`.

```ts
const exampleCloneBehavior = {
Comment on lines +265 to +266

@gweiermann Gerrit Weiermann (gweiermann) Apr 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea to emphasize the type of the parameter. The actual type is probably different:

Suggested change
```ts
const exampleCloneBehavior = {
```ts
interface CloneBehavior {
overwrites: object; // object that follows the same structure as the entity to overwrite its properties
cloneChildren: boolean;
}
const example: CloneBehavior = {

Edit: but we can also postpone that idea for a second iteration where we'd add a type column in the parameters table for all APIs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea but would also suggest to postpone it for the next iteration and do it in the same way for all APIs as you suggested.

It would also be nice to add those types to the SDK itself in the same step, not just to the docs. Currently the clone behavior is a parameter without a type (just any).

// Replace values in the cloned entity before it is saved
overwrites: {
name: 'Copy of the original entity',
active: false
},
// Set to false if child entities should not be cloned
cloneChildren: true
}
```
10 changes: 5 additions & 5 deletions docs/admin-sdk/api-reference/ui/actionButton.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { location, ui } from "@shopware-ag/meteor-admin-sdk";

if (location.is(location.MAIN_HIDDEN)) {
ui.actionButton.add({
action: "your-app_customer-detail-action",
name: "your-app_customer-detail-action",
entity: "customer",
view: "detail",
label: "Test action",
Expand All @@ -34,7 +34,7 @@ if (location.is(location.MAIN_HIDDEN)) {

| Name | Required | Description |
| :----------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `action` | true | A unique name of your action |
| `name` | true | A unique identifier for your action |
| `entity` | true | The entity this action is for possible values: `product`, `order`, `category`, `promotion`, `customer` or `media`. Value `media` is available in Shopware version 6.7.1 |
| `view` | true | Determines if the action button appears on the listing or detail page, possible values: `detail`,`list` or item. View `item` is only used for entity `media` and in version 6.7.1 |
| `label` | true | The label of your action button |
Expand All @@ -58,7 +58,7 @@ import { location, ui } from "@shopware-ag/meteor-admin-sdk";

if (location.is(location.MAIN_HIDDEN)) {
ui.actionButton.add({
action: "your-app_customer-detail-action",
name: "your-app_customer-detail-action",
entity: "customer",
view: "detail",
label: "Test action",
Expand All @@ -81,7 +81,7 @@ if (location.is(location.MAIN_HIDDEN)) {
import { ui } from "@shopware-ag/meteor-admin-sdk";

ui.actionButton.add({
action: "your-app_customer-detail-action",
name: "your-app_customer-detail-action",
entity: "customer",
view: "detail",
meteorIcon: "regular-analytics",
Expand All @@ -104,7 +104,7 @@ ui.actionButton.add({
import { ui } from "@shopware-ag/meteor-admin-sdk";

ui.actionButton.add({
action: "test-media-button",
name: "test-media-button",
entity: "media",
view: "item",
meteorIcon: "regular-tools-alt",
Expand Down
8 changes: 4 additions & 4 deletions docs/admin-sdk/api-reference/ui/mediaModal.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ui.mediaModal.open({
allowMultiSelect: false,
fileAccept: "image/png",
selectors: ["fileName", "id", "url"],
callback: ({ fileName, id, url }) => {},
callback: ([{ fileName, id, url }]) => {},
});
```

Expand All @@ -42,8 +42,8 @@ All parameters are similar to the `sw-media-modal-v2` component's props.
| `allowMultiSelect` | false | true | Define single or multiple selection |
| `defaultTab` | false | library | Defines which tab should be opened by default |
| `fileAccept` | false | image/\* | Define the file types which are allowed to be uploaded in Upload tab |
| `selectors` | false | ['fileName', 'id', 'url'] | Selected properties which should be returned in callback function |
| `callback` | true | | Callback function which will be called once the media item is selected. |
| `selectors` | false | ['fileName', 'id', 'url'] | Selected properties which should be returned for each item in the callback array |
| `callback` | true | | Callback function which receives an array of selected media items once a selection is made. |

#### Example

Expand All @@ -54,7 +54,7 @@ ui.mediaModal.open({
initialFolderId: "productMediaFolderId",
allowMultiSelect: false,
selectors: ["fileName", "id", "url"],
callback: ({ fileName, id, url }) => {},
callback: ([{ fileName, id, url }]) => {},
});
```

Expand Down
10 changes: 5 additions & 5 deletions docs/admin-sdk/api-reference/window.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Returns a unique identifier for the current browser window. This is useful when
#### Usage

```ts
adminWindow.getId();
await adminWindow.getId();
```

#### Parameters
Expand All @@ -113,14 +113,14 @@ No parameters required.

#### Return value

A `string` representing a unique identifier for the current window.
A `Promise<string>` that resolves to a unique identifier for the current window.

#### Example

This example clears `sessionStorage` when a duplicated browser tab is detected. This can happen if a user uses the _Duplicate Tab_ feature of some browsers.

```ts
const windowId = adminWindow.getId();
const windowId = await adminWindow.getId();
const storedWindowId = globalThis.sessionStorage.getItem("window-id");

if (windowId !== storedWindowId) {
Expand All @@ -138,7 +138,7 @@ Retrieve the current Administration router path.
#### Usage

```ts
adminWindow.getPath();
await adminWindow.getPath();
```

#### Parameters
Expand All @@ -147,4 +147,4 @@ No parameters required.

#### Return value

Returns a `string` containing the full path, or an empty string if the router is not available.
Returns a `Promise<string>` containing the full path, or an empty string if the router is not available.
5 changes: 4 additions & 1 deletion docs/admin-sdk/develop/translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ Snippet files follow the same structure used by the Shopware Administration. Ove
Reference snippet keys directly in the UI configuration. Example:

```js
sw.ui.componentSection('sw-manufacturer-card-custom-fields__before').add({
import { ui } from '@shopware-ag/meteor-admin-sdk';

ui.componentSection.add({
component: 'card',
positionId: 'sw-manufacturer-card-custom-fields__before',
props: {
title: 'my-app-name.example-card.title',
subtitle: 'my-app-name.example-card.subtitle',
Expand Down
4 changes: 2 additions & 2 deletions docs/admin-sdk/docs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
redirects:
api-reference/ui/component-section.html: api-reference/ui/component-sections.html
api-reference/ui/module/paymentOverviewCard.html: api-reference/ui/paymentOverviewCard.html
api-reference/ui/module/paymentOverviewCard.html: api-reference/ui/purchases-and-payments/paymentOverviewCard.html
internals/how-it-works.html: concepts/architecture.html
internals/datahandling.html: concepts/datahandling.html
api-reference/in-app-purchases/in-app-purchases.html: api-reference/data/in-app-purchases.html
api-reference/in-app-purchases/in-app-purchases.html: api-reference/ui/purchases-and-payments/in-app-purchases.html
api-reference/in-app-purchases/index.html: api-reference/data/index.html
api-reference/ui/module/index.html: api-reference/ui/index.html
faq/index.html: develop/translations.html
Expand Down
3 changes: 1 addition & 2 deletions docs/admin-sdk/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Shopware supports two extension types: **apps** and **plugins**. Both can use th

Apps run on an external server and communicate with Shopware through a defined API. They are the recommended approach because:

- They work with **Shopware Cloud** and self-hosted instances
- They can be distributed through the Shopware Store
- They work with **Shopware Cloud** and self-hosted instances, and they are the only extension type available for **Shopware SaaS**
- The frontend and backend are fully decoupled from the Shopware codebase

Set up an app: [App Installation Flow](./installation-apps.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/admin-sdk/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ What you can do with the SDK:
- Provides a stable, backwards-compatible API for extending the Administration and reducing complexity during Shopware updates
- Abstracts internal complexity, so deep knowledge of the Admin internals is not required
- Written in [TypeScript](https://www.typescriptlang.org/) with full type safety and auto-completion support
- Lightweight and tree-shakable with no external dependencies, allowing granular imports and small bundle sizes
- Lightweight and tree-shakable, allowing granular imports and small bundle sizes

## Prerequisites

Expand Down
Loading