Magento 2 Rest API of cart totals doesn't provide SKU
, Which is necessary for any operation like extension_attributes
/rest/V1/carts/mine/totals
The return array of Items is
array (size=21)
'item_id' => string '139' (length=3)
'name' => string '40Cm Width Protective Packaging Pe Air Bubble Roll Film Wrap' (length=60)
'qty' => int 2
'price' => string '0.0000' (length=6)
'base_price' => string '0.0000' (length=6)
'discount_percent' => string '0.0000' (length=6)
'discount_amount' => string '0.0000' (length=6)
'base_discount_amount' => string '0.0000' (length=6)
'tax_percent' => string '0.0000' (length=6)
'tax_amount' => string '0.0000' (length=6)
'base_tax_amount' => string '0.0000' (length=6)
'row_total' => string '0.0000' (length=6)
'base_row_total' => string '0.0000' (length=6)
'row_total_with_discount' => string '0.0000' (length=6)
'price_incl_tax' => null
'base_price_incl_tax' => null
'row_total_incl_tax' => null
'base_row_total_incl_tax' => null
'weee_tax_applied' => null
'weee_tax_applied_amount' => null
'options' => string '[]' (length=2)
I want to add extension attribute of Image but I need SKU for that, But in this return data Magento doesn't provide SKU.
File is used for API
/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php
Function is used for API
public function get($cartId)
Any one have Fixed the above issue, Or Reported the issue in git ?
How to get SKU in
/rest/V1/carts/mine/totals
response API
Best Answer
Extension attribute is the simplest way to achieve this.
extension_attributes.xml
di.xml
TotalRepositoryPlugin.php
I hope it will work. Let me know if I can help you further :)