From 690a8dfd3527c283b3afc7db8a9c6a49efb9fdb1 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 26 Jul 2024 17:18:05 +0200 Subject: [PATCH] refactor: synchronization service and connected services --- src/Config/Config.php | 9 +++++++++ src/Controller/AbstractApiController.php | 4 +--- src/Interfaces/ShopContentServiceInterface.php | 10 ++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/Interfaces/ShopContentServiceInterface.php diff --git a/src/Config/Config.php b/src/Config/Config.php index bcf698ef3..3116edc9b 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -62,6 +62,15 @@ class Config const COLLECTION_WISHLISTS = 'wishlists'; const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; + const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s'; + + const RANDOM_SYNC_CHECK_MAX = 20; + const INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT = 100000; + + const INCREMENTAL_TYPE_ADD = 'incremental_type_add'; + const INCREMENTAL_TYPE_UPDATE = 'incremental_type_update'; + const INCREMENTAL_TYPE_DELETE = 'incremental_type_delete'; + /** * @param mixed $message * diff --git a/src/Controller/AbstractApiController.php b/src/Controller/AbstractApiController.php index e5b34bf8c..a708d3c32 100644 --- a/src/Controller/AbstractApiController.php +++ b/src/Controller/AbstractApiController.php @@ -17,8 +17,6 @@ use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; -const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s'; - abstract class AbstractApiController extends \ModuleFrontController { /** @@ -187,7 +185,7 @@ protected function handleDataSync(PaginatedApiDataProviderInterface $dataProvide $configurationRepository = $this->module->getService(\PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository::class); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); - $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(MYSQL_DATE_FORMAT); + $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); $offset = 0; $incrementalSync = false; $response = []; diff --git a/src/Interfaces/ShopContentServiceInterface.php b/src/Interfaces/ShopContentServiceInterface.php new file mode 100644 index 000000000..b52c7760b --- /dev/null +++ b/src/Interfaces/ShopContentServiceInterface.php @@ -0,0 +1,10 @@ +