SaaS CMS has officially launched! Learn more now.

Including Open Graph metadata at a variant level.


Was wondering if it was possible to add specific Open Graph metadata (og:url, og:type, og:image, etc.) at a variant level with our current catalogue structure.

We want the variant Image (the right color) to be displayed when the URL is shared.

Variants are accessible via a unique query parameter added to each "Master product".

A "Variant" is a combination of a Color & Size for a specific Style. As such:

Type URL
Master Product 221317
  - Pink (3847) S
  - Pink (3847)  M
  - Pink (3847)  L
  - Taupe (8012) S
  - Taupe (8012) M
  - Taupe (8012) L

We are using Commerce 13.3

Any help would be much appreciated. Thanks!

Nov 04, 2021 15:06

Hi Joelle,

Yes, thats very possible. In your product controller, you can load the variant by the variant code in the query string when it is present.

There is a good code example of loading a products variants in the ProductController of the Foundation code base:

Check out this class: Foundation/CatalogEntryViewModelFactory.cs at develop · episerver/Foundation · GitHub

Once you load the variant you have access any properties associated with it including images if you wish to store them there.


Nov 09, 2021 17:02

Thank you for your help Johnny!

Nov 09, 2021 17:38
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.