Toggle-able attribute filters

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hi,

I'm trying to replace the standard attribute filters such that each attribute option can be toggled on and off via a checkbox - I have no problem with implementing this from an HTML/CSS/Razor standpoint apart from the fact that the Model that drives _FilterSpecsBox doesn't have any option Ids in it, so I can't calculate the appropriate removal URLs.

I notice from the SpecificationFilterModel.PrepareSpecsFilters, that the information that I require is popped into the allFilters variable, which is cached.

I had hoped that since this value is (I presume) always cached prior to rendering the view, that the Razor view could recover this value without repeating all of the calculation code in the Category Model.

Is there any way that I can get back the specific allFilters cache item, or otherwise determine the Id of the specification option for each available option?

Thanks,

Mark
5 years ago
I managed to get this working - my problem was that I was injecting ICacheManager, which gives an instance of PerRequestCacheManager, injecting IStaticCacheManager instead gives an instance of MemoryCacheManager, then the calculated cache key can be recovered.

The optionIds still needs to be retrieved by querying the database, but a simplified query as follows seems to do the trick for categories (but probably not for search results).

    select distinct SpecificationAttributeOptionId
    from Product_Category_Mapping PCM
    inner join Product_SpecificationAttribute_Mapping PSAM on PSAM.ProductId = PCM.ProductId
    left join Product P on PCM.ProductId = P.Id
    where PCM.CategoryId = {0} and P.Published = 1 and P.Deleted = 0
    order by SpecificationAttributeOptionId
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.