Salesforce Commerce Cloud connector configuration

You can create or edit the configuration in the JCR or the File System (YAML) under /ecommerce-salesforce-connector/ecommerces/salesforce-commerce.yaml.

If you do not want the connection definition to appear in any of the subapps, set the enabled property (YAML line 3) to false.

Note, that you can write your own implementation (YAML lines 4-14) or in the JCR under /ecommerce-salesforce-connector/ecommerces/salesforce-commerce.yaml to suit your requirements, for example, to use additional features such as cross- and up-selling or custom features such as your own checkout solution.

/ecommerce-salesforce-connector/ecommerces/salesforce-commerce.yaml
class: info.magnolia.ecommerce.common.EcommerceDefinition
type: salesforce-commerce
enabled: true
implementation:
  products:
    all: info.magnolia.ecommerce.salesforce.products.All
    byId: info.magnolia.ecommerce.salesforce.products.ById
    byCategoryId: info.magnolia.ecommerce.salesforce.products.ByCategoryId
    searchByText: info.magnolia.ecommerce.salesforce.products.SearchByText
  categories:
    all: info.magnolia.ecommerce.salesforce.categories.All
    byId: info.magnolia.ecommerce.salesforce.categories.ById
    byParentCategoryId: info.magnolia.ecommerce.salesforce.categories.ByParentCategoryId
    byProductId: info.magnolia.ecommerce.salesforce.categories.ByProductId
  connectionValidator: info.magnolia.ecommerce.salesforce.common.SalesforceConnectionValidator
connections:
  connection:
    authUrl: https://account.demandware.com/dw/oauth2/access_token
    baseUrl: https://zzxz-003.sandbox.us01.dx.commercecloud.salesforce.com/s/-/dw/data/v20_10
    enabled: true
    credentials:
      username: client_id
      password: password_or_path_to_password_manager
    parameters:
      shopUrl: /s/RefArchGlobal/dw/shop/v20_10
      siteId: site_id
Property Description

class

required

info.magnolia.ecommerce.common.EcommerceDefinition

type

required

Your e-commerce solution: salesforce-commerce

enabled

required

true or false

connections

     connectionName

         authUrl

required

Authentication URL.

         baseUrl

required

Base URL.

         enabled

required

Shows if the connection is enabled or not: true or false

         credentials

             username

required

Salesforce Commerce Cloud client_id.

The username and password (see below) parameter values are the Salesforce API client_id and password you retrieve from the Salesforce Commerce Cloud Account Manager: https://account.demandware.com/.

