protected function _prepareWhereQuery($where, $fullQuery)
    {
        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $query = parent::_prepareWhereQuery($where, $fullQuery);

        $paymentStatus = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("paypalpaymentstatus");
        $paymentStatusList = new \OxidEsales\PayPalModule\Model\OrderPaymentStatusList();

        if ($paymentStatus && $paymentStatus != '-1' && in_array($paymentStatus, $paymentStatusList->getArray())) {
            $query .= " AND ( `oepaypal_order`.`oepaypal_paymentstatus` = " . $database->quote($paymentStatus) . " )";
            $query .= " AND ( `oepaypal_order`.`oepaypal_orderid` IS NOT NULL ) ";
        }

        $payment = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("paypalpayment");
        if ($payment && $payment != '-1') {
            $query .= " and ( oxorder.oxpaymenttype = " . $database->quote($payment) . " )";
        }

        return $query;
    }