- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Need Help Resolving Error When Downloading Settlement Report
Hi everyone,
I'm a beginner in Magento, and I've been tasked by my boss to resolve an issue we're facing when trying to download a settlement report. The error message we’re getting is:
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Need Help Resolving Error When Downloading Settlement Report
Hello @hafizawani8a0d,
Image is not visible, please share in any tool with URL.
![Smiley Happy Smiley Happy](/i/smilies/16x16_smiley-happy.png)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Need Help Resolving Error When Downloading Settlement Report
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Need Help Resolving Error When Downloading Settlement Report
Hi @hafizawani8a0d,
Issue is coming from Fbl module, either it is custom or 3rd party.
You may need to debug in the codebase.
![Smiley Happy Smiley Happy](/i/smilies/16x16_smiley-happy.png)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Need Help Resolving Error When Downloading Settlement Report
Could you please guide me how to debug or changes the code or where i can resolve this issue. I am beginner in magento 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Need Help Resolving Error When Downloading Settlement Report
Hello,
There's an Error on getItemId( ) null on line no 174 in given Fbl/AdvanceReports module file. looks like object is null or not have an getItemId( ) method where try to get so please comment out line or add condition on it and check.
200+ Magento 2 Extensions for Enhanced Shopping Experience.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Need Help Resolving Error When Downloading Settlement Report
Hello @hafizawani8a0d,
The error "Call to a member function getItemId() on null", suggests that the getItemId() function is being called on a variable or object that is null. This usually happens when the system expects a value but doesn't get one, potentially due to a missing or incorrect data load.
The error points to line 174 of /var/www/html/magento2/app/code/Fbl/AdvanceReports/Model/Export/ConvertToCsv.php.
Review this line to see which object is calling the getItemId() function. It's likely that the object being referenced is not properly instantiated or loaded.
Ensure that the item (which is likely a product, order, or other entity) is being properly loaded before the getItemId() function is called. Make sure that $item or the object in question is not null before you call getItemId().
If you're uncertain whether the object is being loaded, add a null check around the getItemId() call.
The issue could stem from the fact that the data (likely a grid collection) is not being passed correctly from the controller to the ConvertToCsv.php model. Check how the data is being fetched from the database or other sources. Ensure that the grid data is not empty when performing the export.
Check the export logic in getCsvFile(). If this function processes a collection or an array of items, make sure that the items are being fetched properly. Look for any faulty logic or incorrect filtering that might result in empty or missing items during the export.
Enable Magento Logs for Debugging:
- Enable logging in Magento to capture more detailed information about the request. You can add a log just before the failing line:
$this->logger->debug('Exporting CSV, Item: ' . var_export($item, true));
after put this log you can check thee log entry in var/log/debug.log
make sure your website is in develeoper mode.
Clear Cache: If you made changes, clear Magento's cache to ensure your changes take effect:
php bin/magento cache:clean php bin/magento cache:flush
Check Permissions: Make sure that all necessary files have the correct permissions, especially if any changes were recently made.
By following these instructions, you should be able to diagnose the problem and prevent the null object issue during the export process.
If the issue will be resolved, Click Kudos & Accept as a Solution.