From 4ce7b776557aa04d5fe2f3a44bdef38bc72e47cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20D=C4=99bi=C5=84ski?= Date: Mon, 2 Mar 2026 16:06:32 +0100 Subject: [PATCH 1/6] IBX-10685: Added information on how to add a custom attribute type to an existing storage definition --- .../AddFloatStorageDefinitionTag.php | 21 +++++++++++++++++++ .../custom_attribute_type/src/Kernel.php | 21 +++++++++++++++++++ docs/pim/create_custom_attribute_type.md | 16 +++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php create mode 100644 code_samples/catalog/custom_attribute_type/src/Kernel.php diff --git a/code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php b/code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php new file mode 100644 index 0000000000..fbb6b10307 --- /dev/null +++ b/code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php @@ -0,0 +1,21 @@ +getDefinition(StorageDefinition::class) + ->addTag('ibexa.product_catalog.attribute.storage_definition', ['type' => 'percent']); + } +} diff --git a/code_samples/catalog/custom_attribute_type/src/Kernel.php b/code_samples/catalog/custom_attribute_type/src/Kernel.php new file mode 100644 index 0000000000..eeb59b80cf --- /dev/null +++ b/code_samples/catalog/custom_attribute_type/src/Kernel.php @@ -0,0 +1,21 @@ +addCompilerPass(new AddFloatStorageDefinitionTag(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); + } +} diff --git a/docs/pim/create_custom_attribute_type.md b/docs/pim/create_custom_attribute_type.md index 71fd03254f..072532c182 100644 --- a/docs/pim/create_custom_attribute_type.md +++ b/docs/pim/create_custom_attribute_type.md @@ -160,7 +160,9 @@ Register the converter as a service and tag it with `ibexa.product_catalog.attri ### Storage definition -Next, prepare a `PercentStorageDefinition` class, which implements `Ibexa\Contracts\ProductCatalog\Local\Attribute\StorageDefinitionInterface`. +You can either create a new storage definition or use an existing one. + +To create a new one, prepare a `PercentStorageDefinition` class, which implements `Ibexa\Contracts\ProductCatalog\Local\Attribute\StorageDefinitionInterface`. ``` php [[= include_file('code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php') =]] @@ -172,6 +174,18 @@ Register the storage definition as a service and tag it with `ibexa.product_cata [[= include_file('code_samples/catalog/custom_attribute_type/config/custom_services.yaml', 41, 44) =]] ``` +However, if you prefer to use an existing storage definition, you need to create a Storage Definition Tag CompilerPass `src/DependencyInjection/AddFloatStorageDefinitionTag.php`: + +``` php +[[= include_file('code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php') =]] +``` + +Add the CompilerPass to the container with a priority higher than 0 so that it runs first `src/Kernel.php`: + +``` php hl_lines="5 7-8 14-20" +[[= include_file('code_samples/catalog/custom_attribute_type/src/Kernel.php') =]] +``` + ## Use new attribute type In the back office you can now add a new Percent attribute to your product type and create a product with it. From e2143b0712b92e242b6bc2de2ba8f54ac57ca3e0 Mon Sep 17 00:00:00 2001 From: mateuszdebinski Date: Mon, 2 Mar 2026 15:16:30 +0000 Subject: [PATCH 2/6] PHP & JS CS Fixes --- .../src/DependencyInjection/AddFloatStorageDefinitionTag.php | 2 +- code_samples/catalog/custom_attribute_type/src/Kernel.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php b/code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php index fbb6b10307..f9f55fa442 100644 --- a/code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php +++ b/code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php @@ -8,8 +8,8 @@ namespace App\DependencyInjection; use Ibexa\ProductCatalog\Local\Persistence\Legacy\Attribute\Float\StorageDefinition; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; class AddFloatStorageDefinitionTag implements CompilerPassInterface { diff --git a/code_samples/catalog/custom_attribute_type/src/Kernel.php b/code_samples/catalog/custom_attribute_type/src/Kernel.php index eeb59b80cf..c8110471c5 100644 --- a/code_samples/catalog/custom_attribute_type/src/Kernel.php +++ b/code_samples/catalog/custom_attribute_type/src/Kernel.php @@ -1,4 +1,4 @@ - Date: Tue, 3 Mar 2026 11:48:42 +0100 Subject: [PATCH 3/6] Corrected CS --- code_samples/catalog/custom_attribute_type/src/Kernel.php | 2 +- docs/pim/create_custom_attribute_type.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code_samples/catalog/custom_attribute_type/src/Kernel.php b/code_samples/catalog/custom_attribute_type/src/Kernel.php index eeb59b80cf..b1af1b7ff3 100644 --- a/code_samples/catalog/custom_attribute_type/src/Kernel.php +++ b/code_samples/catalog/custom_attribute_type/src/Kernel.php @@ -16,6 +16,6 @@ public function build(ContainerBuilder $container): void { parent::build($container); - $container->addCompilerPass(new AddFloatStorageDefinitionTag(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); + $container->addCompilerPass(new AddFloatStorageDefinitionTag()); } } diff --git a/docs/pim/create_custom_attribute_type.md b/docs/pim/create_custom_attribute_type.md index 072532c182..59eae5ebde 100644 --- a/docs/pim/create_custom_attribute_type.md +++ b/docs/pim/create_custom_attribute_type.md @@ -162,7 +162,7 @@ Register the converter as a service and tag it with `ibexa.product_catalog.attri You can either create a new storage definition or use an existing one. -To create a new one, prepare a `PercentStorageDefinition` class, which implements `Ibexa\Contracts\ProductCatalog\Local\Attribute\StorageDefinitionInterface`. +To create a new storage definition, prepare a `PercentStorageDefinition` class, which implements `Ibexa\Contracts\ProductCatalog\Local\Attribute\StorageDefinitionInterface`. ``` php [[= include_file('code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php') =]] @@ -174,13 +174,13 @@ Register the storage definition as a service and tag it with `ibexa.product_cata [[= include_file('code_samples/catalog/custom_attribute_type/config/custom_services.yaml', 41, 44) =]] ``` -However, if you prefer to use an existing storage definition, you need to create a Storage Definition Tag CompilerPass `src/DependencyInjection/AddFloatStorageDefinitionTag.php`: +If you prefer to use an existing storage definition, you need to create a Storage Definition Tag CompilerPass `src/DependencyInjection/AddFloatStorageDefinitionTag.php`: ``` php [[= include_file('code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php') =]] ``` -Add the CompilerPass to the container with a priority higher than 0 so that it runs first `src/Kernel.php`: +Add the CompilerPass to the container. Do it in a `src/Kernel.php` file or in your Bundle class: ``` php hl_lines="5 7-8 14-20" [[= include_file('code_samples/catalog/custom_attribute_type/src/Kernel.php') =]] From d602d73daad877f97a35faa2b938166381e6f27a Mon Sep 17 00:00:00 2001 From: mateuszdebinski Date: Tue, 3 Mar 2026 10:57:42 +0000 Subject: [PATCH 4/6] PHP & JS CS Fixes --- code_samples/catalog/custom_attribute_type/src/Kernel.php | 1 - 1 file changed, 1 deletion(-) diff --git a/code_samples/catalog/custom_attribute_type/src/Kernel.php b/code_samples/catalog/custom_attribute_type/src/Kernel.php index f2f4ac2564..464772c47c 100644 --- a/code_samples/catalog/custom_attribute_type/src/Kernel.php +++ b/code_samples/catalog/custom_attribute_type/src/Kernel.php @@ -4,7 +4,6 @@ use App\DependencyInjection\AddFloatStorageDefinitionTag; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseKernel; From ee160c6e1c87765b9c534ceca59600d3c9110edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20D=C4=99bi=C5=84ski?= Date: Fri, 13 Mar 2026 12:08:53 +0100 Subject: [PATCH 5/6] Corrected CS --- docs/pim/create_custom_attribute_type.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/pim/create_custom_attribute_type.md b/docs/pim/create_custom_attribute_type.md index 59eae5ebde..b2831f4363 100644 --- a/docs/pim/create_custom_attribute_type.md +++ b/docs/pim/create_custom_attribute_type.md @@ -180,7 +180,8 @@ If you prefer to use an existing storage definition, you need to create a Storag [[= include_file('code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php') =]] ``` -Add the CompilerPass to the container. Do it in a `src/Kernel.php` file or in your Bundle class: +Add the CompilerPass to the container. +Do it in a `src/Kernel.php` file or in your Bundle class: ``` php hl_lines="5 7-8 14-20" [[= include_file('code_samples/catalog/custom_attribute_type/src/Kernel.php') =]] From 133d41437537fac8ea09138e9795d659c9c006a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20D=C4=99bi=C5=84ski?= Date: Fri, 13 Mar 2026 12:15:21 +0100 Subject: [PATCH 6/6] regenerated deptrac baseline --- deptrac.baseline.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deptrac.baseline.yaml b/deptrac.baseline.yaml index 62fe56828f..98de4ff9f2 100644 --- a/deptrac.baseline.yaml +++ b/deptrac.baseline.yaml @@ -78,6 +78,8 @@ deptrac: - Ibexa\CorporateAccount\Event\ApplicationWorkflowEvents - Ibexa\CorporateAccount\Persistence\Legacy\ApplicationState\HandlerInterface - Ibexa\CorporateAccount\Persistence\Values\ApplicationStateUpdateStruct + App\DependencyInjection\AddFloatStorageDefinitionTag: + - Ibexa\ProductCatalog\Local\Persistence\Legacy\Attribute\Float\StorageDefinition App\Discounts\Condition\IsAccountAnniversary: - Ibexa\Discounts\Value\AbstractDiscountExpressionAware App\Discounts\Condition\IsAccountAnniversaryConditionFactory: @@ -143,8 +145,6 @@ deptrac: - Ibexa\Bundle\Shipping\Form\Type\ShippingMethodChoiceType App\GraphQL\Schema\MyCustomFieldDefinitionMapper: - Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\DecoratingFieldDefinitionMapper - App\Kernel: - - Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension App\Migrations\Action\AssignSection: - Ibexa\Migration\ValueObject\Step\Action App\Migrations\Action\AssignSectionExecutor: