_getDataObj()->getFilter(); $linkOptions['action'] = 'exportCsv'; $links['exportCsv'] = ['title' => 'Export to CSV', 'url' => $this->url($linkOptions)]; return $links; } protected function _initFromForm(\Qs_Form $form) { $data = $form->getValues(); $data['bought'] = 'y'; $this->_getDataObj()->initFromForm($data); return $this; } protected function _doExportCsv() { $dataObj = $this->_getDataObj(); if ($dataObj->hasFilter()) { $form = $this->_getFilterForm(); if ($form->validate()) { $dataObj->addFilter($form->getValues()); } } $options = ['order' => [$this->_getList()->getOrderBy()]]; $dataObj->setSelectOptions($options); $stmt = $dataObj->getList4ExportStatement(); $rowCallback = function () use ($stmt, $dataObj) { $row = $stmt->fetch(); if ($row) { $dataObj->prepareExportRow($row); } return $row; }; $helper = new ExportCsv([ 'fileName' => $this->getConfig('itemsName') . ' {date}.csv', 'columns' => $dataObj->getExportColumns(), 'rowCallback' => $rowCallback, ]); $helper->export(); $this->_postExportCsv(); exit; } protected function _postExportCsv() { $this->_log(); return $this; } }