Magento2 custom product collection not filtering via color etc.. on listing page

Magento2 custom product collection not filtering via color etc.. on listing page

Following is the code used

public function getClearProductCollection()
    {
        $categoryId = $this->getCategoryName(); // YOUR CATEGORY ID
        $category = $this->categoryFactory->create()->load($categoryId);
        $page=($this->getRequest()->getParam('p'))? $this->getRequest()->getParam('p') : 1;
        //get values of current limit
        $pageSize=($this->getRequest()->getParam('limit'))? $this->getRequest()->getParam('limit') : 2;
        $_productCollection = $category->getProductCollection()
            ->addAttributeToSelect('*')
            ->addAttributeToFilter('online_discount',array('notnull' => true))
            ->setPageSize($pageSize)
            ->setCurPage($page);

        return $_productCollection;
    }