Skip to content

Commit a763c9c

Browse files
committed
Merge remote-tracking branch 'local/ACP2E-1367' into PR_7_JAN_2023
2 parents b551cbe + 996e3d1 commit a763c9c

File tree

3 files changed

+196
-21
lines changed

3 files changed

+196
-21
lines changed

app/code/Magento/Sales/Model/ResourceModel/Provider/Query/IdListBuilder.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\ResourceConnection;
1111
use Magento\Framework\DB\Adapter\AdapterInterface;
1212
use Magento\Framework\DB\Select;
13+
use Magento\Sales\Model\ResourceModel\Grid;
1314

1415
/**
1516
* Query builder for retrieving list of updated order ids that was not synced to grid table.
@@ -80,23 +81,6 @@ private function getConnection(): AdapterInterface
8081
return $this->connection;
8182
}
8283

83-
/**
84-
* Returns update time of the last row in the grid.
85-
*
86-
* @param string $gridTableName
87-
* @return string
88-
*/
89-
private function getLastUpdatedAtValue(string $gridTableName): string
90-
{
91-
$select = $this->getConnection()->select()
92-
->from($this->getConnection()->getTableName($gridTableName), ['updated_at'])
93-
->order('updated_at DESC')
94-
->limit(1);
95-
$row = $this->getConnection()->fetchRow($select);
96-
97-
return $row['updated_at'] ?? '0000-00-00 00:00:00';
98-
}
99-
10084
/**
10185
* Builds select object.
10286
*
@@ -107,15 +91,21 @@ private function getLastUpdatedAtValue(string $gridTableName): string
10791
public function build(string $mainTableName, string $gridTableName): Select
10892
{
10993
$select = $this->getConnection()->select()
110-
->from($mainTableName, [$mainTableName . '.entity_id']);
111-
$lastUpdateTime = $this->getLastUpdatedAtValue($gridTableName);
112-
$select->where($mainTableName . '.updated_at >= ?', $lastUpdateTime);
94+
->from(['main_table' => $mainTableName], ['main_table.entity_id'])
95+
->joinLeft(
96+
['grid_table' => $this->resourceConnection->getTableName($gridTableName)],
97+
'main_table.entity_id = grid_table.entity_id',
98+
[]
99+
);
100+
101+
$select->where('grid_table.entity_id IS NULL');
102+
$select->limit(Grid::BATCH_SIZE);
113103
foreach ($this->additionalGridTables as $table) {
114104
$select->joinLeft(
115105
[$table => $table],
116106
sprintf(
117107
'%s.%s = %s.%s',
118-
$mainTableName,
108+
'main_table',
119109
'entity_id',
120110
$table,
121111
'entity_id'
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCreateOrdersAndCheckGridsTest">
11+
<annotations>
12+
<stories value="Create orders and check grids"/>
13+
<title value="Create orders, invoices, shipments and credit memos and check grids"/>
14+
<description value="Create orders, invoices, shipments and credit memos and check async grids"/>
15+
<severity value="AVERAGE"/>
16+
<useCaseId value="ACP2E-1367" />
17+
<testCaseId value="AC-7106" />
18+
<group value="sales"/>
19+
</annotations>
20+
<before>
21+
<magentoCLI command="config:set dev/grid/async_indexing 1" stepKey="enableAsyncIndexing"/>
22+
<magentoCLI command="cache:clean" stepKey="cacheCleanBefore"/>
23+
<createData entity="ApiCategory" stepKey="createCategory"/>
24+
<createData entity="defaultSimpleProduct" stepKey="createSimpleProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
</before>
28+
29+
<after>
30+
<magentoCLI command="config:set dev/grid/async_indexing 0" stepKey="disableAsyncIndexing"/>
31+
<magentoCLI command="cache:clean" stepKey="cacheCleanAfter"/>
32+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
33+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
34+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
35+
</after>
36+
37+
<createData entity="GuestCart" stepKey="createGuestCartOne"/>
38+
<createData entity="SimpleCartItem" stepKey="addCartItemOne">
39+
<requiredEntity createDataKey="createGuestCartOne"/>
40+
<requiredEntity createDataKey="createSimpleProduct"/>
41+
</createData>
42+
<createData entity="GuestAddressInformation" stepKey="addGuestOrderAddressOne">
43+
<requiredEntity createDataKey="createGuestCartOne"/>
44+
</createData>
45+
<updateData createDataKey="createGuestCartOne" entity="GuestOrderPaymentMethod" stepKey="sendGuestPaymentInformationOne">
46+
<requiredEntity createDataKey="createGuestCartOne"/>
47+
</updateData>
48+
49+
<magentoCLI command="cron:run" stepKey="runCronOne"/>
50+
51+
<createData entity="Invoice" stepKey="invoiceOrderOne">
52+
<requiredEntity createDataKey="createGuestCartOne"/>
53+
</createData>
54+
55+
<createData entity="GuestCart" stepKey="createGuestCartTwo"/>
56+
<createData entity="SimpleCartItem" stepKey="addCartItemTwo">
57+
<requiredEntity createDataKey="createGuestCartTwo"/>
58+
<requiredEntity createDataKey="createSimpleProduct"/>
59+
</createData>
60+
<createData entity="GuestAddressInformation" stepKey="addGuestOrderAddressTwo">
61+
<requiredEntity createDataKey="createGuestCartTwo"/>
62+
</createData>
63+
<updateData createDataKey="createGuestCartTwo" entity="GuestOrderPaymentMethod" stepKey="sendGuestPaymentInformationTwo">
64+
<requiredEntity createDataKey="createGuestCartTwo"/>
65+
</updateData>
66+
67+
<createData entity="Shipment" stepKey="shipOrderOne">
68+
<requiredEntity createDataKey="createGuestCartOne"/>
69+
</createData>
70+
71+
<magentoCLI command="cron:run" stepKey="runCronTwo"/>
72+
73+
<createData entity="GuestCart" stepKey="createGuestCartThree"/>
74+
<createData entity="SimpleCartItem" stepKey="addCartItemThree">
75+
<requiredEntity createDataKey="createGuestCartThree"/>
76+
<requiredEntity createDataKey="createSimpleProduct"/>
77+
</createData>
78+
<createData entity="GuestAddressInformation" stepKey="addGuestOrderAddressThree">
79+
<requiredEntity createDataKey="createGuestCartThree"/>
80+
</createData>
81+
<updateData createDataKey="createGuestCartThree" entity="GuestOrderPaymentMethod" stepKey="sendGuestPaymentInformationThree">
82+
<requiredEntity createDataKey="createGuestCartThree"/>
83+
</updateData>
84+
85+
<createData entity="CreditMemo" stepKey="refundOrderOne">
86+
<requiredEntity createDataKey="createGuestCartOne"/>
87+
</createData>
88+
89+
<createData entity="Invoice" stepKey="invoiceOrderThree">
90+
<requiredEntity createDataKey="createGuestCartThree"/>
91+
</createData>
92+
93+
<createData entity="Shipment" stepKey="shipOrderTwo">
94+
<requiredEntity createDataKey="createGuestCartTwo"/>
95+
</createData>
96+
97+
<magentoCLI command="cron:run" stepKey="runCronThree"/>
98+
99+
<createData entity="Invoice" stepKey="invoiceOrderTwo">
100+
<requiredEntity createDataKey="createGuestCartTwo"/>
101+
</createData>
102+
103+
<createData entity="Shipment" stepKey="shipOrderThree">
104+
<requiredEntity createDataKey="createGuestCartThree"/>
105+
</createData>
106+
107+
<createData entity="CreditMemo" stepKey="refundOrderTwo">
108+
<requiredEntity createDataKey="createGuestCartTwo"/>
109+
</createData>
110+
111+
<magentoCLI command="cron:run" stepKey="runCronFour"/>
112+
113+
<createData entity="CreditMemo" stepKey="refundOrderThree">
114+
<requiredEntity createDataKey="createGuestCartThree"/>
115+
</createData>
116+
117+
<magentoCLI command="cron:run" stepKey="runCronFive"/>
118+
<magentoCLI command="cron:run" stepKey="runCronSix"/>
119+
<magentoCLI command="cron:run" stepKey="runCronSeven"/>
120+
121+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
122+
123+
<actionGroup ref="AdminOrdersPageOpenActionGroup" stepKey="onOrderPage"/>
124+
<waitForPageLoad time="60" stepKey="waitForGrid"/>
125+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearFilters"/>
126+
127+
<grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createGuestCartOne.return$)}}" stepKey="getOrderOneId"/>
128+
<grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createGuestCartTwo.return$)}}" stepKey="getOrderTwoId"/>
129+
<grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createGuestCartThree.return$)}}" stepKey="getOrderThreeId"/>
130+
131+
<actionGroup ref="AdminOpenOrderByEntityIdActionGroup" stepKey="openOrderOne">
132+
<argument name="entityId" value="$createGuestCartOne.return$"/>
133+
</actionGroup>
134+
135+
<actionGroup ref="AdminOpenInvoiceTabFromOrderPageActionGroup" stepKey="openInvoicesTabOrdersPageOne"/>
136+
<waitForLoadingMaskToDisappear stepKey="waitForInvoiceGridLoadingMask1" after="openInvoicesTabOrdersPageOne"/>
137+
<waitForElementVisible selector="{{AdminOrderInvoicesTabSection.viewInvoice}}" stepKey="waitForInvoicesTabOpenedOne"/>
138+
<seeElement selector="{{AdminOrderInvoicesTabSection.viewInvoice}}" stepKey="seeForInvoicesTabOpenedOne"/>
139+
<actionGroup ref="AdminGoToShipmentTabActionGroup" stepKey="goToShipmentTabOne"/>
140+
<seeElement selector="{{AdminOrderShipmentsTabSection.viewShipment}}" stepKey="seeForShipmentTabOpenedOne"/>
141+
<actionGroup ref="AdminGoToCreditMemoTabActionGroup" stepKey="goToCreditMemoTabOne"/>
142+
<see selector="{{AdminOrderCreditMemosTabSection.gridRowCell('1', 'Status')}}" userInput="Refunded" stepKey="seeCreditMemoStatusInGridOne"/>
143+
144+
<actionGroup ref="AdminOpenOrderByEntityIdActionGroup" stepKey="openOrderTwo">
145+
<argument name="entityId" value="$createGuestCartTwo.return$"/>
146+
</actionGroup>
147+
148+
<actionGroup ref="AdminOpenInvoiceTabFromOrderPageActionGroup" stepKey="openInvoicesTabOrdersPageTwo"/>
149+
<waitForLoadingMaskToDisappear stepKey="waitForInvoiceGridLoadingMask2" after="openInvoicesTabOrdersPageTwo"/>
150+
<waitForElementVisible selector="{{AdminOrderInvoicesTabSection.viewInvoice}}" stepKey="waitForInvoicesTabOpenedTwo"/>
151+
<seeElement selector="{{AdminOrderInvoicesTabSection.viewInvoice}}" stepKey="seeForInvoicesTabOpenedTwo"/>
152+
<actionGroup ref="AdminGoToShipmentTabActionGroup" stepKey="goToShipmentTabTwo"/>
153+
<seeElement selector="{{AdminOrderShipmentsTabSection.viewShipment}}" stepKey="seeForShipmentTabOpenedTwo"/>
154+
<actionGroup ref="AdminGoToCreditMemoTabActionGroup" stepKey="goToCreditMemoTabTwo"/>
155+
<see selector="{{AdminOrderCreditMemosTabSection.gridRowCell('1', 'Status')}}" userInput="Refunded" stepKey="seeCreditMemoStatusInGridTwo"/>
156+
157+
<actionGroup ref="AdminOpenOrderByEntityIdActionGroup" stepKey="openOrderThree">
158+
<argument name="entityId" value="$createGuestCartThree.return$"/>
159+
</actionGroup>
160+
161+
<actionGroup ref="AdminOpenInvoiceTabFromOrderPageActionGroup" stepKey="openInvoicesTabOrdersPageThree"/>
162+
<waitForLoadingMaskToDisappear stepKey="waitForInvoiceGridLoadingMask3" after="openInvoicesTabOrdersPageThree"/>
163+
<waitForElementVisible selector="{{AdminOrderInvoicesTabSection.viewInvoice}}" stepKey="waitForInvoicesTabOpenedThree"/>
164+
<seeElement selector="{{AdminOrderInvoicesTabSection.viewInvoice}}" stepKey="seeForInvoicesTabOpenedThree"/>
165+
<actionGroup ref="AdminGoToShipmentTabActionGroup" stepKey="goToShipmentTabThree"/>
166+
<seeElement selector="{{AdminOrderShipmentsTabSection.viewShipment}}" stepKey="seeForShipmentTabOpenedThree"/>
167+
<actionGroup ref="AdminGoToCreditMemoTabActionGroup" stepKey="goToCreditMemoTabThree"/>
168+
<see selector="{{AdminOrderCreditMemosTabSection.gridRowCell('1', 'Status')}}" userInput="Refunded" stepKey="seeCreditMemoStatusInGridThree"/>
169+
</test>
170+
</tests>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminGoToCreditMemoTabActionGroup">
12+
<click selector="{{AdminOrderDetailsOrderViewSection.creditMemos}}" stepKey="clickOrderCreditMemosTab"/>
13+
<waitForLoadingMaskToDisappear stepKey="waitForCreditMemoTabLoad" after="clickOrderCreditMemosTab"/>
14+
</actionGroup>
15+
</actionGroups>

0 commit comments

Comments
 (0)