Support » Plugin: Advanced Woo Search » auto reindex or with cron?

  • Resolved David

    (@dsolsona)


    Hi,
    is there any way to auto reindex or with cron periodicaly? for exemple every hour.

    Thank’s and great plugin!
    David

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Yes, it is possible. You just need to call ‘aws_reindex_table’ action.
    Its can be done with this code:

    do_action('aws_reindex_table');

    If you want to add this action as cron job you can do something like

    add_action( 'wp', 'aws_set_cron' );
    
    function aws_set_cron() {
        if ( ! wp_next_scheduled ( 'aws_reindex_table' ) ) {
            wp_schedule_event(time(), 'hourly', 'aws_reindex_table');
        }
    } 

    This code will run re-index cron job every hour.

    Thread Starter David

    (@dsolsona)

    Thank you Illid! 🙂

    One question. Is necessary reindex manually AWS every time I import products or AWS reindex itseft?

    DAvid

    Plugin Author ILLID

    (@mihail-barinov)

    AWS plugin must re-index all imported content automatically.
    But its depends on way that you import this products.

    Thread Starter David

    (@dsolsona)

    I import with WP All import (www.wpallimport.com)

    DAvid

    Plugin Author ILLID

    (@mihail-barinov)

    Well its must work with this plugin.

    Thread Starter David

    (@dsolsona)

    Thank’s Illid!

    best regards,
    David

    Hello,
    I tried creating the following script but is not working.
    Please help. The only thing I get are the following warnings:

    Notice: Undefined index: data in /var/www/vhosts/apopou.com/httpdocs/wp-content/plugins/advanced-woo-search/includes/class-aws-table.php on line 57

    Notice: Undefined index: offset in /var/www/vhosts/apopou.com/httpdocs/wp-content/plugins/advanced-woo-search/includes/class-aws-table.php on line 93

    Notice: Undefined index: offset in /var/www/vhosts/apopou.com/httpdocs/wp-content/plugins/advanced-woo-search/includes/class-aws-table.php on line 116

    Notice: Undefined index: found_posts in /var/www/vhosts/apopou.com/httpdocs/wp-content/plugins/advanced-woo-search/includes/class-aws-table.php on line 118

    Notice: Undefined index: found_posts in /var/www/vhosts/apopou.com/httpdocs/wp-content/plugins/advanced-woo-search/includes/class-aws-table.php on line 119

    My code:

    <?php
    require_once(dirname(__FILE__) . ‘/../../wp-load.php’);
    require_once(dirname(__FILE__) . ‘/../../wp-includes/plugin.php’);
    ini_set(‘memory_limit’, ‘-1’);

    ini_set(‘display_errors’, 1);
    ini_set(‘display_startup_errors’, 1);
    error_reporting(E_ALL);

    do_action(‘aws_reindex_table’);

    Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Thanks for letting me know about this problem.

    It is the bug that exists during last few plugin versions.
    Before I release new update you can quickly fix it by yourself.

    Please open includes/class-aws-table.php, find line

    $index_meta = $_POST['data'];

    and replace with

    $index_meta = $return ? $return : $_POST['data'];

    Also find

    public function reindex_table_job() {
    
        do {
            $meta = $this->reindex_table( true );
            $offset = (int) isset( $meta['offset'] ) ? $meta['offset'] : 0;
            $start = (int) isset( $meta['start'] ) ? $meta['start'] : 0;
        } while ( !( $offset === 0 && ! $start ) );
    
    }

    and replace with

    public function reindex_table_job() {
    
        $meta = 'start';
    
        do {
            $meta = $this->reindex_table( $meta);
            $offset = (int) isset( $meta['offset'] ) ? $meta['offset'] : 0;
            $start = (int) isset( $meta['start'] ) ? $meta['start'] : 0;
        } while ( !( $offset === 0 && ! $start ) );
    
    }

    After this changes all must work fine.

    • This reply was modified 5 years, 12 months ago by ILLID.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘auto reindex or with cron?’ is closed to new replies.