Zum Hauptinhalt springen

Geplante Attributesrekrutierung

In einigen Fällen kann die Anforderung bestehen, dass die Attributesrekrutierung z.B. einmal pro Nacht läuft. In diesem Fall muss ein CLI-Befehl entwickelt werden, welcher als Cronjob eingerichtet werden kann.

<?php

namespace App\Command;

use Pimcore\Console\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Twocream\ProductAttributeBundle\Components\Queue\Items\RecruitmentQueueItem;

class ScheduledAttributeRecruitingCommand extends AbstractCommand
{
protected ?RecruitmentQueueItem $attributeRecruitment;

public function __construct(?RecruitmentQueueItem $attributeRecruitment = null, $name = null)
{
$this->attributeRecruitment = $attributeRecruitment;

parent::__construct($name);
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->attributeRecruitment->execute(null, null, true);

return AbstractCommand::SUCCESS;
}
}