Plugin Directory

Changeset 3549371


Ignore:
Timestamp:
05/26/2026 03:31:11 PM (5 months ago)
Author:
oasisvisheratinnikolay
Message:

v 3.0.3

Location:
oasiscatalog-importer
Files:
26 added
8 edited

Legend:

Unmodified
Added
Removed
  • oasiscatalog-importer/trunk/languages/oasiscatalog-importer-ru_RU.po

    r3492560 r3549371  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: Oasiscatalog Importer 3.0.2\n"
     3"Project-Id-Version: Oasiscatalog Importer 3.0.3\n"
    44"Report-Msgid-Bugs-To: https://www.oasiscatalog.com\n"
    55"Last-Translator: Nikolay Visheratin\n"
    … …  
    8585
    8686#: oasiscatalog-importer.php:502
    87 msgid "ATTENTION! This option can be changed before importing products. Changing it afterward may result in inconsistent performance"
    88 msgstr "ВНИМАНИЕ! Опцию можно менять до импорта товаров. Если изменить после, возможна неккоретная работа"
     87msgid "ATTENTION! It is recommended to change this option before importing products. If you change it afterward, all current Oasis products will be deleted and re-uploaded"
     88msgstr "ВНИМАНИЕ! Опцию рекомендуется менять до импорта товаров. Если изменить после, все текущие продукты Oasis будут удалены и загружены заново"
    8989
    9090#: oasiscatalog-importer.php:510
  • oasiscatalog-importer/trunk/oasiscatalog-importer.php

    r3492560 r3549371  
    44Plugin URI: https://www.oasiscatalog.com
    55Description: Import products from the oasiscatalog.com catalog to WooCommerce. Upload orders from WooCommerce to oasiscatalog. Application editing widget.
    6 Version: 3.0.2
     6Version: 3.0.3
    77Text Domain: oasiscatalog-importer
    88License: GPL2
    99
    10 WordPress tested:   6.9
    11 Woocommerce tested: 6.9
     10WordPress tested:   7.0
     11Woocommerce tested: 10.7
    1212*/
    1313
    … …  
    500500                        </select>
    501501                        <p class="description"><?php esc_html_e('By default, products are grouped by color and size (for example, a T-shirt with color and size options)', 'oasiscatalog-importer') ?></p>
    502                         <p class="description"><?php esc_html_e('ATTENTION! This option can be changed before importing products. Changing it afterward may result in inconsistent performance', 'oasiscatalog-importer') ?></p>
     502                        <p class="description"><?php esc_html_e('ATTENTION! It is recommended to change this option before importing products. If you change it afterward, all current Oasis products will be deleted and re-uploaded', 'oasiscatalog-importer') ?></p>
    503503                        <?php
    504504                },
    … …  
    631631function oasis_import_sf_checbox($opt, $is, $description = '') {
    632632        echo '<input type="checkbox" class="code" value="1" name="oasis_import_options[' . esc_attr($opt) . ']" ' . ($is ? 'checked' : '') . ' />';
    633         if(!empty($description))
     633        if (!empty($description)) {
    634634                echo '<p class="description">' . esc_html($description) . '</p>';
     635        }
    635636}
    636637
    637638function oasis_import_sf_number($opt, $v, $step, $description = '') {
    638639        echo '<input type="number" maxlength="255" style="width: 120px;" name="oasis_import_options[' . esc_attr($opt) . ']" value="' . esc_attr($v ? $v : '') . '" step="' . esc_attr($step) . '" />';
    639         if(!empty($description))
     640        if (!empty($description)) {
    640641                echo '<p class="description">' . esc_html($description) . '</p>';
     642        }
    641643}
    642644
  • oasiscatalog-importer/trunk/readme.txt

    r3492560 r3549371  
    33Tags: Oasiscatalog, products, catalog, import
    44Requires at least: 5.8
    5 Tested up to: 6.9
    6 Stable tag: 3.0.2
     5Tested up to: 7.0
     6Stable tag: 3.0.3
    77Requires PHP: 7.4
    88License: GPLv2 or later
    … …  
    7272== Changelog ==
    7373
     74= 3.0.3 - 2026-05-26 =
     75- when upgrading from the old version of the plugin, Oasis products will be deleted and reloaded. Please be prepared for this.
     76- fix select grouping
     77- optimization
     78
    7479= 3.0.2 - 2026-03-27 =
    7580- added option show not available products
  • oasiscatalog-importer/trunk/src/lib/Api.php

    r3492560 r3549371  
    1717        public static function getOasisProducts(array $args = []): array
    1818        {
    19                 $fields = 'id,article,group_id,parent_size_id'
     19                $fields = 'id,article,group_id,color_group_id'
    2020                                        . ',is_deleted,is_stopped'
    2121                                        . ',name,full_name,description,defect'
  • oasiscatalog-importer/trunk/src/lib/Cli.php

    r3492560 r3549371  
    9999                        [$groups, $stepTotal] = self::getGroupsProduct($args);
    100100
     101                        $dbDataGroup = [];
     102                        $dbDataProductType = [];
     103                        foreach (Main::getOasisDbRows() as $dbProduct) {
     104                                if (Main::getNeedOptUp($dbProduct, 0b10)) {
     105                                        Main::deleteProductForPostId($dbProduct['post_id']);
     106                                }
     107                                else {
     108                                        $type      = $dbProduct['type'];
     109                                        $groupId   = $dbProduct['group_id'];
     110                                        $productId = $dbProduct['product_id'];
     111
     112                                        $dbDataGroup[$groupId][] = $dbProduct;
     113                                        $dbDataProductType[$groupId][$productId][$type] = $dbProduct;
     114                                }
     115                        }
     116
    101117                        if (self::$cf->limit > 0) {
    102118                                self::$cf->progressStart(Api::getStatProducts()->products, $stepTotal);
    … …  
    108124                        $count = 0;
    109125
    110                         foreach ($groups as $group_id => $products) {
    111                                 self::$cf->log('Начало обработки модели ' . $group_id);
     126                        foreach ($groups as $groupId => $products) {
     127                                self::$cf->log('Начало обработки модели ' . $groupId);
    112128                                $totalStock = array_reduce($products, function($sum, $product) {
    113129                                return $sum + Main::getStock($product);
    114130                                }, 0);
    115                                 $dbGroupProducts = Main::checkGroupProducts($group_id);
     131                                $dbProducts = $dbDataGroup[$groupId] ?? [];
    116132
    117133                                if (count($products) === 1) {
    118134                                        $product   = reset($products);
    119                                         $dbProduct = reset($dbGroupProducts);
    120                                         if (count($dbGroupProducts) > 1) {
    121                                                 Main::deleteProductForPostId(array_map(fn($item) => $item['post_id'], $dbGroupProducts));
     135                                        $dbProduct = reset($dbProducts);
     136                                        if (count($dbProducts) > 1) {
     137                                                Main::deleteProductForPostId(array_map(fn($item) => $item['post_id'], $dbProducts));
    122138                                                $dbProduct = null;
    123139                                        }       
    … …  
    127143                                                self::$cf->log('Обновлен товар OAId='.$product->id.', WPId=' . $dbProduct['post_id']);
    128144                                        } else {
    129                                                 Main::addWcProduct($group_id, $product, $products, $totalStock);
     145                                                Main::addWcProduct($groupId, $product, $products, $totalStock);
    130146                                                self::$cf->log('Добавлен товар id '.$product->id);
    131147                                        }
    … …  
    133149                                }
    134150                                else {
    135                                         if (count($dbGroupProducts) == 1) {
    136                                                 Main::deleteProductForPostId(array_map(fn($item) => $item['post_id'], $dbGroupProducts));
    137                                         }
    138                                         $product = reset($products);
    139                                         $dbProduct = Main::checkProduct($product->id, 'product');
     151                                        if (count($dbProducts) == 1) {
     152                                                Main::checkDeleteGroup($groupId);
     153                                                unset($dbDataProductType[$groupId]);
     154                                        }
     155                                        $product          = reset($products);
     156                                        $dbProduct        = $dbDataProductType[$groupId][$product->id]['product'] ?? null;
     157                                        $dbFirstVariation = $dbDataProductType[$groupId][$product->id]['product_variation'] ?? null;
     158
     159                                        if ($dbFirstVariation && Main::getNeedOptUp($dbFirstVariation, 0b11)) {
     160                                                Main::deleteProductForPostId($dbFirstVariation['post_id']);
     161                                                unset($dbDataProductType[$groupId][$product->id]['product_variation']);
     162                                        }
    140163
    141164                                        if ($dbProduct) {
    142165                                                $wcProductId = $dbProduct['post_id'];
    143166                                                Main::upWcProduct($dbProduct, $product, $products, $totalStock, true);
    144                                                 self::$cf->log('Обновлен товар OAId='.$product->id.', WPId=' . $wcProductId);
     167                                                self::$cf->log('Обновлен товар OAId=' . $product->id . ', WPId=' . $wcProductId);
    145168                                        } else {
    146                                                 Main::checkDeleteGroup($group_id);
    147                                                 $wcProductId = Main::addWcProduct($group_id, $product, $products, $totalStock, true);
     169                                                if (!empty($dbDataProductType[$groupId])) {
     170                                                        Main::checkDeleteGroup($groupId);
     171                                                        unset($dbDataProductType[$groupId]);
     172                                                }
     173                                               
     174                                                $wcProductId = Main::addWcProduct($groupId, $product, $products, $totalStock, true);
    148175                                                if (!$wcProductId) {
    149176                                                        continue;
    150177                                                }
    151                                                 self::$cf->log('Добавлен товар id '.$product->id);
     178                                                self::$cf->log('Добавлен товар id ' . $product->id);
    152179                                        }
    153180
    154181                                        foreach ($products as $variation) {
    155                                                 $dbVariation = Main::checkProduct($variation->id, 'product_variation');
     182                                                $dbVariation = $dbDataProductType[$groupId][$variation->id]['product_variation'] ?? null;
    156183
    157184                                                if ($dbVariation) {
    … …  
    159186                                                        self::$cf->log(' - обновлен вариант OAId=' . $variation->id . ', WPId=' . $dbVariation['post_id']);
    160187                                                } else {
    161                                                         Main::addWcVariation($group_id, $wcProductId, $variation);
     188                                                        Main::addWcVariation($groupId, $wcProductId, $variation);
    162189                                                        self::$cf->log(' - добавлен вариант id ' . $variation->id);
    163190                                                }
    … …  
    338365                if (self::$cf->grouping === 1) {
    339366                        foreach (Api::getOasisProducts($args) as $product) {
    340                                 if (!empty($product->size) && !empty($product->parent_size_id)) {
    341                                         $groups[$product->parent_size_id][$product->id] = $product;
     367                                if (!empty($product->color_group_id)) {
     368                                        $groups[$product->color_group_id][$product->id] = $product;
    342369                                } else {
    343370                                        $groups[$product->id][$product->id] = $product;
  • oasiscatalog-importer/trunk/src/lib/Config.php

    r3492560 r3549371  
    1818        public bool $is_info_log = false;
    1919        public string $mode;
     20        public int $opt_bits;
    2021        public string $upload_path;
    2122
    … …  
    194195                $this->is_without_quotes = !empty($opt['is_without_quotes']);
    195196
     197                $this->opt_bits = 0;
     198                if ($this->is_cdn_photo) {
     199                        $this->opt_bits |= (1 << 0);
     200                }
     201                if ($this->grouping === 1) {
     202                        $this->opt_bits |= (1 << 1);
     203                }
     204
    196205                $this->is_init = true;
    197206        }
  • oasiscatalog-importer/trunk/src/lib/Main.php

    r3492560 r3549371  
    107107        {
    108108                global $wpdb;
    109                 $sql = "SELECT DISTINCT p.ID as post_id, p.post_type as type, pm_product.meta_value as product_id, pm_group.meta_value as group_id, pm_updated.meta_value as updated_at
     109                $sql = "SELECT DISTINCT p.ID as post_id, p.post_type as type, pm_product.meta_value as product_id, pm_group.meta_value as group_id, pm_updated.meta_value as updated
    110110                                FROM {$wpdb->prefix}posts p
    111111                                INNER JOIN {$wpdb->prefix}postmeta pm_product ON p.ID = pm_product.post_id AND pm_product.meta_key = '_oasis_product'
    … …  
    132132                global $wpdb;
    133133                return $wpdb->get_results($wpdb->prepare(
    134                         "SELECT DISTINCT p.ID as post_id, p.post_type as type, pm_product.meta_value as product_id, pm_group.meta_value as group_id, pm_updated.meta_value as updated_at
     134                        "SELECT DISTINCT p.ID as post_id, p.post_type as type, pm_product.meta_value as product_id, pm_group.meta_value as group_id, pm_updated.meta_value as updated
    135135                        FROM {$wpdb->prefix}posts p
    136136                        INNER JOIN {$wpdb->prefix}postmeta pm_product ON p.ID = pm_product.post_id AND pm_product.meta_key = '_oasis_product'
    … …  
    185185                $wcProduct->add_meta_data('_oasis_product', $product->id);
    186186                $wcProduct->add_meta_data('_oasis_group', $group_id);
    187                 $wcProduct->add_meta_data('_oasis_updated', $product->updated_at . ',' . $product->images_updated_at);
     187                $wcProduct->add_meta_data('_oasis_updated', $product->updated_at . ',' . $product->images_updated_at . ',' . self::$cf->opt_bits);
    188188
    189189                $wcProductId = $wcProduct->save();
    … …  
    273273                if ($need_save) {
    274274                        $wcProduct->set_date_modified(time());
    275                         $wcProduct->update_meta_data('_oasis_updated', $product->updated_at . ',' . $product->images_updated_at);
     275                        $wcProduct->update_meta_data('_oasis_updated', $product->updated_at . ',' . $product->images_updated_at . ',' . self::$cf->opt_bits);
    276276                        $wcProduct->save();
    277277                }
    … …  
    342342                        $wcVariation->add_meta_data('_oasis_product', $variation->id);
    343343                        $wcVariation->add_meta_data('_oasis_group', $group_id);
    344                         $wcVariation->add_meta_data('_oasis_updated', $variation->updated_at . ',' . $variation->images_updated_at);
     344                        $wcVariation->add_meta_data('_oasis_updated', $variation->updated_at . ',' . $variation->images_updated_at . ',' . self::$cf->opt_bits);
    345345
    346346                        $wcVariationId = $wcVariation->save();
    … …  
    420420                if ($need_save) {
    421421                        $wcVariation->set_date_modified(time());
    422                         $wcVariation->update_meta_data('_oasis_updated', $variation->updated_at . ',' . $variation->images_updated_at);
     422                        $wcVariation->update_meta_data('_oasis_updated', $variation->updated_at . ',' . $variation->images_updated_at . ',' . self::$cf->opt_bits);
    423423                        $wcVariation->save();
    424424                }
    … …  
    480480        public static function getNeedUp($dbProduct, $product): bool
    481481        {
    482                 $date = explode(',', $dbProduct['updated_at'] ?? '')[0] ?? '';
     482                $date = explode(',', $dbProduct['updated'] ?? '')[0] ?? '';
    483483                return ($product->updated_at ?? '1') > $date;
    484484        }
    … …  
    492492        public static function getNeedImagesUp($dbProduct, $product): bool
    493493        {
    494                 $date = explode(',', $dbProduct['updated_at'] ?? '')[1] ?? '';
    495                 return ($product->images_updated_at ?? '1') > $date;
     494                $date = explode(',', $dbProduct['updated'] ?? '')[1] ?? '';
     495                return ($product->images_updated_at ?? '1') > $date || self::getNeedOptUp($dbProduct, 0b01);
     496        }
     497
     498        /**
     499         * Check need update product for site options
     500         * @param $dbProduct
     501         * @param $mask
     502         * @return bool
     503         */
     504        public static function getNeedOptUp($dbProduct, $mask): bool
     505        {
     506                $opt = intval(explode(',', $dbProduct['updated'] ?? '')[2] ?? 0);
     507                return (($opt & $mask) !== (self::$cf->opt_bits & $mask));
    496508        }
    497509
    … …  
    10231035                global $wpdb;
    10241036                return $wpdb->get_results($wpdb->prepare(
    1025                         "SELECT DISTINCT p.ID as post_id, p.post_type as type, pm_product.meta_value as product_id, pm_group.meta_value as group_id, pm_updated.meta_value as updated_at
     1037                        "SELECT DISTINCT p.ID as post_id, p.post_type as type, pm_product.meta_value as product_id, pm_group.meta_value as group_id, pm_updated.meta_value as updated
    10261038                        FROM {$wpdb->prefix}posts p
    10271039                        INNER JOIN {$wpdb->prefix}postmeta pm_product ON p.ID = pm_product.post_id AND pm_product.meta_key = '_oasis_product'
Note: See TracChangeset for help on using the changeset viewer.