API retrieve the subproducts of a kit/virtual-product

Hello,

We need to retrieve the subproducts of a kit/virtual-product. The API documentation indicates this path: /products/{id}/subproducts

It returns the following response:

[
false,
false,
false
]

I assume it’s a bug, I would expect a list of objects or at least IDs.

Has anyone else encountered this problem?

We are running the docker container tuxgasy/dolibarr:latest

Thanks

Hello,

We found the origin of the bug.

In the file “product/class/api_products.class.php” on the line 465, the variable $keys has only 5 values, whereas the function product->getChildsArbo returns 6 values. Therefore when we apply the function “array_combine” it returns false as there are more values than keys to match them with.

Adding an additional key in “$keys” does fix the problem.

However that is not an acceptable fix for us. Any update of Dolibarr and this fix would be overridden. How can we ask the module’s developer to fix this bug?

Hello,

For bug FIX everthing should be done on GITHUB

There is a bug declaration : Subproducts not returned by module API REST · Issue #19373 · Dolibarr/dolibarr · GitHub
The FIX, that has been pushed on V13 in october : Fix #19070 : Api subproducts was returning false by atm-maxime · Pull Request #19126 · Dolibarr/dolibarr · GitHub

It is also included in V14.0.4

Thanks, we’ll try with the version 14.0.4 :+1:

1 Like