-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
Community Support welcomeShould be supported by the communityShould be supported by the community
Description
Trying to implement in a custom command, by taking inspiration from ProcessManagerSampleCommandSimple.php, what would cause this execute() method to fail like this?
use ExecutionTrait;
protected function execute(InputInterface $input, OutputInterface $output): int
{
$monitoringItem = self::initProcessManager(
implode('|', $input->getOption(self::ARGUMENT_TYPES)),
['autoCreate' => true]
);
$monitoringItem->setStatus(MonitoringItem::STATUS_INITIALIZING);
$types = $input->getOption(self::ARGUMENT_TYPES);
$monitoringItem->setTotalSteps(1 + count($types))->setMessage('Starting process')->save();
$step = 0;
if (in_array(Category::classId(), $types, true)) {
$monitoringItem->setMessage('Indexing categories')->setCurrentStep(++$step)->save();
$this->output->writeln('Indexing categories');
$categories = new Category\Listing();
$categories->setObjectTypes([AbstractObject::OBJECT_TYPE_OBJECT, AbstractObject::OBJECT_TYPE_VARIANT]);
$total = $categories->getTotalCount();
for ($i = 0; $i < (ceil($total / $this->paginationCount)); $i++) {
$categories->setLimit($this->paginationCount);
$categories->setOffset($i * $this->paginationCount);
$monitoringItem->setMessage("Indexing categories (offset {$categories->getOffset()} of {$total})")->setCurrentStep(++$step)->save();
foreach ($categories->getObjects() as $category) {
$this->output->writeln("Indexing {$category->getFullPath()}");
$this->bus->dispatch(new IndexMessage($category->getId(), $category::class));
}
$monitoringItem->setStatus(MonitoringItem::STATUS_RUNNING);
}
}
if (in_array(Product::classId(), $types, true)) {
$monitoringItem->setMessage('Indexing products')->setCurrentStep(++$step)->save();
$this->output->writeln('Indexing products');
$products = new Product\Listing();
$products->setObjectTypes([AbstractObject::OBJECT_TYPE_OBJECT, AbstractObject::OBJECT_TYPE_VARIANT]);
$total = $products->getTotalCount();
for ($i = 0; $i < (ceil($total / $this->paginationCount)); $i++) {
$products->setLimit($this->paginationCount);
$products->setOffset($i * $this->paginationCount);
$monitoringItem->setMessage("Indexing products (offset {$products->getOffset()} of {$total})")->setCurrentStep(++$step)->save();
foreach ($products->getObjects() as $product) {
$this->output->writeln("Indexing {$product->getFullPath()}");
$this->bus->dispatch(new IndexMessage($product->getId(), $product::class));
}
$monitoringItem->setStatus(MonitoringItem::STATUS_RUNNING);
}
}
$monitoringItem->setMessage('Job finished')->setCompleted();
return self::SUCCESS;
}Metadata
Metadata
Assignees
Labels
Community Support welcomeShould be supported by the communityShould be supported by the community
