Cleanup::run( $abort = false )

Summary

No summary available.

Source

File: src/BigCommerce/Import/Processors/Cleanup.php

	public function run() {
		$status = new Status();
		$status->set_status( Status::CLEANING );

		$query = new \WP_Query();
		$tasks = $query->query( [
			'post_type'      => Queue_Task::NAME,
			'post_status'    => 'trash',
			'posts_per_page' => $this->batch,
			'fields'         => 'ids',
		] );

		foreach( $tasks as $post_id ) {
			wp_delete_post( $post_id, true );
		}

		if ( $query->found_posts > count( $tasks ) ) {
			return; // delete more in the next batch
		}

		delete_option( Listing_Fetcher::PRODUCT_LISTING_MAP );
		delete_option( Product_Data_Fetcher::FILTERED_LISTING_MAP );
		delete_option( Import_Type::IMPORT_TYPE );

		$status->set_status( Status::COMPLETED );

		$this->clean_customer_group_transients();

		wp_unschedule_hook( Cron_Runner::START_CRON );
		wp_unschedule_hook( Cron_Runner::CONTINUE_CRON );

		$status->rotate_logs(); // must rotate _after_ status set to complete

		do_action( 'bigcommerce/log', Error_Log::INFO, __( 'Import complete', 'bigcommerce' ), [] );
	}

	/**
	 * Remove customers group transient cache after sync in order to retrieve fresh groups data
	 */
	private function clean_customer_group_transients(): void {


User Contributed Notes

You must log in before being able to contribute a note or feedback.