groupRepository = $groupRepository; } /** * @inheritdoc */ public function getCustomAttribute($attributeCode) { switch ($attributeCode) { case self::$stateAttributeCode: $this->setStateValue(); break; case self::$customerGroupAttributeCode: $this->setCustomerGroupValue(); break; } return parent::getCustomAttribute($attributeCode); } /** * Update invoice state value * Method set text label instead id value * @return void */ private function setStateValue() { $value = $this->getData(self::$stateAttributeCode); /** @var \Magento\Framework\Phrase $state */ $state = Invoice::getStates()[$value]; $this->setCustomAttribute(self::$stateAttributeCode, $state->getText()); } /** * Update customer group value * Method set group code instead id value * @return void */ private function setCustomerGroupValue() { $value = $this->getData(self::$customerGroupAttributeCode); try { $group = $this->groupRepository->getById($value); $this->setCustomAttribute(self::$customerGroupAttributeCode, $group->getCode()); } catch (NoSuchEntityException $e) { $this->setCustomAttribute(self::$customerGroupAttributeCode, 'N/A'); } } }