GithubHelp home page GithubHelp logo

Comments (3)

vienthuong avatar vienthuong commented on September 6, 2024

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 :)

from shopware-php-sdk.

larsbo avatar larsbo commented on September 6, 2024

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.

from shopware-php-sdk.

larsbo avatar larsbo commented on September 6, 2024

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

from shopware-php-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.