Benjamin Roth authored on06/11/2024 17:16:57
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,61 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+/*
6
+ * This file is part of vonRotenberg WMFGO Cevisio Bundle.
7
+ *
8
+ * (c) vonRotenberg
9
+ *
10
+ * @license proprietary
11
+ */
12
+
13
+namespace vonRotenberg\WmfgoCevisioBundle\Command;
14
+
15
+use Contao\CoreBundle\Framework\ContaoFramework;
16
+use Contao\System;
17
+use Symfony\Component\Console\Command\Command;
18
+use Symfony\Component\Console\Input\InputInterface;
19
+use Symfony\Component\Console\Output\OutputInterface;
20
+use Symfony\Component\Console\Style\SymfonyStyle;
21
+use vonRotenberg\WmfgoCevisioBundle\Cron\ShopwareImportProductsJob;
22
+
23
+class ShopwareImportProductsCommand extends Command
24
+{
25
+    protected static $defaultName = 'shopware:import-products';
26
+
27
+    /**
28
+     * @var ContaoFramework
29
+     */
30
+    private $framework;
31
+
32
+    public function __construct(ContaoFramework $framework)
33
+    {
34
+        $this->framework = $framework;
35
+
36
+        parent::__construct();
37
+    }
38
+
39
+    protected function configure(): void
40
+    {
41
+        $this
42
+            ->setName(self::$defaultName)
43
+            ->setDescription('Import products in Shopware instance')
44
+        ;
45
+    }
46
+
47
+    protected function execute(InputInterface $input, OutputInterface $output): int
48
+    {
49
+        $this->framework->initialize();
50
+
51
+        $io = new SymfonyStyle($input, $output);
52
+        $io->title('Product import to Shopware');
53
+
54
+        /** @var ShopwareImportProductsJob $import */
55
+        $import = System::getContainer()->get(ShopwareImportProductsJob::class);
56
+
57
+        $import->import('cli', $io);
58
+
59
+        return 0;
60
+    }
61
+}