_sitemapFactory = $sitemapFactory; $this->_filesystem = $filesystem; $this->documentRoot = $documentRoot ?: ObjectManager::getInstance()->get(DocumentRoot::class); parent::__construct($context, $data); } /** * Prepare link to display in grid * * @param \Magento\Framework\DataObject $row * @return string */ public function render(\Magento\Framework\DataObject $row) { /** @var $sitemap \Magento\Sitemap\Model\Sitemap */ $sitemap = $this->_sitemapFactory->create(); $sitemap->setStoreId($row->getStoreId()); $url = $this->escapeHtml($sitemap->getSitemapUrl($row->getSitemapPath(), $row->getSitemapFilename())); $fileName = preg_replace('/^\//', '', $row->getSitemapPath() . $row->getSitemapFilename()); $documentRootPath = $this->documentRoot->getPath(); $directory = $this->_filesystem->getDirectoryRead($documentRootPath); if ($directory->isFile($fileName)) { return sprintf('%1$s', $url); } return $url; } }