How to Get Invoice Comments List Programmatically in Magento 2? - Magento source24


Hello magento friends todays in this blog post im share with you to How to Get Invoice Comments List Programmatically in Magento 2.

To programmatically retrieve the invoice comments list in Magento 2, you can use the Magento 2 API or create a custom script. I'll explain both approaches:

➤ Using Magento 2 API:

Magento 2 provides an extensive REST API that allows you to access various data, including invoices and comments. To get the invoice comments list using the API, follow these steps:

➤ Step 1: Authenticate and obtain the access token.

➤  Step 2: Make an API call to retrieve the invoice comments.

Here's a sample code snippet in PHP using cURL to make the API call:


How to Get Invoice Comments List Programmatically in Magento 2? - Magento source24


Remember to replace 'your-magento2-site.com', 'your_access_token', and 'invoice_id' with your Magento 2 site URL, API access token, and the actual invoice ID, respectively.

 Using Custom Script:

If you prefer a custom PHP script within your Magento 2 module or extension, you can use Magento 2's built-in models to retrieve the invoice comments list. Here's an example of how to do it:


How to Get Invoice Comments List Programmatically in Magento 2? - Magento source24

➔ Make sure to place this script in the root folder of your Magento installation.

  Remember that these examples are simplified and may require additional error handling and permission checks. Also, ensure you have proper authentication and authorization mechanisms in place to protect sensitive data.



Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post