Changeset 3549371
- Timestamp:
- 05/26/2026 03:31:11 PM (5 months ago)
- Location:
- oasiscatalog-importer
- Files:
-
- 26 added
- 8 edited
-
tags/3.0.3 (added)
-
tags/3.0.3/assets (added)
-
tags/3.0.3/assets/css (added)
-
tags/3.0.3/assets/css/bootstrap.min.css (added)
-
tags/3.0.3/assets/css/branding-widget.css (added)
-
tags/3.0.3/assets/css/style.css (added)
-
tags/3.0.3/assets/js (added)
-
tags/3.0.3/assets/js/bootstrap.min.js (added)
-
tags/3.0.3/assets/js/branding-widget.js (added)
-
tags/3.0.3/assets/js/custom.js (added)
-
tags/3.0.3/assets/js/order.js (added)
-
tags/3.0.3/assets/js/tree.js (added)
-
tags/3.0.3/assets/js/widget.js (added)
-
tags/3.0.3/languages (added)
-
tags/3.0.3/languages/oasiscatalog-importer-ru_RU.mo (added)
-
tags/3.0.3/languages/oasiscatalog-importer-ru_RU.po (added)
-
tags/3.0.3/oasiscatalog-importer.php (added)
-
tags/3.0.3/readme.txt (added)
-
tags/3.0.3/src (added)
-
tags/3.0.3/src/branding.php (added)
-
tags/3.0.3/src/lib (added)
-
tags/3.0.3/src/lib/Api.php (added)
-
tags/3.0.3/src/lib/Cli.php (added)
-
tags/3.0.3/src/lib/Config.php (added)
-
tags/3.0.3/src/lib/Main.php (added)
-
tags/3.0.3/src/order.php (added)
-
trunk/languages/oasiscatalog-importer-ru_RU.mo (modified) ( previous)
-
trunk/languages/oasiscatalog-importer-ru_RU.po (modified) (2 diffs)
-
trunk/oasiscatalog-importer.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/lib/Api.php (modified) (1 diff)
-
trunk/src/lib/Cli.php (modified) (6 diffs)
-
trunk/src/lib/Config.php (modified) (2 diffs)
-
trunk/src/lib/Main.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
oasiscatalog-importer/trunk/languages/oasiscatalog-importer-ru_RU.po
r3492560 r3549371 1 1 msgid "" 2 2 msgstr "" 3 "Project-Id-Version: Oasiscatalog Importer 3.0. 2\n"3 "Project-Id-Version: Oasiscatalog Importer 3.0.3\n" 4 4 "Report-Msgid-Bugs-To: https://www.oasiscatalog.com\n" 5 5 "Last-Translator: Nikolay Visheratin\n" … … 85 85 86 86 #: 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 "ВНИМАНИЕ! Опцию можно менять до импорта товаров. Если изменить после, возможна неккоретная работа"87 msgid "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" 88 msgstr "ВНИМАНИЕ! Опцию рекомендуется менять до импорта товаров. Если изменить после, все текущие продукты Oasis будут удалены и загружены заново" 89 89 90 90 #: oasiscatalog-importer.php:510 -
oasiscatalog-importer/trunk/oasiscatalog-importer.php
r3492560 r3549371 4 4 Plugin URI: https://www.oasiscatalog.com 5 5 Description: Import products from the oasiscatalog.com catalog to WooCommerce. Upload orders from WooCommerce to oasiscatalog. Application editing widget. 6 Version: 3.0. 26 Version: 3.0.3 7 7 Text Domain: oasiscatalog-importer 8 8 License: GPL2 9 9 10 WordPress tested: 6.911 Woocommerce tested: 6.910 WordPress tested: 7.0 11 Woocommerce tested: 10.7 12 12 */ 13 13 … … 500 500 </select> 501 501 <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> 503 503 <?php 504 504 }, … … 631 631 function oasis_import_sf_checbox($opt, $is, $description = '') { 632 632 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)) { 634 634 echo '<p class="description">' . esc_html($description) . '</p>'; 635 } 635 636 } 636 637 637 638 function oasis_import_sf_number($opt, $v, $step, $description = '') { 638 639 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)) { 640 641 echo '<p class="description">' . esc_html($description) . '</p>'; 642 } 641 643 } 642 644 -
oasiscatalog-importer/trunk/readme.txt
r3492560 r3549371 3 3 Tags: Oasiscatalog, products, catalog, import 4 4 Requires at least: 5.8 5 Tested up to: 6.96 Stable tag: 3.0. 25 Tested up to: 7.0 6 Stable tag: 3.0.3 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 72 72 == Changelog == 73 73 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 74 79 = 3.0.2 - 2026-03-27 = 75 80 - added option show not available products -
oasiscatalog-importer/trunk/src/lib/Api.php
r3492560 r3549371 17 17 public static function getOasisProducts(array $args = []): array 18 18 { 19 $fields = 'id,article,group_id, parent_size_id'19 $fields = 'id,article,group_id,color_group_id' 20 20 . ',is_deleted,is_stopped' 21 21 . ',name,full_name,description,defect' -
oasiscatalog-importer/trunk/src/lib/Cli.php
r3492560 r3549371 99 99 [$groups, $stepTotal] = self::getGroupsProduct($args); 100 100 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 101 117 if (self::$cf->limit > 0) { 102 118 self::$cf->progressStart(Api::getStatProducts()->products, $stepTotal); … … 108 124 $count = 0; 109 125 110 foreach ($groups as $group _id => $products) {111 self::$cf->log('Начало обработки модели ' . $group _id);126 foreach ($groups as $groupId => $products) { 127 self::$cf->log('Начало обработки модели ' . $groupId); 112 128 $totalStock = array_reduce($products, function($sum, $product) { 113 129 return $sum + Main::getStock($product); 114 130 }, 0); 115 $db GroupProducts = Main::checkGroupProducts($group_id);131 $dbProducts = $dbDataGroup[$groupId] ?? []; 116 132 117 133 if (count($products) === 1) { 118 134 $product = reset($products); 119 $dbProduct = reset($db GroupProducts);120 if (count($db GroupProducts) > 1) {121 Main::deleteProductForPostId(array_map(fn($item) => $item['post_id'], $db GroupProducts));135 $dbProduct = reset($dbProducts); 136 if (count($dbProducts) > 1) { 137 Main::deleteProductForPostId(array_map(fn($item) => $item['post_id'], $dbProducts)); 122 138 $dbProduct = null; 123 139 } … … 127 143 self::$cf->log('Обновлен товар OAId='.$product->id.', WPId=' . $dbProduct['post_id']); 128 144 } else { 129 Main::addWcProduct($group _id, $product, $products, $totalStock);145 Main::addWcProduct($groupId, $product, $products, $totalStock); 130 146 self::$cf->log('Добавлен товар id '.$product->id); 131 147 } … … 133 149 } 134 150 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 } 140 163 141 164 if ($dbProduct) { 142 165 $wcProductId = $dbProduct['post_id']; 143 166 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); 145 168 } 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); 148 175 if (!$wcProductId) { 149 176 continue; 150 177 } 151 self::$cf->log('Добавлен товар id ' .$product->id);178 self::$cf->log('Добавлен товар id ' . $product->id); 152 179 } 153 180 154 181 foreach ($products as $variation) { 155 $dbVariation = Main::checkProduct($variation->id, 'product_variation');182 $dbVariation = $dbDataProductType[$groupId][$variation->id]['product_variation'] ?? null; 156 183 157 184 if ($dbVariation) { … … 159 186 self::$cf->log(' - обновлен вариант OAId=' . $variation->id . ', WPId=' . $dbVariation['post_id']); 160 187 } else { 161 Main::addWcVariation($group _id, $wcProductId, $variation);188 Main::addWcVariation($groupId, $wcProductId, $variation); 162 189 self::$cf->log(' - добавлен вариант id ' . $variation->id); 163 190 } … … 338 365 if (self::$cf->grouping === 1) { 339 366 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; 342 369 } else { 343 370 $groups[$product->id][$product->id] = $product; -
oasiscatalog-importer/trunk/src/lib/Config.php
r3492560 r3549371 18 18 public bool $is_info_log = false; 19 19 public string $mode; 20 public int $opt_bits; 20 21 public string $upload_path; 21 22 … … 194 195 $this->is_without_quotes = !empty($opt['is_without_quotes']); 195 196 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 196 205 $this->is_init = true; 197 206 } -
oasiscatalog-importer/trunk/src/lib/Main.php
r3492560 r3549371 107 107 { 108 108 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 _at109 $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 110 110 FROM {$wpdb->prefix}posts p 111 111 INNER JOIN {$wpdb->prefix}postmeta pm_product ON p.ID = pm_product.post_id AND pm_product.meta_key = '_oasis_product' … … 132 132 global $wpdb; 133 133 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 _at134 "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 135 135 FROM {$wpdb->prefix}posts p 136 136 INNER JOIN {$wpdb->prefix}postmeta pm_product ON p.ID = pm_product.post_id AND pm_product.meta_key = '_oasis_product' … … 185 185 $wcProduct->add_meta_data('_oasis_product', $product->id); 186 186 $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); 188 188 189 189 $wcProductId = $wcProduct->save(); … … 273 273 if ($need_save) { 274 274 $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); 276 276 $wcProduct->save(); 277 277 } … … 342 342 $wcVariation->add_meta_data('_oasis_product', $variation->id); 343 343 $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); 345 345 346 346 $wcVariationId = $wcVariation->save(); … … 420 420 if ($need_save) { 421 421 $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); 423 423 $wcVariation->save(); 424 424 } … … 480 480 public static function getNeedUp($dbProduct, $product): bool 481 481 { 482 $date = explode(',', $dbProduct['updated _at'] ?? '')[0] ?? '';482 $date = explode(',', $dbProduct['updated'] ?? '')[0] ?? ''; 483 483 return ($product->updated_at ?? '1') > $date; 484 484 } … … 492 492 public static function getNeedImagesUp($dbProduct, $product): bool 493 493 { 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)); 496 508 } 497 509 … … 1023 1035 global $wpdb; 1024 1036 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 _at1037 "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 1026 1038 FROM {$wpdb->prefix}posts p 1027 1039 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)