Cert++
Close

Linking CMS images and attachments to product records

Key Takeaway

A ProductMedia record links a product to CMS content, and its media group sets what the media is for, such as the listing image.

In a B2B Commerce store, product images and attachments are linked to products through ProductMedia records. Each record points to a Product2 record and to Salesforce CMS content. The store reads that content through a channel to the CMS workspace. You can create these links one product at a time in the store, in bulk with a CSV product import, or through the API. These links matter because they connect a product to the images and attachments the store shows for it.

How a product links to its media

ProductMedia, available in API version 49.0 and later, is the object that adds rich media, including images and attachments, to a product. Think of a ProductMedia record as a connector between a product and CMS content. Its fields hold the details:

  • ProductId is a lookup to Product2, so it names the product.
  • ElectronicMediaId is a polymorphic lookup to ManagedContent or ManagedContentInfo, so the media it points to is CMS content.
  • ElectronicMediaGroupId is a lookup to ElectronicMediaGroup, so it names the media group.
  • SortOrder sets the order the media is displayed in.

ProductMedia supports create(), update(), upsert(), delete(), and query(), so an integration can link media to products through the API. ProductMediaChangeEvent (API version 57.0) provides change events. Field history is available for tracked fields. Sharing rules are available for the object.

ProductMedia belongs to the Product and Category Media data model, which connects products and categories to images and other attachments. The model's objects include Product2, ProductCategory, ProductMedia, ProductCategoryMedia, ElectronicMediaUse, ElectronicMediaGroup, and ManagedContentInfo. These objects require a B2B Commerce license. To access product media, a user needs the B2B Commerce license and a CMS workspace.

Salesforce Accredited B2B Commerce Developer Professional Study Guide

Checklist progress

0/124Learned

Manage data intelligently with regard to relationships and integrations as needed to support getting a B2B Storefront established and running

0/29

Product bundles versus product sets

Learn this concept

Tiered and volume pricing data model

Learn this concept

WebCart and its related cart objects

Learn this concept

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Salesforce Accredited B2B Commerce Developer Professional studiers.