I added a new column to quote item(lets call custom_type). So I extended \Magento\Quote\Model\Cart\Totals\Item
to implement getters and setters for my column.
public function getCustomType()
{
return $this->_get('custom_type');
}
public function setCustomType($type)
{
return $this->setData('custom_type', $type);
}
It is sufficient to get/set my new column values. It works when we get the column values. But if I try to get the value in checkout review page(#payments), the value is not returned because Magento uses REST to get the item information(missing interface signatures).
So the problem arises here. I need to add interface for these two methods in \Magento\Quote\Api\Data\TotalsItemInterface
to get the values using REST. I am creating a separate module, so I can't touch the core code.
How do I achieve this? Any suggestions.
Best Answer
Finally, answering my own question. We have to use extensions attributes to achieve this. We have to access our custom attribute through extension attributes which is available in the respective interfaces. Hope it guides someone.