Developer forum

Forum » Development » Product save notification

Product save notification


Reply
Hi

Is there any notification for product save like the one for product group?
[Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Group.Updated)]
Or how can I access the product when it is saved?

Kind regards
/Magnus

Replies

 
Reply

Hi,

There is no notification AFAIK.

You could probably use Ribbon extensibility or...

Another approach is to use extensibility available in the searching api...


public class ProductSavedHandler : Dynamicweb.Extensibility.Searching.IDataItemListener
    {
[ModificationsCategory("eCommerce")]
        public void HandleDataItemModifications(string category, Dynamicweb.Extensibility.Searching.DataItemModificationsInfo info)
        {
            var productinfo = info as Dynamicweb.Extensibility.Searching.ProductModificationsInfo;
            if(productinfo == null) return;
 
            switch (productinfo.State)
            {
                case Dynamicweb.Extensibility.Searching.DataItemState.New:
                case Dynamicweb.Extensibility.Searching.DataItemState.Updated:
                    var product = new Dynamicweb.eCommerce.Products.Product(productinfo.ID, productinfo.VariantID, productinfo.LanguageID);
                    // do your stuff here
                    break;
            }        
        }
    }
 


Note: The HandleDataItemModifications might be called more than once when a product is saved.


BR.
Morten

 

You must be logged in to post in the forum