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 %} + +
+

{{ 'sylius.ui.details'|trans }}

+ +
+ {{ form_errors(form) }} + +
+
+
+ {{ form_row(form.code) }} + {{ form_row(form.enabled) }} + {% if product.simple %} + {{ form_row(form.variant.shippingRequired) }} + {% else %} + {{ form_row(form.options, {'remote_url': path('sylius_admin_ajax_product_options_by_phrase'), 'load_edit_url': path('sylius_admin_ajax_find_product_options')}) }} + {{ form_row(form.variantSelectionMethod) }} + {% endif %} + + {# Nothing to see here. #} + +
+
+
+ {{ form_row(form.channels) }} + {{ form_row(form.packable) }} +
+
+ {% if product.simple %} +
+
+

{{ 'sylius.ui.pricing'|trans }}

+ {% include "@SyliusAdmin/Product/_channel_pricing.html.twig" with { product: product, variantForm: form.variant } only %} +
+
+ {% endif %} + + {{ translationFormWithSlug(form.translations, '@SyliusAdmin/Product/_slugField.html.twig', product) }} + {% if product.simple %} + +
+
+

{{ 'sylius.ui.shipping'|trans }}

+
+ {{ form_row(form.variant.shippingCategory) }} + {{ form_row(form.variant.width) }} + {{ form_row(form.variant.height) }} + {{ form_row(form.variant.depth) }} + {{ form_row(form.variant.weight) }} +
+
+
+

{{ 'sylius.ui.taxes'|trans }}

+
+ {{ form_row(form.variant.taxCategory) }} +
+
+
+ {% endif %} + + {{ sylius_template_event(['sylius.admin.product.' ~ action ~ '.tab_details', 'sylius.admin.product.tab_details'], {'form': form}) }} +
+