1

I created a module and want to use it through cron, and in the end I call the cron: run command, here are my files, what is wrong here?

namespace AutoAddtocart\BundleAddtocart\Cron;

class Addtocartauto
{

    protected $_logger;

    public function __construct(

        \Psr\Log\LoggerInterface $logger
    )
    {

        $this->_logger = $logger;
    }

    public function execute()
    {
        $this->_logger->debug('Cron run successfully');
        return $this;
    }

}

Cron xml file

<?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="AutoAddtocart\BundleAddtocart\Cron\Addtocartauto" method="execute"  name="add_to_cart_by_cron">
            <schedule>* * * * *</schedule>
        </job>
    </group>
</config>
2
  • 1
    Run cron:run from your terminal in your Magento folder and check cron_schedule database table, if your add_to_cart_by_cron job_code is coming or not. Sep 18, 2019 at 4:04
  • can you check var/logs if logs are printing or not the message Cron run successfully
    – Mohit Rane
    Sep 18, 2019 at 4:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.