Skip to content

Commit 087469f

Browse files
committed
Add Admin UI SDK support
1 parent 36c15e5 commit 087469f

7 files changed

Lines changed: 63 additions & 41 deletions

File tree

INSTALL.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ To required environment add:
1515

1616
* I/O Management API with OAuth Server-to-Server
1717
* I/O Events
18+
* Adobe Commerce as a Cloud Service (SaaS) - is required to manage authorization between the application and your Adobe Commerce instance.
1819

1920

2021
### Adobe API Mesh (Optional)
@@ -98,3 +99,13 @@ Add to `.env` line `FEED_GENERATOR_PROVIDER_ID=<id>`
9899

99100
11. The app is ready to use. Please save the link to your application environment. Additionally, you can replicate all steps in your production environment and publish the application, so it will be available on your exchange dashboard.
100101

102+
## Adding to Adobe Admin UI (SaaS)
103+
104+
For Adobe Commerce SaaS, you can add the module to be available in your Commerce Admin.
105+
106+
1. Go to Stores -> Configuration in your Adobe Commerce Admin
107+
2. Go to Adobe Services -> Admin UI SDK
108+
3. Click "Configure extensions" and choose respective Environment and Application.
109+
4. Save changes.
110+
111+
For more information and troubleshooting please go to: https://developer.adobe.com/commerce/extensibility/admin-ui-sdk/configuration/

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ Header and Footer currently have a support to variables (Only 1 actually)
199199

200200
Variables are defined using double curly braces (`{{ }}`) and correspond to fields in the Adobe Commerce GraphQL product output. For example, `{{sku}}` will be replaced with the product's SKU.
201201

202-
##### Additional parameters
202+
##### Additional parameterss
203+
204+
Note: The examples in 'Additional parameters' show how to use the parameters. The tag names may be different in your API, as they are specific to your system.
203205

204206
###### Repeating Tags with `count`
205207

