diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php index 82c612c1a781d..9f274de129289 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Grid/Collection.php @@ -8,6 +8,8 @@ use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy; use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory; use Magento\Framework\Event\ManagerInterface as EventManager; +use Magento\Framework\Exception\LocalizedException; +use Magento\Sales\Ui\Component\DataProvider\Order\Document; use Psr\Log\LoggerInterface as Logger; /** @@ -15,6 +17,12 @@ */ class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult { + + /** + * @inheritdoc + */ + protected $document = Document::class; + /** * Initialize dependencies. * @@ -24,6 +32,7 @@ class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvide * @param EventManager $eventManager * @param string $mainTable * @param string $resourceModel + * @throws LocalizedException */ public function __construct( EntityFactory $entityFactory, diff --git a/app/code/Magento/Sales/Ui/Component/DataProvider/Order/Document.php b/app/code/Magento/Sales/Ui/Component/DataProvider/Order/Document.php new file mode 100644 index 0000000000000..5d37c6bb3a32d --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/DataProvider/Order/Document.php @@ -0,0 +1,71 @@ +groupRepository = $groupRepository; + } + + /** + * @inheritdoc + * @throws LocalizedException + */ + public function getCustomAttribute($attributeCode) + { + if (self::$customerGroupAttributeCode === $attributeCode) { + $this->setCustomerGroupValue(); + } + return parent::getCustomAttribute($attributeCode); + } + + /** + * Method set group code instead id value + * + * @return void + * @throws LocalizedException + */ + 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'); + } + } +}