Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

ManufacturerCacheEventConsumer.cs

using Nop.Core.Domain.Catalog;
using Nop.Services.Caching;
using Nop.Services.Discounts;

namespace Nop.Services.Catalog.Caching;

/// 
/// Represents a manufacturer cache event consumer
/// 
public partial class ManufacturerCacheEventConsumer : CacheEventConsumer
{
    /// 
    /// Clear cache data
    /// 
    /// Entity
    /// Entity event type
    /// A task that represents the asynchronous operation
    protected override async Task ClearCacheAsync(Manufacturer entity, EntityEventType entityEventType)
    {
        await RemoveByPrefixAsync(NopDiscountDefaults.ManufacturerIdsPrefix);

        if (entityEventType != EntityEventType.Insert)
        {
            await RemoveByPrefixAsync(NopCatalogDefaults.ProductManufacturersPrefix);
            await RemoveByPrefixAsync(NopCatalogDefaults.ManufacturersByCategoryPrefix);
        }

        if (entityEventType == EntityEventType.Delete)
            await RemoveAsync(NopCatalogDefaults.SpecificationAttributeOptionsByManufacturerCacheKey, entity);

        await RemoveAsync(NopDiscountDefaults.AppliedDiscountsCacheKey, nameof(Manufacturer), entity);

        await base.ClearCacheAsync(entity, entityEventType);
    }
}