<?php declare(strict_types=1);
namespace ThemeOkeOnline;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Storefront\Framework\ThemeInterface;
class ThemeOkeOnline extends Plugin implements ThemeInterface
{
public function getThemeConfigPath(): string
{
return 'theme.json';
}
public function postInstall(InstallContext $installContext): void
{
parent::postInstall($installContext);
$connection = $this->container->get(Connection::class);
// loop trough category table, add every category to oo_category_info table, with empty contents.
$categories = $connection->fetchAll('SELECT HEX(id) as id,created_at FROM `category`;');
foreach ($categories as $category) {
$category = [
'id' => Uuid::randomBytes(),
'category_id' => Uuid::fromHexToBytes($category['id']),
'created_at' => $category['created_at']
];
$query = $connection->executeStatement('INSERT INTO `oo_category_info` (`id`, `category_id`, `created_at`) VALUES (:id, :category_id, :created_at);', $category);
}
}
}