E-commerce Integration: Magento 2

Magento 2 integration cover image

The Magento 2 integration allows you to relate products and categories from your Magento store to your CMS content.

This enables you to accomplish a numbers of things such as embedding shoppable products in the middle of blog posts and implementing featured product/category sections.

In addition to this, the integration can be combined with LexasCMS’s personalisation features, enabling you to show personalised product/category recommendations to each customer.

In this guide, we’ll explain how the integration works and then show you how to install, configure and use it.

How does it work?

Under the hood, the Magento 2 integration is actually quite simple. After installation, the Magento 2 application creates and configures a couple of internal content types, one being for products and the other for categories.

These content types can then be referenced by LexasCMS’s relationship field type as you would with any content types defined by you.

When a relationship is created, LexasCMS will capture the SKU/ID of the product/category, to be returned by the Content Delivery API. This data can then be used to fetch the full product/category data from your Magento API.

1. Generate a Magento access token

Before you can install LexasCMS’s Magento 2 application, you first need to create and configure an integration within your Magento 2 admin panel. The integration will generate an access token which you’ll need later.

Start by logging into your Magento admin panel, and navigating to the System > Integrations section.

From here, click on the Add New Integration button.

Add new integration in Magento 2 admin panel

Give your integration a name, enter your password and then click on the API tab on the sidebar to the left.

Configure Magento 2 integration

Set the Resource Access field to Custom, provide the integration with access to the Product and Category resources.

After that, click the Save & Activate option from the save buttons dropdown menu.

Configure Magento 2 integration permissions

Check that the displayed permissions are correct and then click the Allow button to activate the integration.

Activate Magento 2 integration

Once the integration has been activated, you’ll be shown a set of credentials. Copy the Access Token, as you’ll need it in the next step.

Copy access token for Magento 2 integration

2. Install the Magento 2 application

Once you have your access token from the previous step, you’ll need to install the Magento 2 application on your space.

To install the Magento 2 application:

  1. Navigate to the Settings > Apps section of your space
  2. Click the Install Application button
  3. Enter a name for your application
  4. Select Magento 2 as the application type
  5. Enter your Magento stores base URL and store code
  6. Enter the access token that you created earlier
  7. Click the Install Application button

3. Configure your content model

As mentioned earlier, the Magento 2 application defines a couple of new content types, one being for products and other for categories.

The new content types are named in the following format:

[Application Name]: [Entity Type]

For example, for an application named My Magento Store, the product content type would be called My Magento Store: Product.

In order create relationships between your Magento products/categories, you’ll need to create or update a relationship field in one of your own content types, to reference one or both of the new ones provided by the application.

This is done from the Configuration tab of a relationship fields configuration modal, in exactly the same way as you would with any other content type.

4. Retrieve data

Once your content model has been updated, any relationships that you create will be returned from the Content Delivery API in exactly the same way as relationships to your own content types.

The only difference is that the relationship data will only contain the SKU/ID of the product/category, which you can then use to retrieve the full product/category data from your Magento API.

Integrates with your favourite tools and frameworks

© 2021 Status200 Ltd.