Skip to content

Exception FacetId, Code field table sylius_product_option #282

@arjan-coolminds

Description

@arjan-coolminds

We seem to have a little issue in bitbag/elasticsearch-plugin 5.2.1.

bitbag/elasticsearch-plugin 5.2.1
sylius/sylius 2.0.10
sylius/b2b-kit 2.1.2

It so happens that end-users put numbers in the code field at the product options in the Admin panel and I was under the impression that within the Sylius Realm, every code field should always be interpretated as a string as a consequence of the translations model.

But the elasticsearch plugin will raise an exception as it expects a string if clicking on a product in the shop.

Can I enforce string-only codes for product options, or is it perhaps a parameter or is this a bug?

Trace sample;

request.CRITICAL: Uncaught PHP Exception TypeError: "BitBag\SyliusElasticsearchPlugin\Facet\Registry::addFacet(): Argument #1 ($facetId) must be of type string, int given, called in /var/www/html/vendor/bitbag/elasticsearch-plugin/src/Facet/AutoDiscoverRegistry.php on line 50" at Registry.php line 20 {"exception":"[object] (TypeError(code: 0): BitBag\SyliusElasticsearchPlugin\Facet\Registry::addFacet(): Argument #1 ($facetId) must be of type string, int given, called in /var/www/html/vendor/bitbag/elasticsearch-plugin/src/Facet/AutoDiscoverRegistry.php on line 50 at /var/www/html/vendor/bitbag/elasticsearch-plugin/src/Facet/Registry.php:20)"} []

Considered table:
(row with id 2 will raise the exception.)

select * from sylius_product_option\G
*************************** 1. row ***************************
id: 1
code: abcdef
position: 0
created_at: 2025-07-01 12:46:02
updated_at: 2025-07-01 12:46:02
*************************** 2. row ***************************
id: 2
code: 1234
position: 1
created_at: 2025-07-01 14:19:26
updated_at: 2025-07-01 14:19:26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions