Skip to content

Commit c0088d3

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #25412: Admin > Advanced Report > Changing link (by @rafaelstz) - #30008: Fix missing escape Url method (by @mrtuvn) - #28216: Replace hard-coded list of category attributes (by @fredden) - #30065: Input type datetime is used in lib styles (by @GrimLink) - #29726: Allow specify font type when declare custom font (by @mrtuvn) - #28389: Add a head.additional block to adminhtml layout (by @gsomoza) Fixed GitHub Issues: - #25411: Magento_Analytics wrong link (reported by @rafaelstz) has been fixed in #25412 by @rafaelstz in 2.4-develop branch Related commits: 1. 9efef99 2. c01dd2a 3. 6a0f133 4. d69bd9d 5. 42eb8a0 6. 1e8b12e 7. 08c9f33 - #30036: [Issue] Fix missing escape Url method (reported by @m2-assistant[bot]) has been fixed in #30008 by @mrtuvn in 2.4-develop branch Related commits: 1. 777c7c7 2. d2f3466 3. 5f69036 - #13440: Adding custom attribute to category doesn't show store specific value (reported by @maxxeh1) has been fixed in #28216 by @fredden in 2.4-develop branch Related commits: 1. e9511e8 2. af9f897 3. 3bd5fa0 4. 471dc6b 5. fd5b12e 6. d3e011c 7. 8d899e1 8. d62b0b5 9. 223a7f5 10. 18eaaf1 11. 13c45d1 12. fe28e23 13. 58651f9 14. d267e3b 15. e2c42e6 16. 749ee55 17. e59de41 18. cebb5be 19. c3ce246 - #30064: Input type datetime is used in lib styles (reported by @GrimLink) has been fixed in #30065 by @GrimLink in 2.4-develop branch Related commits: 1. d15f34d 2. beb817f - #29719: Font format incorrect import in theme (reported by @mrtuvn) has been fixed in #29726 by @mrtuvn in 2.4-develop branch Related commits: 1. 9e48f91 - #29165: [Issue] Add a head.additional block to adminhtml layout (reported by @m2-assistant[bot]) has been fixed in #28389 by @gsomoza in 2.4-develop branch Related commits: 1. 336b463 2. 75cc0b4 3. 01bc9cf
2 parents 3c3c8ed + 5d7686c commit c0088d3

File tree

15 files changed

+244
-166
lines changed

15 files changed

+244
-166
lines changed

app/code/Magento/Analytics/Model/ReportUrlProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class ReportUrlProvider
4747
*/
4848
private $urlReportConfigPath = 'analytics/url/report';
4949

50+
/**
51+
* Path to Advanced Reporting documentation URL.
52+
*
53+
* @var string
54+
*/
55+
private $urlReportDocConfigPath = 'analytics/url/documentation';
56+
5057
/**
5158
* @param AnalyticsToken $analyticsToken
5259
* @param OTPRequest $otpRequest
@@ -80,13 +87,15 @@ public function getUrl()
8087
));
8188
}
8289

83-
$url = $this->config->getValue($this->urlReportConfigPath);
8490
if ($this->analyticsToken->isTokenExist()) {
91+
$url = $this->config->getValue($this->urlReportConfigPath);
8592
$otp = $this->otpRequest->call();
8693
if ($otp) {
8794
$query = http_build_query(['otp' => $otp], '', '&');
8895
$url .= '?' . $query;
8996
}
97+
} else {
98+
$url = $this->config->getValue($this->urlReportDocConfigPath);
9099
}
91100

92101
return $url;

app/code/Magento/Analytics/Test/Mftf/ActionGroup/AssertAdminAdvancedReportingPageUrlActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
<switchToNextTab stepKey="switchToNewTab"/>
1717
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
18-
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
18+
<seeInCurrentUrl url="reports/advanced-reporting" stepKey="seeAssertAdvancedReportingPageUrl"/>
1919
</actionGroup>
2020
</actionGroups>

app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,10 @@ class ReportUrlProviderTest extends TestCase
4343
*/
4444
private $flagManagerMock;
4545

