Skip to content

Commit f21a00e

Browse files
author
Mohan Ahuja
committed
ACP2E-345: Unable to save product URL key with a hyphen "-" at end.
- Fixing semantic version failures
1 parent 7d1bf0c commit f21a00e

File tree

3 files changed

+76
-30
lines changed

3 files changed

+76
-30
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ public function modifyMeta(array $meta)
150150
$meta = $this->customizeWeightField($meta);
151151
$meta = $this->customizeNewDateRangeField($meta);
152152
$meta = $this->customizeNameListeners($meta);
153-
$meta = $this->customizeUrlKeyField($meta);
154153

155154
return $meta;
156155
}
@@ -400,35 +399,6 @@ protected function customizeNameListeners(array $meta)
400399
);
401400
}
402401

403-
/**
404-
* Customize URL KEY field
405-
*
406-
* @param array $meta
407-
* @return array
408-
* @since 101.0.1
409-
*/
410-
protected function customizeUrlKeyField(array $meta): array
411-
{
412-
$switcherConfig = [
413-
'tooltip' => [
414-
'link' => 'https://docs.magento.com/user-guide/catalog/catalog-urls.html',
415-
'description' => __(
416-
'The URL key should consist of lowercase characters with hyphens to separate words.'
417-
),
418-
],
419-
];
420-
421-
$path = $this->arrayManager->findPath(
422-
ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY,
423-
$meta,
424-
null,
425-
'children'
426-
);
427-
$meta = $this->arrayManager->merge($path . static::META_CONFIG_PATH, $meta, $switcherConfig);
428-
429-
return $meta;
430-
}
431-
432402
/**
433403
* The getter function to get the locale currency for real application code
434404
*
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;
9+
10+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
11+
use Magento\Framework\Stdlib\ArrayManager;
12+
13+
class Seo extends AbstractModifier
14+
{
15+
/**
16+
* @var ArrayManager
17+
*/
18+
private ArrayManager $arrayManager;
19+
20+
/**
21+
* @param ArrayManager $arrayManager
22+
*/
23+
public function __construct(
24+
ArrayManager $arrayManager
25+
) {
26+
$this->arrayManager = $arrayManager;
27+
}
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
public function modifyData(array $data): array
33+
{
34+
return $data;
35+
}
36+
37+
/**
38+
* @inheritDoc
39+
*/
40+
public function modifyMeta(array $meta): array
41+
{
42+
$meta = $this->customizeUrlKeyField($meta);
43+
44+
return $meta;
45+
}
46+
47+
/**
48+
* Customize URL KEY field
49+
*
50+
* @param array $meta
51+
* @return array
52+
*/
53+
protected function customizeUrlKeyField(array $meta): array
54+
{
55+
$urlKeyConfig = [
56+
'tooltip' => [
57+
'link' => 'https://docs.magento.com/user-guide/catalog/catalog-urls.html',
58+
'description' => __(
59+
'The URL key should consist of lowercase characters with hyphens to separate words.'
60+
),
61+
],
62+
];
63+
64+
$path = $this->arrayManager->findPath(
65+
ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY,
66+
$meta,
67+
null,
68+
'children'
69+
);
70+
return $this->arrayManager->merge($path . static::META_CONFIG_PATH, $meta, $urlKeyConfig);
71+
}
72+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@
162162
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\LayoutUpdate</item>
163163
<item name="sortOrder" xsi:type="number">160</item>
164164
</item>
165+
<item name="seo_update" xsi:type="array">
166+
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Seo</item>
167+
<item name="sortOrder" xsi:type="number">170</item>
168+
</item>
165169
</argument>
166170
</arguments>
167171
</virtualType>

0 commit comments

Comments
 (0)