Skip to content

Commit 9d73f27

Browse files
committed
ACP2E-2770: Double-byte characters (special characters) in Product Name field blocks product creation in backend
1 parent aad41a1 commit 9d73f27

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/code/Magento/Catalog/Model/Product/Url.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ public function formatUrlKey($str)
119119
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
120120
)) {
121121
return $this->filter->translitUrl($str);
122+
} else {
123+
$str = preg_replace('/\s+/', '-', $str);
124+
$str = mb_strtolower($str);
125+
$str = trim($str, '-');
122126
}
123127

124128
return $str;

app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ public function testFormatUrlKey(): void
139139
$this->assertEquals($resultString, $this->model->formatUrlKey($strIn));
140140
}
141141

142+
/**
143+
* @return void
144+
*/
145+
public function testFormatUrlKeyWithoutTransliteration(): void
146+
{
147+
$strIn = 'Some string ';
148+
$resultString = 'some-string';
149+
150+
$this->scopeConfig->expects($this->once())
151+
->method('getValue')
152+
->with(
153+
\Magento\Catalog\Helper\Product::XML_PATH_APPLY_TRANSLITERATION_TO_URL,
154+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
155+
)->willReturn(false);
156+
$this->assertEquals($resultString, $this->model->formatUrlKey($strIn));
157+
}
158+
142159
/**
143160
* @dataProvider getUrlDataProvider
144161
* @covers \Magento\Catalog\Model\Product\Url::getUrl

0 commit comments

Comments
 (0)