After some more investigations I see that the [dbo].[tblPropertyDefinition] table is not updated with the new metafield.
Initially was an warning that we had a metafield with the name Weight same as a property for variants. We removed that and still the issue persists.
Any help would be appreciated.
Thank youm
I can confirm that we have code to process cases when you linked/unlinked metafield from metaclass on a remote site (for example, Commerce Manager). However, if the changes happen in the same site then I'm not sure. I'll look into it.
I had a chance to look into it, and the reason for not processing local events was to avoid a loop of events. However, you can work around that by adding this into your code
var contentTypeModelScanners = ServiceLocator.Current.GetAllInstances<IContentTypeModelScanner>();
foreach (var scanner in contentTypeModelScanners)
{
scanner.RegisterModels();
scanner.Sync(true);
}
after adding or removing the metafield(s)
Hi again
Eventually we couldn't make that work.
We tried that approach, but unfortunatellywe didn't have success as the scanner.Sync(true) is throwing and error: "Value cannot be null. Parameter name: key"
And couldn't debug that. There seem to be around 140 objects in the scanner that needs to be updated and probably one of them has some issue.
I tried to look into what is throwing the error, but couldn't find the issue.
We tried to write a job trying to do that and got the same issue.
We also looked into trying to force the change from the commerce manager, still no luck, unlinking and save and then linking again the meta field would not display it
Do you have any idea on what could we looke further into this?
Is there a posibility to trigger this from a job or an API call or even maybe even isolate the call that are made initially at site start when the metafields are updated?
Thanks,
This is done by Commerce during startup, so there is no need for you to do that yourself.
I was thinking to run the same code from a job, not at the start.
The issue is that we have releases each 2 weeks and we don't restart on other times.
But new metafields are sometimes added and we would like for them to be available faster.
We have an import that creates metafields from the code. The relations and the values reach the DB. But the fields don't show on the Commerce UI or on the code retrieving the data for PDPs.
When the site is restarted the metafields are present on the UI too.
Do you know how to make the fields displayed without a site restart? (for production)
I already looked at the MetaField.ClearCache and MetaClass.ClearCache, but no luck. Is there a call that we can do when the fields are created to force them to be dislayed?
Thanks