Skip to content

Commit 09384df

Browse files
authored
Merge pull request #8103 from magento-l3/JAN272023_PR_arul
[L3 Kings] Bugfix delivery
2 parents 2fd8581 + 423cd2a commit 09384df

File tree

30 files changed

+982
-58
lines changed

30 files changed

+982
-58
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/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>

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private function handleImageRemoveError($postData, $productId)
230230
}
231231
if ($removedImagesAmount) {
232232
$expectedImagesAmount = count($postData['product']['media_gallery']['images']) - $removedImagesAmount;
233-
$product = $this->productRepository->getById($productId);
233+
$product = $this->productRepository->getById($productId, false, null, true);
234234
$images = $product->getMediaGallery('images');
235235
if (is_array($images) && $expectedImagesAmount != count($images)) {
236236
$this->messageManager->addNoticeMessage(
@@ -295,6 +295,7 @@ private function copyToStore($data, $productId, $store)
295295
*
296296
* @return DataPersistorInterface|mixed
297297
* @deprecated 101.0.0
298+
* @see we don't recommend this approach anymore
298299
*/
299300
protected function getDataPersistor()
300301
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="VerifySuccessMessagesWithoutWarningActionGroup">
12+
<annotations>
13+
<description>Verify the success messages without notification post product save and see the product image is deleted.</description>
14+
</annotations>
15+
16+
<waitForPageLoad stepKey="waitForProductPageLoad1"/>
17+
<!--Verify notification and success messages-->
18+
<see selector="{{StorefrontMessagesSection.success}}" userInput="{{ProductFormMessages.save_success}}" stepKey="seeSuccessMessage"/>
19+
<dontSee selector="{{StorefrontMessagesSection.noticeMessage}}" userInput="{{ProductFormMessages.remove_image_notice}}" stepKey="seeNotification"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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="AdminDeleteProductsImageWithCustomOptionTest">
12+
<annotations>
13+
<stories value="Product with any custom option causes an error when deleting product images"/>
14+
<features value="Catalog"/>
15+
<title value="Error occurred while delete products image any custom option"/>
16+
<description value="When a product is created with custom option and added images, then save the product after deleting the image, Magento shows a warming message."/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-7556"/>
19+
<useCaseId value="ACP2E-1479"/>
20+
<group value="Catalog"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24+
<createData entity="ApiCategory" stepKey="category"/>
25+
<!--Create product with small, base, and thumbnail image-->
26+
<createData entity="ApiSimpleProduct" stepKey="productWithImages">
27+
<requiredEntity createDataKey="category"/>
28+
</createData>
29+
<updateData createDataKey="productWithImages" entity="productWithOptions2" stepKey="updateProductWithCustomOption"/>
30+
<!--Add images to the product-->
31+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="visitAdminProductPage2">
32+
<argument name="productId" value="$$productWithImages.id$$"/>
33+
</actionGroup>
34+
<waitForPageLoad stepKey="waitForProductPageLoad1"/>
35+
<actionGroup ref="AddProductImageActionGroup" stepKey="addImageToProduct">
36+
<argument name="image" value="ProductImage"/>
37+
</actionGroup>
38+
<waitForPageLoad stepKey="waitForProductPageLoad2"/>
39+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct1"/>
40+
</before>
41+
<after>
42+
<!--Delete prerequisite entities-->
43+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
44+
<deleteData createDataKey="productWithImages" stepKey="deleteProductWithImages"/>
45+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
46+
</after>
47+
<!--Open product page on admin-->
48+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openProductEditPage">
49+
<argument name="productId" value="$$productWithImages.id$$"/>
50+
</actionGroup>
51+
<waitForPageLoad stepKey="waitForProductPageLoad1"/>
52+
<!--Remove product image and save-->
53+
<actionGroup ref="RemoveProductImageByNameActionGroup" stepKey="removeProductFromCart2">
54+
<argument name="image" value="ProductImage"/>
55+
</actionGroup>
56+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct5"/>
57+
<!--Verify the success messages without notification-->
58+
<actionGroup ref="VerifySuccessMessagesWithoutWarningActionGroup" stepKey="verifySuccessMessages"/>
59+
<!-- Assert product first image not in admin product form -->
60+
<actionGroup ref="AssertProductImageNotInAdminProductPageActionGroup" stepKey="assertProductImageNotInAdminProductPage">
61+
<argument name="image" value="ProductImage"/>
62+
</actionGroup>
63+
</test>
64+
</tests>

0 commit comments

Comments
 (0)