Skip to content

Commit f8e1571

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #24 from magento-firedrakes/MAGETWO-44160
[Merchant Beta][Firedrakes] Bugfixes
2 parents 77fbc91 + ee348f0 commit f8e1571

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ public function setValidationFilter($websiteId, $customerGroupId, $couponCode =
8989
/* We need to overwrite joinLeft if coupon is applied */
9090
$this->getSelect()->reset();
9191
parent::_initSelect();
92-
9392
$this->addWebsiteGroupDateFilter($websiteId, $customerGroupId, $now);
9493
$select = $this->getSelect();
95-
9694
$connection = $this->getConnection();
9795
if (strlen($couponCode)) {
9896
$select->joinLeft(
@@ -103,8 +101,11 @@ public function setValidationFilter($websiteId, $customerGroupId, $couponCode =
103101
),
104102
['code']
105103
);
106-
$select->where('main_table.coupon_type = ? ', \Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON);
107104
$orWhereConditions = [
105+
$connection->quoteInto(
106+
'main_table.coupon_type = ? ',
107+
\Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON
108+
),
108109
$connection->quoteInto(
109110
'(main_table.coupon_type = ? AND rule_coupons.type = 0)',
110111
\Magento\SalesRule\Model\Rule::COUPON_TYPE_AUTO
@@ -118,8 +119,19 @@ public function setValidationFilter($websiteId, $customerGroupId, $couponCode =
118119
\Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC
119120
),
120121
];
122+
$andWhereConditions = [
123+
$connection->quoteInto(
124+
'rule_coupons.code = ?',
125+
$couponCode
126+
),
127+
$connection->quoteInto(
128+
'(rule_coupons.expiration_date IS NULL OR rule_coupons.expiration_date >= ?)',
129+
$this->_date->date('Y-m-d')
130+
),
131+
];
121132
$orWhereCondition = implode(' OR ', $orWhereConditions);
122-
$select->orWhere('(' . $orWhereCondition . ') AND rule_coupons.code = ?', $couponCode);
133+
$andWhereCondition = implode(' AND ', $andWhereConditions);
134+
$select->where('(' . $orWhereCondition . ') AND ' . $andWhereCondition);
123135
} else {
124136
$this->addFieldToFilter(
125137
'main_table.coupon_type',

app/code/Magento/Theme/view/frontend/templates/html/pager.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<?php if ($block->isShowPerPage()): ?>
117117
<div class="limiter">
118118
<strong class="limiter-label"><?php echo __('Show') ?></strong>
119-
<select id="limiter" data-mage-redirect="{'event':'change'}" class="limiter-options">
119+
<select id="limiter" data-mage-init='{"redirectUrl": {"event":"change"}}' class="limiter-options">
120120
<?php foreach ($block->getAvailableLimit() as $_key => $_limit): ?>
121121
<option value="<?php echo $block->getLimitUrl($_key) ?>"<?php if ($block->isLimitCurrent($_key)): ?>
122122
selected="selected"<?php endif ?>>

dev/tests/integration/testsuite/Magento/SalesRule/Model/Resource/Rule/CollectionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public function testSetValidationFilter($couponCode, $expectedItems)
3636
public function setValidationFilterDataProvider()
3737
{
3838
return [
39-
'Check type COUPON' => ['coupon_code', ['#1', '#2', '#5']],
39+
'Check type COUPON' => ['coupon_code', ['#1', '#5']],
4040
'Check type NO_COUPON' => ['', ['#2', '#5']],
41-
'Check type COUPON_AUTO' => ['coupon_code_auto', ['#2', '#4', '#5']],
42-
'Check result with auto generated coupon' => ['autogenerated_3_1', ['#2', '#3', '#5']],
41+
'Check type COUPON_AUTO' => ['coupon_code_auto', ['#4', '#5']],
42+
'Check result with auto generated coupon' => ['autogenerated_3_1', ['#3', '#5']],
4343
'Check result with non actual previously generated coupon' => [
4444
'autogenerated_2_1',
4545
['#2', '#5'],
4646
],
47-
'Check result with wrong code' => ['wrong_code', ['#2', '#5']]
47+
'Check result with wrong code' => ['wrong_code', ['#5']]
4848
];
4949
}
5050
}

0 commit comments

Comments
 (0)