akeneo / api-php-client

PHP client of Akeneo PIM API

Home Page:https://packagist.org/packages/akeneo/api-php-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api-php-client calls undefined function in pim

gernhard1337 opened this issue · comments

Hello,

i use Akeneo Pim 5.0 with Api Client 6.0
With the following Code (taken from tutorial)

$client->getCategoryApi()->upsert('winter_collection', [ 'parent' => 'master', 'labels' => [ 'en_US' => 'Winter Collection', 'fr_FR' => 'Collection Hiver', ] ]);

i get always an error. However as far as it seems it is not my fault. This shows this error log:

[2022-10-18 20:45:14] php.CRITICAL: Uncaught Error: Call to undefined method Akeneo\Pim\Enrichment\Component\Category\Model\Category::getIdentifier() {"exception":"[object] (Error(code: 0): Call to undefined method Akeneo\\Pim\\Enrichment\\Component\\Category\\Model\\Category::getIdentifier() at /srv/pim/src/Elbenwald/CategoryBuilder/CategoryBuilder.php:152)"} [] [2022-10-18 20:45:14] request.CRITICAL: Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\UndefinedMethodError: "Attempted to call an undefined method named "getIdentifier" of class "Akeneo\Pim\Enrichment\Component\Category\Model\Category"." at /srv/pim/src/Elbenwald/CategoryBuilder/CategoryBuilder.php line 152 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Attempted to call an undefined method named \"getIdentifier\" of class \"Akeneo\\Pim\\Enrichment\\Component\\Category\\Model\\Category\". at /srv/pim/src/Elbenwald/CategoryBuilder/CategoryBuilder.php:152)"} [] [2022-10-18 20:45:14] doctrine.DEBUG: SELECT value FROM oro_config_value WHERE name = "language" AND section = "pim_ui" LIMIT 1 [] [] [2022-10-18 20:45:14] security.DEBUG: Invoked controller "FOS\RestBundle\Controller\TwigExceptionController::showAction". (SUB_REQUEST) [] [] [2022-10-18 20:45:15] request.CRITICAL: Uncaught PHP Exception Akeneo\Pim\ApiClient\Exception\ServerErrorHttpException: "Internal Server Error (see https://api.akeneo.com/php-client/exception.html#server-exception)" at /srv/pim/vendor/akeneo/api-php-client/src/Client/HttpExceptionHandler.php line 66 {"exception":"[object] (Akeneo\\Pim\\ApiClient\\Exception\\ServerErrorHttpException(code: 500): Internal Server Error (see https://api.akeneo.com/php-client/exception.html#server-exception) at /srv/pim/vendor/akeneo/api-php-client/src/Client/HttpExceptionHandler.php:66)"} [] [2022-10-18 20:45:15] security.DEBUG: Invoked controller "FOS\RestBundle\Controller\TwigExceptionController::showAction". (SUB_REQUEST) [] []

the function getIdentifier(); is not defined. How could this get resolved?
This failure also triggers only after execution. The category is upserted in Akeneo and only afterwards the Exception is thrown.

i am so sorry. Please delete this Issue. This problem was based on me and not the Client.

Hi @gernhard1337
Do you mind sharing what the problem was?

I have a Event Listener and tried to retrieve a product by its sku, given by an event. This event is on.post_save and i thought this event triggers only on product save but it triggers every time when something is saved. So it works for product save but if i save a category there i get the problem because the category -save-event has no identifier.