magento / magento/community-features

Extending quote item with extension attributes - problem with load/save of attributes

Open
#152 2 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

API devguild Priority: P2
Dominant language
No language data
Stars
46
Forks
14
PR merge metrics
No merged PRs in 30d

Description

### Summary (*)

Recently, I was trying to extend quote item with extension attributes. I needed it inside cart and checkout. So there are actually two ways for loading and persisting extension attributes along extended model.

* First is creating plugins on repository of entity which has these new attributes.
For `CartItemRepository` this maybe would work for webapi - inside cart, checkout quote items are loaded in other ways - sometimes from `qoute` - by items collection, sometimes by directly loading model. It turns out that `CartItemRepository` is not very useful in frontend. Here comes also other grave problem - service contracts vs ,methods loading/returing/requiring concret implementations - many cases for `quote` and `quote item`.
* Second way is adding handles to `ExtensionPool`, but it requires resource model using `EntityManager`, which is is not recommended . Despite of this for qoute item it is imposible, beacause, crud operations are performed in 'old-fashioned' way.

Finally, to perform crud operations on cart and checkout, with main logic in subtotals I ended up with plugins for three classes and override 5 methods - `quote items` are not loaded in any consistent way.

### Examples (*)

Hard to provide - generally module doesn't seem to follow general guidelines from Magento.

### Proposed solution

Clean up crud operations for `quote` and `quote item`, so service contract are used more widely on frontend, so we are not relying on implementations, but on contracts.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing CartItemRepository, ExtensionPool, and the quote and quote-item loading and persistence paths mentioned in the issue. Define the scope of consistent contract-based CRUD and verify that extension attributes load and save across cart and checkout flows without relying on concrete implementations.

Written by the indexing model from the issue text.

Assessment

Domain
api, backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.