> For the complete documentation index, see [llms.txt](https://docs.nosto.com/magento-2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nosto.com/magento-2/addons/cmp/guides/overriding-or-extending-functionalities/customize-exclude-filters.md).

# Customize Exclude Filters

If custom product filtering is done on Magento's backend after receiving the GraphQL response from Nosto, this will cause the total counter of displayed products to be inaccurate. To fix this, we recommend adding a custom field to the products and use exclude filters to be sent along with the GraphQL query

### Adding exclude filters to GraphQL query

1. Make sure you followed our guide to create an override module [Overriding or Extending Functionalities](https://github.com/Nosto/wiki-docs/blob/Magento2/addons/cmp/guides/overriding-or-extending-functionalities/addons/cmp/guides/overriding-or-extending-functionalities/README.md)
2. Use the sample code snippet below to add your custom exclusion logic

```php
<?php

namespace MyNosto\NostoCmp\Plugin;

use Nosto\Cmp\Model\Facet\Facet;

class UpdateExcludedFilters
{
    /**
     * @param $subject
     * @param Facet $facets
     * @return Facet
     */
    public function afterGetFilters($subject, Facet $facets)
    {
        $facets->getExcludeFilters()->setCustomFields(
            "my_custom_field",
            ['my_custom_field_value']
        );

        return new Facet($facets->getIncludeFilters(), $facets->getExcludeFilters());
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nosto.com/magento-2/addons/cmp/guides/overriding-or-extending-functionalities/customize-exclude-filters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
