Skip to content

Commit 990fad3

Browse files
Symbol attribute added
1 parent 4e3c8e7 commit 990fad3

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

docs/pim/symbol_attribute_type.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
description: Create a symbol attribute type that enables for the efficient representation of string-based values while enforcing their format in product specifications.
3+
---
4+
5+
# Symbol attribute type
6+
7+
In product specifications, the symbol attribute type enables the efficient representation of string-based data and enforces their format.
8+
9+
This feature allows you to store standard product identifiers (such as EAN or ISBN) in the [Product Information Management](pim_guide.md) system.
10+
11+
## Build-in symbol attribute formats
12+
13+
The built-in symbol attribute formats in `ibexa/product-catalog-symbol-attribute` are listed below:
14+
15+
| Name | Description | Example |
16+
|-----------------|-----------------|-----------------|
17+
| Generic | Accepts any string value | #FR1.2 |
18+
| Generic (alphabetic characters only) | Accepts any string value that contais only letters | ABCD |
19+
| Generic (digits only) | Accepts any string value that contais only digits | 123456 |
20+
| Generic (alphanumeric characters only) | Accepts any string value that contains only letters or digits | 2N6405G |
21+
| Generic (hexadecimal digits only) | Accepts any string value that contains only hexadecimal digits (digits or A-F characters) | DEADBEEF |
22+
| EAN-8 | European Article Number (8 characters) | 29033706 |
23+
| EAN-13 | European Article Number (13 characters) | 5023920187205 |
24+
| EAN-14 | European Article Number (14 characters) | 50239201872050 |
25+
| ISBN-10 | International Standard Book Number (10 characters) | 0-19-852663-6 |
26+
| ISBN-13 | International Standard Book Number (13 characters) | 978-1-86197-876-9 |
27+
28+
!!! caution
29+
30+
Maximum length of the symbol value is 160 characters.
31+
32+
## Create custom symbol attribute format
33+
34+
Under the `ibexa_product_catalog_symbol_attribute.formats` key, you can use configuration to create your own symbol format.
35+
36+
See the example below:
37+
38+
``` yaml
39+
ibexa_product_catalog_symbol_attribute:
40+
formats:
41+
manufacturer_part_number:
42+
name: 'Manufacturer Part Number'
43+
pattern: '/^[A-Z]{3}-\d{5}$/'
44+
examples:
45+
- 'RPI-14645'
46+
- 'MSS-24827'
47+
- 'SEE-15444'
48+
```
49+
50+
This following example specifies the format for a "Manufacturer Part Number", defined with the `manufacturer_part_number` identifier.
51+
52+
The pattern is specified using a regular expression.
53+
According to the pattern option, the attribute value:
54+
55+
- must be a string
56+
- begins with three capital letters (A-Z), followed by a hyphen ("-")
57+
- ends with five numbers (0-9), with no other characters before or after
58+
59+
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.
60+
61+
To validate checksum of symbol:
62+
63+
1\. Create a class implementing the `\Ibexa\Contracts\ProductCatalogSymbolAttribute\Value\ChecksumInterface` interface.
64+
65+
2\. Register the class as a service using the `ibexa.product_catalog.attribute.symbol.checksum` tag and specify the format identifier using the `format` attribute.
66+
67+
See below the example implementation of checksum validation using Luhn formula:
68+
69+
``` php
70+
[[= include_file('code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php') =]]
71+
```
72+
73+
Example service definition:
74+
75+
``` yaml
76+
services:
77+
App\PIM\Symbol\Format\Checksum\LuhnChecksum:
78+
tags:
79+
- name: ibexa.product_catalog.attribute.symbol.checksum
80+
format: my_format
81+
```
82+
The format attribute (`my_format`) is the identifier used under the `ibexa_product_catalog_symbol_attribute.formats` key.
83+
84+
## Search for products with given symbol attribute
85+
86+
You can use `SymbolAttribute` Search Criterion to find products by symbol attribute:
87+
88+
For more information, see [SymbolAttribute Criterion](symbolattribute_criterion.md).

0 commit comments

Comments
 (0)