Page 1 of 1

Problem with CSV in pro module for inventory

Posted: Sun Sep 10, 2023 8:11 am
by 14Steve14
Version 1.0.8.20
PHP version 1.8.21

I have added a few new columns into the admin/stats_inventory.php file to include some of the other data stored in the database after adding other Pro modules such as Cost Price and MSRP. On the admin backend when opening the file it shows correctly with all the new headings and columns showing all the correct information, so working as it should.

The problem comes when clicking on the Create CSV button. For some reason the csv that is created does not include all the new column and I cannot figure out why. I have cleared the server cache, computer cache and cannot see anything in the page code that should make it only show the original columns.

Can someone test this just to see whether its me or a problem with the code, or maybe I am just plain missing something somewhere.

Re: Problem with CSV in pro module for inventory

Posted: Sun Sep 10, 2023 8:23 pm
by burt

Code: Select all

// array of SOME of the data to be injected into spreadsheet
// you can add more data in here if you like.  If you do then make sure that you also add a heading (see L34 of this file) in the correct place - the new heading can be hardcoded rather than a TABLE_HEADING_XYZ.
Did you add in your column data here?

Re: Problem with CSV in pro module for inventory

Posted: Mon Sep 11, 2023 7:29 am
by 14Steve14
burt wrote: Sun Sep 10, 2023 8:23 pm

Code: Select all

// array of SOME of the data to be injected into spreadsheet
// you can add more data in here if you like.  If you do then make sure that you also add a heading (see L34 of this file) in the correct place - the new heading can be hardcoded rather than a TABLE_HEADING_XYZ.
Did you add in your column data here?
Gary @burt

The initial bit of code you have above which is commented out is actually missing from the file, but I did add all the new entries needed in a block as it all shows on the page, but not when creating the CSV.

In the latest version 1.0.8.20 there is only one block of code, where as in the earlier version 1.0.7.11 I use there are two blocks of code, one for the page and one for the CSV I assume. I take it something has been updated.

Re: Problem with CSV in pro module for inventory

Posted: Mon Sep 11, 2023 8:13 am
by burt
Looks like it moved to the action file;

admin/includes/actions/stats_inventory/csv.php

Similar idea though.

Re: Problem with CSV in pro module for inventory

Posted: Mon Sep 11, 2023 9:08 am
by 14Steve14
Cheers @burt Gary

never thought of looking there. Thought it would all be in the same file for some reason or maybe some note in the original file that a bit has been moved.

I will have a play with that file now and make a note somewhere about the change.

Re: Problem with CSV in pro module for inventory

Posted: Mon Sep 11, 2023 10:02 am
by ecartz
14Steve14 wrote: Mon Sep 11, 2023 9:08 am some note in the original file that a bit has been moved.
This pattern is common in admin files now. Look for

Code: Select all

  require 'includes/segments/process_action.php';
to see if it is present. Or just look in admin/includes/actions/[page-name]/

The point of this is to allow add-ons to add new actions without having to modify code. They can just drop a new file for the new action rather than ask you to modify the existing file.