Plugin Directory

Changeset 3392156


Ignore:
Timestamp:
11/08/2025 12:02:58 PM (4 months ago)
Author:
hamsalam
Message:

1.5.4

Location:
sync-basalam/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sync-basalam/trunk/CHANGELOG.md

    r3391225 r3392156  
    11# Changelog
     2
     3<details>
     4<summary>1.5.5 - 2025-01-15</summary>
     5
     6### Changed / Improved
     7
     8- Optimized fetch creatable products query using direct SQL for better performance
     9- Improved API service manager to properly decode JSON responses
     10- Enhanced update job detection logic to avoid false positive job status checks
     11
     12### Fixed
     13
     14- Fixed API response handling by properly decoding JSON data
     15- Removed commented-out legacy code from plugin initialization
     16- Fixed quick update job status detection in admin dashboard
     17- Resolved duplicate job checking that was causing incorrect "in progress" states
     18
     19</details>
    220
    321<details>
  • sync-basalam/trunk/includes/admin/class-sync-basalam-product-service.php

    r3381046 r3392156  
    8383    public static function fetch_creatable_products($args)
    8484    {
    85         $posts_per_page = $args['posts_per_page'] ?? 100;
    86         $offset = $args['offset'] ?? 0;
    87         $include_out_of_stock = $args['include_out_of_stock'] ?? false;
    88 
    89         $meta_query = [
    90             'meta_query' => [
    91                 'relation' => 'AND',
    92                 [
    93                     'key'     => 'sync_basalam_product_id',
    94                     'compare' => 'NOT EXISTS',
    95                 ],
    96                 [
    97                     'key'     => '_price',
    98                     'compare' => 'EXISTS',
    99                 ],
    100                 [
    101                     'key'     => '_price',
    102                     'value'   => 1000,
    103                     'type'    => 'NUMERIC',
    104                     'compare' => '>=',
    105                 ],
    106                 [
    107                     'key'     => '_downloadable',
    108                     'value'   => 'yes',
    109                     'compare' => '!=',
    110                 ],
    111                 [
    112                     'key'     => '_virtual',
    113                     'value'   => 'yes',
    114                     'compare' => '!=',
    115                 ],
    116                 [
    117                     'relation' => 'OR',
    118                     [
    119                         'key'     => '_thumbnail_id',
    120                         'compare' => 'EXISTS',
    121                     ],
    122                     [
    123                         'key'     => '_product_image_gallery',
    124                         'value'   => '',
    125                         'compare' => '!=',
    126                     ],
    127                 ],
    128             ],
    129         ];
    130 
    131         if (!$include_out_of_stock) {
    132             $meta_query[] = [
    133                 'key'     => '_stock_status',
    134                 'value'   => 'instock',
    135                 'compare' => '=',
    136             ];
    137         }
    138 
    139         $product_ids = get_posts([
    140             'post_type'      => 'product',
    141             'post_status'    => 'publish',
    142             'posts_per_page' => $posts_per_page,
    143             'offset'         => $offset,
    144             'fields'         => 'ids',
    145             'meta_query'     => $meta_query,
    146         ]);
    147 
    148         $product_ids = array_filter($product_ids, function ($id) {
    149             return get_post_type($id) === 'product';
    150         });
    151 
    152         return array_values($product_ids);
    153     }
     85        global $wpdb;
     86
     87        $posts_per_page = intval($args['posts_per_page'] ?? 50);
     88        $offset = intval($args['offset'] ?? 0);
     89
     90        $posts_table = $wpdb->posts;
     91        $meta_table = $wpdb->postmeta;
     92
     93        $query = $wpdb->prepare("
     94        SELECT p.ID
     95        FROM {$posts_table} AS p
     96        LEFT JOIN {$meta_table} AS basalam
     97            ON basalam.post_id = p.ID
     98            AND basalam.meta_key = 'sync_basalam_product_id'
     99        WHERE p.post_type = 'product'
     100            AND p.post_status = 'publish'
     101            AND basalam.post_id IS NULL
     102        ORDER BY p.ID DESC
     103        LIMIT %d OFFSET %d
     104    ", $posts_per_page, $offset);
     105
     106        $ids = $wpdb->get_col($query);
     107
     108        return array_map('intval', $ids);
     109    }
     110
    154111
    155112    public static function enqueue_all_products_for_update($offset)
  • sync-basalam/trunk/includes/class-sync-basalam-plugin.php

    r3391225 r3392156  
    44class Sync_basalam_Plugin
    55{
    6     const VERSION = '1.5.4';
     6    const VERSION = '1.5.5';
    77
    88    public function __construct()
     
    241241    }
    242242
    243     // private function init_wp_bg_process()
    244     // {
    245     //     global $SyncBasalamBulkUpdateProducts;
    246     //     global $SyncBasalamProductsConnectDispatcher;
    247 
    248     //     $SyncBasalamBulkUpdateProducts = new SyncBasalamBulkUpdateProducts();
    249     //     $SyncBasalamProductsConnectDispatcher = new SyncBasalamProductsConnectDispatcher();
    250 
    251     //     new SyncBasalamProductCreateDispatcher();
    252 
    253     //     new SyncBasalamCreateProduct();
    254     //     new SyncBasalamUpdateProduct();
    255     // }
    256 
    257243    private function init_wp_bg_process()
    258244    {
  • sync-basalam/trunk/includes/services/class-sync-basalam-api-service-manager.php

    r3391225 r3392156  
    6565
    6666        return [
    67             'body' => $body,
     67            'body' => json_decode($body, true),
    6868            'status_code' => $status_code
    6969        ];
  • sync-basalam/trunk/readme.txt

    r3391225 r3392156  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.5.4
     7Stable tag: 1.5.5
    88License: GPL-2.0-or-later 
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html 
  • sync-basalam/trunk/sync-basalam.php

    r3391225 r3392156  
    55 * Plugin Name: sync basalam | ووسلام
    66 * Description: با استفاده از پلاگین ووسلام  میتوایند تمامی محصولات ووکامرس را با یک کلیک به غرفه باسلامی خود اضافه کنید‌، همچنین تمامی سفارش باسلامی شما به سایت شما اضافه میگردد.
    7  * Version: 1.5.4
     7 * Version: 1.5.5
    88 * Author: Woosalam Dev
    99 * Author URI: https://wp.hamsalam.ir/
  • sync-basalam/trunk/templates/admin/menu/main/main-connected.php

    r3391225 r3392156  
    1313
    1414
    15 $quick_update_job = $job_manager->get_job(['job_type' => 'sync_basalam_update_all_products']);
    16 $quick_update_processing_job = $job_manager->get_job(['job_type' => 'sync_basalam_update_all_products']);
     15$quick_update_processing_job = $job_manager->get_job(['job_type' => 'sync_basalam_update_all_products', 'status' => 'pending', 'processing']);
    1716$count_quick_update_batches = $SyncBasalamBulkUpdateProducts ? $SyncBasalamBulkUpdateProducts->count_batches() : 0;
    1817
     
    2423$single_update_count = $job_manager->get_count_jobs(['job_type' => 'sync_basalam_update_single_product', 'status' => ['pending', 'processing']]);
    2524
    26 $has_active_update_jobs = ($quick_update_job || $quick_update_processing_job || $full_update_job || $full_update_processing_job || $single_update_count > 0 || $count_quick_update_batches > 0);
     25$has_active_update_jobs = ($quick_update_processing_job || $full_update_job || $full_update_processing_job || $single_update_count > 0 || $count_quick_update_batches > 0);
    2726$active_update_type = '';
    28 if ($quick_update_job || $quick_update_processing_job) {
     27if ($quick_update_processing_job) {
    2928    $active_update_type = 'quick';
    3029} elseif ($full_update_job || $full_update_processing_job || $single_update_count > 0) {
  • sync-basalam/trunk/templates/admin/menu/main/modal/update-product.php

    r3391225 r3392156  
    5454                </div>
    5555            </div>
    56         <?php elseif ($quick_update_job || $quick_update_processing_job): ?>
     56        <?php elseif ($quick_update_processing_job): ?>
    5757            <!-- Display when quick update job (sync_basalam_update_all_products) is running -->
    5858            <div id="quick-update-in-progress" style="display:block;margin:10px">
Note: See TracChangeset for help on using the changeset viewer.