Skip to content

Commit

Permalink
Add cron logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Quazz authored Sep 8, 2020
1 parent 149af69 commit ce1aced
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Cron/GenerateFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
namespace Magefox\GoogleShopping\Cron;

use Psr\Log\LoggerInterface;
use Magento\Framework\File\Csv;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magefox\GoogleShopping\Model\Xmlfeed;

class GenerateFile
{
protected $logger;

public function __construct(
LoggerInterface $logger,
Csv $csvProcessor,
DirectoryList $directoryList,
Filesystem $filesystem,
Xmlfeed $xmlFeed
) {
$this->logger = $logger;
$this->filesystem = $filesystem;
$this->directoryList = $directoryList;
$this->csvProcessor = $csvProcessor;
$this->xmlFeed = $xmlFeed;
}

/**
* Sync all products assigned to 'axitech' source to PCRT
*
* @return void
*/
public function execute()
{
try {
$fileDirectoryPath = $this->filesystem->getDirectoryWrite(
\Magento\Framework\App\Filesystem\DirectoryList::PUB
);
$fileName = 'googleshopping.xml';

$xmldata = $this->xmlFeed->getFeed();
$fileDirectoryPath->writeFile($fileName, $xmldata);
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
}
}

0 comments on commit ce1aced

Please sign in to comment.