From 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 25 Aug 2026 22:57:22 +0000
Subject: [PATCH] =It's been a minute. I went through the Routes and associated Managers and ensured they played together well. Reworked the Cache.php, and I think I caught all the references. Moving away from JVBase() root class, to individuall classes that are Instanced. Double checked for the ABSPATH check in every file, and added index.php to every directory that didn't already have it. Also still working on the MenuBlock to work with WooCommerce for now for Northeh

---
 inc/integrations/SyncHelpers.php |   64 ++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/inc/integrations/SyncHelpers.php b/inc/integrations/SyncHelpers.php
index f2d0ca0..8cdaf59 100644
--- a/inc/integrations/SyncHelpers.php
+++ b/inc/integrations/SyncHelpers.php
@@ -1,6 +1,10 @@
 <?php
 namespace JVBase\integrations;
 
+use JVBase\managers\queue\executors\IntegrationExecutor;
+use JVBase\managers\queue\mergers\DefaultMerger;
+use JVBase\managers\queue\Queue;
+use JVBase\managers\queue\TypeConfig;
 use JVBase\meta\Meta;
 use WP_Query;
 
@@ -20,11 +24,13 @@
 	protected static string $syncCustomer;
 	protected static string $import;
 
+
 	protected function setQueueTypes():void
 	{
 		self::$syncTo = $this->service_name.'_sync_to';
 		self::$deleteFrom = $this->service_name.'_delete_from';
 		self::$syncFrom = $this->service_name.'_sync_from';
+		self::$syncCustomer = $this->service_name.'_sync_customer';
 		//TODO: What is the difference between sync_from and import?
 		self::$import = $this->service_name.'import_from';
 	}
@@ -38,6 +44,17 @@
 			default => ''
 		};
 	}
+	public function setServiceItemID(int $itemID, string $id, string $type = 'post'):bool
+	{
+
+		$result = match($type) {
+			'post'	=> Meta::forPost($itemID)->set("_{$this->service_name}_item_id", $id),
+			'term','taxonomy'	=> Meta::forTerm($itemID)->set("_{$this->service_name}_item_id", $id),
+			'user'	=> Meta::forUser($itemID)->set("_{$this->service_name}_item_id", $id),
+			default => false
+		};
+		return $result !== false;
+	}
 	protected function updateItemStatus(int|array $items, string $status = 'pending', string $type = 'post'):void
 	{
 		if (!is_array($items)) {
@@ -141,4 +158,51 @@
 		]);
 		return is_wp_error($get) || empty($get) ? false : [$get[0], 'user'];
 	}
+
+	public function registerQueueTypes():void
+	{
+		if (empty($this->syncTaxonomies) && empty($this->syncPostTypes)) {
+			return;
+		}
+		$queue = Queue::getInstance();
+		$executor = new IntegrationExecutor();
+
+		$queue->registry()->register(self::$syncTo, new TypeConfig(
+			mergeable: new DefaultMerger('items'),
+			executor: $executor,
+			chunkKey: 'items',
+			chunkSize: 50,
+			maxRetries: 3,
+		));
+
+		if ($this->canSync['delete']) {
+			$queue->registry()->register(self::$deleteFrom, new TypeConfig(
+				mergeable: new DefaultMerger('external_ids'),
+				executor: $executor,
+				chunkKey: 'external_ids',
+				chunkSize: 200,
+				maxRetries: 2
+			));
+		}
+
+		$queue->registry()->register(self::$syncFrom, new TypeConfig(
+			executor: $executor,
+			maxRetries: 3
+		));
+
+		$this->registerAdditionalQueueTypes($executor);
+	}
+
+	/**
+	 * Empty. Integration extensions can register additional operation types here
+	 * @param IntegrationExecutor $executor
+	 * @return void
+	 */
+	protected function registerAdditionalQueueTypes(IntegrationExecutor $executor):void	{}
+
+	/**
+	 * @return void Sets the $this->contentTypes, which is an array of TYPE => [$fields]
+	 * Should probably set the endpoints here as well, which would be an array of [ TYPE => [ 'create' => '','update' =>'', 'delete'=>'', 'batchCreate'=>'','batchUpdate'=>'', 'batchDelete'=>''] endpoints
+	 */
+	abstract protected function setContentTypes():void;
 }

--
Gitblit v1.10.0