# How to add new custom filter for 'Is New' on product listing page?

**URL:** <https://forum.shopware.com/t/how-to-add-new-custom-filter-for-is-new-on-product-listing-page/102945>\
**Category:** Shopware 6 (English)\
**Tags:** general, programming\
**Created:** [13. Februar 2024 um 10:00 UTC](https://forum.shopware.com/t/how-to-add-new-custom-filter-for-is-new-on-product-listing-page/102945 "2024-02-13T10:00:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aayusha.cybercom](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@aayusha.cybercom](https://forum.shopware.com/u/aayusha.cybercom)\
**Post date:** [13. Februar 2024 um 10:00 UTC](https://forum.shopware.com/t/how-to-add-new-custom-filter-for-is-new-on-product-listing-page/102945/1 "2024-02-13T10:00:23Z")

</div>

I am trying to add custom listing filter - ‚Is New‘ on basis of release date of product.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/5/8/58608372cea9c1a817745536cbd9636557b8344c.png)  
‚Mark products as ‚new‘, for ? days‘ config from Settings =\> Products

If config days + release date is greater than the current date then it is considered as new product.

For that, I need to add custom listing filter on product page

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/3/8/38a0fd1f3f82ab3b1441f53e3a3da89c77208805.png)

I have added a subscriber for that and also html code in filter-panel.html.twig

> class AddNewListingFilter implements EventSubscriberInterface  
> {
> 
> ```
> public static function getSubscribedEvents()
> {
> return [
> ProductListingCollectFilterEvent::class => 'addFilter'
> ];
> }
> public function addFilter(ProductListingCollectFilterEvent $event): void
> {
> // fetch existing filters
> $filters = $event->getFilters();
> $request = $event->getRequest();
> 
> $filtered = (bool) $request->get('isNew');
> $ids = [];
> $filter = new Filter(
> // name
> 'isNew',
> $filtered === true,
> [
> new FilterAggregation(
> 'isNew',
> new MaxAggregation('isNew', 'product.isNew'),
> [new RangeFilter(
> 'product.releaseDate', 
> [RangeFilter::GTE => 'DATE_SUB(CURRENT_DATE(), INTERVAL 90 DAY)']
> )]
> ),
> ],
> new RangeFilter(
> 'product.releaseDate', 
> [RangeFilter::GTE => 'DATE_SUB(CURRENT_DATE(), INTERVAL 90 DAY)']
> ),
> $filtered
> );
> // Add your custom filter
> $filters->add($filter);
> }
> 
> ```

This code does not work. Please help me with this. Thank you in advance.
