markshust / magento2-module-ordergrid

The Order Grid module adds more details to the order grid in the admin.
MIT License
85 stars 30 forks source link

[Bug] Call to undefined method Magento\Framework\Api\Search\Document::getData() in /.../vendor/markshust/magento2-module-ordergrid/Plugin/FormatOrderItemsExport.php:25 #14

Open bohdan-harniuk opened 1 year ago

bohdan-harniuk commented 1 year ago

I've got next exception while using the <exportButton/> component on the ui component grid (listing):

Error: Call to undefined method Magento\Framework\Api\Search\Document::getData() in /.../vendor/markshust/magento2-module-ordergrid/Plugin/FormatOrderItemsExport.php:25
Stack trace:
#0 /.../vendor/magento/framework/Interception/Interceptor.php(121): MarkShust\OrderGrid\Plugin\FormatOrderItemsExport->beforeGetRowData()
#1 /.../vendor/magento/framework/Interception/Interceptor.php(153): Magento\Ui\Model\Export\MetadataProvider\Interceptor->Magento\Framework\Interception\{closure}()
#2 /.../generated/code/Magento/Ui/Model/Export/MetadataProvider/Interceptor.php(41): Magento\Ui\Model\Export\MetadataProvider\Interceptor->___callPlugins()
#3 /.../vendor/magento/module-ui/Model/Export/ConvertToCsv.php(92): Magento\Ui\Model\Export\MetadataProvider\Interceptor->getRowData()
#4 /.../vendor/magento/module-ui/Controller/Adminhtml/Export/GridToCsv.php(70): Magento\Ui\Model\Export\ConvertToCsv->getCsvFile()
#5 /.../vendor/magento/framework/Interception/Interceptor.php(58): Magento\Ui\Controller\Adminhtml\Export\GridToCsv->execute()
#6 /.../vendor/magento/framework/Interception/Interceptor.php(138): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->___callParent()
#7 /.../vendor/magento/framework/Interception/Interceptor.php(153): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->Magento\Framework\Interception\{closure}()
#8 /.../generated/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv/Interceptor.php(23): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->___callPlugins()
#9 /.../vendor/magento/framework/App/Action/Action.php(111): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->execute()
#10 /.../vendor/magento/module-backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch()
#11 /.../vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch()
#12 /.../vendor/magento/framework/Interception/Interceptor.php(138): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->___callParent()
#13 /.../vendor/magento/module-backend/App/Action/Plugin/Authentication.php(145): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->Magento\Framework\Interception\{closure}()
#14 /.../vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch()
#15 /.../vendor/magento/framework/Interception/Interceptor.php(153): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->Magento\Framework\Interception\{closure}()
#16 /.../generated/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv/Interceptor.php(32): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->___callPlugins()
#17 /.../vendor/magento/framework/App/FrontController.php(245): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->dispatch()
#18 /.../vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#19 /.../vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
#20 /.../vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#21 /.../vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#22 /.../vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#23 /.../generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#24 /.../vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#25 /.../generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()
#26 /.../vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#27 /.../pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#28 {main}

Steps to reproduce:

  1. Go to the grid listing ui component with export button ui component
  2. instantiated object of \Magento\Framework\Api\Search\DocumentInterface type in the executed context is not instance of \Magento\Framework\DataObject
  3. Open export to dropdown
  4. Click Export button

Screenshots:

Screenshot 2023-05-22 at 20 26 43

Magento version: Adobe Commerce ver. 2.4.4-p2

I've added a temporarily fix for myself (git patch):

diff --git a/vendor/markshust/magento2-module-ordergrid/Plugin/FormatOrderItemsExport.php b/vendor/markshust/magento2-module-ordergrid/Plugin/FormatOrderItemsExport.php
index 4ae7a4f..401f24a 100644
--- a/vendor/markshust/magento2-module-ordergrid/Plugin/FormatOrderItemsExport.php
+++ b/vendor/markshust/magento2-module-ordergrid/Plugin/FormatOrderItemsExport.php
@@ -22,7 +22,7 @@ class FormatOrderItemsExport
         &$options
     ): array
     {
-        if ($orderItems = $document->getData('order_items')) {
+        if ($document instanceof \Magento\Framework\DataObject && $orderItems = $document->getData('order_items')) {
             $decodedItems = html_entity_decode($orderItems);
             $explodedItems = explode('</div><div>', $decodedItems);

--
hgati commented 1 year ago

I am using Magento 2.4.6 with PHP 8.2, and I haven't encountered any issues https://pasteboard.co/FsYXU5bIAG73.png