From 84fbd90f763ca95be59e1a22ba7176ab89c9de6f Mon Sep 17 00:00:00 2001 From: Mohamed Abbas Date: Tue, 3 Dec 2024 16:23:54 +0530 Subject: [PATCH] customer group code issue fixed --- app/code/Magento/Customer/Model/Group.php | 2 +- app/code/Magento/Customer/Model/ResourceModel/Group.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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); }