From ff57170106a4e2ff2ab00b08f49d0f5d5c6d467c Mon Sep 17 00:00:00 2001 From: DominicWatts Date: Wed, 30 Mar 2022 16:55:43 +0100 Subject: [PATCH] Update Generatesitemapxml.php --- .../Console/Command/Generatesitemapxml.php | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/app/code/Neman/Generatesitemapxml/Console/Command/Generatesitemapxml.php b/app/code/Neman/Generatesitemapxml/Console/Command/Generatesitemapxml.php index a8627f9..b1a55a7 100644 --- a/app/code/Neman/Generatesitemapxml/Console/Command/Generatesitemapxml.php +++ b/app/code/Neman/Generatesitemapxml/Console/Command/Generatesitemapxml.php @@ -1,4 +1,5 @@ get('Magento\Framework\App\ResourceConnection'); -$connection = $resource->getConnection(); -$tableName = $resource->getTableName('sitemap'); //gives table name with prefix - -//Select Data from table -$sql = "Select * FROM " . $tableName; -$result = $connection->fetchAll($sql); // gives associated array, table fields as key in array. - -if (!$result) -{ -$sql = "Insert Into " . $tableName . " VALUES (1,NULL,'sitemap.xml','/',NULL,1);"; -$connection->query($sql); - -echo "No sitemap records found. Default (sitemap.xml) added under docroot folder."; -} - -else -{ -echo "Has something. We will use data from Dashboard --> Marketing --> Sitemap area or sitemap SQL table."; -} - class Generatesitemapxml extends Command { - - const NAME_ARGUMENT = "name"; - const NAME_OPTION = "option"; - /** * Enable/disable configuration */ @@ -124,21 +95,14 @@ protected function execute( InputInterface $input, OutputInterface $output ) { - - $errors = []; - - // check if Marketing --> Sitemap has any fields added - //$rows = mysql_result(mysql_query('SELECT COUNT(*) FROM sitemap'), 0); - - // check if scheduled generation enabled if (!$this->_scopeConfig->isSetFlag( self::XML_PATH_GENERATION_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) ) { - $output->writeln('Sitemap generated at docroot. If Nginx please symlink it to pub/. No scheduled generation enabled still!!!'); + $output->writeln('No generation scheduled'); } $collection = $this->_collectionFactory->create(); @@ -197,10 +161,6 @@ protected function configure() { $this->setName("sitemap:generate"); $this->setDescription("Generate xml sitemap"); - $this->setDefinition([ - new InputArgument(self::NAME_ARGUMENT, InputArgument::OPTIONAL, "Name"), - new InputOption(self::NAME_OPTION, "-a", InputOption::VALUE_NONE, "Option functionality") - ]); parent::configure(); } }