46-
/**
47-
* @var ObjectManagerHelper
48-
*/
49-
private $objectManagerHelper;
50-
5146
/**
5247
* @var ReportUrlProvider
5348
*/
54-
private $reportUrlProvider;
55-
56-
/**
57-
* @var string
58-
*/
59-
private $urlReportConfigPath = 'path/url/report';
49+
private $model;
6050

6151
/**
6252
* @return void
@@ -71,35 +61,36 @@ protected function setUp(): void
7161

7262
$this->flagManagerMock = $this->createMock(FlagManager::class);
7363

74-
$this->objectManagerHelper = new ObjectManagerHelper($this);
64+
$objectManagerHelper = new ObjectManagerHelper($this);
7565

76-
$this->reportUrlProvider = $this->objectManagerHelper->getObject(
66+
$this->model = $objectManagerHelper->getObject(
7767
ReportUrlProvider::class,
7868
[
7969
'config' => $this->configMock,
8070
'analyticsToken' => $this->analyticsTokenMock,
8171
'otpRequest' => $this->otpRequestMock,
8272
'flagManager' => $this->flagManagerMock,
83-
'urlReportConfigPath' => $this->urlReportConfigPath,
8473
]
8574
);
8675
}
8776

8877
/**
8978
* @param bool $isTokenExist
9079
* @param string|null $otp If null OTP was not received.
80+
* @param string $configPath
81+
* @return void
9182
*
9283
* @dataProvider getUrlDataProvider
9384
*/
94-
public function testGetUrl($isTokenExist, $otp)
85+
public function testGetUrl(bool $isTokenExist, ?string $otp, string $configPath): void
9586
{
9687
$reportUrl = 'https://example.com/report';
9788
$url = '';
9889

9990
$this->configMock
10091
->expects($this->once())
10192
->method('getValue')
102-
->with($this->urlReportConfigPath)
93+
->with($configPath)
10394
->willReturn($reportUrl);
10495
$this->analyticsTokenMock
10596
->expects($this->once())
@@ -114,18 +105,19 @@ public function testGetUrl($isTokenExist, $otp)
114105
if ($isTokenExist && $otp) {
115106
$url = $reportUrl . '?' . http_build_query(['otp' => $otp], '', '&');
116107
}
117-
$this->assertSame($url ?: $reportUrl, $this->reportUrlProvider->getUrl());
108+
109+
$this->assertSame($url ?: $reportUrl, $this->model->getUrl());
118110
}
119111

120112
/**
121113
* @return array
122114
*/
123-
public function getUrlDataProvider()
115+
public function getUrlDataProvider(): array
124116
{
125117
return [
126-
'TokenDoesNotExist' => [false, null],
127-
'TokenExistAndOtpEmpty' => [true, null],
128-
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab'],
118+
'TokenDoesNotExist' => [false, null, 'analytics/url/documentation'],
119+
'TokenExistAndOtpEmpty' => [true, null, 'analytics/url/report'],
120+
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab', 'analytics/url/report'],
129121
];
130122
}
131123

@@ -140,6 +132,6 @@ public function testGetUrlWhenSubscriptionUpdateRunning()
140132
->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
141133
->willReturn('http://store.com');
142134
$this->expectException(SubscriptionUpdateException::class);
143-
$this->reportUrlProvider->getUrl();
135+
$this->model->getUrl();
144136
}
145137
}

app/code/Magento/Analytics/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<otp>https://advancedreporting.rjmetrics.com/otp</otp>
1616
<report>https://advancedreporting.rjmetrics.com/report</report>
1717
<notify_data_changed>https://advancedreporting.rjmetrics.com/report</notify_data_changed>
18+
<documentation>https://docs.magento.com/user-guide/reports/advanced-reporting.html</documentation>
1819
</url>
1920
<integration_name>Magento Analytics user</integration_name>
2021
<general>

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<body>
1818
<attribute name="id" value="html-body"/>
1919
<block name="require.js" class="Magento\Backend\Block\Page\RequireJs" template="Magento_Backend::page/js/require_js.phtml"/>
20+
<block class="Magento\Framework\View\Element\Template" name="head.additional" template="Magento_Backend::page/container.phtml"/>
2021
<referenceContainer name="global.notices">
2122
<block class="Magento\Backend\Block\Page\Notices" name="global_notices" as="global_notices" template="Magento_Backend::page/notices.phtml"/>
2223
</referenceContainer>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<?= $block->getChildHtml(); ?>

