Vulnerability in EPiServer.Forms
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?
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
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.
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.