Documentation Center

Get a commerce product

Use the externalItem GraphQL query get a single Magento Commerce product.

Query syntax

The following code illustrates required format for the GraphQL request, followed by a description of the input values:

{
   externalItem([eclUri: "ECL-URI"]
                [identity: {
                    namespace: "NAMESPACE",
                    id: "IDENTIFIER",
                    type: "TYPE"
                }]) 
   {
      ... on TYPE {
      RESPONSE_FIELD_1
      RESPONSE_FIELD_2
      RESPONSE_FIELD_n
      }
   }
}

Fields and inputs

eclUri
ECL-URI for the entity being requested.
When using the Connector for integration with Content Manager and External Content Library (ECL), the ECL-URI can be used as an alternative to the identity parameter. It is normally something that comes from Tridion Sites in form of an ECL component link.
identity
The identity object is formed from the following field values to uniquely identify the entity to be retrieved:
namespace
Where NAMESPACE is the namespace where the external data is made available.
If defined at a higher level of the query, the namespace does not need to be separately specified here.
id
Where IDENTIFIER is the unique identifier provided by the external system.
type
Where TYPE refers to the external entity type.
... on TYPE
Defines the query response, where:
  • TYPE is the entity type and matches the TYPE value in the identity section.
  • RESPONSE_FIELD_1 to RESPONSE_FIELD_n are the specific data fields that you want to be returned in the response.
The GraphQL type definition of the entity type determines which fields are available in a response.

Example request and response

The first sample code block illustrates a request to retrieve a product based on its ECL URI. The second code block illustrates the corresponding response with the requested product details.

RequestResponse
{
  externalItem(eclUri: "ecl:2-magento-TUgwMS1TLUJsYWNr!5F;
Y29udGVudA!25;3d!25;3d-MagentoProduct-file") {
    ... on MagentoProduct {
      title
      filename
      summary
      description
      price {
        currency
        formattedValue
        value
      }
      quantity
      inStock
      weight  
     images {
       altText
       contentType
       imageReference
       imageType
       mediaType
     }
      thumbnail
    }
  }
}

























{
  "data": {
    "externalItem": {
      "title": "Chaz Kangeroo Hoodie-S-Black",
      "filename": "TUgwMS1TLUJsYWNr_Y29udGVudA%3d%3d.mht",
      "summary": "",
      "description": "<p>Ideal for cold-weather training or work outdoors, the Chaz 
Hoodie promises superior warmth with every wear. Thick material blocks out the wind 
as ribbed cuffs and bottom band seal in body heat.</p> \n<p>• Two-tone gray heather 
hoodie.<br />• Drawstring-adjustable hood. <br />• Machine wash/dry.</p>",
      "price": {
        "currency": "EUR",
        "formattedValue": "€ 52",
        "value": "52"
      },
      "quantity": 100,
      "inStock": "In stock",
      "weight": "1 lbs",
      "images": [
        {
          "altText": "",
          "contentType": "image/jpeg",
          "imageReference": "http://10.111.32.21:8081/cd/api/external/binary/magento/
eyJDb250ZW50VHlwZSI6ImltYWdlL2pwZWciLCJFbnRpdHlUeXBlIjoiSW1hZ2UifQ%3d%3d/
NTc%253d_TUgwMS1TLUJsYWNr_YXNzZXQ%253d",
          "imageType": "image",
          "mediaType": "image"
        },
        {
          "altText": "",
          "contentType": "image/jpeg",
          "imageReference": "http://10.111.32.21:8081/cd/api/external/binary/magento/
eyJDb250ZW50VHlwZSI6ImltYWdlL2pwZWciLCJFbnRpdHlUeXBlIjoiSW1hZ2UifQ%3d%3d/
NTc%253d_TUgwMS1TLUJsYWNr_YXNzZXQ%253d",
          "imageType": "small_image",
          "mediaType": "image"
        },
        {
          "altText": "",
          "contentType": "image/jpeg",
          "imageReference": "http://10.111.32.21:8081/cd/api/external/binary/magento/
eyJDb250ZW50VHlwZSI6ImltYWdlL2pwZWciLCJFbnRpdHlUeXBlIjoiSW1hZ2UifQ%3d%3d/
NTc%253d_TUgwMS1TLUJsYWNr_YXNzZXQ%253d",
          "imageType": "thumbnail",
          "mediaType": "image"
        }
      ],
      "thumbnail": "http://10.111.32.21:8081/cd/api/external/binary/magento/
eyJDb250ZW50VHlwZSI6ImltYWdlL2pwZWciLCJFbnRpdHlUeXBlIjoiVGh1bWJuYWlsIn0%3d/
TUgwMS1TLUJsYWNr_Y29udGVudA%253d%253d"
    }
  }
}