# woo-mailerlite/3.1.25/admin/controllers/WooMailerLiteAdminSyncController.php

MailerLite – WooCommerce integration, version 3.1.25. 48 lines.

- Page: https://pluginprobe.com/plugins/woo-mailerlite/3.1.25/code/admin/controllers/WooMailerLiteAdminSyncController.php
- Raw: https://pluginprobe.com/plugins/woo-mailerlite/3.1.25/raw/admin/controllers/WooMailerLiteAdminSyncController.php
- Modified: 2025-12-09T08:41:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woo-mailerlite/3.1.25/code/admin/controllers/WooMailerLiteAdminSyncController.php#L10-L20`.

```php
<?php

class WooMailerLiteAdminSyncController extends WooMailerLiteController
{
    public function sync()
    {
        $this->authorize();
        $alreadyStarted = WooMailerLiteCache::get('manual_sync', false);
        if (!$alreadyStarted) {
            WooMailerLiteCache::set('manual_sync', true, 18000);
        }

        // save count in cache
        $untrackedCategories = WooMailerLiteCategory::getUntrackedCategoriesCount();
        $untrackedProducts = WooMailerLiteProduct::getUntrackedProductsCount();
        $untrackedCustomers = WooMailerLiteCustomer::getUntrackedCustomersCount();
        WooMailerLiteCache::set('resource_sync_counts', [
            'categories' => $untrackedCategories,
            'products' => $untrackedProducts,
            'customers' => $untrackedCustomers,
        ], 18000);
        $totalUntrackedResources = $untrackedCategories + $untrackedProducts + $untrackedCustomers;
        if ($totalUntrackedResources == 0) {
            WooMailerLiteCache::delete('manual_sync');
            return $this->response('no resources to sync', 200);
        }

        WooMailerLiteCategorySyncJob::dispatch();

        return $this->response([
            'message' => 'Sync in progress',
            'data' => [
                'totalUntrackedResources' => $totalUntrackedResources
            ]
        ], function_exists('as_enqueue_async_action') ? 203 : 202);
    }

    public function resetSync()
    {
        $this->authorize();
        WooMailerLiteCache::delete('manual_sync');
        WooMailerLiteProductSyncResetJob::dispatchSync();
        return $this->response(['message' => 'reset sync completed', 'data' => [
            'totalUntrackedResources' => WooMailerLiteCategory::getUntrackedCategoriesCount() + WooMailerLiteProduct::getUntrackedProductsCount() +  WooMailerLiteCustomer::getUntrackedCustomersCount()
        ]], 202);
    }
}

```
