Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Tutorial 2 - ExtensionProfile

Tutorial 2 - ExtensionProfile

Introduction

In this tutorial, you will study a new resource with a linking and reading strategy. You will see how data can be extracted from the out-of-the-box profiles representation and inserted into the ExtendedProfile's representation. This method can be used to customize the output of any Cortex API resource.

Warning: Before you begin

Make sure your development environment has been properly set up as described in Setting up your Developer Environment.

Begin: Installing Cortex API Tutorials

Source files

The files created in this tutorial are found in the tutorials zip under /Rest-Tutorials/rest-resource-extensionprofile directory.

rest-resource-extensionprofile has the following directory structure:

  • <artifact_id>
    • src
      • main
        • java
        • resources
          • OSGI-INF
            • blueprint
              • extensionprofile-blueprint
              • springCtx-import
            • config
              • permission.properties
          • spring
            • applicationContext-extensionprofile-resource.xml
      • test
        • java
    • target
    • pom.xml

LinkToExtensionProfileStrategy.java

LinkToExtensionProfileStrategy.java is the link strategy implementation. It is responsible for creating links to other resources.

ReadExtensionProfileCommandBuilder.java

ReadExtensionProfileCommandBuilder.java is the builder for the read strategy. This is injected into the resource operator.

ReadProfileStrategy.java

ReadProfileStrategy.java is the read strategy implementation. It is responsible for extracting data from other resources.