Skip to content

Commit 572741a

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-l3/magento2ce into ACP2E-1609
2 parents 66f5ece + c766d6c commit 572741a

File tree

67 files changed

+3823
-192
lines changed

Some content is hidden

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

67 files changed

+3823
-192
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,16 @@ public function getHtml()
109109
' value="' .
110110
$this->localeResolver->getLocale() .
111111
'"/>';
112-
$scriptString = '
113-
require(["jquery", "mage/calendar"], function($){
114-
$("#' .
115-
$htmlId .
116-
'_range").dateRange({
117-
dateFormat: "' .
118-
$format .
119-
'",
120-
buttonText: "' . $this->escapeHtml(__('Date selector')) .
121-
'",
112+
$scriptString = 'require(["jquery", "mage/calendar"], function($){
113+
$("#' . $htmlId . '_range").dateRange({
114+
dateFormat: "' . $format . '",
115+
buttonText: "' . $this->escapeHtml(__('Date selector')) . '",
116+
buttonImage: "' . $this->getViewFileUrl('Magento_Theme::calendar.png') . '",
122117
from: {
123-
id: "' .
124-
$htmlId .
125-
'_from"
118+
id: "' . $htmlId . '_from"
126119
},
127120
to: {
128-
id: "' .
129-
$htmlId .
130-
'_to"
121+
id: "' . $htmlId . '_to"
131122
}
132123
})
133124
});';

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Datetime extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Date
1717
/**
1818
* full day is 86400, we need 23 hours:59 minutes:59 seconds = 86399
1919
*/
20-
const END_OF_DAY_IN_SECONDS = 86399;
20+
public const END_OF_DAY_IN_SECONDS = 86399;
2121

2222
/**
2323
* @inheritdoc
@@ -123,6 +123,7 @@ public function getHtml()
123123
timeFormat: "' . $timeFormat . '",
124124
showsTime: ' . ($this->getColumn()->getFilterTime() ? 'true' : 'false') . ',
125125
buttonText: "' . $this->escapeHtml(__('Date selector')) . '",
126+
buttonImage: "' . $this->getViewFileUrl('Magento_Theme::calendar.png') . '",
126127
from: {
127128
id: "' . $htmlId . '_from"
128129
},

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DateTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
use Magento\Backend\Block\Context;
1111
use Magento\Backend\Block\Widget\Grid\Column;
1212
use Magento\Backend\Block\Widget\Grid\Column\Filter\Date;
13+
use Magento\Framework\App\Request\Http;
1314
use Magento\Framework\Escaper;
1415
use Magento\Framework\Locale\ResolverInterface;
1516
use Magento\Framework\Math\Random;
1617
use Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface;
1718
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1819
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
20+
use Magento\Framework\View\Asset\Repository;
1921
use PHPUnit\Framework\MockObject\MockObject;
2022
use PHPUnit\Framework\TestCase;
2123

2224
/**
2325
* Class DateTest to test Magento\Backend\Block\Widget\Grid\Column\Filter\Date
2426
*
27+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2528
*/
2629
class DateTest extends TestCase
2730
{
@@ -49,6 +52,16 @@ class DateTest extends TestCase
4952
/** @var Context|MockObject */
5053
private $contextMock;
5154

55+
/**
56+
* @var Http|MockObject
57+
*/
58+
private $request;
59+
60+
/**
61+
* @var Repository|MockObject
62+
*/
63+
private $repositoryMock;
64+
5265
protected function setUp(): void
5366
{
5467
$this->mathRandomMock = $this->getMockBuilder(Random::class)
@@ -88,6 +101,23 @@ protected function setUp(): void
88101
$this->contextMock->expects($this->once())->method('getEscaper')->willReturn($this->escaperMock);
89102
$this->contextMock->expects($this->once())->method('getLocaleDate')->willReturn($this->localeDateMock);
90103

104+
$this->request = $this->getMockBuilder(Http::class)
105+
->disableOriginalConstructor()
106+
->getMock();
107+
108+
$this->contextMock->expects($this->once())
109+
->method('getRequest')
110+
->willReturn($this->request);
111+
112+
$this->repositoryMock = $this->getMockBuilder(Repository::class)
113+
->disableOriginalConstructor()
114+
->setMethods(['getUrlWithParams'])
115+
->getMock();
116+
117+
$this->contextMock->expects($this->once())
118+
->method('getAssetRepository')
119+
->willReturn($this->repositoryMock);
120+
91121
$objectManagerHelper = new ObjectManager($this);
92122
$this->model = $objectManagerHelper->getObject(
93123
Date::class,
@@ -116,6 +146,14 @@ public function testGetHtmlSuccessfulTimestamp()
116146
'from' => $yesterday->getTimestamp(),
117147
'to' => $tomorrow->getTimestamp()
118148
];
149+
$params = ['_secure' => false];
150+
$fileId = 'Magento_Theme::calendar.png';
151+
$fileUrl = 'file url';
152+
153+
$this->repositoryMock->expects($this->once())
154+
->method('getUrlWithParams')
155+
->with($fileId, $params)
156+
->willReturn($fileUrl);
119157

120158
$this->mathRandomMock->expects($this->any())->method('getUniqueHash')->willReturn($uniqueHash);
121159
$this->columnMock->expects($this->once())->method('getHtmlId')->willReturn($id);

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DatetimeTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@
1010
use Magento\Backend\Block\Context;
1111
use Magento\Backend\Block\Widget\Grid\Column;
1212
use Magento\Backend\Block\Widget\Grid\Column\Filter\Datetime;
13+
use Magento\Framework\App\Request\Http;
1314
use Magento\Framework\Escaper;
1415
use Magento\Framework\Locale\ResolverInterface;
1516
use Magento\Framework\Math\Random;
1617
use Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface;
1718
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1819
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
20+
use Magento\Framework\View\Asset\Repository;
1921
use PHPUnit\Framework\MockObject\MockObject;
2022
use PHPUnit\Framework\TestCase;
2123

2224
/**
2325
* Class DateTimeTest to test Magento\Backend\Block\Widget\Grid\Column\Filter\Date
26+
*
27+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2428
*/
2529
class DatetimeTest extends TestCase
2630
{
@@ -48,6 +52,16 @@ class DatetimeTest extends TestCase
4852
/** @var Context|MockObject */
4953
private $contextMock;
5054

55+
/**
56+
* @var Http|MockObject
57+
*/
58+
private $request;
59+
60+
/**
61+
* @var Repository|MockObject
62+
*/
63+
private $repositoryMock;
64+
5165
protected function setUp(): void
5266
{
5367
$this->mathRandomMock = $this->getMockBuilder(Random::class)
@@ -87,6 +101,23 @@ protected function setUp(): void
87101
$this->contextMock->expects($this->once())->method('getEscaper')->willReturn($this->escaperMock);
88102
$this->contextMock->expects($this->once())->method('getLocaleDate')->willReturn($this->localeDateMock);
89103

104+
$this->request = $this->getMockBuilder(Http::class)
105+
->disableOriginalConstructor()
106+
->getMock();
107+
108+
$this->contextMock->expects($this->once())
109+
->method('getRequest')
110+
->willReturn($this->request);
111+
112+
$this->repositoryMock = $this->getMockBuilder(Repository::class)
113+
->disableOriginalConstructor()
114+
->setMethods(['getUrlWithParams'])
115+
->getMock();
116+
117+
$this->contextMock->expects($this->once())
118+
->method('getAssetRepository')
119+
->willReturn($this->repositoryMock);
120+
90121
$objectManagerHelper = new ObjectManager($this);
91122
$this->model = $objectManagerHelper->getObject(
92123
Datetime::class,
@@ -115,6 +146,14 @@ public function testGetHtmlSuccessfulTimestamp()
115146
'from' => $yesterday->getTimestamp(),
116147
'to' => $tomorrow->getTimestamp()
117148
];
149+
$params = ['_secure' => false];
150+
$fileId = 'Magento_Theme::calendar.png';
151+
$fileUrl = 'file url';
152+
153+
$this->repositoryMock->expects($this->once())
154+
->method('getUrlWithParams')
155+
->with($fileId, $params)
156+
->willReturn($fileUrl);
118157

119158
$this->mathRandomMock->expects($this->any())->method('getUniqueHash')->willReturn($uniqueHash);
120159
$this->columnMock->expects($this->once())->method('getHtmlId')->willReturn($id);

app/code/Magento/Catalog/Test/Fixture/Product.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ public function apply(array $data = []): ?DataObject
120120
public function revert(DataObject $data): void
121121
{
122122
$service = $this->serviceFactory->create(ProductRepositoryInterface::class, 'deleteById');
123-
$service->execute(
124-
[
125-
'sku' => $data->getSku()
126-
]
127-
);
123+
$service->execute(['sku' => $data->getSku()]);
128124
}
129125

130126
/**
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminSaveProductByCustomDateWithCustomDateAttributeTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Adding Custom Date Attribute To Products"/>
14+
<title value="Issue while saving the date type product attribute"/>
15+
<description value="When we add the 01/01/1970 to the product attribute of the custom date type, it is throwing an error."/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="AC-8290"/>
18+
<useCaseId value="ACP2E-1749"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
28+
</before>
29+
<after>
30+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
31+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
32+
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteAttribute">
33+
<argument name="ProductAttribute" value="dateProductAttribute"/>
34+
</actionGroup>
35+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
36+
<argument name="indices" value=""/>
37+
</actionGroup>
38+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="resetGridFilter"/>
39+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
40+
</after>
41+
42+
<!-- Generate date for use as default value, needs to be MM/d/YYYY and mm/d/yy -->
43+
<generateDate date="now" format="m/j/Y" stepKey="generateDefaultDate"/>
44+
45+
<!-- Navigate to Stores > Attributes > Product. -->
46+
<actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="goToProductAttributes"/>
47+
48+
<!-- Create new Product Attribute as Date, with code and default value. -->
49+
<actionGroup ref="CreateProductAttributeWithDateFieldActionGroup" stepKey="createAttribute">
50+
<argument name="attribute" value="dateProductAttribute"/>
51+
<argument name="date" value="{$generateDefaultDate}"/>
52+
</actionGroup>
53+
54+
<!-- Go to default attribute set edit page -->
55+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
56+
<!-- Assert created attribute in unassigned section -->
57+
<see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.unassignedAttributesTree}}" stepKey="seeAttributeInUnassigned"/>
58+
<!-- Assign attribute to product group -->
59+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
60+
<argument name="group" value="Product Details"/>
61+
<argument name="attribute" value="{{dateProductAttribute.attribute_code}}"/>
62+
</actionGroup>
63+
<!-- Assert attribute in a group -->
64+
<see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.groupTree}}" stepKey="seeAttributeInGroup"/>
65+
<!-- Save attribute set -->
66+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/>
67+
68+
<!-- Open Product Edit Page and set custom attribute value 01/01/1970 and save the product-->
69+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForProduct">
70+
<argument name="product" value="$createProduct$"/>
71+
</actionGroup>
72+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct">
73+
<argument name="product" value="$createProduct$"/>
74+
</actionGroup>
75+
<fillField selector="{{AdminProductFormSection.newAddedAttributeInput(dateProductAttribute.attribute_code)}}" userInput="01/01/1970" stepKey="fillCustomDateValue"/>
76+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
77+
<!-- Open Product Index Page and filter the product by date 01/01/1970 -->
78+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex2"/>
79+
<actionGroup ref="FilterProductGridByCustomDateRangeActionGroup" stepKey="filterProductGridByCustomDateRange">
80+
<argument name="code" value="{{dateProductAttribute.attribute_code}}"/>
81+
<argument name="date" value="1/01/1970"/>
82+
</actionGroup>
83+
<!-- Check products filtering and see the product custom date 01/01/1970 successfully appeared -->
84+
<see selector="{{AdminProductGridSection.productGridNameProduct($createProduct.name$)}}" userInput="$createProduct.name$" stepKey="seeProductName"/>
85+
</test>
86+
</tests>

app/code/Magento/CatalogGraphQl/etc/graphql/di.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,20 @@
208208
</argument>
209209
</arguments>
210210
</virtualType>
211+
<type name="Magento\EavGraphQl\Model\TypeResolver\AttributeMetadata">
212+
<arguments>
213+
<argument name="entityTypes" xsi:type="array">
214+
<item name="PRODUCT" xsi:type="string">CatalogAttributeMetadata</item>
215+
</argument>
216+
</arguments>
217+
</type>
218+
<type name="Magento\Framework\GraphQl\Schema\Type\Enum\DefaultDataMapper">
219+
<arguments>
220+
<argument name="map" xsi:type="array">
221+
<item name="AttributeEntityTypeEnum" xsi:type="array">
222+
<item name="catalog_product" xsi:type="string">catalog_product</item>
223+
</item>
224+
</argument>
225+
</arguments>
226+
</type>
211227
</config>

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,7 @@ type SimpleWishlistItem implements WishlistItemInterface @doc(description: "Cont
531531

532532
type VirtualWishlistItem implements WishlistItemInterface @doc(description: "Contains a virtual product wish list item.") {
533533
}
534+
535+
enum AttributeEntityTypeEnum {
536+
CATALOG_PRODUCT
537+
}

app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Import\Product;
77

8+
use Magento\Store\Model\Store;
9+
810
/**
911
* @api
1012
* @since 100.0.2
@@ -119,6 +121,7 @@ protected function createCategory($name, $parentId)
119121
$category->setIsActive(true);
120122
$category->setIncludeInMenu(true);
121123
$category->setAttributeSetId($category->getDefaultAttributeSetId());
124+
$category->setStoreId(Store::DEFAULT_STORE_ID);
122125
$category->save();
123126
$this->categoriesCache[$category->getId()] = $category;
124127
return $category->getId();

0 commit comments

Comments
 (0)