app/code/Magento/Catalog/Model/Category/DataProvider.php

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use Magento\Eav\Model\Entity\Type;
2323
use Magento\Framework\App\ObjectManager;
2424
use Magento\Framework\App\RequestInterface;
25+
use Magento\Framework\AuthorizationInterface;
26+
use Magento\Framework\Config\DataInterfaceFactory;
2527
use Magento\Framework\Exception\LocalizedException;
2628
use Magento\Framework\Exception\NoSuchEntityException;
2729
use Magento\Framework\Registry;
@@ -32,7 +34,6 @@
3234
use Magento\Ui\Component\Form\Field;
3335
use Magento\Ui\DataProvider\EavValidationRules;
3436
use Magento\Ui\DataProvider\Modifier\PoolInterface;
35-
use Magento\Framework\AuthorizationInterface;
3637
use Magento\Ui\DataProvider\ModifierPoolDataProvider;
3738

3839
/**
@@ -153,6 +154,11 @@ class DataProvider extends ModifierPoolDataProvider
153154
*/
154155
private $categoryFactory;
155156

157+
/**
158+
* @var DataInterfaceFactory
159+
*/
160+
private $uiConfigFactory;
161+
156162
/**
157163
* @var ScopeOverriddenValue
158164
*/
@@ -177,6 +183,7 @@ class DataProvider extends ModifierPoolDataProvider
177183
* @var AuthorizationInterface
178184
*/
179185
private $auth;
186+
180187
/**
181188
* @var Image
182189
*/
@@ -202,6 +209,7 @@ class DataProvider extends ModifierPoolDataProvider
202209
* @param ArrayManager|null $arrayManager
203210
* @param FileInfo|null $fileInfo
204211
* @param Image|null $categoryImage
212+
* @param DataInterfaceFactory|null $uiConfigFactory
205213
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
206214
*/
207215
public function __construct(
@@ -223,7 +231,8 @@ public function __construct(
223231
ScopeOverriddenValue $scopeOverriddenValue = null,
224232
ArrayManager $arrayManager = null,
225233
FileInfo $fileInfo = null,
226-
?Image $categoryImage = null
234+
?Image $categoryImage = null,
235+
?DataInterfaceFactory $uiConfigFactory = null
227236
) {
228237
$this->eavValidationRules = $eavValidationRules;
229238
$this->collection = $categoryCollectionFactory->create();
@@ -240,6 +249,10 @@ public function __construct(
240249
$this->arrayManager = $arrayManager ?: ObjectManager::getInstance()->get(ArrayManager::class);
241250
$this->fileInfo = $fileInfo ?: ObjectManager::getInstance()->get(FileInfo::class);
242251
$this->categoryImage = $categoryImage ?? ObjectManager::getInstance()->get(Image::class);
252+
$this->uiConfigFactory = $uiConfigFactory ?? ObjectManager::getInstance()->create(
253+
DataInterfaceFactory::class,
254+
['instanceName' => \Magento\Ui\Config\Data::class]
255+
);
243256

244257
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);
245258
}
@@ -611,7 +624,7 @@ private function convertValues($category, $categoryData): array
611624

612625
$categoryData[$attributeCode][0]['url'] = $this->categoryImage->getUrl($category, $attributeCode);
613626

614-
$categoryData[$attributeCode][0]['size'] = isset($stat) ? $stat['size'] : 0;
627+
$categoryData[$attributeCode][0]['size'] = $stat['size'];
615628
$categoryData[$attributeCode][0]['type'] = $mime;
616629
}
617630
}
@@ -645,56 +658,42 @@ public function getDefaultMetaData($result)
645658
*/
646659
protected function getFieldsMap()
647660
{
648-
return [
649-
'general' => [
650-
'parent',
651-
'path',
652-
'is_active',
653-
'include_in_menu',
654-
'name',
655-
],
656-
'content' => [
657-
'image',
658-
'description',
659-
'landing_page',
660-
],
661-
'display_settings' => [
662-
'display_mode',
663-
'is_anchor',
664-
'available_sort_by',
665-
'use_config.available_sort_by',
666-
'default_sort_by',
667-
'use_config.default_sort_by',
668-
'filter_price_range',
669-
'use_config.filter_price_range',
670-
],
671-
'search_engine_optimization' => [
672-
'url_key',
673-
'url_key_create_redirect',
674-
'url_key_group',
675-
'meta_title',
676-
'meta_keywords',
677-
'meta_description',
678-
],
679-
'assign_products' => [
680-
],
681-
'design' => [
682-
'custom_use_parent_settings',
683-
'custom_apply_to_products',
684-
'custom_design',
685-
'page_layout',
686-
'custom_layout_update',
687-
'custom_layout_update_file'
688-
],
689-
'schedule_design_update' => [
690-
'custom_design_from',
691-
'custom_design_to',
692-
],
693-
'category_view_optimization' => [
694-
],
695-
'category_permissions' => [
696-
],
697-
];
661+
$referenceName = 'category_form';
662+
$config = $this->uiConfigFactory
663+
->create(['componentName' => $referenceName])
664+
->get($referenceName);
665+
666+
if (empty($config)) {
667+
return [];
668+
}
669+
670+
$fieldsMap = [];
671+
672+
foreach ($config['children'] as $group => $node) {
673+
// Skip disabled components (required for Commerce Edition)
674+
if ($node['arguments']['data']['config']['componentDisabled'] ?? false) {
675+
continue;
676+
}
677+
678+
$fields = [];
679+
680+
foreach ($node['children'] as $childName => $childNode) {
681+
if (!empty($childNode['children'])) {
682+
// <container/> nodes need special handling
683+
foreach (array_keys($childNode['children']) as $grandchildName) {
684+
$fields[] = $grandchildName;
685+
}
686+
} else {
687+
$fields[] = $childName;
688+
}
689+
}
690+
691+
if (!empty($fields)) {
692+
$fieldsMap[$group] = $fields;
693+
}
694+
}
695+
696+
return $fieldsMap;
698697
}
699698

