diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php index 4f6b86c9850b1..a460254acdaf2 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php @@ -89,10 +89,8 @@ public function setValidationFilter($websiteId, $customerGroupId, $couponCode = /* We need to overwrite joinLeft if coupon is applied */ $this->getSelect()->reset(); parent::_initSelect(); - $this->addWebsiteGroupDateFilter($websiteId, $customerGroupId, $now); $select = $this->getSelect(); - $connection = $this->getConnection(); if (strlen($couponCode)) { $select->joinLeft( @@ -103,8 +101,11 @@ public function setValidationFilter($websiteId, $customerGroupId, $couponCode = ), ['code'] ); - $select->where('main_table.coupon_type = ? ', \Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON); $orWhereConditions = [ + $connection->quoteInto( + 'main_table.coupon_type = ? ', + \Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON + ), $connection->quoteInto( '(main_table.coupon_type = ? AND rule_coupons.type = 0)', \Magento\SalesRule\Model\Rule::COUPON_TYPE_AUTO @@ -118,8 +119,19 @@ public function setValidationFilter($websiteId, $customerGroupId, $couponCode = \Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC ), ]; + $andWhereConditions = [ + $connection->quoteInto( + 'rule_coupons.code = ?', + $couponCode + ), + $connection->quoteInto( + '(rule_coupons.expiration_date IS NULL OR rule_coupons.expiration_date >= ?)', + $this->_date->date('Y-m-d') + ), + ]; $orWhereCondition = implode(' OR ', $orWhereConditions); - $select->orWhere('(' . $orWhereCondition . ') AND rule_coupons.code = ?', $couponCode); + $andWhereCondition = implode(' AND ', $andWhereConditions); + $select->where('(' . $orWhereCondition . ') AND ' . $andWhereCondition); } else { $this->addFieldToFilter( 'main_table.coupon_type', diff --git a/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml b/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml index d38a7f72de14b..80b2a58c3bd70 100644 --- a/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml +++ b/app/code/Magento/Theme/view/frontend/templates/html/pager.phtml @@ -116,7 +116,7 @@ isShowPerPage()): ?>
- getAvailableLimit() as $_key => $_limit): ?>