First, log into your Salesforce Account Manager (https://account.demandware.com) and go to the API Client tab to create a new API client.

When creating the API client, note that:

  • The password you create for the new API client is used as the password parameter value (see next cell).

  • We recommend you use the Salesforce Commerce API role, client_secret_post Token Endpoint Auth method and JWT Access Token Format.

See Add an API Client in the Salesforce documentation for more information.

Next, log into the Salesforce Business Manager to configure Open Commerce API (OCAPI) client permissions for the API client you created:

  1. Select Administration > Site Development > Open Commerce API Settings. Salesforce Business Manager

  2. Add the API client for both the Shop and Data APIs.

    Shop API configuration example:

    Shop API

    Basic sample sandbox configuration: shop_api.xml

    Data API configuration example:

    Data API

    Basic sample sandbox configuration: data_api.xml

  3. Use the client_id from Salesforce as the username in the Magnolia salesforce-commerce.yaml file.

See "Client Permissions" in the Salesforce documentation for more information.

             password

required

Password entered when creating the Salesforce Commerce Cloud API client (or the path to the Magnolia password manager where the password is stored).

See details in the cell above.

         parameters

             shopUrl

required

URL used for cart and checkout functionality for Salesforce.

             siteId

required

The site_id from Salesforce.

You must enter a valid site_id value for product pricing information to be displayed correctly.

You can set this property to no-site to create a connection to all unassigned Salesforce catalogs.

However, if you do so, note that no price information is displayed in the product detail component for the selected product.

Viewing and testing connections

This section explains how to view and test the connection between the Magnolia E-commerce add-on module and your external commerce solution using the E-commerce app.

  1. Open the E-commerce app Configuration tab.

  2. Select a connection.

  3. Click View to see the details of your connection to an external e-commerce solution.

    View connection dialog

Depending on your external e-commerce solution, the connection information displayed may be:

  • Definition name - The unique definition name. This name appears in the Catalogs subapp.

  • Connection name - The unique name for the connection configured.

  • E-commerce type - The type of external e-commerce solution you are connected to.

  • Authentication URL - Authentication URL for the solution you are connected to.

  • Base URL - Base URL for the solution you are connected to.

  • Username and Password - Credentials to access the external solution. Passwords or client secrets can be managed in the Passwords app.

  • Connection enabled - Shows if the connection is enabled or not. You may choose to disable the configuration, for example, to improve performance times or to test a connection in one environment before enabling it in another.

Click Test connection to check the connection configuration is correct. A message appears indicating if the test is successful or not.

Once you’ve tested your connection, go to the E-commerce tab. You can see the connections you have configured listed with the catalogs they contain.

Connection configuration validator

The info.magnolia.ecommerce.common.ConnectionValidator interface and its implementations check if a connection configuration is valid.

The connection validation check is executed when you click Test connection.

If the connectionValidator property is not configured, the default info.magnolia.ecommerce.common.DefaultConnectionValidator implementation is used. The default connection validator fallback only checks if the categories are returned by the service. This could give a false negative in some cases where the connection works but no categories exist.

The implementations of info.magnolia.ecommerce.common.ConnectionValidator are configured under: <module-name>/ecommerces/<definition-name>.yaml:

  • Default implementation: info.magnolia.ecommerce.common.DefaultConnectionValidator

    Evaluates the connection configuration as valid if it returns a non-empty list of categories.

  • commercetools: info.magnolia.ecommerce.commercetools.common.CommercetoolsConnectionValidator

    Evaluates the connection configuration as valid if no exceptions are thrown when getting the project.

  • Adobe Commerce (formerly Magento): info.magnolia.ecommerce.magento.common.MagentoConnectionValidator

    Evaluates the connection configuration as valid when a not empty token is returned.

  • Salesforce: info.magnolia.ecommerce.salesforce.common.SalesforceConnectionValidator

    Evaluates the connection configuration as valid when getting catalogs does not throw an exception when connection parameter siteId equals no-site. In other cases, a site with a configured `siteId must be returned.

  • SAP commerce: info.magnolia.ecommerce.sap.common.SapConnectionValidator

    Evaluates the connection configuration as valid when the returned list of BaseSites contains the configured connection name.

For example, this is a snippet of the connection configuration and implementation with the connectionValidator set to the Commercetools implementation:

class: info.magnolia.ecommerce.common.EcommerceDefinition
type: commercetools
enabled: true
implementation:
  products:
    all: info.magnolia.ecommerce.commercetools.products.All
    byId: info.magnolia.ecommerce.commercetools.products.ById
    byCategoryId: info.magnolia.ecommerce.commercetools.products.ByCategoryId
    searchByText: info.magnolia.ecommerce.commercetools.products.SearchByText
  categories:
    all: info.magnolia.ecommerce.commercetools.categories.All
    byId: info.magnolia.ecommerce.commercetools.categories.ById
    byParentCategoryId: info.magnolia.ecommerce.commercetools.categories.ByParentCategoryId
    byProductId: info.magnolia.ecommerce.commercetools.categories.ByProductId
  connectionValidator: info.magnolia.ecommerce.commercetools.common.CommercetoolsConnectionValidator

Configuring the cache

By default, the content pulled from your external e-commerce solution is updated every 300 seconds (5 minutes). You can configure the cache setting via YAML:

resources/ecommerce/config.yaml
cachingDefinition:
  enabled: true
  invalidateInSeconds: 300

Configuring the images displayed in the E-commerce app

Images stored in your third-party e-commerce solution are displayed in the product detail view of the app.

You can configure:

  • If a single image or multiple images are displayed

  • The size of image(s) displayed.

For example:

ecommerce-ui/apps/ecommerce.yaml
    form:
      properties:
        images:
          label: Product image(s)
          $type: multipleImageField
          converterClass: info.magnolia.ecommerce.app.productdetail.field.URLsToStrings
          imageRatio: 60
Property Description

images

required

     label

optional

Field label displayed to editors. The value can be literal or a key of a message bundle.

If you do not provide the property, Magnolia will fall back to a generated i18n key.

If you do not want a label at all, define the property and set its value to a blank space such as label: " " in YAML.

     $type

required

Field type:

  • multipleImageField displays all images for the product (use with URLsToStrings converter).

  • URLImageField displays only the first image for the product (use with ListOfURLsToString converter).

     converterClass

required

info.magnolia.ecommerce.app.productdetail.field.URLsToStrings converts all images for the product. info.magnolia.ecommerce.app.productdetail.field.ListOfURLsToString converts only the first image for the product.

     imageRatio

optional

Defines the ratio of displayed images to the original images in percentage. In the example above, the value 60 is 60% of the original image size.

If the property isn’t set, the images are displayed in their original size.

Configuring chooser dialogs (v1.3+)

You can configure the component definition chooser dialogs introduced in v1.3.

You can find the component configuration under /ecommerce-templating/dialogs/components. There is also a section on chooser dialogs on the Category & Product use cases page.

The components introduced in v1.3 are suffixed with -v3. Those with no suffix are provided for backwards compatibility with E-commerce v1.2.x.

Product chooser dialog

By default, the chooser dialogs have four columns: connector, category, product and preview.

The Connector column is displayed when you have more than one connector correctly configured and enabled.

If you only have one connection enabled or correctly configured with a definitionName and connectionName in /<my-connector>/ecommerces/<my-connector>.yaml then the Connector column is disabled by default, unless you set enableCategorySelection to false.

The Category and Product columns are displayed by default. You can disable them using the enableCategorySelection and enableProductSelection properties under /ecommerce-templating/dialogs/components/<any-v3-component>.yaml.

By default, the system remembers the last selected item in a given chooser dialog. You can use the rememberLastSelectedLocation property to change this.

Property Description

$type

You can use this as a shortcut for class if the definition class is annotated with info.magnolia.ui.field.FieldType. The proper value is defined by the annotation.

Example class annotation
@FieldType("ecommerceProductLinkField")
public class EcommerceProductLinkFieldDefinition extends EcommerceLinkFieldDefinition {
...
}

See Field types for general values and the ecommercechooser directory for specific e-commerce field types (some examples are given at the end of this section).

enableCategorySelection

optional, default is `true`

Set to false to disable the category, product and preview columns.

The product column depends on the category column, so if enableCategorySelection is false, then any value set for enableProductSelection is overridden.

enableProductSelection

optional, default is `true`

Set to false to disable the product and preview columns.

rememberLastSelectedLocation

optional, default is `true`

When set to true, the system remembers the last item selected and positions a returning user on it when they reopen the same chooser dialog.

When set to false, nothing is preselected in the chooser dialogs.

Each type of e-commerce chooser dialog has its own last selected location. For example, the Product Detail component dialog does not share its last selected location with the Product Teaser component dialog and vice versa.

When the Pages app is closed, all remembered locations are removed.

Configuring text classification and image recognition for e-commerce content

If you have configured them, both Image Recognition and Text Classification are enabled for your e-commerce content.

To trigger the tagging operation, select a product and click Tag product in the E-commerce app action bar. You can view the tags generated in the ecommerce workspace in JCR Browser app (system properties view) or in the Tags app. You can search for products based on the tags in the Find Bar.

Default configuration:

ecommerce-decoration/config.yaml
imageRecogniserEnabled: true
textClassifierEnabled: true
autoRecognitionEnabled: false
Property Description

imageRecogniserEnabled

required, default is true

Enables image recognition functionality for e-commerce content.

Disable this functionality by setting the property to false.

textClassifierEnabled

required, default is true

Enables text classification functionality for e-commerce content.

Disable this functionality by setting the property to false.

autoRecognitionEnabled

required, default is false

Enables automatic tagging.

You can enable automatic tagging by setting the autoRecognitionEnabled property to true.

This action starts when the user opens a product list and may take a long time to execute.

Configuring timeout

You can configure connectionTimeoutInSeconds (the time needed to connect to the e-commerce solution) and readTimeoutInSeconds (the time needed to read and show the data you selected).

The default value for connectionTimeoutInSeconds is 10 while the default value for readTimeoutInSeconds is 30.

These values can be customized in the Resource Files app. Find the connector you want to modify, open the folder, and choose the config.yaml file:

/config.yaml
connectionTimeoutInSeconds: 30
readTimeoutInSeconds: 10
Replacing the value with lower than 1 results in error in commercetools, and infinite timeouts in other available connectors.
In commercetools you can set only the connectionTimeoutInSeconds. Adobe Commerce (formerly Magento), Salesforce Commerce Cloud, and SAP Commerce Cloud (formerly Hybris) support both connectionTimeoutInSeconds and readTimeoutInSeconds.
Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Ecommerce module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules