Actually i created custom column in quote_item and trying to update the value once product added to the cart programmatically magento2 custom module using Model.
If Anyone have idea please guide me. Thanks in Advance.
Asked
Active
Viewed 1,642 times
0
Hitesh Balpande
- 1,906
- 2
- 25
- 69
-
i tried this link but not working https://magento.stackexchange.com/questions/177372/update-custom-column-data-in-quote-table-magento-2 – Hitesh Balpande Jun 10 '19 at 13:55
-
You need this for only frontend area or want for all area. – Amit Bera Jun 10 '19 at 14:18
-
@AmitBera yes i am doing it for frontend area only – Hitesh Balpande Jun 10 '19 at 14:21
1 Answers
3
I suggest you use implement extension attribute for this field at here.
See how to use Extension attribute. https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html
Make your field as an extension attribute of data interface Magento\Quote\Api\Data\CartItemInterface
Create extension_attributes.xml at app/code/{Vendor}/{Module}/etc/
<?xml version="1.0"?>
<config>
<extension_attributes for="Magento\Quote\Api\Data\CartItemInterface">
<attribute code="{YOUR_FIELD_NAME}" type="{FIELD_TYPE}">
</attribute>
</extension_attributes>
</config>
After that you to set this field value using event checkout_cart_product_add_after
Amit Bera
- 77,456
- 20
- 123
- 237