PluginProbe
MailerLite – WooCommerce integration / 3.1.27
MailerLite – WooCommerce integration v3.1.27
3.1.27 3.1.25 3.1.26 3.1.24 3.1.23 3.1.22 3.1.21 3.1.20 3.1.19 3.1.18 3.1.17 3.1.16 3.1.15 1.8.7 1.8.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 All 148 releases
woo-mailerlite / includes / jobs / WooMailerLiteProductVariantsMigrationJob.php

WooMailerLiteProductVariantsMigrationJob.php in MailerLite – WooCommerce integration 3.1.27, at includes/jobs/WooMailerLiteProductVariantsMigrationJob.php

33 lines 1007 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * After the support for Product Variants, we need to reset the tracked products and re-sync them to MailerLite.
5 * This job will reset the tracked products and re-sync them to MailerLite.
6 */
7 class WooMailerLiteProductVariantsMigrationJob extends WooMailerLiteAbstractJob
8 {
9 public function handle($data = [])
10 {
11 WooMailerLiteLog()->info('variants:migration:handle');
12
13 $products = WooMailerLiteProduct::tracked()->get(100);
14 if ($products->hasItems()) {
15 foreach ($products->items as $product) {
16 $product->tracked = false;
17 $product->save();
18 }
19 }
20
21 if (isset(self::$jobModel)) {
22 self::$jobModel->delete();
23 }
24
25 if (WooMailerLiteProduct::getTrackedProductsCount()) {
26 self::dispatchSync();
27 } else {
28 WooMailerLiteProductSyncJob::dispatch();
29 WooMailerLiteLog()->info('variants:migration:products-reset-complete');
30 }
31 }
32 }
33