There are various ways to do this:
The recommended way is to have the strongly typed content type for your metaclass, and set it like this:
yourContent.YourProperty = "new value";
ContentRepository.Save(yourContent, SaveAction.Publish);
this works for Commerce 7.5+
Thanks Sapna & Quan for prompt response. Can you please help me a bit more. Let me explain further. Here is my code:
public class InitializationModule : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
var contentEvents = context.Locate.ContentEvents();
contentEvents.PublishedContent += EventsPublishedContent;
}
}
private void EventsPublishedContent(object sender, EventArgs e)
{
//Here I will call a web service. This web method will return me an id. I need to save this id into current published product metafield.
}
Please suggest if I can update metafield in above event. Does eventargs holds current published product information? FYI, I have created Metafields, Metaclass through UI only.
Hi,
I have created few metafields and associate these with a meta class. After that I have created Product and publish it. On Publish event, I want to update these metafield's value of published product. Please suggest how to update. FYI, I am able to capture publish event.
Thanks.