> 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/guides/overriding-or-extending-functionalities/overriding-product-data/excluding-products.md).

# Excluding Products

In order to exclude certain products from being indexed, you will need to override the Nosto product model and flag it to be excluded.

Start by reading [how to extend Nosto module](/magento-2/guides/overriding-or-extending-functionalities.md) and [how to alter Nosto product data](/magento-2/guides/overriding-or-extending-functionalities/overriding-product-data.md).

File `app/code/My/Nosto/Observer/Product/Load.php`

```php
<?php

namespace My\Nosto\Observer\Product;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class Load implements ObserverInterface
{
    public function __construct()
    {
    }

    /**
     * Observer for "nosto_product_load_before" event
     *
     * @param Observer $observer
     * @return void
     */
    public function execute(Observer $observer)
    {
        /* @var $product \NostoProduct */
        $product = $observer->getProduct();
        $modelFilter = $observer->getData('modelFilter');

        // If the product meets your desired criteria, set valid to false
        foreach ($product->getCategories() as $category) {
            if ($category === 'category') {
                $modelFilter->setValid(false);
            }
        }
    }
}
```


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.nosto.com/magento-2/guides/overriding-or-extending-functionalities/overriding-product-data/excluding-products.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
