Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 4ee8196

Browse files
Merge pull request #1667 from magento-engcom/develop-prs
[EngCom] Public Pull Requests - develop - MAGETWO-83276: [2.3] Magento 2 Store Code validation regex: doesn't support uppercase letters in store code #12010 - MAGETWO-82951: Check attribute unique between same fields in magento commerce [backport] #11622
2 parents 927a6e2 + 81d99b5 commit 4ee8196

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object)
908908
'value' => trim($value),
909909
];
910910

911-
$entityIdField = $attributeBackend->getEntityIdField();
911+
$entityIdField = $object->getResource()->getLinkField();
912912
$select->from(
913913
$attributeBackend->getTable(),
914914
$entityIdField

app/code/Magento/Store/Model/ResourceModel/Website.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function readAllWebsites()
5353
->select()
5454
->from($this->getTable('store_website'));
5555

56-
foreach($this->getConnection()->fetchAll($select) as $websiteData) {
56+
foreach ($this->getConnection()->fetchAll($select) as $websiteData) {
5757
$websites[$websiteData['code']] = $websiteData;
5858
}
5959

@@ -69,7 +69,7 @@ public function readAllWebsites()
6969
*/
7070
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
7171
{
72-
if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
72+
if (!preg_match('/^[a-z]+[a-z0-9_]*$/i', $object->getCode())) {
7373
throw new \Magento\Framework\Exception\LocalizedException(
7474
__(
7575
'Website code may only contain letters (a-z), numbers (0-9) or underscore (_),'

app/code/Magento/Store/Model/Store.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
use Magento\Framework\App\Http\Context;
1313
use Magento\Framework\App\ObjectManager;
1414
use Magento\Framework\App\ScopeInterface as AppScopeInterface;
15-
use Magento\Framework\Filesystem;
1615
use Magento\Framework\DataObject\IdentityInterface;
17-
use Magento\Framework\Url\ScopeInterface as UrlScopeInterface;
16+
use Magento\Framework\Filesystem;
1817
use Magento\Framework\Model\AbstractExtensibleModel;
18+
use Magento\Framework\Url\ScopeInterface as UrlScopeInterface;
1919
use Magento\Framework\UrlInterface;
2020
use Magento\Store\Api\Data\StoreInterface;
2121

@@ -463,7 +463,7 @@ protected function _getValidationRulesBeforeSave()
463463
$storeLabelRule->setMessage(__('Name is required'), \Zend_Validate_NotEmpty::IS_EMPTY);
464464
$validator->addRule($storeLabelRule, 'name');
465465

466-
$storeCodeRule = new \Zend_Validate_Regex('/^[a-z]+[a-z0-9_]*$/');
466+
$storeCodeRule = new \Zend_Validate_Regex('/^[a-z]+[a-z0-9_]*$/i');
467467
$storeCodeRule->setMessage(
468468
__(
469469
'The store code may contain only letters (a-z), numbers (0-9) or underscore (_),'

0 commit comments

Comments
 (0)