Skip to content

Commit f2b6601

Browse files
authored
Merge pull request #1 from comwrap/saas
Saas compatibility
2 parents 40d79c6 + 6838c84 commit f2b6601

136 files changed

Lines changed: 84652 additions & 54283 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ExtensionRegistration.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

INSTALL.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ To required environment add:
1717
* I/O Events
1818

1919

20-
### Adobe Api Mesh
20+
### Adobe Api Mesh (Optional)
2121

2222
1. Add "Api Mesh" service to your environment.
2323
2. Rename file `adobe-api/mesh/mesh.json.dist` into `adobe-api/mesh/mesh.json`.
2424
3. Change required options inside `adobe-api/mesh/mesh.json`.
25-
* MAGENTO-URL (This should be your Adobe Commerce system's base URL.)
26-
* MAGENTO-TOKEN
27-
28-
You can obtain the token by following these [steps](https://experienceleague.adobe.com/en/docs/commerce-admin/systems/integrations). Copy the Access Token value once generated. Additionally, you need to enable the "[Integration Token](https://experienceleague.adobe.com/en/docs/commerce-admin/systems/integrations)" functionality if it is not enabled yet. The generated token does not expire, but it can be updated if necessary.
25+
* AC-URL (This should be your Adobe Commerce system's base URL to GQL Endpoint)
2926

3027
3. Provision Mesh by using this file with `aio api-mesh create adobe-api/mesh/mesh.json`.
3128

@@ -39,19 +36,47 @@ To required environment add:
3936
Set following variables:
4037

4138
```
42-
MESH_SOURCE_URL= // Your Mesh URL
43-
AC_API_TOKEN= // Adobe Commerce Integration Bearer Token
39+
AC_GRAPHQL_URL= // Your GraphQL URL
4440
AC_DEFAULT_STORE_CODE= // Default Adobe Commerce Store Code
41+
AC_ENVIRONMENT_ID= // Your Environment ID for Catalog Service if used (optional)
42+
```
43+
44+
6. Configure Adobe Commerce Authorization
45+
46+
In env.dist file you will find set of Auth parameters.
47+
48+
**For Adobe Commerce PaaS:**
49+
50+
These values can be copied from the Integration Details under System > Integrations in your Adobe Commerce backend
51+
52+
```
53+
COMMERCE_CONSUMER_KEY=
54+
COMMERCE_CONSUMER_SECRET=
55+
COMMERCE_ACCESS_TOKEN=
56+
COMMERCE_ACCESS_TOKEN_SECRET=
57+
```
58+
59+
**For Adobe Commerce SaaS:**
60+
61+
Documentation how to get these values is available here: https://developer.adobe.com/developer-console/docs/guides/authentication/ServerToServerAuthentication/implementation
62+
63+
```
64+
OAUTH_CLIENT_ID=
65+
OAUTH_CLIENT_SECRET=
66+
OAUTH_TECHNICAL_ACCOUNT_ID=
67+
OAUTH_TECHNICAL_ACCOUNT_EMAIL=
68+
OAUTH_ORG_ID=
69+
OAUTH_SCOPES=AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets, event_receiver_api
4570
```
4671

47-
6. Create Event Provider for Feed Generator. Run `aio event provider create` and define name. Copy `id` from output.
72+
7. Create Event Provider for Feed Generator. Run `aio event provider create` and define name. Copy `id` from output.
4873
Add to `.env` line `FEED_GENERATOR_PROVIDER_ID=<id>`
4974

50-
7. Create Event Metadata for Feed Generator. Run `aio event eventmetadata create PROVIDERID`. Define event code as `feed.generate` and define description as `Generate Feed`.
75+
8. Create Event Metadata for Feed Generator. Run `aio event eventmetadata create PROVIDERID`. Define event code as `feed.generate` and define description as `Generate Feed`.
5176

52-
8. Run `aio app deploy` to deploy the app.
77+
9. Run `aio app deploy` to deploy the app.
5378

54-
9. Go To your application environment via Browser. Click on "Add Service" -> Event -> 3rd Party Custom Events -> And select your provider and event subscription. In Receiver define "Runtime action" as `processGeneration` action.
79+
10. Go To your application environment via Browser. Click on "Add Service" -> Event -> 3rd Party Custom Events -> And select your provider and event subscription. In Receiver define "Runtime action" as `processGeneration` action.
5580

56-
10. 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.
81+
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.
5782

README.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Feed Generator is a service that simplifies the process of generating product fe
44

55
## Installation
66

7+
Module compartible with both Adobe Commerce SaaS and PaaS.
8+
79
Please see [INSTALL.md](INSTALL.md) for more details.
810

911
## Home page / Grid
@@ -97,8 +99,24 @@ Based on this GQL schema you can use the following variables (starting inside of
9799
* {{description.html}}
98100
* {{price_range.minimum_price.regular_price.value}}
99101
* {{price_range.minimum_price.regular_price.currency}}
102+
* {{SimpleProduct||weight}}
103+
104+
SimpleProduct||** definition will be decoded like:
105+
106+
```graphql
107+
products(search: "Motiv") {
108+
items {
109+
... on SimpleProduct {
110+
weight
111+
}
112+
}
113+
}
114+
```
100115

101-
… and so on depends on a schema used
116+
… and so on depends on a schema used.
117+
118+
[!NOTE]
119+
In case you do not see some fields in autocompletion, it may be because your Schema has some custom or complex attributes. You can always enter them manually, and we would be happy to hear from you to add them to a future release.
102120

103121
### Filtering
104122

@@ -179,7 +197,7 @@ Header and Footer currently have a support to variables (Only 1 actualy)
179197

180198
### Dynamic variables
181199

182-
Variables are defined using double curly braces (`{{ }}`) and correspond to fields in the Magento GraphQL product output. For example, `{{sku}}` will be replaced with the product's SKU.
200+
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.
183201

184202
##### Additonal parameters
185203

@@ -188,17 +206,26 @@ Variables are defined using double curly braces (`{{ }}`) and correspond to fiel
188206
When a variable corresponds to an array, you can use the `count` property to repeat the XML tag for each element in the array. For instance, using `count=5` will generate up to 5 tags, each containing a different value from the array.
189207

190208
```xml
191-
<g:brand count=5>{{manufacturer}}</g:brand>
209+
<g:brand>{{manufacturer count="5"}}</g:brand>
192210
```
193211

194212
##### Selecting Specific Array Elements with `index`
195213

196214
To select a specific element from an array, use the `index` property. This will generate a single tag with the value of the specified element from the array.
197215

198216
```xml
199-
<g:product_type index=2>{{categories.name}}</g:product_type>
217+
<g:product_type>{{categories.name index="2"}}</g:product_type>
218+
```
219+
220+
##### Selecting Attribute with Specific code
221+
222+
```xml
223+
<color>{{attributes.value code='color'}}</color>
200224
```
201225

226+
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.
227+
228+
202229
#### Example
203230

204231
```xml
@@ -254,12 +281,14 @@ Regenerate Feed - will trigger the event “generate.feed” for a particular fe
254281

255282
Action will be invoked when `feed.generate` event added.
256283

257-
* `getGqlSchema` - retrieve graphql schema from target magento app.
284+
* `getGqlSchema` - retrieve graphql schema from target Adobe Commerce.
258285

259-
* `getAllStores` - get all Magento stores by API
286+
* `getAllStores` - get all Adobe Commerce Stores by API
260287

261288
* `generateByCron` - trigger feed generation by OpenWisk alarms.
262289

290+
* `getConfig` - receive public module configs. Currently only return type of authorization (ims vs oauth).
291+
263292
Action is running every 30 minutes and checking by feed settings if it have to be regenerate. Process regeneration if necessary.
264293

265294
### Web elements
@@ -281,7 +310,7 @@ Action is running every 30 minutes and checking by feed settings if it have to b
281310
* Feed Item: Big text field to have XML | JSON there with feed item body
282311
* Feed Header
283312
* Feed Footer
284-
* Store View - select with list of available store views on Magento (websites also have to be there, but it is not possible to select them)
313+
* Store View - select with list of available store views on Adobe Commerce (websites also have to be there, but it is not possible to select them)
285314

286315
After saving the form, it saved into key/value storage and user have to be redirected to dashboard. Success message have to be shown there.
287316

actions/meshGql.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

adobe-api/mesh/mesh.json.dist

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
{
22
"meshConfig": {
33
"sources": [
4-
{
5-
"name": "REST",
6-
"handler": {
7-
"openapi": {
8-
"source": "MAGENTO-URL/rest/schema?services=storeStoreRepositoryV1,storeGroupRepositoryV1,storeWebsiteRepositoryV1",
9-
"schemaHeaders": {
10-
"Authorization": "Bearer MAGENTO-TOKEN"
11-
},
12-
"operationHeaders": {
13-
"Authorization": "Bearer {context.headers['m-ac-rest-api-token']}",
14-
"Content-Type": "application/json"
15-
},
16-
"includeHttpDetails": true
17-
}
18-
}
19-
},
204
{
215
"name": "GraphQL",
226
"handler": {
237
"graphql": {
24-
"endpoint": "MAGENTO-URL/graphql",
8+
"endpoint": "AC-URL/graphql",
259
"operationHeaders": {
26-
"store": "{context.headers['m-ac-gql-store-code']}",
27-
"Content-Type": "application/json"
10+
"Content-Type": "application/json",
11+
"Magento-Environment-Id": "{context.headers['Magento-Environment-Id']}",
12+
"Magento-Website-Code": "{context.headers['Magento-Website-Code']}",
13+
"Magento-Store-View-Code": "{context.headers['Magento-Store-View-Code']}",
14+
"Magento-Store-Code": "{context.headers['Magento-Store-Code']}",
15+
"Magento-Customer-Group": "{context.headers['Magento-Customer-Group']}",
16+
"x-api-key": "{context.headers['x-api-key']}",
17+
"Authorization": "{context.headers['Authorization']}",
18+
"store": "{context.headers['store']}"
2819
}
2920
}
3021
}

app.config.yaml

Lines changed: 7 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,7 @@
1-
application:
2-
actions: actions
3-
web: web-src
4-
runtimeManifest:
5-
packages:
6-
feed-generator:
7-
license: Apache-2.0
8-
inputs:
9-
LOG_LEVEL: debug
10-
apiKey: $SERVICE_API_KEY
11-
mesh_source_url: $MESH_SOURCE_URL
12-
m-ac-rest-api-token: $AC_API_TOKEN
13-
m-ac-gql-store-code: $AC_DEFAULT_STORE_CODE
14-
actions:
15-
saveFeed:
16-
function: actions/saveFeed/index.js
17-
web: 'yes'
18-
runtime: nodejs:20
19-
annotations:
20-
require-adobe-auth: true
21-
final: true
22-
deleteFeed:
23-
function: actions/deleteFeed/index.js
24-
web: 'yes'
25-
runtime: nodejs:20
26-
annotations:
27-
require-adobe-auth: true
28-
final: true
29-
getAllFeeds:
30-
function: actions/getAllFeeds/index.js
31-
web: 'yes'
32-
runtime: nodejs:20
33-
annotations:
34-
require-adobe-auth: true
35-
final: true
36-
getFeedByUuid:
37-
function: actions/getAllFeeds/getByUuid.js
38-
web: 'yes'
39-
runtime: nodejs:20
40-
annotations:
41-
require-adobe-auth: true
42-
final: true
43-
regenerateFeed:
44-
function: actions/regenerateFeed/index.js
45-
web: 'yes'
46-
runtime: nodejs:20
47-
inputs:
48-
providerId: $FEED_GENERATOR_PROVIDER_ID
49-
eventCode: feed.generate
50-
annotations:
51-
require-adobe-auth: true
52-
final: true
53-
processGeneration:
54-
function: actions/regenerateFeed/generate.js
55-
web: 'no'
56-
runtime: nodejs:20
57-
inputs:
58-
eventCode: feed.generate
59-
annotations:
60-
require-adobe-auth: false
61-
final: true
62-
relations:
63-
event-listener-for:
64-
- feed.generate
65-
generateByCron:
66-
function: actions/regenerateFeed/generateByCron.js
67-
web: 'no'
68-
runtime: nodejs:20
69-
annotations:
70-
require-adobe-auth: false
71-
final: true
72-
getAllStores:
73-
function: actions/magentoActions/getAllStores.js
74-
web: 'yes'
75-
runtime: nodejs:20
76-
annotations:
77-
require-adobe-auth: true
78-
final: true
79-
getGqlSchema:
80-
function: actions/magentoActions/getGqlSchema.js
81-
web: 'yes'
82-
runtime: nodejs:20
83-
annotations:
84-
require-adobe-auth: true
85-
final: true
86-
triggers:
87-
everyHalfOfHour:
88-
feed: /whisk.system/alarms/interval
89-
inputs:
90-
minutes: 30
91-
rules:
92-
everyHalfOfHourRule:
93-
trigger: everyHalfOfHour
94-
action: generateByCron
1+
extensions:
2+
commerce/backend-ui/1:
3+
$include: src/commerce-backend-ui-1/ext.config.yaml
4+
productDependencies:
5+
- code: COMMC
6+
minVersion: 2.4.5
7+
maxVersion: 3.0.0

env.dist

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Your Adobe Commerce GraphQL URL / OR Mesh URL
2+
AC_GRAPHQL_URL=
3+
# Your system Environment ID for Catalog Service OR Tennant ID of SaaS (optional, for SaaS or for Catalog Service endpoints)
4+
AC_ENVIRONMENT_ID=
5+
6+
# Default Store to use for default setup
7+
AC_DEFAULT_STORE_CODE=default
8+
9+
# Default Runtime Setup
10+
OAUTH_BASE_URL=https://ims-na1.adobelogin.com/ims/token/
11+
IO_MANAGEMENT_BASE_URL=https://api.adobe.io/events/
12+
13+
# Event provider for feed generation
14+
FEED_GENERATOR_PROVIDER_ID=
15+
16+
# Rest API URL. Commerce base URL should finish with slash '/'
17+
COMMERCE_BASE_URL=
18+
19+
20+
# Commerce OAuth configs
21+
# These values can be copied from the Integration Details under System > Integrations
22+
COMMERCE_CONSUMER_KEY=
23+
COMMERCE_CONSUMER_SECRET=
24+
COMMERCE_ACCESS_TOKEN=
25+
COMMERCE_ACCESS_TOKEN_SECRET=
26+
27+
# OAuth configs for SaaS (IMS)
28+
## More info: https://developer.adobe.com/developer-console/docs/guides/authentication/ServerToServerAuthentication/implementation
29+
30+
OAUTH_CLIENT_ID=
31+
OAUTH_CLIENT_SECRET=
32+
OAUTH_TECHNICAL_ACCOUNT_ID=
33+
OAUTH_TECHNICAL_ACCOUNT_EMAIL=
34+
OAUTH_ORG_ID=
35+
OAUTH_SCOPES=AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets, event_receiver_api

0 commit comments

Comments
 (0)