cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help Resolving Error When Downloading Settlement Report

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:



Capture.PNG

 

This error seems to occur in the ConvertToCsv.php file. Since I’m new to Magento, I’m not sure how to resolve this. Could someone guide me on what might be causing this issue and how I can fix it?
 



6 REPLIES 6

Re: Need Help Resolving Error When Downloading Settlement Report

Hello @hafizawani8a0d,

 

Image is not visible, please share in any tool with URL.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Need Help Resolving Error When Downloading Settlement Report

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.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

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

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.

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

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.