volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Make Assets mandatory (Commerce 8.11.4)

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

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

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.