I want to add category id filter to Magento 2 product collection but it doesn't filter the collection in required manner. I am trying in below way:
$collection = $this->_productCollectionFactory->create()->addAttributeToSelect('*')
->joinField('category_id', 'catalog_category_product', 'category_id', 'product_id=entity_id', null, 'left')
->addFieldToFilter('category_id', ['nin' => 25]);
I don't want any product from category id 25 to be included in collection.