Posted on 07/10/2025 15:20:28

private async Task<Product> CreateProductAsync(DynamicsModelDto model, Language language)
{
var workflow = _workflowService.GetById(Convert.ToInt32(WorkflowId));
var workflowState = workflow is not null ? _workflowStateService.GetStates(workflow).FirstOrDefault() : null;
var product = new Product()
{
Id = RegexExtensions.RemoveNonAlphanumeric(model.No!, "_"),
Number = model.No,
Name = HttpUtility.HtmlDecode(await GetItemTranslation(model.No!, language) ?? model.Description),
Active = true,
LanguageId = language.LanguageId,
NeverOutOfStock = true
};
if (workflowState is not null)
{
_productService.Save(product);
product.WorkflowStateId = workflowState.Id;
using(var context = new NotificationContext(NotificationContext.NotificationState.Notify))
{
NotificationManager.Notify(Ecommerce.Product.ProductWorkflowStateChanged, new Ecommerce.Product.ProductWorkflowStateChangedArgs(product, 0));
}
}
}
There is some more code related to other fields, but this part of the add in related to creation of the product and emitting the workflow notification.
I've tried adding a context around the notificationmanager. But doesnt change a thing, when running the code locally i still dont get an email saved to the disk