November Happy Hour will be moved to Thursday December 5th.

Make Assets mandatory (Commerce 8.11.4)

Vote:
 

Hi

Is it posible to every time I create a Product its MUST have a assets (Mandatory), like a picture?

Juan

#122632
Jun 08, 2015 16:28
Vote:
 

Hi,

You can hook into catalog events.

http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Commerce/8/Content/catalog-events/

http://world.episerver.com/blogs/K-Khan-/Dates/2015/5/hook-into-catalog-events/

In theory this should work

var contenEventHandler = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<EPiServer.Core.IContentEvents>();
                contenEventHandler.SavingContent += contenEventHandler_SavingContent;

void contenEventHandler_SavingContent(object sender, ContentEventArgs e)
        {
//your conditions and actions
            e.CancelAction = true;
        }



Regards
/K

#122652
Jun 09, 2015 11:29
Vote:
 

Thanks Khan,

The idea is to prevent saving a product and show the client a error msg if the assets list is empty, or some other condition in assets.

I will try the eventHandler...

Juan 

#122656
Jun 09, 2015 12:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.