scheduled import

Pending

Import WP Pro Updated 3 weeks ago 10 Replies

Heather asked 3 weeks ago on May 19, 2026 at 6:19 pm

When I select the scheduled import and click the “get latest file” it does not actually get the latest file.

it uses the one that is cached – when I run the regular import when it is checked as well it does not get the latest stuff — I have a webhook that calls some of your extra code to fix it when I am forcing it to run on my own – but it would be nice to use your scheduler and not have to call my own code to ensure the file is overwritten – I have this code that I use to make sure the import gets the new stuff 

// ── Trigger Import WP via Container ──────────────────────────────────────────
try {

    if ( ! class_exists( ‘ImportWP\Container’ ) ) {
        throw new Exception( ‘ImportWP\Container class not found — is the plugin active?’ );
    }

    $container        = \ImportWP\Container::getInstance();
    $importer_manager = $container->get( ‘importer_manager’ );

    if ( ! $importer_manager ) {
        throw new Exception( ‘importer_manager service not found in container’ );
    }

    // Set the current user to the one configured on the importer
    $importer_manager->set_current_user( $importer_id );

    // ── Force Import WP to re-fetch our CSV before running ───────────────
    // Import WP has two hooks we use here:
    //
    //   iwp/importer/run_fetch_file   — forces a file fetch at import start
    //   iwp/importer/datasource/local — overrides the local source path
    //
    // Together these tell Import WP to always grab our freshly deployed CSV
    // regardless of what datasource is configured on the importer settings.

    add_filter( ‘iwp/importer/run_fetch_file’, function() {
        return true;
    } );

    add_filter( ‘iwp/importer/datasource/local’, function( $source, $raw_source, $importer_data ) use ( $csv_path ) {
        error_log( ‘[PivotDoor Webhook] Overriding datasource path to: ‘ . $csv_path );
        return $csv_path;
    }, 10, 3 );

    // Also handle remote datasource type in case the importer is set to remote
    add_filter( ‘iwp/importer/datasource/remote’, function( $source, $raw_source, $importer_data ) use ( $csv_path ) {
        error_log( ‘[PivotDoor Webhook] Overriding remote datasource path to: ‘ . $csv_path );
        return $csv_path;
    }, 10, 3 );

    // ── Clear stale session state before running ─────────────────────────
    // Import WP stores session state in a WordPress option. If a previous
    // session ID is still stored there, import() will throw “Session has
    // changed” and return the cached result instead of starting fresh.
    // Deleting the option forces import() to initialise a new clean session.
    $state_option = ‘iwp_importer_state_’ . $importer_id;
    delete_option( $state_option );
    error_log( ‘[PivotDoor Webhook] Cleared stale session state for importer #’ . $importer_id );

    // Run the import
    $result = $importer_manager->import( $importer_id, get_current_user_id() );

    $status = isset( $result[‘status’] ) ? $result[‘status’] : ‘unknown’;
 
 
Thanks
Heather

 

J

James replied Support Agent

3 weeks ago on May 19, 2026 at 7:57 pm

Hi Heather, 

To help figure out your issue, can you go to Settings / Tools >General Settings and Enable Debug Mode.

Then go back to the importer and schedule, and wait for the importer to run.

Once it has ran, at the bottom right of the importer there should be a "<> Show Debug" button that has an "Import Logs" section, this should give me more information about what the importer is doing.

James

HD

Heather replied privately

3 weeks ago on May 20, 2026 at 2:58 pm

J

James replied Support Agent

3 weeks ago on May 20, 2026 at 3:02 pm

Hi, 

In the logs the importer says its

Copied file: /nas/content/live/pivotdoor/wp-content/uploads/importwp/uploads/54817-51-K2aarQJJ5iLF-import.csv -type=csv -mime=text/csv -memory=38.68 MB

Is that the file you want the importer to import, from its name it seems that it is referencing a prevously uploaded file, what settings do you have in the select a file / datasource tab?

Can you please export and attach your importer settings to this ticket by going to Tools > Import WP > Settings / Tools > Import / Export and select and export your importer as a JSON file.

James

 

HD

Heather replied privately

3 weeks ago on May 20, 2026 at 3:12 pm

J

James replied Support Agent

3 weeks ago on May 20, 2026 at 3:15 pm

Thanks for confirming.

So the importer is copying the file into the uploads directorym Based on the previous mentioned line in the log:

Copied file: /nas/content/live/pivotdoor/wp-content/uploads/importwp/uploads/54817-51-K2aarQJJ5iLF-import.csv -type=csv -mime=text/csv -memory=38.68 MB

Can you disable your custom code, and enable the scheduler.

Once the scheduler runs, check the logs for same line (but will have a different path), then view that file and compare it to the file that you are importing to make sure the contents are the same.

James

 

HD

Heather replied privately

3 weeks ago on May 20, 2026 at 3:18 pm

HD

Heather replied privately

3 weeks ago on May 20, 2026 at 3:19 pm

J

James replied Support Agent

3 weeks ago on May 20, 2026 at 3:21 pm

Based on that log it is copying the file from 

/nas/content/live/pivotdoor/wp-content/uploads/troubleshooting-csv/import.csv

To your uploads directory.

/nas/content/live/pivotdoor/wp-content/uploads/importwp/uploads/54817-51-K2aarQJJ5iLF-import.csv

can you confirm those files match what you expect, if not can you re-schedule the import and once its ran, attach the /nas/content/live/pivotdoor/wp-content/uploads/troubleshooting-csv/import.csv and the file that is mentioned in its latest log at the time

 

 

HD

Heather replied privately

3 weeks ago on May 20, 2026 at 4:43 pm

HD

Heather replied privately

3 weeks ago on May 20, 2026 at 4:45 pm