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.
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.
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.
Give your integration a name, enter your password and then click on the API tab on the sidebar to the left.
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.
Check that the displayed permissions are correct and then click the Allow button to activate the 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.
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:
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.
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.
© 2021 Status200 Ltd.