Skip to content

CSV export only exports first page of records even when all are selected #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
katechap opened this issue Apr 14, 2022 · 7 comments
Open

Comments

@katechap
Copy link

I've used CSV export in other omeka sites over the past couple of years to successfully to export all items from a site into CSV, but in a recent install (Omeka Classic 3.0.2, CSV Exporter 1.1.2) it only exports the first page of records even though it says all 17,000 are selected. Is there a limit to the number of records that can be exported? I've tried it in Safari and Chrome with the same results.

@dicksonlaw583
Copy link
Collaborator

By default, there is a limit of 1 page built into Omeka for export formats due to potential issues for timeout on Omeka setups with many items. See this related ticket: #7

If you wish to temporarily lift this limit for this plugin, you can try to apply the workaround from one of the replies on that ticket. Open CsvExportPlugin.php, and add items_browse_per_page to the filters array like this:

    protected $_filters = array(
        'response_contexts',
        'action_contexts',
        'items_browse_per_page',
    );

And this method to the main CsvExportPlugin class:

    public function filterItemsBrowsePerPage($perPage, $args) {
        if(isset($_GET['output']) && $_GET['output'] == 'csv') {
            $perPage = null;
        }
        return $perPage;
    }    

I cannot guarantee the functionality of this, however, as the request may time out before the output could be fully generated.

@jovi-juan
Copy link

FWIW I made these changes and successfully exported 18,900 items. You might need to adjust the memory limits in the .ini files

1 similar comment
@jovi-juan
Copy link

FWIW I made these changes and successfully exported 18,900 items. You might need to adjust the memory limits in the .ini files

@andrisi
Copy link

andrisi commented Aug 22, 2022

Another temporary fix, without hacking into the source code is to set the nomber of items displayed per page for the site to a high number. For me 3000 worked just fine.

@WebMarketingMatters
Copy link

Hi guys,

Just after a little help, if I may?

We've installed the CSVEsport Plugin and followed the steps above to add the items_browse_per_page line within CsvExportPlugin.php and the method to the main CsvExportPlugin, however, we received a 500 error upon viewing the site.

Can I please confirm where part 2 (method to the main CsvExportPlugin) should be added? @dicksonlaw583

I also saw the note fro, @andrisi RE the fix by changing the pagination number within the CMS. How and where is this achieved? We have around 600 items to export.

Failing this, what do you suggest we adjust the memory limits to in the .ini files? @jovi-juan

Thanks

@dicksonlaw583
Copy link
Collaborator

dicksonlaw583 commented Oct 17, 2022

Part 2 should be added just after the body for filterActionContexts, but before the closing brace for the class body.

<?php
class CsvExportPlugin extends Omeka_Plugin_AbstractPlugin
{
    /* ... */
    public function filterActionContexts($contexts, $args) {
        // Browse and show views for Items
        if ($args['controller'] instanceof ItemsController) {
            $contexts['browse'][] = 'csv';
            $contexts['show'][] = 'csv';
        // Show view for Collections
        } elseif ($args['controller'] instanceof CollectionsController) {
            $contexts['show'][] = 'csv';
        }
        return $contexts;
    }

    public function filterItemsBrowsePerPage($perPage, $args) {
        if(isset($_GET['output']) && $_GET['output'] == 'csv') {
            $perPage = null;
        }
        return $perPage;
    }    
}

@WebMarketingMatters
Copy link

Part 2 should be added just after the body for filterActionContexts, but before the closing brace for the class body.

<?php
class CsvExportPlugin extends Omeka_Plugin_AbstractPlugin
{
    /* ... */
    public function filterActionContexts($contexts, $args) {
        // Browse and show views for Items
        if ($args['controller'] instanceof ItemsController) {
            $contexts['browse'][] = 'csv';
            $contexts['show'][] = 'csv';
        // Show view for Collections
        } elseif ($args['controller'] instanceof CollectionsController) {
            $contexts['show'][] = 'csv';
        }
        return $contexts;
    }

    public function filterItemsBrowsePerPage($perPage, $args) {
        if(isset($_GET['output']) && $_GET['output'] == 'csv') {
            $perPage = null;
        }
        return $perPage;
    }    
}

Thanks @dicksonlaw583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants