Skip to content

Commit 0edc82d

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-l3/magento2ce into ACP2E-1551
2 parents e2a6694 + d48a739 commit 0edc82d

File tree

107 files changed

+3346
-607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3346
-607
lines changed

app/code/Magento/Backend/Block/Dashboard/Totals.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Reports\Model\ResourceModel\Order\Collection;
1414
use Magento\Reports\Model\ResourceModel\Order\CollectionFactory;
1515
use Magento\Store\Model\Store;
16+
use Magento\Framework\App\ObjectManager;
1617

1718
/**
1819
* Adminhtml dashboard totals bar
@@ -31,19 +32,27 @@ class Totals extends Bar
3132
*/
3233
protected $_moduleManager;
3334

35+
/**
36+
* @var Period
37+
*/
38+
private $period;
39+
3440
/**
3541
* @param Context $context
3642
* @param CollectionFactory $collectionFactory
3743
* @param Manager $moduleManager
3844
* @param array $data
45+
* @param Period|null $period
3946
*/
4047
public function __construct(
4148
Context $context,
4249
CollectionFactory $collectionFactory,
4350
Manager $moduleManager,
44-
array $data = []
51+
array $data = [],
52+
?Period $period = null
4553
) {
4654
$this->_moduleManager = $moduleManager;
55+
$this->period = $period ?? ObjectManager::getInstance()->get(Period::class);
4756
parent::__construct($context, $collectionFactory, $data);
4857
}
4958

@@ -63,7 +72,8 @@ protected function _prepareLayout()
6372
) || $this->getRequest()->getParam(
6473
'group'
6574
);
66-
$period = $this->getRequest()->getParam('period', Period::PERIOD_24_HOURS);
75+
$firstPeriod = array_key_first($this->period->getDatePeriods());
76+
$period = $this->getRequest()->getParam('period', $firstPeriod);
6777

6878
/* @var $collection Collection */
6979
$collection = $this->_collectionFactory->create()->addCreateAtPeriodFilter(

app/code/Magento/Backend/Model/Dashboard/Chart/Date.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Backend\Model\Dashboard\Chart;
99

10+
use DateTimeZone;
1011
use Magento\Backend\Model\Dashboard\Period;
1112
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1213
use Magento\Reports\Model\ResourceModel\Order\CollectionFactory;
@@ -54,40 +55,32 @@ public function getByPeriod(string $period): array
5455
'',
5556
true
5657
);
57-
5858
$timezoneLocal = $this->localeDate->getConfigTimezone();
59-
$localStartDate = new \DateTime($dateStart->format('Y-m-d H:i:s'), new \DateTimeZone($timezoneLocal));
60-
$localEndDate = new \DateTime($dateEnd->format('Y-m-d H:i:s'), new \DateTimeZone($timezoneLocal));
59+
60+
$dateStart->setTimezone(new DateTimeZone($timezoneLocal));
61+
$dateEnd->setTimezone(new DateTimeZone($timezoneLocal));
6162

6263
if ($period === Period::PERIOD_24_HOURS) {
63-
$localEndDate = new \DateTime('now', new \DateTimeZone($timezoneLocal));
64-
$localStartDate = clone $localEndDate;
65-
$localStartDate->modify('-1 day');
66-
$localStartDate->modify('+1 hour');
67-
} elseif ($period === Period::PERIOD_TODAY) {
68-
$localEndDate->modify('now');
69-
} else {
70-
$localEndDate->setTime(23, 59, 59);
71-
$localStartDate->setTime(0, 0, 0);
64+
$dateEnd->modify('-1 hour');
7265
}
7366

7467
$dates = [];
7568

76-
while ($localStartDate <= $localEndDate) {
69+
while ($dateStart <= $dateEnd) {
7770
switch ($period) {
7871
case Period::PERIOD_7_DAYS:
7972
case Period::PERIOD_1_MONTH:
80-
$d = $localStartDate->format('Y-m-d');
81-
$localStartDate->modify('+1 day');
73+
$d = $dateStart->format('Y-m-d');
74+
$dateStart->modify('+1 day');
8275
break;
8376
case Period::PERIOD_1_YEAR:
8477
case Period::PERIOD_2_YEARS:
85-
$d = $localStartDate->format('Y-m');
86-
$localStartDate->modify('first day of next month');
78+
$d = $dateStart->format('Y-m');
79+
$dateStart->modify('first day of next month');
8780
break;
8881
default:
89-
$d = $localStartDate->format('Y-m-d H:00');
90-
$localStartDate->modify('+1 hour');
82+
$d = $dateStart->format('Y-m-d H:00');
83+
$dateStart->modify('+1 hour');
9184
}
9285

9386
$dates[] = $d;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminDashboardTotalsBlockTest" extends="AdminCheckDashboardWithChartsTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Order Totals on Magento dashboard"/>
15+
<title value="Dashboard First Shows Wrong Information about Revenue"/>
16+
<description value="Revenue on Magento dashboard page is displaying properly"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="ACP2E-1294"/>
19+
<useCaseId value="ACSD-46523"/>
20+
<group value="backend"/>
21+
</annotations>
22+
<remove keyForRemoval="checkQuantityWasChanged"/>
23+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardTotals('Revenue')}}" stepKey="waitForRevenueAfter"/>
24+
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Revenue')}}" stepKey="grabRevenueAfter"/>
25+
<selectOption userInput="1m" selector="select#dashboard_chart_period" stepKey="selectOneMonthPeriod"/>
26+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/>
27+
<selectOption userInput="today" selector="select#dashboard_chart_period" stepKey="selectTodayPeriod"/>
28+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearAfterSelectTodayPeriod"/>
29+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardTotals('Revenue')}}" stepKey="waitForRevenueAfterSelectTodayPeriod"/>
30+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="waitForQuantityAfterSelectTodayPeriod"/>
31+
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Revenue')}}" stepKey="grabRevenueAfterSelectTodayPeriod"/>
32+
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityAfterSelectTodayPeriod"/>
33+
<assertEquals stepKey="checkTodayRevenue">
34+
<actualResult type="const">$grabRevenueAfter</actualResult>
35+
<expectedResult type="const">$grabRevenueAfterSelectTodayPeriod</expectedResult>
36+
</assertEquals>
37+
<assertEquals stepKey="checkTodayQuantity">
38+
<actualResult type="const">$grabQuantityAfter</actualResult>
39+
<expectedResult type="const">$grabQuantityAfterSelectTodayPeriod</expectedResult>
40+
</assertEquals>
41+
</test>
42+
</tests>

app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function draw()
101101
}
102102

103103
if (!isset($drawItems[$optionId])) {
104-
$drawItems[$optionId] = ['lines' => [], 'height' => 15];
104+
$drawItems[$optionId] = ['lines' => [], 'height' => 20];
105105
}
106106

107107
// draw selection attributes
@@ -112,7 +112,7 @@ public function draw()
112112
'feed' => $x,
113113
];
114114

115-
$drawItems[$optionId] = ['lines' => [$line], 'height' => 15];
115+
$drawItems[$optionId] = ['lines' => [$line], 'height' => 20];
116116

117117
$line = [];
118118
$prevOptionId = $attributes['option_id'];
@@ -199,17 +199,18 @@ public function draw()
199199
if ($option['value']) {
200200
$text = [];
201201
$printValue = $option['print_value'] ?? $this->filterManager->stripTags($option['value']);
202+
$printValue = str_replace(PHP_EOL, ', ', $printValue);
202203
$values = explode(', ', $printValue);
203204
foreach ($values as $value) {
204-
foreach ($this->string->split($value, 30, true, true) as $subValue) {
205+
foreach ($this->string->split($value, 50, true, true) as $subValue) {
205206
$text[] = $subValue;
206207
}
207208
}
208209

209210
$lines[][] = ['text' => $text, 'feed' => $leftBound + 5];
210211
}
211212

212-
$drawItems[] = ['lines' => $lines, 'height' => 15];
213+
$drawItems[] = ['lines' => $lines, 'height' => 20, 'shift' => 5];
213214
}
214215
}
215216

app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private function drawChildrenItems(): array
105105
}
106106

107107
if (!isset($drawItems[$optionId])) {
108-
$drawItems[$optionId] = ['lines' => [], 'height' => 15];
108+
$drawItems[$optionId] = ['lines' => [], 'height' => 20];
109109
}
110110

111111
if ($childItem->getOrderItem()->getParentItem() && $prevOptionId != $attributes['option_id']) {
@@ -239,17 +239,18 @@ private function drawCustomOptions(array $draw): array
239239
if ($option['value']) {
240240
$text = [];
241241
$printValue = $option['print_value'] ?? $this->filterManager->stripTags($option['value']);
242+
$printValue = str_replace(PHP_EOL, ', ', $printValue);
242243
$values = explode(', ', $printValue);
243244
foreach ($values as $value) {
244-
foreach ($this->string->split($value, 30, true, true) as $subValue) {
245+
foreach ($this->string->split($value, 50, true, true) as $subValue) {
245246
$text[] = $subValue;
246247
}
247248
}
248249

249250
$lines[][] = ['text' => $text, 'feed' => 40];
250251
}
251252

252-
$draw[] = ['lines' => $lines, 'height' => 15];
253+
$draw[] = ['lines' => $lines, 'height' => 20, 'shift' => 5];
253254
}
254255
}
255256

app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function draw()
9999
}
100100

101101
if (!isset($drawItems[$optionId])) {
102-
$drawItems[$optionId] = ['lines' => [], 'height' => 15];
102+
$drawItems[$optionId] = ['lines' => [], 'height' => 20];
103103
}
104104

105105
if ($childItem->getParentItem() && $prevOptionId != $attributes['option_id']) {
@@ -109,7 +109,7 @@ public function draw()
109109
'feed' => 100,
110110
];
111111

112-
$drawItems[$optionId] = ['lines' => [$line], 'height' => 15];
112+
$drawItems[$optionId] = ['lines' => [$line], 'height' => 20];
113113

114114
$line = [];
115115

@@ -169,23 +169,24 @@ public function draw()
169169
true
170170
),
171171
'font' => 'italic',
172-
'feed' => 60,
172+
'feed' => 110,
173173
];
174174

175175
if ($option['value']) {
176176
$text = [];
177177
$printValue = $option['print_value'] ?? $this->filterManager->stripTags($option['value']);
178+
$printValue = str_replace(PHP_EOL, ', ', $printValue);
178179
$values = explode(', ', $printValue);
179180
foreach ($values as $value) {
180181
foreach ($this->string->split($value, 50, true, true) as $subValue) {
181182
$text[] = $subValue;
182183
}
183184
}
184185

185-
$lines[][] = ['text' => $text, 'feed' => 65];
186+
$lines[][] = ['text' => $text, 'feed' => 115];
186187
}
187188

188-
$drawItems[] = ['lines' => $lines, 'height' => 15];
189+
$drawItems[] = ['lines' => $lines, 'height' => 20, 'shift' => 5];
189190
}
190191
}
191192

app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/InvoiceTestProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function getData(): array
2424
'display_both' => [
2525
'expected' => [
2626
1 => [
27-
'height' => 15,
27+
'height' => 20,
2828
'lines' => [
2929
[
3030
[
@@ -176,7 +176,7 @@ public function getData(): array
176176
'including_tax' => [
177177
'expected' => [
178178
1 => [
179-
'height' => 15,
179+
'height' => 20,
180180
'lines' => [
181181
[
182182
[
@@ -251,7 +251,7 @@ public function getData(): array
251251
'excluding_tax' => [
252252
'expected' => [
253253
1 => [
254-
'height' => 15,
254+
'height' => 20,
255255
'lines' => [
256256
[
257257
[

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected function parseSelections($rowData, $entityId)
201201
$this->_cachedOptions[$entityId][$option['name']] = $option;
202202
$this->_cachedOptions[$entityId][$option['name']]['selections'] = [];
203203
}
204-
$this->_cachedOptions[$entityId][$option['name']]['selections'][] = $option;
204+
$this->_cachedOptions[$entityId][$option['name']]['selections'][$option['sku']] = $option;
205205
$this->_cachedOptionSelectQuery[] = [(int)$entityId, $option['name']];
206206
}
207207
}

app/code/Magento/BundleImportExport/Test/Mftf/Data/ImportData.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,17 @@
127127
<data key="bundleOption2Required">false</data>
128128
<data key="bundleOption2NumberOfProducts">1</data>
129129
</entity>
130+
<entity name="ImportProduct_Bundle2" type="product">
131+
<data key="fileName">catalog_import_duplicate_bundle_products.csv</data>
132+
<data key="name">import-product-bundle-with-duplicates</data>
133+
<data key="sku">import-product-bundle2</data>
134+
<data key="type_id">bundle</data>
135+
<data key="attribute_set_id">4</data>
136+
<data key="attributeSetText">Default</data>
137+
<data key="urlKey">import-product-bundle2</data>
138+
<data key="bundleOption1Title">Bundle Option A</data>
139+
<data key="bundleOption1InputType">radio</data>
140+
<data key="bundleOption1Required">true</data>
141+
<data key="bundleOption1NumberOfProducts">2</data>
142+
</entity>
130143
</entities>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminImportDuplicateBundleProductsWithoutImagesTest">
12+
<annotations>
13+
<title value="Bundle product import issue"/>
14+
<stories value="Asserting bundle product import functionality and verify data in product option "/>
15+
<description value="The merchant is having issues with importing Bundled Products via CSV. When they import a CSV where the same SKU is duplicated, duplicated records are created for the product option."/>
16+
<testCaseId value="AC-7646"/>
17+
<useCaseId value="ACP2E-1478"/>
18+
<features value="Sales"/>
19+
<severity value="AVERAGE"/>
20+
<group value="importExport"/>
21+
<group value="Bundle"/>
22+
</annotations>
23+
<before>
24+
<!-- Create Simple Product1 -->
25+
<createData entity="_defaultCategory" stepKey="createCategory"/>
26+
<createData entity="SimpleProduct" stepKey="createSimpleProduct1">
27+
<field key="name">SimpleProduct1</field>
28+
<field key="sku">SimpleProduct1</field>
29+
<requiredEntity createDataKey="createCategory"/>
30+
</createData>
31+
<!-- Create Simple Product2 -->
32+
<createData entity="SimpleProduct" stepKey="createSimpleProduct2">
33+
<field key="name">SimpleProduct2</field>
34+
<field key="sku">SimpleProduct2</field>
35+
<requiredEntity createDataKey="createCategory"/>
36+
</createData>
37+
<!-- Login as Admin -->
38+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
39+
</before>
40+
<after>
41+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
42+
<deleteData createDataKey="createSimpleProduct1" stepKey="deleteSimpleProduct1"/>
43+
<deleteData createDataKey="createSimpleProduct2" stepKey="deleteSimpleProduct2"/>
44+
<deleteData url="/V1/products/{{ImportProduct_Bundle2.urlKey}}" stepKey="deleteImportedBundleProduct"/>
45+
<actionGroup ref="NavigateToAndResetProductGridToDefaultViewActionGroup" stepKey="navigateToAndResetProductGridToDefaultView"/>
46+
<!-- Logout -->
47+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
48+
</after>
49+
<!-- Import Bundle Product & Assert No Errors -->
50+
<actionGroup ref="AdminNavigateToImportPageActionGroup" stepKey="navigateToImportPage"/>
51+
<actionGroup ref="AdminFillImportFormActionGroup" stepKey="fillImportForm">
52+
<argument name="importFile" value="{{ImportProduct_Bundle2.fileName}}"/>
53+
</actionGroup>
54+
<actionGroup ref="AdminClickCheckDataImportActionGroup" stepKey="clickCheckData"/>
55+
<see selector="{{AdminImportValidationMessagesSection.success}}" userInput="{{ImportCommonMessages.validFile}}" stepKey="seeCheckDataResultMessage"/>
56+
<dontSeeElementInDOM selector="{{AdminImportValidationMessagesSection.importErrorList}}" stepKey="dontSeeErrorMessage"/>
57+
<actionGroup ref="AdminClickImportActionGroup" stepKey="clickImport"/>
58+
<see selector="{{AdminImportValidationMessagesSection.messageByType('success')}}" userInput="{{ImportCommonMessages.success}}" stepKey="seeImportMessage"/>
59+
<dontSeeElementInDOM selector="{{AdminImportValidationMessagesSection.importErrorList}}" stepKey="dontSeeErrorMessage2"/>
60+
<!-- Reindex -->
61+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
62+
<argument name="indices" value=""/>
63+
</actionGroup>
64+
<!-- Admin: Verify Bundle Product Options Data on Edit Product Page -->
65+
<actionGroup ref="NavigateToCreatedProductEditPageActionGroup" stepKey="goToBundleProductEditPage">
66+
<argument name="product" value="ImportProduct_Bundle2"/>
67+
</actionGroup>
68+
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
69+
<scrollTo selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" stepKey="scrollUpABit"/>
70+
<actionGroup ref="AdminVerifyBundleProductOptionActionGroup" stepKey="verifyBundleProductOption1">
71+
<argument name="optionTitle" value="{{ImportProduct_Bundle.bundleOption1Title}}"/>
72+
<argument name="inputType" value="{{ImportProduct_Bundle.bundleOption1InputType}}"/>
73+
<argument name="required" value="{{ImportProduct_Bundle.bundleOption1Required}}"/>
74+
<argument name="numberOfProducts" value="{{ImportProduct_Bundle.bundleOption1NumberOfProducts}}"/>
75+
<argument name="index" value="1"/>
76+
</actionGroup>
77+
</test>
78+
</tests>

0 commit comments

Comments
 (0)