Skip to content

Commit 123a4f0

Browse files
Merge branch '2.4-develop' into fix-ups-tracking
2 parents 5031159 + b0eec73 commit 123a4f0

File tree

9 files changed

+186
-59
lines changed

9 files changed

+186
-59
lines changed

app/code/Magento/Customer/view/frontend/web/js/validation.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ define([
88
], function ($, moment, utils) {
99
'use strict';
1010

11+
$.validator.addMethod(
12+
'validate-date',
13+
function (value, element, params) {
14+
var dateFormat = utils.convertToMomentFormat(params.dateFormat);
15+
16+
if (value === '') {
17+
return true;
18+
}
19+
20+
return moment(value, dateFormat, true).isValid();
21+
},
22+
$.mage.__('Invalid date')
23+
);
24+
1125
$.validator.addMethod(
1226
'validate-dob',
1327
function (value, element, params) {

app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Reports\Model\ResourceModel\Quote\Item;
89

@@ -17,6 +18,8 @@
1718
*/
1819
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
1920
{
21+
private const PREPARED_FLAG_NAME = 'reports_collection_prepared';
22+
2023
/**
2124
* Join fields
2225
*
@@ -99,6 +102,11 @@ protected function _construct()
99102
public function prepareActiveCartItems()
100103
{
101104
$quoteItemsSelect = $this->getSelect();
105+
106+
if ($this->getFlag(self::PREPARED_FLAG_NAME)) {
107+
return $quoteItemsSelect;
108+
}
109+
102110
$quoteItemsSelect->reset()
103111
->from(['main_table' => $this->getTable('quote_item')], '')
104112
->columns('main_table.product_id')
@@ -114,6 +122,7 @@ public function prepareActiveCartItems()
114122
)->group(
115123
'main_table.product_id'
116124
);
125+
$this->setFlag(self::PREPARED_FLAG_NAME, true);
117126

118127
return $quoteItemsSelect;
119128
}

app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Quote/CollectionTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\Event\ManagerInterface;
1616
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1717
use Magento\Quote\Model\ResourceModel\Quote;
18+
use Magento\Reports\Model\ResourceModel\Quote\Collection;
1819
use PHPUnit\Framework\MockObject\MockObject;
1920
use PHPUnit\Framework\TestCase;
2021

@@ -42,7 +43,7 @@ protected function setUp(): void
4243
public function testGetSelectCountSql()
4344
{
4445
/** @var MockObject $collection */
45-
$collection = $this->getMockBuilder(\Magento\Reports\Model\ResourceModel\Quote\Collection::class)
46+
$collection = $this->getMockBuilder(Collection::class)
4647
->setMethods(['getSelect'])
4748
->disableOriginalConstructor()
4849
->getMock();
@@ -62,20 +63,25 @@ public function testPrepareActiveCartItems()
6263
$constructArgs = $this->objectManager
6364
->getConstructArguments(\Magento\Reports\Model\ResourceModel\Quote\Item\Collection::class);
6465
$collection = $this->getMockBuilder(\Magento\Reports\Model\ResourceModel\Quote\Item\Collection::class)
65-
->setMethods(['getSelect', 'getTable'])
66+
->setMethods(['getSelect', 'getTable', 'getFlag', 'setFlag'])
6667
->disableOriginalConstructor()
6768
->setConstructorArgs($constructArgs)
6869
->getMock();
6970

70-
$collection->expects($this->once())->method('getSelect')->willReturn($this->selectMock);
71+
$collection->expects($this->exactly(2))->method('getSelect')->willReturn($this->selectMock);
7172
$this->selectMock->expects($this->once())->method('reset')->willReturnSelf();
7273
$this->selectMock->expects($this->once())->method('from')->willReturnSelf();
7374
$this->selectMock->expects($this->atLeastOnce())->method('columns')->willReturnSelf();
7475
$this->selectMock->expects($this->once())->method('joinInner')->willReturnSelf();
7576
$this->selectMock->expects($this->once())->method('where')->willReturnSelf();
7677
$this->selectMock->expects($this->once())->method('group')->willReturnSelf();
7778
$collection->expects($this->exactly(2))->method('getTable')->willReturn('table');
79+
$collection->expects($this->once())->method('setFlag')
80+
->with('reports_collection_prepared')->willReturnSelf();
7881
$collection->prepareActiveCartItems();
82+
$collection->method('getFlag')
83+
->with('reports_collection_prepared')->willReturn(true);
84+
$this->assertEquals($this->selectMock, $collection->prepareActiveCartItems());
7985
}
8086

8187
public function testLoadWithFilter()

app/code/Magento/Sales/Model/ResourceModel/Order/Handler/State.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Sales\Model\Order;
1010

1111
/**
12-
* Class State
12+
* Checking order status and adjusting order status before saving
1313
*/
1414
class State
1515
{
@@ -34,6 +34,7 @@ public function check(Order $order)
3434
if (in_array($currentState, [Order::STATE_PROCESSING, Order::STATE_COMPLETE])
3535
&& !$order->canCreditmemo()
3636
&& !$order->canShip()
37+
&& $order->getIsNotVirtual()
3738
) {
3839
$order->setState(Order::STATE_CLOSED)
3940
->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CLOSED));

0 commit comments

Comments
 (0)