<?php declare(strict_types=1);
namespace TigerMedia\General\CMSCollection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\CustomField\CustomFieldTypes;
class CMSCollection extends Plugin
{
public function activate(ActivateContext $activateContext): void
{
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$this->installCustomFieldsForManufacturers($activateContext, $customFieldSetRepository);
parent::activate($activateContext);
}
private function installCustomFieldsForManufacturers(ActivateContext $context, ?object $customFieldSetRepository): void
{
$connection = $this->container->get('Doctrine\DBAL\Connection');
$customFieldSetRepository->upsert([[
'id' => Uuid::fromStringToHex('Tiger Brands Listing'),
'name' => 'tiger_brands',
'active' => true,
'config' => [
'label' => [
'en-GB' => 'Tiger Brands Settings'
],
],
'customFields' => $this->getCustomFields(),
'relations' => [
[
'id' => Uuid::fromStringToHex('tigerbrandmanufacturer'),
'entityName' => 'product_manufacturer'
]
]
]], $context->getContext());
}
private function getCustomFields(): array
{
return [
[
'id' => Uuid::fromStringToHex('displaybrands'),
'name' => 'displaybrands',
'type' => CustomFieldTypes::BOOL,
'config' => [
'type' => 'checkbox',
'componentName' => 'sw-field',
'bordered' => false,
'label' => [
'en-GB' => 'Display in Storefront'
],
'customFieldPosition' => 0,
'helpText' => [
'en-GB' => 'Displays specific brand in Storefront'
]
]
]
];
}
}