10 use Magento\Customer\Api\Data\GroupInterfaceFactory;
33 \
Magento\Framework\Registry $coreRegistry,
59 if (array_key_exists(
'code', $customerGroupData)) {
60 $customerGroupData[
'customer_group_code'] = $customerGroupData[
'code'];
61 unset($customerGroupData[
'code']);
63 $this->
_getSession()->setCustomerGroupData($customerGroupData);
73 $taxClass = (int)$this->
getRequest()->getParam(
'tax_class');
76 $customerGroup =
null;
79 $resultRedirect = $this->resultRedirectFactory->create();
81 $customerGroupCode = (string)$this->
getRequest()->getParam(
'code');
83 $customerGroup = $this->groupRepository->getById((
int)
$id);
84 $customerGroupCode = $customerGroupCode ?: $customerGroup->getCode();
86 $customerGroup = $this->groupDataFactory->create();
88 $customerGroup->setCode(!empty($customerGroupCode) ? $customerGroupCode :
null);
89 $customerGroup->setTaxClassId($taxClass);
91 $this->groupRepository->save($customerGroup);
93 $this->messageManager->addSuccess(
__(
'You saved the customer group.'));
94 $resultRedirect->setPath(
'customer/group');
95 }
catch (\Exception $e) {
96 $this->messageManager->addError($e->getMessage());
97 if ($customerGroup !=
null) {
99 $this->dataObjectProcessor->buildOutputDataArray(
101 \
Magento\Customer\Api\Data\GroupInterface::class
105 $resultRedirect->setPath(
'customer/group/edit', [
'id' =>
$id]);
107 return $resultRedirect;
109 return $this->resultForwardFactory->create()->forward(
'new');
storeCustomerGroupDataToSession($customerGroupData)
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, GroupRepositoryInterface $groupRepository, GroupInterfaceFactory $groupDataFactory, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor)