Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this sdk work with custom entities? #50

Open
almare opened this issue Sep 14, 2022 · 4 comments
Open

Does this sdk work with custom entities? #50

almare opened this issue Sep 14, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@almare
Copy link

almare commented Sep 14, 2022

I tried to import my products which uses custom entities but without success. Then I tried to get a created product with my custom association also without success. So my question is does this sdk support custom extensions at all? I didn't find any documentation about that topic. Thanks

@vienthuong
Copy link
Owner

Hi @almare
The custom entities is not yet implemented in this SDK and I will try to implement it in the future but unfortunately I am not sure when it will be available. And can you describe more what your specific needs? code example etc?

Any help would welcome :)

@vienthuong vienthuong added enhancement New feature or request help wanted Extra attention is needed labels Sep 21, 2022
@larsbo
Copy link

larsbo commented Mar 6, 2023

Any progress with custom associations?

Use case: A shopware plugin adds a new entity and an association to an existing entity. if you wan to load the shopware entity together with the new association it not shows up in the result:

$orderRepository = RepositoryFactory::create(OrderDefinition::ENTITY_NAME);

$criteria = new Criteria();
$criteria->addAssociation('custom_entity');

$result = $orderRepository->search($criteria, $context);

The custom association should show up inside the extensions response part:

$response = $this->decodeResponse($response);

But this doesn't work because of the default Accept header here:

'Accept' => 'application/vnd.api+json',

If you change this to just application/json the response contains the extension data but the sdk cannot parse it correctly.

@larsbo
Copy link

larsbo commented Mar 8, 2023

The reason for the missing associations is that the sdk only considers the data part of the response here:

$entities = [];
foreach ($response['data'] as $entityRaw) {
$entity = $this->hydrateEntity($entityRaw['type'], $entityRaw, $response, $context);
$entities[$entity->id] = $entity;
}
/** @var EntityCollection $collection */
$collection = new $collectionClass($entities);
return $collection;

And because of the application/vnd.api+json accept header the shopware 6 api but the associations not into the data.extensions part but into a separate included response part:
Bildschirm­foto 2023-03-08 um 14 01 17

@Schrank
Copy link

Schrank commented Jun 23, 2024

Hi! Same problem here.
My impression is, that this API works the same way as Shopware internally, that means if we add the Collection, Definition and Entity then it should work. So it would be cool to have some kind of script which generates the three classes from the counterpart in shopware. Although I'm not sure wether it works that way 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants