diff --git a/app/code/Magento/Customer/Model/Group.php b/app/code/Magento/Customer/Model/Group.php index 9cb09a4ed3f0b..3c8851796e8e4 100644 --- a/app/code/Magento/Customer/Model/Group.php +++ b/app/code/Magento/Customer/Model/Group.php @@ -172,7 +172,7 @@ public function beforeSave() */ protected function _prepareData() { - $this->setCode(substr($this->getCode(), 0, self::GROUP_CODE_MAX_LENGTH)); + $this->setCode(preg_match('/^.{1,' . self::GROUP_CODE_MAX_LENGTH . '}/us', $this->getCode(), $matches) ? $matches[0] : ''); return $this; } } diff --git a/app/code/Magento/Customer/Model/ResourceModel/Group.php b/app/code/Magento/Customer/Model/ResourceModel/Group.php index 6b56298500c57..50d73531b72db 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Group.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Group.php @@ -124,7 +124,7 @@ protected function _createCustomersCollection() protected function _beforeSave(\Magento\Framework\Model\AbstractModel $group) { /** @var \Magento\Customer\Model\Group $group */ - $group->setCode(substr($group->getCode(), 0, $group::GROUP_CODE_MAX_LENGTH)); + $group->setCode(preg_match('/^.{1,' . $group::GROUP_CODE_MAX_LENGTH . '}/us', $group->getCode(), $matches) ? $matches[0] : ''); return parent::_beforeSave($group); }