shopware / admin-extension-sdk

The Admin Extension SDK can be used by Shopware 6 apps and plugins. This library allows them to extend the administration with custom functionality.
https://developer.shopware.com/resources/admin-extension-sdk/
46 stars 13 forks source link

Admin Extension SDK

Tests NPM Package

DEPRECATION WARNING

⚠️ This repository is considered deprecated and will be archived in March 2024. For the new version of this tool please go to meteor-admin-sdk.

Old Description

The admin-extension-sdk is a JavaScript library for all Shopware 6 App and Plugin developer which want an easy way to extend and customize the administration.

See Documentation

Installation

Using NPM:

Install it to your package.json

npm i --save @shopware-ag/admin-extension-sdk

and import it in your app:

// import everything
import * as sw from '@shopware-ag/admin-extension-sdk';

// or import only needed functionality
import { notification }  from '@shopware-ag/admin-extension-sdk';

Using CDN:

Import the source from the CDN

// use the latest version available
<script src="https://unpkg.com/@shopware-ag/admin-extension-sdk/cdn"></script>

// use a fix version (example here: 1.2.3)
<script src="https://unpkg.com/@shopware-ag/admin-extension-sdk@1.2.3/cdn"></script>

and then you can access it with the global variable sw.

sw.notification.dispatch({
  title: 'My first notification',
  message: 'This was really easy to do'
})

Features

Examples

Throw a notification:

sw.notification.dispatch({
  title: 'My first notification',
  message: 'This was really easy to do'
})

Get the system currency:

const currency = await sw.context.getCurrency();

Subscribe for UI locale changes:

let currentLocale = 'en-GB';

sw.context.subscribeLocale(({ locale }) => {
  currentLocale = locale;
})

See more examples in the Documentation.