Plugin Directory

Changeset 2747414


Ignore:
Timestamp:
06/24/2022 06:52:51 AM (4 years ago)
Author:
relevanz
Message:

improve product export performance

Location:
releva-nz/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • releva-nz/trunk/README.txt

    r2721057 r2747414  
    6464* improve conversion tracking
    6565* support for Wordpress 6
     66
     67= 2.1.2 =
     68* improve product export performance
  • releva-nz/trunk/includes/class-relevatracking.php

    r2721057 r2747414  
    7070
    7171        $this->plugin_name = 'relevatracking';
    72         $this->version = '2.1.1';
     72        $this->version = '2.1.2';
    7373
    7474        $this->load_dependencies();
  • releva-nz/trunk/public/class-relevatracking-public.php

    r2721057 r2747414  
    209209        $auth = isset($_GET['auth'])?$_GET['auth']:'';
    210210        $page = isset($_GET['page'])?$_GET['page']:0;
     211        $limit = isset($_GET['limit'])?$_GET['limit']:500;
    211212
    212213        if( $auth != md5( $apikey.':'.$client_id ) )
     
    215216        }
    216217
     218        $args = array(
     219            'status' => 'publish',
     220            'limit' => -1,
     221            'orderby' => 'id',
     222            'order' => 'asc'
     223        );
     224
     225        /*
    217226        $args = array(
    218227            'post_status'   => array('publish'),
     
    223232            'order' => 'asc',
    224233        );
     234        */
     235
    225236        if( $page > 0 )
    226237        {
    227             $args['posts_per_page'] = 2500;
    228             $args['paged'] = $page;
    229         }
    230 
    231         $the_query = new WP_Query( $args );
     238            $args['limit'] = $limit;
     239            $args['page'] = $page;
     240        }
     241
     242        $products = wc_get_products( $args );
     243
    232244        // The Loop
    233245        $numProducts = 0;
     
    243255        fputcsv($op, $header, ',', '"');
    244256
    245         if( $the_query->have_posts() )
    246         {
    247257            //while ( $the_query->have_posts() ) {
    248258            //$the_query->the_post();
    249             foreach ($the_query->posts as $product_id) {
    250 
     259            foreach ($products as $p) {
     260                $product_id = $p->id;
    251261                //$the_query->post->ID = $product_id
    252262
     
    294304            }
    295305
    296 
    297         }
    298306        fclose($op);
    299307
     
    485493    // FRONT PAGE Index page
    486494    public function retargeting_front_page() {
     495        $user_id = get_current_user_id();
     496
    487497   // URL:  https://pix.hyj.mobi/rt?t=d&action=s&cid=CLIENT_ID
    488498        if ( is_front_page() ) {
    489499            $this->url_js='https://pix.hyj.mobi/rt?t=d&action=s&cid='.$this->client_id;
     500            if($user_id != 0) {
     501                $this->url_js .= '&customer_id='.$user_id;
     502            }
    490503            echo $this->render( 'front-page' );
    491504        }
     
    494507    // CATEGORY PAGE
    495508    public function retargeting_category() {
     509        $user_id = get_current_user_id();
     510
    496511        // URL:  https://pix.hyj.mobi/rt?t=d&action=c&cid=CLIENT_ID&id=CATEGORY_ID
    497512        //echo "<pre>is_product_taxonomy"; var_export(is_product_taxonomy() ); echo "</pre>";
     
    503518            $id = $cat->term_id;
    504519            $this->url_js='https://pix.hyj.mobi/rt?t=d&action=c&cid='.$this->client_id.'&id='.$id;
     520            if($user_id != 0) {
     521                $this->url_js .= '&customer_id='.$user_id;
     522            }
    505523            echo $this->render( 'front-page' );
    506524         }
     
    510528    // CATEGORY PAGE
    511529    public function retargeting_cart() {
     530        $user_id = get_current_user_id();
     531
    512532        // URL:  https://pix.hyj.mobi/rt?t=d&action=w&cid=CLIENT_ID
    513533        if (is_cart() ) {
    514534            $this->url_js='https://pix.hyj.mobi/rt?t=d&action=w&cid='.$this->client_id;
     535            if($user_id != 0) {
     536                $this->url_js .= '&customer_id='.$user_id;
     537            }
    515538            echo $this->render( 'front-page' );         
    516539        }
     
    519542    // PRODUCT PAGE
    520543    public function retargeting_product() {
     544        $user_id = get_current_user_id();
     545
    521546    //URL:  https://pix.hyj.mobi/rt?t=d&action=p&cid=CLIENT_ID&id=PRODUCT_ID
    522547        if ( is_product() ) {
     
    527552            }
    528553            $this->url_js='https://pix.hyj.mobi/rt?t=d&action=p&cid='.$this->client_id.'&id='.$id;
     554            if($user_id != 0) {
     555                $this->url_js .= '&customer_id='.$user_id;
     556            }
    529557            echo $this->render( 'front-page' );
    530558        }
     
    534562    // Order Success page
    535563    public function retargeting_confirmation() {
     564        $user_id = get_current_user_id();
    536565/*
    537566    URL:  https://d.hyj.mobi/convNetw?cid=CLIENT_ID&orderId=ORDER_ID&amount=ORDER_TOTAL&eventName=ARTILE_ID1,ARTILE_ID2,ARTILE_ID3&network=relevanz
     
    547576
    548577            $this->url_js='https://d.hyj.mobi/convNetw?cid='.$this->client_id.'&orderId='.$this->order_id.'&amount='.$this->order_total.'&eventName='.$eventname.'&network=relevanz';
     578            if($user_id != 0) {
     579                $this->url_js .= '&customer_id='.$user_id;
     580            }
    549581
    550582            //echo "<pre>"; var_export($this->url_js); echo "</pre>";
     
    555587
    556588    public function retargeting_other() {
     589        $user_id = get_current_user_id();
     590
    557591        if(!is_front_page() && !(function_exists('is_product_category') && is_product_category()) && !is_product() && !is_order_received_page() && !is_cart()) {
    558592            $this->url_js='https://pix.hyj.mobi/rt?t=d&action=s&cid='.$this->client_id;
     593            if($user_id != 0) {
     594                $this->url_js .= '&customer_id='.$user_id;
     595            }
    559596            echo $this->render( 'front-page' );         
    560597        }
  • releva-nz/trunk/relevatracking.php

    r2721057 r2747414  
    1717 * Plugin URI:        https://releva.nz
    1818 * Description:       Technology for personalized advertising
    19  * Version:           2.1.1
     19 * Version:           2.1.2
    2020 * Author:            releva.nz
    2121 * License:           GPL-2.0+
Note: See TracChangeset for help on using the changeset viewer.