diff --git a/src/Entity/Product/Product.php b/src/Entity/Product/Product.php index cadaa8e..9359354 100644 --- a/src/Entity/Product/Product.php +++ b/src/Entity/Product/Product.php @@ -8,14 +8,23 @@ use Sylius\Component\Core\Model\Product as BaseProduct; use Sylius\Component\Product\Model\ProductTranslationInterface; -/** - * @ORM\Entity - * @ORM\Table(name="sylius_product") - */ #[ORM\Entity] #[ORM\Table(name: 'sylius_product')] class Product extends BaseProduct { + #[ORM\Column(type: 'boolean', options: ['default' => false])] + private bool $packable = false; + + public function isPackable(): bool + { + return $this->packable; + } + + public function setPackable(bool $packable): void + { + $this->packable = $packable; + } + protected function createTranslation(): ProductTranslationInterface { return new ProductTranslation(); diff --git a/src/Form/Extension/ProductTypeExtension.php b/src/Form/Extension/ProductTypeExtension.php new file mode 100644 index 0000000..1225ab2 --- /dev/null +++ b/src/Form/Extension/ProductTypeExtension.php @@ -0,0 +1,25 @@ +add('packable', CheckboxType::class) + ; + } + + public static function getExtendedTypes(): iterable + { + yield ProductType::class; + } +} diff --git a/src/Migrations/Version20240508114451.php b/src/Migrations/Version20240508114451.php new file mode 100644 index 0000000..90d5b1c --- /dev/null +++ b/src/Migrations/Version20240508114451.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE sylius_product ADD packable TINYINT(1) DEFAULT 0 NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE sylius_product DROP packable'); + } +} diff --git a/templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig b/templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig new file mode 100644 index 0000000..e385920 --- /dev/null +++ b/templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig @@ -0,0 +1,69 @@ +{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationFormWithSlug %} + +