volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

AI OnAI Off

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 https://www.domain.com/en-ca/clothing/tops/beautiful-ity-blazer/
  - Pink (3847) S https://www.domain.com/en-ca/clothing/tops/ity-blazer/?variationCode=221317_3847_S_1
  - Pink (3847)  M https://www.domain.com/en-ca/clothing/tops/ity-blazer/?variationCode=221317_3847_M_1
  - Pink (3847)  L https://www.domain.com/en-ca/clothing/tops/ity-blazer/?variationCode=221317_3847_L_1
  - Taupe (8012) S https://www.domain.com/en-ca/clothing/tops/ity-blazer/?variationCode=221317_8012_S_1
  - Taupe (8012) M https://www.domain.com/en-ca/clothing/tops/ity-blazer/?variationCode=221317_8012_M_1
  - Taupe (8012) L https://www.domain.com/en-ca/clothing/tops/ity-blazer/?variationCode=221317_8012_L_1

We are using Commerce 13.3

Any help would be much appreciated. Thanks!

#266229
Nov 04, 2021 15:06
Vote:

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:

https://github.com/episerver/Foundation

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.

Thanks

#266453
Nov 09, 2021 17:02

Thank you for your help Johnny!

#266474
Nov 09, 2021 17:38
error 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.