2

I'm trying to set up a custom cron job as per this tutorial, but Stores -> Configuration -> Advanced -> Advanceddoes not exist on my backend.

This is what the Advanced menu looks like for me: This is what the Advanced menu looks like for me.

This is what step 2 (before any code) the tutorial thinks it should look like: This is what step 2 (before any code) the tutorial thinks it should look like.

Was that tab removed in 2.2?

Mehran
  • 492
  • 3
  • 14
Shane
  • 21
  • 4

2 Answers2

0

Please add below files in your custom module for custom cron:-

Path: \Vendor\SampleModule\Cron\AddItem.php

<?php

namespace Vendor\SampleModule\Cron;

use Vendor\SampleModule\Model\ItemFactory;
use Vendor\SampleModule\Model\Config;

class AddItem
{
    private $itemFactory;

    private $config;

    //add your dependency here        
    public function __construct(ItemFactory $itemFactory, Config $config)
    {
        $this->itemFactory = $itemFactory;
        $this->config = $config;
    }

    public function execute()
    {
        //you can add your logic here
        if ($this->config->isEnabled()) {
            $this->itemFactory->create()
                ->setName('Scheduled item')
                ->setDescription('Created at ' . time())
                ->save();
        }
    }
}

Path: \Vendor\SampleModule\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 name="vendorAddItem" instance="Vendor\SampleModule\Cron\AddItem" method="execute">
            <schedule>*/5 * * * *</schedule>
        </job>
    </group>
</config>

Please check your cron job using below command:-

php bin/magento cron:run
Purushotam Sharma
  • 1,657
  • 2
  • 26
  • 59
0

The menu item Stores > Configuration > Advanced > Advanced seems to have been removed in Magento 2.2 together with the functionality to disable modules:

Magento 2.2 Cant find how to disable module from back end

I've been searching for it, too - but no chance to find it.

Rohan Hapani
  • 17,388
  • 9
  • 54
  • 96
hey
  • 1,137
  • 1
  • 10
  • 27