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?

1
  • Post your code what you have done so peoples can understand
    – Keyur Shah
    Commented Dec 29, 2017 at 8:20

2 Answers 2

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
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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.