@@ -217,15 +219,14 @@ To select a specific element from an array, use the `index` property. This will
217219
<g:product_type>{{categories.name index="2"}}</g:product_type>
218220
```
219221

220-
##### Selecting Attribute with Specific code
222+
##### Selecting Attribute with Specific code (SaaS specific feature)
221223

222224
```xml
223225
<color>{{attributes.value code='color'}}</color>
224226
```
225227

226228
Add attributes.value is an Array of attributes, to get specific attribute, you can use "code" parameter and define attribute with which code you want to use.
227229

228-
229230
#### Example for Google Feed
230231

231232
##### Header
@@ -242,11 +243,11 @@ Add attributes.value is an Array of attributes, to get specific attribute, you c
242243
<g:id>{{sku}}</g:id>
243244
<title>{{name}}</title>
244245
<description>{{description.html}}</description>
245-
<link>https://www.URL.com/{{detail_page}}</link>
246+
<link>https://www.URL.com/{{url_key}}</link>
246247
<g:image_link>{{image.url}}</g:image_link>
247248
<g:condition>new</g:condition>
248249
<g:price>{{price_range.maximum_price.final_price.value}} {{price_range.maximum_price.final_price.currency}}</g:price>
249-
<g:product_type index=2>{{categories.name}}</g:product_type>
250+
<g:category index="2">{{categories.name}}</g:category>
250251
<g:mpn>{{sku}}</g:mpn>
251252
<g:additional_image_link><![CDATA[{{image.url}}?width=350&height=350&fit=crop]]></g:additional_image_link>
252253
</item>
@@ -257,10 +258,11 @@ Add attributes.value is an Array of attributes, to get specific attribute, you c
257258
```xml
258259
<item>
259260
<sku>{{sku}}</sku>
260-
<weight>{{SimpleProduct||weight}}</weight>
261-
<image>{{media_gallery.url count="2"}}</image>
261+
<weight>{{description}}</weight>
262+
<image>{{images.url count="2"}}</image>
262263
<color>{{attributes.value code='color'}}</color>
263-
<price>{{SimpleProduct||price_range.maximum_price.final_price.value}}</price>
264+
<color>{{attributes.value code='weight'}}</color>
265+
<price>{{SimpleProductView||price.final.amount.value}} {{SimpleProductView||price.final.amount.currency}}</price>
264266
</item>
265267
```
266268

adobe-api/mesh/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ then
1313

1414
### API Mesh access
1515

16-
Mesh api GraphQl endpoint follows next patter https://graph.adobe.io/api/{meshId}/graphql?api_key={mesh_api_key}
16+
Mesh api GraphQl endpoint follows next pattern https://graph.adobe.io/api/{meshId}/graphql?api_key={mesh_api_key}
1717

1818
{mesh_api_key} can be moved to headers, so GQL endpoint will be
1919
https://graph.adobe.io/api/{meshId}/graphql and need to add header `X-Api-Key` with value `{mesh_api_key}`
@@ -47,7 +47,7 @@ After this `aio api-mesh` commands should works fine.
4747

4848
-------------------------------------------------
4949

50-
If Adobe Mesh Gql response fail need to check source URL (magento.host): SSL certificate MUST be VALID, otherwise Mesh GQL enpoint response error.
50+
If Adobe Mesh Gql response fail need to check source URL (magento.host): SSL certificate MUST be VALID, otherwise Mesh GQL endpoint response error.
5151

5252
-------------------------------------------------
5353

@@ -63,7 +63,7 @@ If Adobe Mesh Gql response fail need to check source URL (magento.host): SSL cer
6363
"handler": {
6464
"openapi": {
6565
"source": "https://magento.host/rest/schema?services=storeWebsiteRepositoryV1",
66-
// can be udpated to /rest/schema?services=all if we want to use all rest enpoint in mesh
66+
// can be updated to /rest/schema?services=all if we want to use all rest enpoint in mesh
6767
6868
"schemaHeaders": {
6969
"Authorization": "Bearer {context.headers['x-ac-api-token']}"

src/commerce-backend-ui-1/actions/regenerateFeed/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const { Core, Events } = require('@adobe/aio-sdk')
22
const uuid = require('uuid')
3+
4+
const { getImsAccessToken } = require('@adobe/commerce-sdk-auth')
5+
const { fromParams } = require('../auth')
6+
37
const {
48
CloudEvent
59
} = require("cloudevents");
@@ -12,8 +16,6 @@ async function main (params) {
1216

1317
try {
1418

15-
console.log("called index.js")
16-
1719
params['payload'] = {"uuid": params.uuid}
1820

1921
// check for missing request input parameters and headers
@@ -26,8 +28,14 @@ async function main (params) {
2628
}
2729

2830
// extract the user Bearer token from the Authorization header
29-
const token = getBearerToken(params)
31+
let token = getBearerToken(params)
3032

33+
const authParams = fromParams(params)
34+
if (authParams?.ims) {
35+
const imsResponse = await getImsAccessToken(authParams.ims)
36+
token = imsResponse.access_token
37+
}
38+
3139
// initialize the client
3240
const orgId = params.__ow_headers['x-gw-ims-org-id']
3341

src/commerce-backend-ui-1/actions/utils/generation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ async function generateFeed(uuid, params) {
4242
"expiration": "2023-03-03T12:58:47.000Z",
4343
"value": {
4444
"created_at": "2023-03-02T12:58:47.770Z",
45-
"feedBody": "<item>\n <g:id>{{sku}}</g:id>\n <title>{{SimpleProduct||weight}}</title>\n \n <g:image_link>{{image.url count='2'}}</g:image_link>\n </item>",
45+
"feedBody": "<item>\n <g:id>{{sku}}</g:id>\n <g:category index=\"2\">{{categories.name}}</g:category>\n \n <g:image_link>{{image.url count='2'}}</g:image_link>\n </item>",
4646
"feedFooter": "</items>",
4747
"feedHeader": "<items>",
4848
"feedName": "Test XML",
4949
"feed_type": "xml",
5050
"generated_at": "",
5151
"status": "pending",
5252
"store_code": "de||main_website_store||base",
53-
"searchQuery": "Motiv",
53+
"searchQuery": "Gum",
5454
// "filterQuery": "{\n \"attribute\": \"price\",\n \"range\": {\n \"from\": 10,\n \"to\": 100\n }\n}"
5555
}
5656
}

src/commerce-backend-ui-1/actions/utils/placeholderHandler.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -119,32 +119,33 @@ const handleCategories = (placeholder, item, feed, type) => {
119119
let itemCounter = 0;
120120
for (let placeholderPart of placeholderParts) {
121121

122-
if (value.toString() === "") {
123-
124-
if (itemCounter === 0) {
125-
126-
/**
127-
* @ToDo Consider to use index as a property for define position of the value in the array if there are multiple values
128-
* Example:
129-
* Categories: {{categories.name index=0}}
130-
* Json:
131-
* {
132-
* "categories": [
133-
* {"name": "Category 1"},
134-
* {"name": "Category 2"}
135-
* ]
136-
* }
137-
*/
138-
// if (placeholderProperties['index'] !== undefined) {
139-
// value = item[placeholderPart][placeholderProperties['index']];
140-
// } else {
141-
value = item[placeholderPart][0];
142-
// }
143-
} else {
144-
value = item[placeholderPart]
122+
if (typeof value !== "undefined") {
123+
124+
if (value.toString() === "") {
125+
if (itemCounter === 0) {
126+
/**
127+
* @ToDo Consider to use index as a property for define position of the value in the array if there are multiple values
128+
* Example:
129+
* Categories: {{categories.name index=0}}
130+
* Json:
131+
* {
132+
* "categories": [
133+
* {"name": "Category 1"},
134+
* {"name": "Category 2"}
135+
* ]
136+
* }
137+
*/
138+
// if (placeholderProperties['index'] !== undefined) {
139+
// value = item[placeholderPart][placeholderProperties['index']];
140+
// } else {
141+
value = item[placeholderPart][0];
142+
// }
143+
} else {
144+
value = item[placeholderPart]
145+
}
146+
} else {
147+
value = value[placeholderPart];
145148
}
146-
} else {
147-
value = value[placeholderPart];
148149
}
149150
itemCounter++;
150151
}

src/commerce-backend-ui-1/web-src/src/component/ExtensionRegistration.js.dist renamed to src/commerce-backend-ui-1/web-src/src/component/ExtensionRegistration.js

File renamed without changes.

0 commit comments

Comments
 (0)