Give me idea for creating cron script for importing product csv file
1 Answer
Can you please look into this one - Blog
Can you please check this link
To create a cronjob:
app/code/Test/HelloWorld/etc/crontab.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="default">
<job instance="Test\HelloWorld\Cron\Test" method="execute" name="test_helloworld_cron">
<schedule>* * * * *</schedule>
</job>
</group>
</config>
app/code/Test/HelloWorld/Cron/Test.php
<?php
namespace Test\HelloWorld\Cron;
class Test
{
public function execute()
{
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/cron.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info(__METHOD__);
return $this;
}
}