import = $import; } /** * Return element html * * @param AbstractElement $element * * @return string * * @throws LocalizedException */ public function _getElementHtml(AbstractElement $element) { $importTypes = [ 'location', 'block', 'block_v6' ]; $urls = []; foreach ($importTypes as $type) { $startDownloadingUrl = $this->getUrl( 'amasty_geoip/geoip/startDownloading', [ 'type' => $type, 'action' => 'download_and_import' ] ); $startUrl = $this->getUrl( 'amasty_geoip/geoip/start', [ 'type' => $type, 'action' => 'download_and_import' ] ); $processUrl = $this->getUrl( 'amasty_geoip/geoip/process', [ 'type' => $type, 'action' => 'download_and_import' ] ); $commitUrl = $this->getUrl( 'amasty_geoip/geoip/commit', [ 'type' => $type, 'action' => 'download_and_import' ] ); $urls[] = [ 'start' => $startUrl, 'process' => $processUrl, 'commit' => $commitUrl, 'download' => $startDownloadingUrl ]; } $block = $this->getLayout() ->createBlock(\Amasty\Geoip\Block\Adminhtml\Template::class) ->setTemplate('Amasty_Geoip::download_n_import.phtml') ->setConfig(json_encode($urls)); $this->setDNIData($block); return $block->toHtml(); } public function setDNIData($block) { if ($block->geoipHelper->isDone() && $this->import->importTableHasData()) { $width = 100; $completedClass = "-completed"; $importedClass = "-completed"; $importDate = $block->_scopeConfig->getValue('amgeoip/import/date_download'); if (!empty($importDate)) { $importDate = __('Last Imported: ') . $importDate; } } else { $width = 0; $completedClass = "-failed"; $importedClass = "-failed"; $importDate = ''; } $block->setWidth($width) ->setCompletedClass($completedClass) ->setImportedClass($importedClass) ->setImportDate($importDate); } }