Since Magento 2.1, Cart has a
@deprecated tag. Nevertheless, it is still used by Magento itself to store products when shopping. Is the deprecation intended, and if so, and what should we use instead?
My guess is that the Magento team is planning to implement service contracts for this class.
However as of 2.1 if you check the
app/code/Magento/Checkout/Api folder there's no class (yet) that implements such service contract.
I assume it'll happen at some point and the Magento team flagged that model to be deprecated in the future. However as I said and as you said, it is still used in the software so you can still keep using it for now.
I reckon this
@deprecated tag is a similar flag as the one for the
load() method from
Same goes for the XML
<action> tag which is deprecated but still is the only option in some cases: http://goo.gl/laVP35 and is still widely used in 2.1: https://github.com/magento/magento2/search?l=xml&q=action&utf8=%E2%9C%93
The commit that deprecated the cart model is c4e9a77403655646a18d4277de96429c86bd34fa with the message
MAGETWO-51558: Mark Checkout Cart model as deprecated
This doesn't tell much, especially since this is the only commit that references the internal ticket number "MAGETWO-51558"
\Magento\Checkout\Api still does not contain any new service contracts and
\Magento\Quote\Api\CartItemRepositoryInterface cannot replace the cart model either, I agree with your suspicion that it has been deprecated too early.
Of course, a final answer can only be given by a Magento employee.