From 0ff312bdad096d313331f6882d1ecb1e991b812b Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Thu, 24 Oct 2024 14:56:19 +0200 Subject: [PATCH 01/12] Symbol attribute type described --- docs/pim/symbol_attribute_type.md | 190 ++++++++++++++++++ .../product_search_criteria.md | 11 +- .../symbolattribute_criterion.md | 22 ++ mkdocs.yml | 1 + 4 files changed, 220 insertions(+), 4 deletions(-) create mode 100644 docs/pim/symbol_attribute_type.md create mode 100644 docs/search/criteria_reference/symbolattribute_criterion.md diff --git a/docs/pim/symbol_attribute_type.md b/docs/pim/symbol_attribute_type.md new file mode 100644 index 0000000000..0224697e93 --- /dev/null +++ b/docs/pim/symbol_attribute_type.md @@ -0,0 +1,190 @@ +--- +description: Create a symbol attribute type that enables for the efficient representation of string-based values while enforcing their format in product specifications. +--- + +# Symbol attribute type + +In product specifications, the symbol attribute type enables the efficient representation of string-based data and enforces their format. + +## Installation + +### Download the bundle + +To get the most recent stable version of this bundle, open a command terminal, navigate to your project directory, and run the following command: + +``` bash +ibexa/product-catalog-symbol-attribute +``` + +!!! caution + + To use this command requires you need to first install the Composer locally. + For more information about Composer installation process, see [documentation](install_ibexa_dxp.md#get-composer). + +### Enable the bundle + +Flex enables and configures the `IbexaProductCatalogSymbolAttributeBundle` automatically. +If you don't use it, you can manually enable Flex by adding the line below to the Kernel of your project: + +``` php +// config/bundles.php + +return [ + // ... + Ibexa\Bundle\ProductCatalogSymbolAttribute\IbexaProductCatalogSymbolAttributeBundle => ['all' => true], + // ... +]; +``` + +### Update database schema + +To store symbol attribute values, the `IbexaProductCatalogSymbolAttributeBundle` needs an extra table. +The following SQL query can be used to build the required database structure: + +``` bash +create table ibexa_product_specification_attribute_symbol ( + id int not null primary key, + value varchar(255) null, + constraint ibexa_product_specification_attribute_symbol_fk + foreign key (id) references ibexa_product_specification_attribute (id) + on update cascade on delete cascade +) collate = utf8mb4_unicode_520_ci; + +create index ibexa_product_specification_attribute_symbol_value_idx + on ibexa_product_specification_attribute_symbol (value); +``` + +### Create symbol attribute definition (optional) + +Now, you're able to define symbol attributes at this point. + +To create symbol attribute definition, in the back office, go to **Product catalog** -> **Attributes**, and click **Create**. +Then, choose **Symbol** attribute type. + +## Build-in symbol attribute formats + +The built-in symbol attribute formats in `ibexa/product-catalog-symbol-attribute` are listed below: + +| Name | Description | Example | +|-----------------|-----------------|-----------------| +| Generic | Accepts any string value | #FR1.2 | +| Generic (alphabetic characters only) | Accepts any string value that contais only letters | ABCD | +| Generic (digits only) | Accepts any string value that contais only digits | 123456 | +| Generic (alphanumeric characters only) | Accepts any string value that contains only letters or digits | 2N6405G | +| Generic (hexadecimal digits only) | Accepts any string value that contains only hexadecimal digits (digits or A-F characters) | DEADBEEF | +| EAN-8 | European Article Number (8 characters) | 29033706 | +| EAN-13 | European Article Number (13 characters) | 5023920187205 | +| EAN-14 | European Article Number (14 characters) | 50239201872050 | +| ISBN-10 | International Standard Book Number (10 characters) | 0-19-852663-6 | +| ISBN-13 | International Standard Book Number (13 characters) | 978-1-86197-876-9 | + +!!! caution + + Maximum length of the symbol value is 160 characters. + +## Create custom symbol attribute format + +Under the `ibexa_product_catalog_symbol_attribute.formats` key, you can use configuration to create your own symbol format. + +See the example below: + +``` yaml +ibexa_product_catalog_symbol_attribute: + formats: + manufacturer_part_number: + name: 'Manufacturer Part Number' + pattern: '/^[A-Z]{3}-\d{5}$/' + examples: + - 'RPI-14645' + - 'MSS-24827' + - 'SEE-15444' +``` + +The following example specifies the format for a "Manufacturer Part Number." + +According to the pattern option, the value: + +- must be a string +- uses a regular expression +- begins with three capital letters +- ends with five numbers + +Certain formats, such as the International Standard Book Number (ISBN-10) and the European Article Number (EAN-13), contain checksum digits and are self-validating. + +To validate checksum of symbol: + +1\. Implement `\Ibexa\Contracts\ProductCatalogSymbolAttribute\Value\ChecksumInterface`: + +``` php +getDigits($value); + + $count = count($digits); + $total = 0; + for ($i = $count - 2; $i >= 0; $i -= 2) { + $digit = $digits[$i]; + if ($i % 2 === 0) { + $digit *= 2; + } + + $total += $digit > 9 ? $digit - 9 : $digit; + } + + $checksum = $digits[$count - 1]; + + return $total + $checksum === 0; + } + + /** + * Returns an array of digits from the given value (skipping any formatting characters). + * + * @return int[] + */ + private function getDigits(string $value): array + { + $chars = array_filter( + str_split($value), + static fn (string $char): bool => $char !== '-' + ); + + return array_map('intval', array_values($chars)); + } +} +``` + +## Search for products with given symbol attribute + +You can use `SymbolAttribute` Search Criterion to find products by symbol attribute: + +For more information, see [SymbolAttribute Criterion](symbolattribute_criterion.md). \ No newline at end of file diff --git a/docs/search/criteria_reference/product_search_criteria.md b/docs/search/criteria_reference/product_search_criteria.md index a31f6cabbc..1c78c2ff02 100644 --- a/docs/search/criteria_reference/product_search_criteria.md +++ b/docs/search/criteria_reference/product_search_criteria.md @@ -35,11 +35,14 @@ Search Criterion let you filter product by specific attributes, for example, col |[ProductCategory](productcategory_criterion.md)|Product category assigned to product| |[ProductCode](productcode_criterion.md)|Product's code| |[ProductName](productname_criterion.md)|Product's name| -|[ProductStock](productstock_criterion.md)|Product's numerical stock| -|[ProductStockRange](productstockrange_criterion.md)|Product's numerical stock| +|[RangeMeasurementAttributeMinimum](rangemeasurementattributeminimum_criterion.md)|Minimum value of product's measurement attribute| +|[RangeMeasurementAttributeMaximum](rangemeasurementattributemaximum_criterion.md)|Maximum value of product's measurement attribute| +|[SymbolAttribute](symbolattribute_criterion.md)|Value of product's symbol attribute| +|[SimpleMeasurementAttribute](simplemeasurementattribute_criterion.md)|Value of product's measurement attribute| +|[BasePrice](baseprice_criterion.md)|Product's base price| +|[CustomPrice](customprice_criterion.md)|Product's custom price| |[ProductType](producttype_criterion.md)|Product type| |[RangeMeasurementAttributeMaximum](rangemeasurementattributemaximum_criterion.md)|Maximum value of product's measurement attribute| |[RangeMeasurementAttributeMinimum](rangemeasurementattributeminimum_criterion.md)|Minimum value of product's measurement attribute| |[SelectionAttribute](selectionattribute_criterion.md)|Value of product's selection attribute| -|[SimpleMeasurementAttribute](simplemeasurementattribute_criterion.md)|Value of product's measurement attribute| - +|[SimpleMeasurementAttribute](simplemeasurementattribute_criterion.md)|Value of product's measurement attribute| \ No newline at end of file diff --git a/docs/search/criteria_reference/symbolattribute_criterion.md b/docs/search/criteria_reference/symbolattribute_criterion.md new file mode 100644 index 0000000000..d7ca5d4bbb --- /dev/null +++ b/docs/search/criteria_reference/symbolattribute_criterion.md @@ -0,0 +1,22 @@ +--- +description: SymbolAttribute Criterion +--- + +# SymbolAttributeCriterion + +The `SymbolAttribute` Search Criterion searches for products by symbol attribute. + +## Arguments + +- `value` - string representing the attribute value + +## Example + +### PHP + +``` php +$query = new ProductQuery(); +$query->setFilter(new SymbolAttribute('ean', '5023920187205')); +// ... +$results = $productService->findProducts($query); +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index ae83fcbcf8..fda01ac5f4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -361,6 +361,7 @@ nav: - Create product code generator: pim/create_product_code_generator.md - Create custom catalog filter: pim/create_custom_catalog_filter.md - Create custom name schema: pim/create_custom_name_schema_strategy.md + - Use symbol attribute type: pim/symbol_attribute_type.md - Add remote PIM support: pim/add_remote_pim_support.md - Commerce: - Commerce: commerce/commerce.md From 60fdb8b5a586a712ad7b37fc49ec8691500cdda7 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Fri, 25 Oct 2024 12:39:47 +0200 Subject: [PATCH 02/12] Fixes after review --- .../Symbol/Format/Checksum/LuhnChecksum.php | 46 ++++++++ docs/pim/symbol_attribute_type.md | 102 +++++------------- .../symbolattribute_criterion.md | 14 ++- 3 files changed, 81 insertions(+), 81 deletions(-) create mode 100644 code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php diff --git a/code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php b/code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php new file mode 100644 index 0000000000..3e7e405774 --- /dev/null +++ b/code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php @@ -0,0 +1,46 @@ +getDigits($value); + + $count = count($digits); + $total = 0; + for ($i = $count - 2; $i >= 0; $i -= 2) { + $digit = $digits[$i]; + if ($i % 2 === 0) { + $digit *= 2; + } + + $total += $digit > 9 ? $digit - 9 : $digit; + } + + $checksum = $digits[$count - 1]; + + return $total + $checksum === 0; + } + + /** + * Returns an array of digits from the given value (skipping any formatting characters). + * + * @return int[] + */ + private function getDigits(string $value): array + { + $chars = array_filter( + str_split($value), + static fn (string $char): bool => $char !== '-' + ); + + return array_map('intval', array_values($chars)); + } +} \ No newline at end of file diff --git a/docs/pim/symbol_attribute_type.md b/docs/pim/symbol_attribute_type.md index 0224697e93..17baf14196 100644 --- a/docs/pim/symbol_attribute_type.md +++ b/docs/pim/symbol_attribute_type.md @@ -6,6 +6,8 @@ description: Create a symbol attribute type that enables for the efficient repre In product specifications, the symbol attribute type enables the efficient representation of string-based data and enforces their format. +This feature allows you to store standard product identifiers (such as EAN or ISBN) in the [Product Information Management](pim_guide.md) system. + ## Installation ### Download the bundle @@ -13,25 +15,20 @@ In product specifications, the symbol attribute type enables the efficient repre To get the most recent stable version of this bundle, open a command terminal, navigate to your project directory, and run the following command: ``` bash -ibexa/product-catalog-symbol-attribute +composer require ibexa/product-catalog-symbol-attribute ``` -!!! caution - - To use this command requires you need to first install the Composer locally. - For more information about Composer installation process, see [documentation](install_ibexa_dxp.md#get-composer). - ### Enable the bundle -Flex enables and configures the `IbexaProductCatalogSymbolAttributeBundle` automatically. -If you don't use it, you can manually enable Flex by adding the line below to the Kernel of your project: +Symfony Flex enables and configures the `IbexaProductCatalogSymbolAttributeBundle` automatically. +If you don't use it, you can manually enable this bundle by adding the line below to the Kernel of your project: ``` php // config/bundles.php return [ // ... - Ibexa\Bundle\ProductCatalogSymbolAttribute\IbexaProductCatalogSymbolAttributeBundle => ['all' => true], + Ibexa\Bundle\ProductCatalogSymbolAttribute\IbexaProductCatalogSymbolAttributeBundle::class => ['all' => true], // ... ]; ``` @@ -41,7 +38,7 @@ return [ To store symbol attribute values, the `IbexaProductCatalogSymbolAttributeBundle` needs an extra table. The following SQL query can be used to build the required database structure: -``` bash +``` sql create table ibexa_product_specification_attribute_symbol ( id int not null primary key, value varchar(255) null, @@ -100,88 +97,39 @@ ibexa_product_catalog_symbol_attribute: - 'SEE-15444' ``` -The following example specifies the format for a "Manufacturer Part Number." +This following example specifies the format for a "Manufacturer Part Number", defined with the `manufacturer_part_number` identifier. -According to the pattern option, the value: +The pattern is specified using a regular expression. +According to the pattern option, the attribute value: - must be a string -- uses a regular expression -- begins with three capital letters -- ends with five numbers +- begins with three capital letters (A-Z), followed by a hyphen ("-") +- ends with five numbers (0-9), with no other characters before or after Certain formats, such as the International Standard Book Number (ISBN-10) and the European Article Number (EAN-13), contain checksum digits and are self-validating. To validate checksum of symbol: -1\. Implement `\Ibexa\Contracts\ProductCatalogSymbolAttribute\Value\ChecksumInterface`: - -``` php -getDigits($value); - - $count = count($digits); - $total = 0; - for ($i = $count - 2; $i >= 0; $i -= 2) { - $digit = $digits[$i]; - if ($i % 2 === 0) { - $digit *= 2; - } - - $total += $digit > 9 ? $digit - 9 : $digit; - } - - $checksum = $digits[$count - 1]; - - return $total + $checksum === 0; - } - - /** - * Returns an array of digits from the given value (skipping any formatting characters). - * - * @return int[] - */ - private function getDigits(string $value): array - { - $chars = array_filter( - str_split($value), - static fn (string $char): bool => $char !== '-' - ); - - return array_map('intval', array_values($chars)); - } -} +``` yaml +services: + App\PIM\Symbol\Format\Checksum\LuhnChecksum: + tags: + - name: ibexa.product_catalog.attribute.symbol.checksum + format: my_format ``` +The format attribute (`my_format`) is the identifier used under the `ibexa_product_catalog_symbol_attribute.formats` key. ## Search for products with given symbol attribute diff --git a/docs/search/criteria_reference/symbolattribute_criterion.md b/docs/search/criteria_reference/symbolattribute_criterion.md index d7ca5d4bbb..70bcfc9982 100644 --- a/docs/search/criteria_reference/symbolattribute_criterion.md +++ b/docs/search/criteria_reference/symbolattribute_criterion.md @@ -4,19 +4,25 @@ description: SymbolAttribute Criterion # SymbolAttributeCriterion -The `SymbolAttribute` Search Criterion searches for products by symbol attribute. +The `SymbolAttribute` Search Criterion searches for products by [symbol attribute](symbol_attribute_type.md). ## Arguments -- `value` - string representing the attribute value +- `identifier` - identifier of the format +- `value` - array with the values to search for ## Example ### PHP ``` php +setFilter(new SymbolAttribute('ean', '5023920187205')); -// ... +$query->setFilter(new SymbolAttribute('ean', ['5023920187205'])); +/** @var \Ibexa\Contracts\ProductCatalog\ProductServiceInterface $productService*/ $results = $productService->findProducts($query); ``` \ No newline at end of file From b037ab176e7758333be902177bb5739cc6bf81ce Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Fri, 25 Oct 2024 10:43:47 +0000 Subject: [PATCH 03/12] PHP CS Fixes --- code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php b/code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php index 3e7e405774..2860f9aec9 100644 --- a/code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php +++ b/code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php @@ -43,4 +43,4 @@ private function getDigits(string $value): array return array_map('intval', array_values($chars)); } -} \ No newline at end of file +} From 528bf4e3d581fa4a988b9c8104a66bf68c9300a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 9 Jul 2025 12:54:08 +0200 Subject: [PATCH 04/12] Resolved conflicts in product search criteria --- .../criteria_reference/product_search_criteria.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/search/criteria_reference/product_search_criteria.md b/docs/search/criteria_reference/product_search_criteria.md index 1c78c2ff02..35a3948ac3 100644 --- a/docs/search/criteria_reference/product_search_criteria.md +++ b/docs/search/criteria_reference/product_search_criteria.md @@ -35,14 +35,11 @@ Search Criterion let you filter product by specific attributes, for example, col |[ProductCategory](productcategory_criterion.md)|Product category assigned to product| |[ProductCode](productcode_criterion.md)|Product's code| |[ProductName](productname_criterion.md)|Product's name| -|[RangeMeasurementAttributeMinimum](rangemeasurementattributeminimum_criterion.md)|Minimum value of product's measurement attribute| -|[RangeMeasurementAttributeMaximum](rangemeasurementattributemaximum_criterion.md)|Maximum value of product's measurement attribute| -|[SymbolAttribute](symbolattribute_criterion.md)|Value of product's symbol attribute| -|[SimpleMeasurementAttribute](simplemeasurementattribute_criterion.md)|Value of product's measurement attribute| -|[BasePrice](baseprice_criterion.md)|Product's base price| -|[CustomPrice](customprice_criterion.md)|Product's custom price| +|[ProductStock](productstock_criterion.md)|Product's numerical stock| +|[ProductStockRange](productstockrange_criterion.md)|Product's numerical stock| |[ProductType](producttype_criterion.md)|Product type| |[RangeMeasurementAttributeMaximum](rangemeasurementattributemaximum_criterion.md)|Maximum value of product's measurement attribute| |[RangeMeasurementAttributeMinimum](rangemeasurementattributeminimum_criterion.md)|Minimum value of product's measurement attribute| |[SelectionAttribute](selectionattribute_criterion.md)|Value of product's selection attribute| -|[SimpleMeasurementAttribute](simplemeasurementattribute_criterion.md)|Value of product's measurement attribute| \ No newline at end of file +|[SimpleMeasurementAttribute](simplemeasurementattribute_criterion.md)|Value of product's measurement attribute| +|[SymbolAttribute](symbolattribute_criterion.md)|Value of product's symbol attribute| From 4dec593fb42e53faf4bb79114c869d60cf0bd783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 9 Jul 2025 17:34:19 +0200 Subject: [PATCH 05/12] Added composer dependency --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index eebf291e30..734baa69ba 100644 --- a/composer.json +++ b/composer.json @@ -70,7 +70,8 @@ "ibexa/twig-components": "~4.6.x-dev", "ibexa/tree-builder": "~4.6.x-dev", "ibexa/discounts": "~4.6.x-dev", - "ibexa/discounts-codes": "~4.6.x-dev" + "ibexa/discounts-codes": "~4.6.x-dev", + "ibexa/product-catalog-symbol-attribute": "~4.6.x-dev" }, "scripts": { "fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots", From 4db77ba32999d90873da790409161144734d2443 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Thu, 10 Jul 2025 11:34:29 +0200 Subject: [PATCH 06/12] fixes --- docs/pim/symbol_attribute_type.md | 9 +++++---- .../criteria_reference/symbolattribute_criterion.md | 1 + mkdocs.yml | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/pim/symbol_attribute_type.md b/docs/pim/symbol_attribute_type.md index 17baf14196..acd3ac7429 100644 --- a/docs/pim/symbol_attribute_type.md +++ b/docs/pim/symbol_attribute_type.md @@ -1,10 +1,11 @@ --- description: Create a symbol attribute type that enables for the efficient representation of string-based values while enforcing their format in product specifications. +edition: lts-update --- # Symbol attribute type -In product specifications, the symbol attribute type enables the efficient representation of string-based data and enforces their format. +The Symbol attribute type LTS update enables the efficient representation of string-based data and enforces their format in product specifications. This feature allows you to store standard product identifiers (such as EAN or ISBN) in the [Product Information Management](pim_guide.md) system. @@ -69,9 +70,9 @@ The built-in symbol attribute formats in `ibexa/product-catalog-symbol-attribute | Generic (digits only) | Accepts any string value that contais only digits | 123456 | | Generic (alphanumeric characters only) | Accepts any string value that contains only letters or digits | 2N6405G | | Generic (hexadecimal digits only) | Accepts any string value that contains only hexadecimal digits (digits or A-F characters) | DEADBEEF | -| EAN-8 | European Article Number (8 characters) | 29033706 | +| EAN-8 | European Article Number (8 characters) | 96385074 | | EAN-13 | European Article Number (13 characters) | 5023920187205 | -| EAN-14 | European Article Number (14 characters) | 50239201872050 | +| EAN-14 | European Article Number (14 characters) | 12345678901231 | | ISBN-10 | International Standard Book Number (10 characters) | 0-19-852663-6 | | ISBN-13 | International Standard Book Number (13 characters) | 978-1-86197-876-9 | @@ -104,7 +105,7 @@ According to the pattern option, the attribute value: - must be a string - begins with three capital letters (A-Z), followed by a hyphen ("-") -- ends with five numbers (0-9), with no other characters before or after +- ends with five digits (0-9), with no other characters before or after Certain formats, such as the International Standard Book Number (ISBN-10) and the European Article Number (EAN-13), contain checksum digits and are self-validating. diff --git a/docs/search/criteria_reference/symbolattribute_criterion.md b/docs/search/criteria_reference/symbolattribute_criterion.md index 70bcfc9982..d4632638a2 100644 --- a/docs/search/criteria_reference/symbolattribute_criterion.md +++ b/docs/search/criteria_reference/symbolattribute_criterion.md @@ -1,5 +1,6 @@ --- description: SymbolAttribute Criterion +edition: lts-update --- # SymbolAttributeCriterion diff --git a/mkdocs.yml b/mkdocs.yml index fda01ac5f4..782f2e86ff 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -593,6 +593,7 @@ nav: - RangeMeasurementAttributeMaximum: search/criteria_reference/rangemeasurementattributemaximum_criterion.md - SimpleMeasurementAttribute: search/criteria_reference/simplemeasurementattribute_criterion.md - SelectionAttribute: search/criteria_reference/selectionattribute_criterion.md + - SymbolAttribute: search/criteria_reference/symbolattribute_criterion.md - Order Search Criteria: - Order Search Criteria: search/criteria_reference/order_search_criteria.md - CompanyName: search/criteria_reference/order_company_name_criterion.md From dc91ecb72f28c0dad250afa761088cd9705cedcc Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Mon, 14 Jul 2025 12:06:06 +0200 Subject: [PATCH 07/12] review fixes --- .../search/src/Query/SymbolAttributeTypeQuery.php | 9 +++++++++ docs/pim/symbol_attribute_type.md | 13 +++---------- .../criteria_reference/symbolattribute_criterion.md | 10 +--------- 3 files changed, 13 insertions(+), 19 deletions(-) create mode 100644 code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php diff --git a/code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php b/code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php new file mode 100644 index 0000000000..2629daec53 --- /dev/null +++ b/code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php @@ -0,0 +1,9 @@ +setFilter(new SymbolAttribute('ean', ['5023920187205'])); +/** @var \Ibexa\Contracts\ProductCatalog\ProductServiceInterface $productService*/ +$results = $productService->findProducts($query); \ No newline at end of file diff --git a/docs/pim/symbol_attribute_type.md b/docs/pim/symbol_attribute_type.md index acd3ac7429..512c77b51f 100644 --- a/docs/pim/symbol_attribute_type.md +++ b/docs/pim/symbol_attribute_type.md @@ -40,16 +40,9 @@ To store symbol attribute values, the `IbexaProductCatalogSymbolAttributeBundle` The following SQL query can be used to build the required database structure: ``` sql -create table ibexa_product_specification_attribute_symbol ( - id int not null primary key, - value varchar(255) null, - constraint ibexa_product_specification_attribute_symbol_fk - foreign key (id) references ibexa_product_specification_attribute (id) - on update cascade on delete cascade -) collate = utf8mb4_unicode_520_ci; - -create index ibexa_product_specification_attribute_symbol_value_idx - on ibexa_product_specification_attribute_symbol (value); +CREATE TABLE ibexa_product_specification_attribute_symbol (id INT NOT NULL, value VARCHAR(160) DEFAULT NULL, PRIMARY KEY(id)); +CREATE INDEX ibexa_product_specification_attribute_symbol_value_idx ON ibexa_product_specification_attribute_symbol (value); +ALTER TABLE ibexa_product_specification_attribute_symbol ADD CONSTRAINT ibexa_product_specification_attribute_symbol_fk FOREIGN KEY (id) REFERENCES ibexa_product_specification_attribute (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE; ``` ### Create symbol attribute definition (optional) diff --git a/docs/search/criteria_reference/symbolattribute_criterion.md b/docs/search/criteria_reference/symbolattribute_criterion.md index d4632638a2..f14d2694f0 100644 --- a/docs/search/criteria_reference/symbolattribute_criterion.md +++ b/docs/search/criteria_reference/symbolattribute_criterion.md @@ -17,13 +17,5 @@ The `SymbolAttribute` Search Criterion searches for products by [symbol attribut ### PHP ``` php -setFilter(new SymbolAttribute('ean', ['5023920187205'])); -/** @var \Ibexa\Contracts\ProductCatalog\ProductServiceInterface $productService*/ -$results = $productService->findProducts($query); +[[= include_file(‘code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php’) =]] ``` \ No newline at end of file From c83c9a2231bf364b43039ae8b631e255f29d419c Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Mon, 14 Jul 2025 10:22:50 +0000 Subject: [PATCH 08/12] PHP & JS CS Fixes --- .../search/src/Query/SymbolAttributeTypeQuery.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php b/code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php index 2629daec53..2c449d97b8 100644 --- a/code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php +++ b/code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php @@ -1,9 +1,9 @@ -setFilter(new SymbolAttribute('ean', ['5023920187205'])); -/** @var \Ibexa\Contracts\ProductCatalog\ProductServiceInterface $productService*/ -$results = $productService->findProducts($query); \ No newline at end of file +/** @var \Ibexa\Contracts\ProductCatalog\ProductServiceInterface $productService */ +$results = $productService->findProducts($query); From a7f9a212d6558bd985bb7fb8ffcaaf323b168d38 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Tue, 15 Jul 2025 09:05:08 +0200 Subject: [PATCH 09/12] symbol_attribute_type.md moved to Attributes folder --- docs/pim/{ => attributes}/symbol_attribute_type.md | 0 mkdocs.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/pim/{ => attributes}/symbol_attribute_type.md (100%) diff --git a/docs/pim/symbol_attribute_type.md b/docs/pim/attributes/symbol_attribute_type.md similarity index 100% rename from docs/pim/symbol_attribute_type.md rename to docs/pim/attributes/symbol_attribute_type.md diff --git a/mkdocs.yml b/mkdocs.yml index 782f2e86ff..9e83b1f939 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -349,6 +349,7 @@ nav: - Products: pim/products.md - Attributes: - Date and Time attribute: pim/attributes/date_and_time.md + - Symbol attribute type: pim/attributes/symbol_attribute_type.md - Product API: pim/product_api.md - Catalogs: pim/catalogs.md - Catalog API: pim/catalog_api.md @@ -361,7 +362,6 @@ nav: - Create product code generator: pim/create_product_code_generator.md - Create custom catalog filter: pim/create_custom_catalog_filter.md - Create custom name schema: pim/create_custom_name_schema_strategy.md - - Use symbol attribute type: pim/symbol_attribute_type.md - Add remote PIM support: pim/add_remote_pim_support.md - Commerce: - Commerce: commerce/commerce.md From a139c9c4723afd08893c223f68ac1d0be034c057 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Tue, 15 Jul 2025 12:27:56 +0200 Subject: [PATCH 10/12] fixes; mysql added --- .../config/mysql/symbol_attribute.sql | 2 ++ .../config/postgresql/symbol_attribute.sql | 3 +++ docs/ibexa_products/editions.md | 1 + docs/pim/attributes/symbol_attribute_type.md | 16 +++++++++++----- .../symbolattribute_criterion.md | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 code_samples/symbol_attribute/config/mysql/symbol_attribute.sql create mode 100644 code_samples/symbol_attribute/config/postgresql/symbol_attribute.sql diff --git a/code_samples/symbol_attribute/config/mysql/symbol_attribute.sql b/code_samples/symbol_attribute/config/mysql/symbol_attribute.sql new file mode 100644 index 0000000000..5157c20e37 --- /dev/null +++ b/code_samples/symbol_attribute/config/mysql/symbol_attribute.sql @@ -0,0 +1,2 @@ +CREATE TABLE ibexa_product_specification_attribute_symbol (id INT NOT NULL, value VARCHAR(160) DEFAULT NULL, INDEX ibexa_product_specification_attribute_symbol_value_idx (value), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_520_ci` ENGINE = InnoDB; +ALTER TABLE ibexa_product_specification_attribute_symbol ADD CONSTRAINT ibexa_product_specification_attribute_symbol_fk FOREIGN KEY (id) REFERENCES ibexa_product_specification_attribute (id) ON UPDATE CASCADE ON DELETE CASCADE \ No newline at end of file diff --git a/code_samples/symbol_attribute/config/postgresql/symbol_attribute.sql b/code_samples/symbol_attribute/config/postgresql/symbol_attribute.sql new file mode 100644 index 0000000000..4ad6b65bef --- /dev/null +++ b/code_samples/symbol_attribute/config/postgresql/symbol_attribute.sql @@ -0,0 +1,3 @@ +CREATE TABLE ibexa_product_specification_attribute_symbol (id INT NOT NULL, value VARCHAR(160) DEFAULT NULL, PRIMARY KEY(id)); +CREATE INDEX ibexa_product_specification_attribute_symbol_value_idx ON ibexa_product_specification_attribute_symbol (value); +ALTER TABLE ibexa_product_specification_attribute_symbol ADD CONSTRAINT ibexa_product_specification_attribute_symbol_fk FOREIGN KEY (id) REFERENCES ibexa_product_specification_attribute (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE; \ No newline at end of file diff --git a/docs/ibexa_products/editions.md b/docs/ibexa_products/editions.md index 02b083b3ca..6accca22ad 100644 --- a/docs/ibexa_products/editions.md +++ b/docs/ibexa_products/editions.md @@ -65,3 +65,4 @@ The features brought by LTS Updates become standard parts of the next LTS releas | [AI Actions](ai_actions_guide.md) | ✔ | ✔ | ✔ | | [Date and time attribute type](date_and_time.md) | ✔ | ✔ | ✔ | | [Discounts](discounts.md) | | | ✔ | +| [Symbol attribute type](symbol_attribute_type.md) | ✔ | ✔ | ✔ | \ No newline at end of file diff --git a/docs/pim/attributes/symbol_attribute_type.md b/docs/pim/attributes/symbol_attribute_type.md index 512c77b51f..edc0e568d4 100644 --- a/docs/pim/attributes/symbol_attribute_type.md +++ b/docs/pim/attributes/symbol_attribute_type.md @@ -39,11 +39,17 @@ return [ To store symbol attribute values, the `IbexaProductCatalogSymbolAttributeBundle` needs an extra table. The following SQL query can be used to build the required database structure: -``` sql -CREATE TABLE ibexa_product_specification_attribute_symbol (id INT NOT NULL, value VARCHAR(160) DEFAULT NULL, PRIMARY KEY(id)); -CREATE INDEX ibexa_product_specification_attribute_symbol_value_idx ON ibexa_product_specification_attribute_symbol (value); -ALTER TABLE ibexa_product_specification_attribute_symbol ADD CONSTRAINT ibexa_product_specification_attribute_symbol_fk FOREIGN KEY (id) REFERENCES ibexa_product_specification_attribute (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE; -``` +=== "MySQL" + + ``` sql + [[= include_file('code_samples/symbol_attribute/config/mysql/symbol_attribute.sql') =]] + ``` + +=== "PostgreSQL" + + ``` sql + [[= include_file('code_samples/symbol_attribute/config/postgresql/symbol_attribute.sql') =]] + ``` ### Create symbol attribute definition (optional) diff --git a/docs/search/criteria_reference/symbolattribute_criterion.md b/docs/search/criteria_reference/symbolattribute_criterion.md index f14d2694f0..53c6a241cd 100644 --- a/docs/search/criteria_reference/symbolattribute_criterion.md +++ b/docs/search/criteria_reference/symbolattribute_criterion.md @@ -17,5 +17,5 @@ The `SymbolAttribute` Search Criterion searches for products by [symbol attribut ### PHP ``` php -[[= include_file(‘code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php’) =]] +[[= include_file('code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php') =]] ``` \ No newline at end of file From eb06677139560e14043a2ae957cd9fb9b3ec4216 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Wed, 16 Jul 2025 10:10:01 +0200 Subject: [PATCH 11/12] fix in the table --- docs/pim/attributes/symbol_attribute_type.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pim/attributes/symbol_attribute_type.md b/docs/pim/attributes/symbol_attribute_type.md index edc0e568d4..726385a247 100644 --- a/docs/pim/attributes/symbol_attribute_type.md +++ b/docs/pim/attributes/symbol_attribute_type.md @@ -42,7 +42,7 @@ The following SQL query can be used to build the required database structure: === "MySQL" ``` sql - [[= include_file('code_samples/symbol_attribute/config/mysql/symbol_attribute.sql') =]] + [[= include_file('code_samples/symbol_attribute/config/mysql/symbol_attribute.sql', glue=' ') =]] ``` === "PostgreSQL" From 21154815edbdd330a9cb407e3ff02d6823ae49da Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Wed, 16 Jul 2025 11:40:15 +0200 Subject: [PATCH 12/12] fix --- docs/pim/attributes/symbol_attribute_type.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pim/attributes/symbol_attribute_type.md b/docs/pim/attributes/symbol_attribute_type.md index 726385a247..a72b04f5dd 100644 --- a/docs/pim/attributes/symbol_attribute_type.md +++ b/docs/pim/attributes/symbol_attribute_type.md @@ -48,7 +48,7 @@ The following SQL query can be used to build the required database structure: === "PostgreSQL" ``` sql - [[= include_file('code_samples/symbol_attribute/config/postgresql/symbol_attribute.sql') =]] + [[= include_file('code_samples/symbol_attribute/config/postgresql/symbol_attribute.sql', glue=' ') =]] ``` ### Create symbol attribute definition (optional)