custom/plugins/ThemeOkeonline/src/ThemeOkeOnline.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace ThemeOkeOnline;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  6. use Shopware\Core\Framework\Uuid\Uuid;
  7. use Shopware\Storefront\Framework\ThemeInterface;
  8. class ThemeOkeOnline extends Plugin implements ThemeInterface
  9. {
  10.     public function getThemeConfigPath(): string
  11.     {
  12.         return 'theme.json';
  13.     }
  14.     public function postInstall(InstallContext $installContext): void
  15.     {
  16.         parent::postInstall($installContext);
  17.         $connection $this->container->get(Connection::class);
  18.         // loop trough category table, add every category to oo_category_info table, with empty contents.
  19.         $categories $connection->fetchAll('SELECT HEX(id) as id,created_at FROM `category`;');
  20.         foreach ($categories as $category) {
  21.             $category = [
  22.                 'id' => Uuid::randomBytes(),
  23.                 'category_id' => Uuid::fromHexToBytes($category['id']),
  24.                 'created_at' => $category['created_at']
  25.             ];
  26.             $query $connection->executeStatement('INSERT INTO `oo_category_info` (`id`, `category_id`, `created_at`) VALUES (:id, :category_id, :created_at);'$category);
  27.         }
  28.     }
  29. }