-
Notifications
You must be signed in to change notification settings - Fork 9.4k
\Magento\Quote\Api\CartItemRepositoryInterface::save method doesn't save passed cartItem #5914
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
Comments
I think with extension attributes you need to supply the code yourself to save, store and otherwise process the value. For example take a look at and then this plugin: |
Yes, I know about this. All other extended attributes (custom extended attributes) will be lost and there is not ability to save them. The BuyRequest data is built by CartItemOptionsProcessor. There are hardcoded custom_options processor for all prodcuts and special processors for each type of products (except simple product). There is no ability to specify custom processor. As solution I used plugin for \Magento\Quote\Model\Quote\Item\CartItemOptionsProcessor and there I process my extended attribute. However I don't think it's a good solution, sure there should be more elegant solution. |
Hi Yuriy!
For me this request returned "amazingValue" as expected. |
To process the value of extension attribute you need to create plugins to \Magento\Quote\Model\Quote\Item\Repository getList() and save() methods. |
Hi thank you for response, However, the save method of cart item repository returns saved item and the item doesn't have any extended attributes. |
It looks like the plugin is needed not only for saving extended attributes to DB but even for transferring them from passed quote item to returned quote item. |
If it's okay then I'm okay with closing the issue. |
$this->cartItemRepository->save() returns another object and some properties will be absent there. |
[TSG-CSL3] For 2.4 (pr36)
Preconditions
Magento 2.1
Steps to reproduce
Expected result
Actual result
Moreover, if you load existing cartItem, assign an extension_attribute to the cartItem and pass it to the \Magento\Quote\Api\CartItemRepositoryInterface::save method then cartItem will not be updated. Only BuyRequest will be taken from the passed cartItem for updating of exiting cartItem.
Simular problem with product_option of cart item. It's possible to create extension_attributes for product option (or use custom_options) but it is impossible to add your own logic as CartItemProcessor.
The text was updated successfully, but these errors were encountered: