Skip to content

Commit 6676ab9

Browse files
committed
MAGE-938 Add stub for command class
1 parent 1743f99 commit 6676ab9

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

Console/Command/ReplicaCommand.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Console\Command;
4+
5+
use Magento\Framework\Console\Cli;
6+
use Symfony\Component\Console\Command\Command;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Input\InputOption;
9+
use Symfony\Component\Console\Input\InputArgument;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
12+
class ReplicaCommand extends Command
13+
{
14+
const STORE_ARGUMENT = 'store';
15+
16+
/**
17+
* @inheritDoc
18+
*/
19+
protected function configure(): void
20+
{
21+
$this->setName('algolia:replicas:sync')
22+
->setDescription('Sync configured sorting attributes in Magento to Algolia replica indices')
23+
->setDefinition([
24+
new InputArgument(self::STORE_ARGUMENT, InputArgument::OPTIONAL, 'ID for store to be synced with Algolia (optional), if not specified all stores will be synced'),
25+
]);
26+
27+
parent::configure();
28+
}
29+
30+
/** @inheritDoc */
31+
protected function execute(InputInterface $input, OutputInterface $output): int
32+
{
33+
$name = $input->getArgument(self::STORE_ARGUMENT);
34+
35+
if ($name) {
36+
$output->writeln('<info>Syncing store ' . $name . '!</info>');
37+
} else {
38+
$output->writeln('<info>Syncing all stores</info>');
39+
}
40+
41+
return Cli::RETURN_SUCCESS;
42+
}
43+
}

etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,11 @@
144144
<argument name="resourceModel" xsi:type="string">Algolia\AlgoliaSearch\Model\ResourceModel\QueueArchive\Collection</argument>
145145
</arguments>
146146
</virtualType>
147+
<type name="Magento\Framework\Console\CommandListInterface">
148+
<arguments>
149+
<argument name="commands" xsi:type="array">
150+
<item name="replica_sync_command" xsi:type="object">Algolia\AlgoliaSearch\Console\Command\ReplicaCommand</item>
151+
</argument>
152+
</arguments>
153+
</type>
147154
</config>

0 commit comments

Comments
 (0)