Other releases

Learn about recent changes to other important features, and how to apply them using the TypeScript or Java SDK.

  • After completing this page, you should be able to:

    • Identify how the changes affect the TypeScript and Java SDKs.
    • Apply the updated features using the TypeScript or Java SDK.
  • Product Selections

    Product Selections became generally available.

    It's a really useful feature that lets you manage your product catalog by customizing a selection of products for any of your sales channels such as brand sites, regional shops, or brick-and-mortar stores. It helps you in showcasing the right products to the right customers at the right time, whether you're creating exclusive or inclusive collections for different market segments, seasonal line-ups, or themed selections that tell a story.

    The following code sample shows how you can create a new Product Selection and add Products to it:

    import { apiRoot } from '../impl/apiClient.js'; // Update to map to your API root
    async function selectionCreate() {
    try {
    const response = await apiRoot
    .productSelections()
    .post({
    body: {
    key: 'berlin_product_selection-6',
    name: {
    'en-GB': 'Berlin Product Selection',
    'en-US': 'Berlin Product Selection',
    'de-DE': 'Berlin Product Selection',
    },
    },
    })
    .execute();
    console.log('Selection created', JSON.stringify(response.body, null, 2));
    const addSelectionResponse = await apiRoot
    .productSelections()
    .withId({ ID: response.body.id })
    .post({
    body: {
    version: response.body.version,
    actions: [
    {
    action: 'addProduct',
    product: {
    key: 'meadow-rug',
    typeId: 'product',
    },
    variantSelection: {
    type: 'includeOnly',
    skus: ['MR-08', 'MR-05'],
    },
    },
    ],
    },
    })
    .execute();
    console.log(
    'Selection created',
    JSON.stringify(addSelectionResponse.body, null, 2)
    );
    } catch (error) {
    console.log(JSON.stringify(error, null, 2));
    }
    }
    selectionCreate();

    You can see the newly created Product Selection in the Merchant Center.

    Assigned Products in the Product Selection list.

    Attribute Groups

    Attribute Groups became generally available.

    Team permissions are an important aspect of guaranteeing appropriate access for your team members. With Attribute Groups, you can group Attributes together so that Merchant Center Team permissions can define with more granularity which Product data is editable.

    The following code sample shows how you can create an Attribute Group:

    import { apiRoot } from '../impl/apiClient.js'; // Update to map to your API root
    const colourAttibuteGroup = {
    key: 'product_color_fields',
    name: {
    'en-GB': 'Product Color Fields',
    'en-US': 'Product Color Fields',
    'de-DE': 'Product Color Fields',
    },
    description: {
    'en-GB': 'Attributes related to the color of the product',
    'en-US': 'Attributes related to the color of the product',
    'de-DE': 'Attribute im Zusammenhang mit der Farbe des Produkts',
    },
    attributes: [
    { key: 'color' },
    { key: 'colorlabel' },
    { key: 'color-filter' },
    ],
    };
    async function attibuteGroup(attibuteGroup) {
    try {
    const response = await apiRoot
    .attributeGroups()
    .post({
    body: attibuteGroup,
    })
    .execute();
    console.log('Success', JSON.stringify(response.body, null, 2));
    } catch (error) {
    console.log(JSON.stringify(error, null, 2));
    }
    }
    attibuteGroup(colourAttibuteGroup);

    Now, when selecting Team permissions for editing Attributes on Products in the Merchant Center, we can select which Attribute Group/s should be editable.

    Attribute Groups in Team permissions

    New endpoint to check if a resource exists

    In a fluid environment with quick changes on resources done by a plethora of integrations, resources might not even exist anymore. Until now, when you tried to access a resource, your only way was to constantly watch for an error. We introduced a new endpoint for checking if a resource exists.

    As you already know, all communication to Composable Commerce APIs has traditionally been done using GET, POST, or DELETE calls; we have now added HEAD calls to the mix. To check if a resource exists, all you have to do now is to send a HEAD request to the specific resource and analyze the response status code. If the resource exists, a 200 is returned; else a 404. The presence of only the status code in the response makes the HEAD request faster and more lightweight than a GET request.

    The following code sample shows how you can check if a resource (Product) exists:

    import { apiRoot } from '../impl/apiClient.js'; // Update to map to your API root
    const productKey = 'chianti-wine-glass';
    async function productKeyHead(params) {
    try {
    const response = await apiRoot
    .products()
    .withKey({ key: 'chianti-wine-glass' })
    .head()
    .execute();
    console.log('Success', JSON.stringify(response.body, null, 2));
    } catch (error) {
    console.log(JSON.stringify(error, null, 2));
    }
    }
    productKeyHead(productKey);

    Extended CustomLineItem

    The CustomLineItem resource was extended with a new field, taxedPricePortions. If multiple Shipping Methods are used, this field will contain an array of taxed Prices for each Shipping Method.

    Custom Line Items are a great way to adjust the Price of your Cart without using Discounts or to add an item to the Cart that is not part of your product catalog.

    SDK observability

    We added support for the New Relic observability platform to our SDKs. It helps monitor your system's health, track API usage, and pinpoint areas for optimization. With this powerful feature, you can ensure that your digital commerce solution operates at peak efficiency.

    For more information about observability and how to set it up for your application, see Observability. We suggest going through the information on the page, as part of the learning requirements of this module. The examination includes questions related to the content given here.

    Test your knowledge