diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php index 9c261fa31bc25..b73395780ac70 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php @@ -9,16 +9,10 @@ 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\Sales\Ui\Component\DataProvider\Document; use Psr\Log\LoggerInterface as Logger; class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult { - /** - * @inheritdoc - */ - protected $document = Document::class; - /** * Initialize dependencies. * diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/DataProvider/DocumentTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/DataProvider/DocumentTest.php deleted file mode 100644 index 8052c06eee8d9..0000000000000 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/DataProvider/DocumentTest.php +++ /dev/null @@ -1,98 +0,0 @@ -initAttributeValueFactoryMock(); - - $this->groupRepository = $this->getMockForAbstractClass(GroupRepositoryInterface::class); - - $this->document = new Document($this->attributeValueFactory, $this->groupRepository); - } - - /** - * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute - */ - public function testGetStateAttribute() - { - $this->document->setData('state', Invoice::STATE_PAID); - - $this->groupRepository->expects(static::never()) - ->method('getById'); - - $attribute = $this->document->getCustomAttribute('state'); - static::assertEquals('Paid', $attribute->getValue()); - } - - /** - * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute - */ - public function testGetCustomerGroupAttribute() - { - $this->document->setData('customer_group_id', 1); - - $group = $this->getMockForAbstractClass(GroupInterface::class); - - $this->groupRepository->expects(static::once()) - ->method('getById') - ->willReturn($group); - - $group->expects(static::once()) - ->method('getCode') - ->willReturn('General'); - - $attribute = $this->document->getCustomAttribute('customer_group_id'); - static::assertEquals('General', $attribute->getValue()); - } - - /** - * Create mock for attribute value factory - * @return void - */ - private function initAttributeValueFactoryMock() - { - $this->attributeValueFactory = $this->getMockBuilder(AttributeValueFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - - $attributeValue = new AttributeValue(); - - $this->attributeValueFactory->expects(static::once()) - ->method('create') - ->willReturn($attributeValue); - } -} diff --git a/app/code/Magento/Sales/Ui/Component/DataProvider/Document.php b/app/code/Magento/Sales/Ui/Component/DataProvider/Document.php deleted file mode 100644 index 3030a16cc18b9..0000000000000 --- a/app/code/Magento/Sales/Ui/Component/DataProvider/Document.php +++ /dev/null @@ -1,91 +0,0 @@ -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'); - } - } -} diff --git a/app/code/Magento/Ui/Model/Export/MetadataProvider.php b/app/code/Magento/Ui/Model/Export/MetadataProvider.php index dd0bc20255d9a..59f3af18de451 100755 --- a/app/code/Magento/Ui/Model/Export/MetadataProvider.php +++ b/app/code/Magento/Ui/Model/Export/MetadataProvider.php @@ -174,7 +174,7 @@ public function getRowData(DocumentInterface $document, $fields, $options): arra if (isset($options[$column][$key])) { $row[] = $options[$column][$key]; } else { - $row[] = ''; + $row[] = $key; } } else { $row[] = $document->getCustomAttribute($column)->getValue(); diff --git a/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php b/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php index 1d581e84dbdf0..1b86bc14c7df7 100755 --- a/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php +++ b/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php @@ -261,7 +261,7 @@ public function getRowDataProvider() ], ], 'expected' => [ - '', + 'key_2', ], ], [