I am having this error when trying to export csv file with customer fields from Magento 2.2.5 admin:
1 exception(s):
Exception #0 (Exception): Notice: Undefined offset: 0 in /var/www/html/vendor/magento/module-customer/Ui/Component/DataProvider/Document.php on line 168
Exception #0 (Exception): Notice: Undefined offset: 0 in /var/www/html/vendor/magento/module-customer/Ui/Component/DataProvider/Document.php on line 168
#0 /var/www/html/vendor/magento/module-customer/Ui/Component/DataProvider/Document.php(168): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined offse...', '/var/www/html/v...', 168, Array)
#1 /var/www/html/vendor/magento/module-customer/Ui/Component/DataProvider/Document.php(108): Magento\Customer\Ui\Component\DataProvider\Document->setWebsiteValue()
#2 /var/www/html/vendor/magento/module-ui/Model/Export/MetadataProvider.php(159): Magento\Customer\Ui\Component\DataProvider\Document->getCustomAttribute('website_id')
#3 /var/www/html/vendor/magento/module-ui/Model/Export/ConvertToCsv.php(84): Magento\Ui\Model\Export\MetadataProvider->getRowData(Object(Magento\Customer\Ui\Component\DataProvider\Document), Array, Array)
#4 /var/www/html/vendor/magento/module-ui/Controller/Adminhtml/Export/GridToCsv.php(72): Magento\Ui\Model\Export\ConvertToCsv->getCsvFile()
#5 /var/www/html/generated/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv/Interceptor.php(24): Magento\Ui\Controller\Adminhtml\Export\GridToCsv->execute()
#6 /var/www/html/vendor/magento/framework/App/Action/Action.php(107): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->execute()
#7 /var/www/html/vendor/magento/module-backend/App/AbstractAction.php(229): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#8 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#9 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->___callParent('dispatch', Array)
#10 /var/www/html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#11 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#12 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#13 /var/www/html/generated/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv/Interceptor.php(39): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->___callPlugins('dispatch', Array, NULL)
#14 /var/www/html/vendor/magento/framework/App/FrontController.php(55): Magento\Ui\Controller\Adminhtml\Export\GridToCsv\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#15 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#16 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#17 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#18 /var/www/html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#19 /var/www/html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#20 /var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
#21 /var/www/html/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()
#22 /var/www/html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#23 {main}
The code in Document.php is:
/**
* Update website value
* Method set website name instead id value
* @return void
*/
private function setWebsiteValue()
{
$value = $this->getData(self::$websiteAttributeCode);
$list = $this->storeManager->getWebsites();
$this->setCustomAttribute(self::$websiteAttributeCode, $list[$value]->getName());
$this->setCustomAttribute(self::$websiteIdAttributeCode, $value);
}
I think that the problem is in:
$list[$value]
Any help please?
Best Answer
I have facing same issue in export customer and fixed to override
module-customer/Ui/Component/DataProvider/Document.php
file.Follow below steps to create custom module for override Document.php file and updated code.