Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Default value based on catalog

Vote:
 

Hi,

I'm trying to set a default value in commerce on content based on the catalog I'm creating the Category/Product/Variant in. I was hoping to set the values by overriding SetDefaultValues(ContentType) but the catalogId is always 0 when creating a new content item until it's published. Second option was to use the content events from an initialization module such as OnCreatingContent but same issue. OnCreatedContent actually contains the catalogId but then it's already too late. Would there be another of dealing with this issue?

Thank you,

Pier

#266750
Nov 15, 2021 15:15
Vote:
 

I just checked on a product item and SetDefaultValues worked fine for me. Can you provide some screenshots, code of your issues. It sounds like you make have something custom in your implementation causing issues

#266757
Nov 15, 2021 20:16
Vote:
 

Hi Scott,

The following implementation isn't the one that supports the Catalog specific but shows the CatalogId not being set when I'm trying to define other values based on it.

#266759
Edited, Nov 15, 2021 20:30
Vote:
 

Although SetDefaultValues doesn't have a CatalogId at this point the ParentLink is set which is a ContentReference. So you can load this to get the correct Catalog Node it belongs to and then look up it's ancestor tree to get the Catalog.

#266814
Nov 16, 2021 15:22
* 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.