700699
/**

app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use Magento\Eav\Model\Entity\Type;
2121
use Magento\Framework\App\RequestInterface;
2222
use Magento\Framework\AuthorizationInterface;
23+
use Magento\Framework\Config\Data;
24+
use Magento\Framework\Config\DataInterfaceFactory;
2325
use Magento\Framework\Registry;
2426
use Magento\Framework\Stdlib\ArrayUtils;
2527
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
@@ -70,6 +72,11 @@ class DataProviderTest extends TestCase
7072
*/
7173
private $categoryFactory;
7274

75+
/**
76+
* @var DataInterfaceFactory|MockObject
77+
*/
78+
private $uiConfigFactory;
79+
7380
/**
7481
* @var Collection|MockObject
7582
*/
@@ -151,6 +158,15 @@ protected function setUp(): void
151158
->disableOriginalConstructor()
152159
->getMock();
153160

161+
$dataMock = $this->getMockBuilder(Data::class)
162+
->disableOriginalConstructor()
163+
->getMock();
164+
$this->uiConfigFactory = $this->getMockBuilder(DataInterfaceFactory::class)
165+
->disableOriginalConstructor()
166+
->getMock();
167+
$this->uiConfigFactory->method('create')
168+
->willReturn($dataMock);
169+
154170
$this->fileInfo = $this->getMockBuilder(FileInfo::class)
155171
->disableOriginalConstructor()
156172
->getMock();
@@ -198,6 +214,7 @@ private function getModel()
198214
'eavConfig' => $this->eavConfig,
199215
'request' => $this->request,
200216
'categoryFactory' => $this->categoryFactory,
217+
'uiConfigFactory' => $this->uiConfigFactory,
201218
'pool' => $this->modifierPool,
202219
'auth' => $this->auth,
203220
'arrayUtils' => $this->arrayUtils,

app/code/Magento/Catalog/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
<plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" />
8181
</type>
8282
<type name="Magento\Catalog\Model\Category\DataProvider">
83+
<arguments>
84+
<argument name="uiConfigFactory" xsi:type="object">uiComponentConfigFactory</argument>
85+
</arguments>
8386
<plugin name="set_page_layout_default_value" type="Magento\Catalog\Model\Plugin\SetPageLayoutDefaultValue" />
8487
</type>
8588
<type name="Magento\Theme\Block\Html\Topmenu">

0 commit comments

Comments
 (0)