From b078680f007539d68c59908f0241d6c7494c6144 Mon Sep 17 00:00:00 2001 From: Tajveez <59474504+tajveez-73@users.noreply.github.com> Date: Wed, 9 Jun 2021 11:55:21 +0500 Subject: [PATCH] Cron fails if directory doesn't Exists my cron failed to create sitemap.xml file because the directory I specified doesn't exist. Warning: XMLWriter::openUri(): Unable to resolve file path in /domains/admin.bedfactorydirect.co.uk/http/vendor/evert/sitemap-php/src/SitemapPHP/Sitemap.php on line 165 by the above code changes the directory will be created programmatically. --- Cron/GenerateSitemap.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cron/GenerateSitemap.php b/Cron/GenerateSitemap.php index 63ee4aa..8444a85 100644 --- a/Cron/GenerateSitemap.php +++ b/Cron/GenerateSitemap.php @@ -66,6 +66,11 @@ public function execute() : void $domain = $this->configuration->getVueStorefrontUrl(); $path = $this->getPubPath(); + // Create directory at Path if doesn't exists + if (!file_exists($path)) { + mkdir($path, 0777, true); + } + // Sitemap configuration $this->sitemap = $this->sitemapFactory->create($domain); $this->sitemap->setPath($path);