From 0843e8e65e199d26d2d51e4a605bfdb40f6b6eb2 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 26 Jul 2024 15:48:57 +0200 Subject: [PATCH 001/162] refactor: rework hooks with traits --- ps_eventbus.php | 1535 +-------------------------------------- src/Traits/UseHooks.php | 1533 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1539 insertions(+), 1529 deletions(-) create mode 100644 src/Traits/UseHooks.php diff --git a/ps_eventbus.php b/ps_eventbus.php index 26aa0ddd..41b6c50b 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -24,10 +24,9 @@ * International Registered Trademark & Property of PrestaShop SA */ -use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; -use PrestaShop\Module\PsEventbus\Service\SynchronizationService; +use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; if (!defined('_PS_VERSION_')) { exit; @@ -37,6 +36,9 @@ class Ps_eventbus extends Module { + // All hooks is here + use PrestaShop\Module\PsEventbus\UseHooks; + /** * @var array */ @@ -65,103 +67,7 @@ class Ps_eventbus extends Module public $version; /** - * List of hook to install at the installation of the module - * - * @var array - */ - private $hookToInstall = [ - 'actionObjectCarrierAddAfter', - 'actionObjectCarrierDeleteAfter', - 'actionObjectCarrierUpdateAfter', - - 'actionObjectCartAddAfter', - 'actionObjectCartUpdateAfter', - - 'actionObjectCartRuleAddAfter', - 'actionObjectCartRuleDeleteAfter', - 'actionObjectCartRuleUpdateAfter', - - 'actionObjectCategoryAddAfter', - 'actionObjectCategoryDeleteAfter', - 'actionObjectCategoryUpdateAfter', - - 'actionObjectCombinationDeleteAfter', - - 'actionObjectCountryAddAfter', - 'actionObjectCountryDeleteAfter', - 'actionObjectCountryUpdateAfter', - - 'actionObjectCurrencyAddAfter', - 'actionObjectCurrencyUpdateAfter', - - 'actionObjectCustomerAddAfter', - 'actionObjectCustomerDeleteAfter', - 'actionObjectCustomerUpdateAfter', - - 'actionObjectImageAddAfter', - 'actionObjectImageDeleteAfter', - 'actionObjectImageUpdateAfter', - - 'actionObjectLanguageAddAfter', - 'actionObjectLanguageDeleteAfter', - 'actionObjectLanguageUpdateAfter', - - 'actionObjectManufacturerAddAfter', - 'actionObjectManufacturerDeleteAfter', - 'actionObjectManufacturerUpdateAfter', - - 'actionObjectOrderAddAfter', - 'actionObjectOrderUpdateAfter', - - 'actionObjectProductAddAfter', - 'actionObjectProductDeleteAfter', - 'actionObjectProductUpdateAfter', - - 'actionObjectSpecificPriceAddAfter', - 'actionObjectSpecificPriceDeleteAfter', - 'actionObjectSpecificPriceUpdateAfter', - - 'actionObjectStateAddAfter', - 'actionObjectStateDeleteAfter', - 'actionObjectStateUpdateAfter', - - 'actionObjectStockAddAfter', - 'actionObjectStockUpdateAfter', - - 'actionObjectStoreAddAfter', - 'actionObjectStoreDeleteAfter', - 'actionObjectStoreUpdateAfter', - - 'actionObjectSupplierAddAfter', - 'actionObjectSupplierDeleteAfter', - 'actionObjectSupplierUpdateAfter', - - 'actionObjectTaxAddAfter', - 'actionObjectTaxDeleteAfter', - 'actionObjectTaxRulesGroupAddAfter', - 'actionObjectTaxRulesGroupDeleteAfter', - 'actionObjectTaxRulesGroupUpdateAfter', - 'actionObjectTaxUpdateAfter', - - 'actionObjectWishlistAddAfter', - 'actionObjectWishlistDeleteAfter', - 'actionObjectWishlistUpdateAfter', - - 'actionObjectZoneAddAfter', - 'actionObjectZoneDeleteAfter', - 'actionObjectZoneUpdateAfter', - - 'actionShippingPreferencesPageSave', - - 'actionObjectEmployeeAddAfter', - 'actionObjectEmployeeDeleteAfter', - 'actionObjectEmployeeUpdateAfter', - - 'actionDispatcherBefore', - ]; - - /** - * @var PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer + * @var ServiceContainer */ private $serviceContainer; @@ -258,7 +164,7 @@ public function install() return $installer->installDatabaseTables() && parent::install() - && $this->registerHook($this->hookToInstall); + && $this->registerHook($this->getHooks()); } /** @@ -323,1435 +229,6 @@ public function getService($serviceName) return $this->getServiceContainer()->getService($serviceName); } - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectImageDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $image = $parameters['object']; - - if (isset($image->id_product)) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectImageAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $image = $parameters['object']; - if (isset($image->id_product)) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectImageUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $image = $parameters['object']; - if (isset($image->id_product)) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectLanguageDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $language = $parameters['object']; - if (isset($language->id)) { - $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); - $synchronizationService->insertDeletedObject( - $language->id, - Config::COLLECTION_LANGUAGES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectLanguageAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectLanguageUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectManufacturerDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $manufacturer = $parameters['object']; - if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectManufacturerAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $manufacturer = $parameters['object']; - if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectManufacturerUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $manufacturer = $parameters['object']; - if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSupplierDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $supplier = $parameters['object']; - if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); - $synchronizationService->insertDeletedObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSupplierAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $supplier = $parameters['object']; - if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSupplierUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $supplier = $parameters['object']; - if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectProductDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectProductAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectProductUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Product $product */ - $product = $parameters['object']; - - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectWishlistDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $wishlist = $parameters['object']; - if (isset($wishlist->id)) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); - $synchronizationService->insertDeletedObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectWishlistAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $wishlist = $parameters['object']; - if (isset($wishlist->id)) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectWishlistUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $wishlist = $parameters['object']; - if (isset($wishlist->id)) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStockAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $stock = $parameters['object']; - if (isset($stock->id)) { - $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStockUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $stock = $parameters['object']; - if (isset($stock->id)) { - $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStoreDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_STORES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStoreAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_STORES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStoreUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $store = $parameters['object']; - if (isset($store->id)) { - $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $store->id, - Config::COLLECTION_STORES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCombinationDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Combination $combination */ - $combination = $parameters['object']; - - if (isset($combination->id)) { - $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); - $synchronizationService->insertDeletedObject( - $combination->id, - Config::COLLECTION_PRODUCT_ATTRIBUTES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCategoryAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $category = $parameters['object']; - - if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCategoryUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $category = $parameters['object']; - - if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCategoryDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $category = $parameters['object']; - - if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); - $synchronizationService->insertDeletedObject( - $category->id, - Config::COLLECTION_CATEGORIES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCustomerAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $customer = $parameters['object']; - - if (isset($customer->id)) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCustomerUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $customer = $parameters['object']; - - if (isset($customer->id)) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCustomerDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $customer = $parameters['object']; - - if (isset($customer->id)) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCurrencyAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $currency = $parameters['object']; - - if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCurrencyUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $currency = $parameters['object']; - - if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCurrencyDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $currency = $parameters['object']; - - if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); - $synchronizationService->insertDeletedObject( - $currency->id, - Config::COLLECTION_CURRENCIES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cart = $parameters['object']; - - if (isset($cart->id)) { - $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cart = $parameters['object']; - - if (isset($cart->id)) { - $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartRuleAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cartRule = $parameters['object']; - - if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartRuleDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cartRule = $parameters['object']; - - if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartRuleUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cartRule = $parameters['object']; - - if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectOrderAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $order = $parameters['object']; - - if (isset($order->id)) { - $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectOrderUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $order = $parameters['object']; - - if (isset($order->id)) { - $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCarrierAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ - $carrier = $parameters['object']; - - if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCarrierUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ - $carrier = $parameters['object']; - - if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCarrierDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ - $carrier = $parameters['object']; - - if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @return void - */ - public function hookActionObjectCountryAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectCountryUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectCountryDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectStateAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectStateUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectStateDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectZoneAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectZoneUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectZoneDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxRulesGroupAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxRulesGroupUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxRulesGroupDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionShippingPreferencesPageSave() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectEmployeeAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectEmployeeDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertDeletedObject( - 0, - Config::COLLECTION_EMPLOYEES, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectEmployeeUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * This is global hook. This hook is called at the beginning of the dispatch method of the Dispatcher - * It's possible to use this hook all time when we don't have specific hook. - * Available since: 1.7.1 - * - * Unable to use hookActionDispatcherAfter. Seem to be have a strange effect. When i use - * this hook and try to dump() the content, no dump appears in the symfony debugger, and no more hooks appear. - * For security reasons, I like to use the before hook, and put it in a try/catch - * - * @param array $parameters - * - * @return void - */ - public function hookActionDispatcherBefore($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - try { - /* - * Class "ActionDispatcherLegacyHooksSubscriber" as implement in 1.7.3.0: - * https://github.com/PrestaShop/PrestaShop/commit/a4ae4544cc62c818aba8b3d9254308f538b7acdc - */ - if ($parameters['controller_type'] != 2) { - return; - } - - if (array_key_exists('route', $parameters)) { - $route = $parameters['route']; - - // when translation is edited or reset, add to incremental sync - if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_TRANSLATIONS, - date(DATE_ATOM), - $this->shopId - ); - } - } - } catch (Exception $e) { - return; - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSpecificPriceAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var SpecificPrice $specificPrice */ - $specificPrice = $parameters['object']; - - if ($specificPrice instanceof SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, - date(DATE_ATOM), - $this->shopId - ); - } - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSpecificPriceUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var SpecificPrice $specificPrice */ - $specificPrice = $parameters['object']; - - if ($specificPrice instanceof SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, - date(DATE_ATOM), - $this->shopId - ); - } - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSpecificPriceDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var SpecificPrice $specificPrice */ - $specificPrice = $parameters['object']; - - if ($specificPrice instanceof SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); - $synchronizationService->insertDeletedObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, - date(DATE_ATOM), - $this->shopId - ); - } - } - } - /** * Set PHP compatibility to 7.1 * diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php new file mode 100644 index 00000000..99fd9fcb --- /dev/null +++ b/src/Traits/UseHooks.php @@ -0,0 +1,1533 @@ + $parameters + * + * @return void + */ + public function hookActionObjectImageDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $image = $parameters['object']; + + if (isset($image->id_product)) { + $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); + $synchronizationService->insertIncrementalSyncObject( + $image->id_product, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectImageAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $image = $parameters['object']; + if (isset($image->id_product)) { + $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $image->id_product, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectImageUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $image = $parameters['object']; + if (isset($image->id_product)) { + $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $image->id_product, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectLanguageDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $language = $parameters['object']; + if (isset($language->id)) { + $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); + $synchronizationService->insertDeletedObject( + $language->id, + Config::COLLECTION_LANGUAGES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectLanguageAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $language = $parameters['object']; + if (isset($language->id) && isset($language->id_product)) { + $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $language->id, + Config::COLLECTION_LANGUAGES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectLanguageUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $language = $parameters['object']; + if (isset($language->id) && isset($language->id_product)) { + $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $language->id, + Config::COLLECTION_LANGUAGES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectManufacturerDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { + $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); + $synchronizationService->insertDeletedObject( + $manufacturer->id, + Config::COLLECTION_MANUFACTURERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectManufacturerAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { + $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $manufacturer->id, + Config::COLLECTION_MANUFACTURERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectManufacturerUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { + $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $manufacturer->id, + Config::COLLECTION_MANUFACTURERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSupplierDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $supplier = $parameters['object']; + if (isset($supplier->id)) { + $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); + $synchronizationService->insertDeletedObject( + $supplier->id, + Config::COLLECTION_SUPPLIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSupplierAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $supplier = $parameters['object']; + if (isset($supplier->id)) { + $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $supplier->id, + Config::COLLECTION_SUPPLIERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSupplierUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $supplier = $parameters['object']; + if (isset($supplier->id)) { + $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $supplier->id, + Config::COLLECTION_SUPPLIERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectProductDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + + if (isset($product->id)) { + $synchronizationService->sendLiveSync('products', $product->id, 'delete'); + $synchronizationService->insertDeletedObject( + $product->id, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectProductAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + if (isset($product->id)) { + $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + + $synchronizationService->insertIncrementalSyncObject( + $product->id, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectProductUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Product $product */ + $product = $parameters['object']; + + if (isset($product->id)) { + $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + + $synchronizationService->insertIncrementalSyncObject( + $product->id, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectWishlistDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $wishlist = $parameters['object']; + if (isset($wishlist->id)) { + $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); + $synchronizationService->insertDeletedObject( + $wishlist->id, + Config::COLLECTION_WISHLISTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectWishlistAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $wishlist = $parameters['object']; + if (isset($wishlist->id)) { + $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $wishlist->id, + Config::COLLECTION_WISHLISTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectWishlistUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $wishlist = $parameters['object']; + if (isset($wishlist->id)) { + $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $wishlist->id, + Config::COLLECTION_WISHLISTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStockAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $stock = $parameters['object']; + if (isset($stock->id)) { + $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $stock->id, + Config::COLLECTION_STOCKS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStockUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $stock = $parameters['object']; + if (isset($stock->id)) { + $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $stock->id, + Config::COLLECTION_STOCKS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStoreDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + if (isset($product->id)) { + $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); + $synchronizationService->insertDeletedObject( + $product->id, + Config::COLLECTION_STORES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStoreAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + if (isset($product->id)) { + $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $product->id, + Config::COLLECTION_STORES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStoreUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $store = $parameters['object']; + if (isset($store->id)) { + $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $store->id, + Config::COLLECTION_STORES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCombinationDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Combination $combination */ + $combination = $parameters['object']; + + if (isset($combination->id)) { + $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); + $synchronizationService->insertDeletedObject( + $combination->id, + Config::COLLECTION_PRODUCT_ATTRIBUTES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCategoryAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $category = $parameters['object']; + + if (isset($category->id)) { + $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $category->id, + Config::COLLECTION_CATEGORIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCategoryUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $category = $parameters['object']; + + if (isset($category->id)) { + $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $category->id, + Config::COLLECTION_CATEGORIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCategoryDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $category = $parameters['object']; + + if (isset($category->id)) { + $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); + $synchronizationService->insertDeletedObject( + $category->id, + Config::COLLECTION_CATEGORIES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCustomerAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $customer = $parameters['object']; + + if (isset($customer->id)) { + $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $customer->id, + Config::COLLECTION_CUSTOMERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCustomerUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $customer = $parameters['object']; + + if (isset($customer->id)) { + $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $customer->id, + Config::COLLECTION_CUSTOMERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCustomerDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $customer = $parameters['object']; + + if (isset($customer->id)) { + $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); + $synchronizationService->insertDeletedObject( + $customer->id, + Config::COLLECTION_CUSTOMERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCurrencyAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $currency = $parameters['object']; + + if (isset($currency->id)) { + $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $currency->id, + Config::COLLECTION_CURRENCIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCurrencyUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $currency = $parameters['object']; + + if (isset($currency->id)) { + $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $currency->id, + Config::COLLECTION_CURRENCIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCurrencyDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $currency = $parameters['object']; + + if (isset($currency->id)) { + $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); + $synchronizationService->insertDeletedObject( + $currency->id, + Config::COLLECTION_CURRENCIES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cart = $parameters['object']; + + if (isset($cart->id)) { + $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cart->id, + Config::COLLECTION_CARTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cart = $parameters['object']; + + if (isset($cart->id)) { + $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cart->id, + Config::COLLECTION_CARTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartRuleAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cartRule = $parameters['object']; + + if (isset($cartRule->id)) { + $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cartRule->id, + Config::COLLECTION_CART_RULES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartRuleDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cartRule = $parameters['object']; + + if (isset($cartRule->id)) { + $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'delete'); + $synchronizationService->insertIncrementalSyncObject( + $cartRule->id, + Config::COLLECTION_CART_RULES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartRuleUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cartRule = $parameters['object']; + + if (isset($cartRule->id)) { + $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cartRule->id, + Config::COLLECTION_CART_RULES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectOrderAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $order = $parameters['object']; + + if (isset($order->id)) { + $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $order->id, + Config::COLLECTION_ORDERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectOrderUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $order = $parameters['object']; + + if (isset($order->id)) { + $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $order->id, + Config::COLLECTION_ORDERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCarrierAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Carrier $carrier */ + $carrier = $parameters['object']; + + if (isset($carrier->id)) { + $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $carrier->id, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCarrierUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Carrier $carrier */ + $carrier = $parameters['object']; + + if (isset($carrier->id)) { + $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $carrier->id, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCarrierDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Carrier $carrier */ + $carrier = $parameters['object']; + + if (isset($carrier->id)) { + $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); + $synchronizationService->insertIncrementalSyncObject( + $carrier->id, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @return void + */ + public function hookActionObjectCountryAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectCountryUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectCountryDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectStateAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectStateUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectStateDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectZoneAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectZoneUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectZoneDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxRulesGroupAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxRulesGroupUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxRulesGroupDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionShippingPreferencesPageSave() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectEmployeeAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_EMPLOYEES, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectEmployeeDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService->insertDeletedObject( + 0, + Config::COLLECTION_EMPLOYEES, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectEmployeeUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_EMPLOYEES, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * This is global hook. This hook is called at the beginning of the dispatch method of the Dispatcher + * It's possible to use this hook all time when we don't have specific hook. + * Available since: 1.7.1 + * + * Unable to use hookActionDispatcherAfter. Seem to be have a strange effect. When i use + * this hook and try to dump() the content, no dump appears in the symfony debugger, and no more hooks appear. + * For security reasons, I like to use the before hook, and put it in a try/catch + * + * @param array $parameters + * + * @return void + */ + public function hookActionDispatcherBefore($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + try { + /* + * Class "ActionDispatcherLegacyHooksSubscriber" as implement in 1.7.3.0: + * https://github.com/PrestaShop/PrestaShop/commit/a4ae4544cc62c818aba8b3d9254308f538b7acdc + */ + if ($parameters['controller_type'] != 2) { + return; + } + + if (array_key_exists('route', $parameters)) { + $route = $parameters['route']; + + // when translation is edited or reset, add to incremental sync + if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_TRANSLATIONS, + date(DATE_ATOM), + $this->shopId + ); + } + } + } catch (Exception $e) { + return; + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSpecificPriceAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var SpecificPrice $specificPrice */ + $specificPrice = $parameters['object']; + + if ($specificPrice instanceof SpecificPrice) { + if (isset($specificPrice->id)) { + $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $specificPrice->id, + Config::COLLECTION_SPECIFIC_PRICES, + date(DATE_ATOM), + $this->shopId + ); + } + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSpecificPriceUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var SpecificPrice $specificPrice */ + $specificPrice = $parameters['object']; + + if ($specificPrice instanceof SpecificPrice) { + if (isset($specificPrice->id)) { + $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $specificPrice->id, + Config::COLLECTION_SPECIFIC_PRICES, + date(DATE_ATOM), + $this->shopId + ); + } + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSpecificPriceDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var SpecificPrice $specificPrice */ + $specificPrice = $parameters['object']; + + if ($specificPrice instanceof SpecificPrice) { + if (isset($specificPrice->id)) { + $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); + $synchronizationService->insertDeletedObject( + $specificPrice->id, + Config::COLLECTION_SPECIFIC_PRICES, + date(DATE_ATOM), + $this->shopId + ); + } + } + } +} From 0f258bb9398f8b734a6c84427f5b5e4a9d517b7d Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 26 Jul 2024 17:18:05 +0200 Subject: [PATCH 002/162] refactor: synchronization service and connected services --- src/Config/Config.php | 9 + src/Controller/AbstractApiController.php | 4 +- .../ShopContentServiceInterface.php | 10 + src/Service/SynchronizationService.php | 229 +++++++++--------- 4 files changed, 136 insertions(+), 116 deletions(-) create mode 100644 src/Interfaces/ShopContentServiceInterface.php diff --git a/src/Config/Config.php b/src/Config/Config.php index bcf698ef..3116edc9 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 e5b34bf8..a708d3c3 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 00000000..b52c7760 --- /dev/null +++ b/src/Interfaces/ShopContentServiceInterface.php @@ -0,0 +1,10 @@ +module = $module; $this->eventbusSyncRepository = $eventbusSyncRepository; $this->incrementalSyncRepository = $incrementalSyncRepository; $this->liveSyncRepository = $liveSyncRepository; $this->deletedObjectsRepository = $deletedObjectsRepository; $this->languageRepository = $languageRepository; + $this->proxyService = $proxyService; $this->payloadDecorator = $payloadDecorator; } /** - * @param PaginatedApiDataProviderInterface $dataProvider - * @param string $type + * @param string $shopContent * @param string $jobId * @param string $langIso * @param int $offset * @param int $limit + * @param int $startTime * @param string $dateNow - * @param int $scriptStartTime - * @param bool $isFull + * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException|ApiException */ - public function handleFullSync( - PaginatedApiDataProviderInterface $dataProvider, - $type, - $jobId, - $langIso, - $offset, - $limit, - $dateNow, - $scriptStartTime, - $isFull + public function sendFullSync( + string $shopContent, + string $jobId, + string $langIso, + int $offset, + int $limit, + int $startTime, + string $dateNow, + bool $debug ) { $response = []; - $data = $dataProvider->getFormattedData($offset, $limit, $langIso); + $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceId = 'PrestaShop\Module\PsEventbusV4\Services\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent + + /** @var Ps_eventbus */ + $module = \Module::getInstanceByName('ps_eventbus'); + + if (!$module->hasService($serviceId)) { + throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + } + + /** @var ShopContentServiceInterface $shopContentApiService */ + $shopContentApiService = $this->module->getService($serviceId); + + /** @var ConfigurationRepository $configurationRepository */ + $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + + $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); + $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); + + $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $debug); $this->payloadDecorator->convertDateFormat($data); if (!empty($data)) { - /** @var ProxyService */ - $proxyService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\ProxyService'); - - $response = $proxyService->upload($jobId, $data, $scriptStartTime, $isFull); + $response = $this->proxyService->upload($jobId, $data, $startTime, true); if ($response['httpCode'] == 201) { $offset += $limit; } } - $remainingObjects = (int) $dataProvider->getRemainingObjectsCount($offset, $langIso); + $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $langIso); if ($remainingObjects <= 0) { $remainingObjects = 0; $offset = 0; } - $this->eventbusSyncRepository->updateTypeSync($type, $offset, $dateNow, $remainingObjects === 0, $langIso); + $this->eventbusSyncRepository->updateTypeSync($shopContent, $offset, $dateNow, $remainingObjects === 0, $langIso); return $this->returnSyncResponse($data, $response, $remainingObjects); } /** - * @param PaginatedApiDataProviderInterface $dataProvider * @param string $type * @param string $jobId - * @param int $limit * @param string $langIso - * @param int $scriptStartTime - * @param bool $isFull + * @param int $limit + * @param int $startTime + * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException */ - public function handleIncrementalSync( - PaginatedApiDataProviderInterface $dataProvider, - $type, - $jobId, - $limit, - $langIso, - $scriptStartTime, - $isFull + public function sendIncrementalSync( + string $shopContent, + string $jobId, + string $langIso, + int $limit, + int $startTime, + bool $debug ) { $response = []; - $objectIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($type, $langIso, $limit); + $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + + /** @var ShopContentServiceInterface $shopContentApiService */ + $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Services\\' . $serviceName . 'Service'); + + $contentIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($shopContent, $langIso, $limit); - if (empty($objectIds)) { + if (empty($contentIds)) { return [ 'total_objects' => 0, 'has_remaining_objects' => false, @@ -164,24 +179,21 @@ public function handleIncrementalSync( ]; } - $data = $dataProvider->getFormattedDataIncremental($limit, $langIso, $objectIds); + $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso, $debug); $this->payloadDecorator->convertDateFormat($data); if (!empty($data)) { - /** @var ProxyService */ - $proxyService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\ProxyService'); - - $response = $proxyService->upload($jobId, $data, $scriptStartTime, $isFull); + $response = $this->proxyService->upload($jobId, $data, $startTime, false); if ($response['httpCode'] == 201) { - $this->incrementalSyncRepository->removeIncrementalSyncObjects($type, $objectIds, $langIso); + $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, $contentIds, $langIso); } } else { - $this->incrementalSyncRepository->removeIncrementalSyncObjects($type, $objectIds, $langIso); + $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, $contentIds, $langIso); } - $remainingObjects = $this->incrementalSyncRepository->getRemainingIncrementalObjects($type, $langIso); + $remainingObjects = $this->incrementalSyncRepository->getRemainingIncrementalObjects($shopContent, $langIso); return $this->returnSyncResponse($data, $response, $remainingObjects); } @@ -203,17 +215,17 @@ public function sendLiveSync($shopContent, $shopContentId, $action) } /** - * @param int $objectId - * @param string $type + * @param array> $contentTypesWithIds + * @param string actionType * @param string $createdAt * @param int $shopId * @param bool $hasMultiLang * * @return void */ - public function insertIncrementalSyncObject($objectId, $type, $createdAt, $shopId, $hasMultiLang = null) + public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $createdAt, $shopId, $hasMultiLang = null) { - if ((int) $objectId === 0) { + if (count($contentTypesWithIds) == 0) { return; } @@ -222,80 +234,71 @@ public function insertIncrementalSyncObject($objectId, $type, $createdAt, $shopI * When random number == 10, we count number of entry exist in database for this specific shop content * If count > 100 000, we removed all entry corresponding to this shop content, and we enable full sync for this */ - if (mt_rand() % $this::RANDOM_SYNC_CHECK_MAX == 0) { - $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($type); - if ($count > $this::INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT) { - $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($type); - - if ($hasDeleted) { - $this->eventbusSyncRepository->updateTypeSync( - $type, - 0, - $createdAt, - false, - $this->languageRepository->getDefaultLanguageIsoCode() - ); + if (mt_rand() % Config::RANDOM_SYNC_CHECK_MAX == 0) { + foreach($contentTypesWithIds as $contentType => $contentIds) { + $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($contentType); + + if ($count > Config::INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT) { + $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); + + if ($hasDeleted) { + $this->eventbusSyncRepository->updateTypeSync( + $contentType, + 0, + $createdAt, + false, + $this->languageRepository->getDefaultLanguageIsoCode() + ); + } } - } - return; + return; + } } - $objectsData = []; + $contentToInsert = []; if ($hasMultiLang) { $allIsoCodes = $this->languageRepository->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { - if ($this->isFullSyncDone($type, $langIso)) { - array_push($objectsData, + foreach($contentTypesWithIds as $contentType => $contentIds) { + if ($this->isFullSyncDone($contentType, $langIso)) { + array_push($contentToInsert, + [ + 'type' => $contentType, + 'id_object' => $contentIds, + 'id_shop' => $shopId, + 'lang_iso' => $langIso, + 'action' => $actionType, + 'created_at' => $createdAt, + ] + ); + } + } + } + } else { + $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + + foreach($contentTypesWithIds as $contentType => $contentIds) { + if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { + array_push($contentToInsert, [ - 'type' => $type, - 'id_object' => $objectId, + 'type' => $contentType, + 'id_object' => $contentIds, 'id_shop' => $shopId, - 'lang_iso' => $langIso, + 'lang_iso' => $defaultIsoCode, + 'action' => $actionType, 'created_at' => $createdAt, ] ); } } - } else { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - - if ($this->isFullSyncDone($type, $defaultIsoCode)) { - array_push($objectsData, - [ - 'type' => $type, - 'id_object' => $objectId, - 'id_shop' => $shopId, - 'lang_iso' => $defaultIsoCode, - 'created_at' => $createdAt, - ] - ); - } - } - - if (empty($objectsData) == false) { - $this->incrementalSyncRepository->insertIncrementalObject($objectsData); } - } - /** - * @param int $objectId - * @param string $type - * @param string $date - * @param int $shopId - * - * @return void - */ - public function insertDeletedObject($objectId, $type, $date, $shopId) - { - if ((int) $objectId === 0) { - return; + if (empty($contentToInsert) == false) { + $this->incrementalSyncRepository->insertIncrementalObject($contentToInsert); } - - $this->deletedObjectsRepository->insertDeletedObject($objectId, $type, $date, $shopId); - $this->incrementalSyncRepository->removeIncrementalSyncObject($type, $objectId); } /** From 30bed6550611ad26e714af35eba68f4f26ce205c Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 10:44:27 +0200 Subject: [PATCH 003/162] feature: add upgrade script --- upgrade/Upgrade-4.0.0.php | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 upgrade/Upgrade-4.0.0.php diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php new file mode 100644 index 00000000..20cfed1c --- /dev/null +++ b/upgrade/Upgrade-4.0.0.php @@ -0,0 +1,66 @@ +query($editIncrementalTable); + + // If ALTER is failed, stop update process + if (!$editIncrementalTableResult) { + return false; + } + + // Backup data from eventbus_deleted_objects + $backupDeletedTable = 'SELECT * FROM `' . _DB_PREFIX_ . 'eventbus_deleted_objects`'; + $backupDeletedTableResult = $db->executeS($backupDeletedTable); + + $elementsCount = count($backupDeletedTableResult); + $index = 0; + + // Insert data from backup into incremental table + $updateIncrementalTable = 'INSERT INTO `' . _DB_PREFIX_ . 'eventbus_incremental_sync` (type, id_object, id_shop, lang_iso, created_at, action) VALUES '; + + foreach ($backupDeletedTableResult as $deletedContent) { + $updateIncrementalTable .= "( + '{$db->escape($deletedContent['type'])}', + {$db->escape($deletedContent['id_object'])}, + {$db->escape($deletedContent['id_shop'])}, + {$db->escape($deletedContent['created_at'])}', + deleted' + )"; + + if (++$index < $elementsCount) { + $updateIncrementalTable .= ','; + } + } + + $updateIncrementalTable .= ' + ON DUPLICATE KEY UPDATE + type = VALUES(type), + id_object = VALUES(id_object), + id_shop = VALUES(id_shop), + created_at = VALUES(created_at) + action = deleted + '; + + $updateIncrementalTableResult = (bool) $db->query($updateIncrementalTable); + + // If insert backup is failed, stop update process + if (!$updateIncrementalTableResult) { + return false; + } + + // Drop eventbus_deleted_objects table + $dropDeletedTable = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'eventbus_deleted_objects`'; + $dropDeletedTableResult = (bool) $db->query($dropDeletedTable); + + return $dropDeletedTableResult; +} From df955c4b7f5879ade5478d4b889b1e57403f2db4 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 10:45:01 +0200 Subject: [PATCH 004/162] fix: update service.yml --- config/front/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/front/services.yml b/config/front/services.yml index a68ff670..b36538f0 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -59,6 +59,7 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - '@PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator' PrestaShop\Module\PsEventbus\Service\SpecificPriceService: From 431f372355d7b92acf8155dcf8f1da1d0544d5f0 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 16:11:34 +0200 Subject: [PATCH 005/162] feat: add front service --- controllers/front/apiFront.php | 38 +++++ src/Config/Config.php | 49 +++++-- src/Service/FrontApiService.php | 248 ++++++++++++++++++++++++++++++++ 3 files changed, 327 insertions(+), 8 deletions(-) create mode 100644 controllers/front/apiFront.php create mode 100644 src/Service/FrontApiService.php diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php new file mode 100644 index 00000000..02204b09 --- /dev/null +++ b/controllers/front/apiFront.php @@ -0,0 +1,38 @@ +module->getService('PrestaShop\Module\PsEventbusV4\Services\ApiService'); + + $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); + } +} + diff --git a/src/Config/Config.php b/src/Config/Config.php index 3116edc9..5b8be4ad 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -4,6 +4,11 @@ class Config { + 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 SYNC_API_MAX_TIMEOUT = 5; const COLLECTOR_MAX_TIMEOUT = 30; const COLLECTOR_MULTIPART_BOUNDARY = 'ps_eventbus_boundary'; @@ -62,14 +67,42 @@ 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'; + public const SHOP_CONTENTS = [ + self::COLLECTION_BUNDLES, + self::COLLECTION_CARRIERS, + self::COLLECTION_CARTS, + self::COLLECTION_CART_PRODUCTS, + self::COLLECTION_CART_RULES, + self::COLLECTION_CATEGORIES, + self::COLLECTION_CURRENCIES, + self::COLLECTION_CUSTOM_PRODUCT_CARRIERS, + self::COLLECTION_CUSTOMERS, + self::COLLECTION_DELETED, + self::COLLECTION_EMPLOYEES, + self::COLLECTION_IMAGES, + self::COLLECTION_IMAGE_TYPES, + self::COLLECTION_LANGUAGES, + self::COLLECTION_MANUFACTURERS, + self::COLLECTION_MODULES, + self::COLLECTION_ORDERS, + self::COLLECTION_ORDER_CART_RULES, + self::COLLECTION_ORDER_DETAILS, + self::COLLECTION_ORDER_STATUS_HISTORY, + self::COLLECTION_PRODUCTS, + self::COLLECTION_PRODUCT_ATTRIBUTES, + self::COLLECTION_PRODUCT_SUPPLIERS, + self::COLLECTION_SHOPS, + self::COLLECTION_SPECIFIC_PRICES, + self::COLLECTION_STOCKS, + self::COLLECTION_STOCK_MVTS, + self::COLLECTION_STORES, + self::COLLECTION_SUPPLIERS, + self::COLLECTION_TAXONOMIES, + self::COLLECTION_THEMES, + self::COLLECTION_TRANSLATIONS, + self::COLLECTION_WISHLISTS, + self::COLLECTION_WISHLIST_PRODUCTS, + ]; /** * @param mixed $message diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php new file mode 100644 index 00000000..d514481d --- /dev/null +++ b/src/Service/FrontApiService.php @@ -0,0 +1,248 @@ +errorHandler = $this->module->getService(ErrorHandler::class); + + try { + $this->startTime = time(); + + $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); + $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); + $this->synchronizationService = $this->module->getService(SynchronizationService::class); + + $this->authorize(); + } catch (\Exception $exception) { + // For ApiHealthCheck, handle the error, and throw UnauthorizedException directly, to catch-up at top level. + if (strpos(get_class($this), 'apiHealthCheckController') !== false) { + $this->errorHandler->handle($exception); + throw new UnauthorizedException('You are not allowed to access to this resource'); + } + + if ($exception instanceof \PrestaShopDatabaseException) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } elseif ($exception instanceof EnvVarException) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } elseif ($exception instanceof FirebaseException) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } + } + } + + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) + { + try { + if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { + $this->exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); + } + + if ($limit < 0) { + $this->exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); + } + + /** @var ConfigurationRepository $configurationRepository */ + $configurationRepository = $this->module->getService('\PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + + $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); + $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); + + $offset = 0; + $incrementalSync = false; + $response = []; + + $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); + + if ($typeSync == false) { + $this->eventbusSyncRepository->insertTypeSync($shopContent, $offset, $dateNow, $langIso); + } + + if ($isFull) { + $response = $this->synchronizationService->sendFullSync( + $shopContent, + $jobId, + $langIso, + $offset, + $limit, + $this->startTime, + $dateNow, + $debug + ); + } else { + $response = $this->synchronizationService->sendIncrementalSync( + $shopContent, + $jobId, + $langIso, + $limit, + $this->startTime, + $debug + ); + } + + $this->exitWithResponse( + [ + 'job_id' => $jobId, + 'object_type' => $shopContent, + 'syncType' => $incrementalSync ? 'incremental' : 'full', + ], + $response + ); + } catch (\PrestaShopDatabaseException $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } catch (EnvVarException $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } catch (FirebaseException $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } catch (\Exception $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } + } + + /** + * @return void + * + * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException + */ + private function authorize() + { + /** @var string $jobId */ + $jobId = \Tools::getValue('job_id', 'empty_job_id'); + + $authorizationResponse = $this->authorizationService->authorizeCall($jobId); + + if (is_array($authorizationResponse)) { + $this->exitWithResponse($authorizationResponse); + } elseif (!$authorizationResponse) { + throw new \PrestaShopDatabaseException('Failed saving job id to database'); + } + + try { + $token = $this->psAccountsAdapterService->getOrRefreshToken(); + } catch (\Exception $exception) { + throw new FirebaseException($exception->getMessage()); + } + + if (!$token) { + throw new FirebaseException('Invalid token'); + } + } + + /** + * @param array $response + * + * @return void + */ + private function exitWithResponse(array $response) + { + $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; + + $this->dieWithResponse($response, $httpCode); + } + + /** + * @param \Exception $exception + * + * @return void + */ + private function exitWithExceptionMessage(\Exception $exception) + { + $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); + + if ($exception instanceof \PrestaShopDatabaseException) { + $code = Config::DATABASE_QUERY_ERROR_CODE; + } elseif ($exception instanceof EnvVarException) { + $code = Config::ENV_MISCONFIGURED_ERROR_CODE; + } elseif ($exception instanceof FirebaseException) { + $code = Config::REFRESH_TOKEN_ERROR_CODE; + } elseif ($exception instanceof QueryParamsException) { + $code = Config::INVALID_URL_QUERY; + } + + $response = [ + 'object_type' => \Tools::getValue('shopContent'), + 'status' => false, + 'httpCode' => $code, + 'message' => $exception->getMessage(), + ]; + + $this->dieWithResponse($response, (int) $code); + } + + /** + * @param array $response + * @param int $code + * + * @return void + */ + private function dieWithResponse(array $response, $code) + { + $httpStatusText = "HTTP/1.1 $code"; + + if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { + $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; + } elseif (isset($response['body']['statusText'])) { + $httpStatusText .= ' ' . $response['body']['statusText']; + } + + $response['httpCode'] = (int) $code; + + header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); + header('Content-Type: application/json;charset=utf-8'); + header($httpStatusText); + + echo json_encode($response, JSON_UNESCAPED_SLASHES); + + exit; + } +} From bcc66e6513c5835a4b5a2144e809505d84949152 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 16:11:56 +0200 Subject: [PATCH 006/162] refactor: remove all old front controllers --- controllers/front/apiCarriers.php | 25 -- controllers/front/apiCartRules.php | 25 -- controllers/front/apiCarts.php | 25 -- controllers/front/apiCategories.php | 25 -- controllers/front/apiCurrencies.php | 25 -- .../front/apiCustomProductCarriers.php | 25 -- controllers/front/apiCustomers.php | 25 -- controllers/front/apiDeletedObjects.php | 34 -- controllers/front/apiEmployees.php | 25 -- controllers/front/apiGoogleTaxonomies.php | 29 -- controllers/front/apiHealthCheck.php | 46 --- controllers/front/apiImageTypes.php | 25 -- controllers/front/apiImages.php | 25 -- controllers/front/apiInfo.php | 51 --- controllers/front/apiLanguages.php | 25 -- controllers/front/apiManufacturers.php | 25 -- controllers/front/apiModules.php | 25 -- controllers/front/apiOrders.php | 25 -- controllers/front/apiProducts.php | 25 -- controllers/front/apiSpecificPrices.php | 25 -- controllers/front/apiStocks.php | 25 -- controllers/front/apiStores.php | 25 -- controllers/front/apiSuppliers.php | 25 -- controllers/front/apiThemes.php | 51 --- controllers/front/apiTranslations.php | 25 -- controllers/front/apiWishlists.php | 25 -- src/Controller/AbstractApiController.php | 358 ------------------ tests/phpstan/phpstan.neon | 1 - 28 files changed, 1095 deletions(-) delete mode 100644 controllers/front/apiCarriers.php delete mode 100644 controllers/front/apiCartRules.php delete mode 100644 controllers/front/apiCarts.php delete mode 100644 controllers/front/apiCategories.php delete mode 100644 controllers/front/apiCurrencies.php delete mode 100644 controllers/front/apiCustomProductCarriers.php delete mode 100644 controllers/front/apiCustomers.php delete mode 100644 controllers/front/apiDeletedObjects.php delete mode 100644 controllers/front/apiEmployees.php delete mode 100644 controllers/front/apiGoogleTaxonomies.php delete mode 100644 controllers/front/apiHealthCheck.php delete mode 100644 controllers/front/apiImageTypes.php delete mode 100644 controllers/front/apiImages.php delete mode 100644 controllers/front/apiInfo.php delete mode 100644 controllers/front/apiLanguages.php delete mode 100644 controllers/front/apiManufacturers.php delete mode 100644 controllers/front/apiModules.php delete mode 100644 controllers/front/apiOrders.php delete mode 100644 controllers/front/apiProducts.php delete mode 100644 controllers/front/apiSpecificPrices.php delete mode 100644 controllers/front/apiStocks.php delete mode 100644 controllers/front/apiStores.php delete mode 100644 controllers/front/apiSuppliers.php delete mode 100644 controllers/front/apiThemes.php delete mode 100644 controllers/front/apiTranslations.php delete mode 100644 controllers/front/apiWishlists.php delete mode 100644 src/Controller/AbstractApiController.php diff --git a/controllers/front/apiCarriers.php b/controllers/front/apiCarriers.php deleted file mode 100644 index 2322915c..00000000 --- a/controllers/front/apiCarriers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CarrierDataProvider::class); - - $response = $this->handleDataSync($carrierDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCartRules.php b/controllers/front/apiCartRules.php deleted file mode 100644 index 9756bbfa..00000000 --- a/controllers/front/apiCartRules.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CartRuleDataProvider::class); - - $response = $this->handleDataSync($cartRuleDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCarts.php b/controllers/front/apiCarts.php deleted file mode 100644 index 5389995b..00000000 --- a/controllers/front/apiCarts.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CartDataProvider::class); - - $response = $this->handleDataSync($cartDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCategories.php b/controllers/front/apiCategories.php deleted file mode 100644 index 32de69d1..00000000 --- a/controllers/front/apiCategories.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CategoryDataProvider::class); - - $response = $this->handleDataSync($categoryDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCurrencies.php b/controllers/front/apiCurrencies.php deleted file mode 100644 index 9e39daa3..00000000 --- a/controllers/front/apiCurrencies.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CurrencyDataProvider::class); - - $response = $this->handleDataSync($currencyDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCustomProductCarriers.php b/controllers/front/apiCustomProductCarriers.php deleted file mode 100644 index 925ed474..00000000 --- a/controllers/front/apiCustomProductCarriers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CustomProductCarrierDataProvider::class); - - $response = $this->handleDataSync($categoryDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCustomers.php b/controllers/front/apiCustomers.php deleted file mode 100644 index bb334118..00000000 --- a/controllers/front/apiCustomers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CustomerDataProvider::class); - - $response = $this->handleDataSync($customerDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiDeletedObjects.php b/controllers/front/apiDeletedObjects.php deleted file mode 100644 index 0a589df7..00000000 --- a/controllers/front/apiDeletedObjects.php +++ /dev/null @@ -1,34 +0,0 @@ -module->getService(DeletedObjectsService::class); - - try { - $response = $deletedObjectsService->handleDeletedObjectsSync($jobId, $this->startTime); - $this->exitWithResponse($response); - } catch (PrestaShopDatabaseException $exception) { - $this->exitWithExceptionMessage($exception); - } catch (EnvVarException $exception) { - $this->exitWithExceptionMessage($exception); - } - } -} diff --git a/controllers/front/apiEmployees.php b/controllers/front/apiEmployees.php deleted file mode 100644 index 0060c415..00000000 --- a/controllers/front/apiEmployees.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(EmployeeDataProvider::class); - - $response = $this->handleDataSync($employeeDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiGoogleTaxonomies.php b/controllers/front/apiGoogleTaxonomies.php deleted file mode 100644 index 01fc2316..00000000 --- a/controllers/front/apiGoogleTaxonomies.php +++ /dev/null @@ -1,29 +0,0 @@ -exitWithExceptionMessage(new Exception('Facebook module is not installed', Config::PS_FACEBOOK_NOT_INSTALLED)); - } - - /** @var GoogleTaxonomyDataProvider $categoryDataProvider */ - $categoryDataProvider = $this->module->getService(GoogleTaxonomyDataProvider::class); - - $response = $this->handleDataSync($categoryDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiHealthCheck.php b/controllers/front/apiHealthCheck.php deleted file mode 100644 index f1c32b69..00000000 --- a/controllers/front/apiHealthCheck.php +++ /dev/null @@ -1,46 +0,0 @@ -isAuthentifiedCall = false; - } - */ - } - - /** - * @return void - * - * @throws PrestaShopException - */ - public function postProcess() - { - /** @var ServerInformationRepository $serverInformationRepository */ - $serverInformationRepository = $this->module->getService(ServerInformationRepository::class); - - $status = $serverInformationRepository->getHealthCheckData($this->isAuthentifiedCall); - - $this->exitWithResponse($status); - } -} diff --git a/controllers/front/apiImageTypes.php b/controllers/front/apiImageTypes.php deleted file mode 100644 index 1c1f1803..00000000 --- a/controllers/front/apiImageTypes.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ImageTypeDataProvider::class); - - $response = $this->handleDataSync($imageTypeDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiImages.php b/controllers/front/apiImages.php deleted file mode 100644 index 87eea66f..00000000 --- a/controllers/front/apiImages.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ImageDataProvider::class); - - $response = $this->handleDataSync($imageDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiInfo.php b/controllers/front/apiInfo.php deleted file mode 100644 index 7115ed53..00000000 --- a/controllers/front/apiInfo.php +++ /dev/null @@ -1,51 +0,0 @@ -module->getService(ServerInformationRepository::class); - - /** @var string $langIso */ - $langIso = Tools::getValue('lang_iso', ''); - $serverInfo = $serverInformationRepository->getServerInformation($langIso); - - /** @var bool $initFullSync */ - $initFullSync = Tools::getValue('full', 0) == 1; - - try { - $response = $this->proxyService->upload($jobId, $serverInfo, $this->startTime, $initFullSync); - } catch (Exception $exception) { - $this->exitWithExceptionMessage($exception); - } - - $this->exitWithResponse( - array_merge( - [ - 'remaining_objects' => 0, - 'total_objects' => 1, - 'job_id' => $jobId, - 'object_type' => $this->type, - 'syncType' => 'full', - ], - $response - ) - ); - } -} diff --git a/controllers/front/apiLanguages.php b/controllers/front/apiLanguages.php deleted file mode 100644 index 9873ef46..00000000 --- a/controllers/front/apiLanguages.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(LanguageDataProvider::class); - - $response = $this->handleDataSync($languageDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiManufacturers.php b/controllers/front/apiManufacturers.php deleted file mode 100644 index e4ffe227..00000000 --- a/controllers/front/apiManufacturers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ManufacturerDataProvider::class); - - $response = $this->handleDataSync($manufacturerDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiModules.php b/controllers/front/apiModules.php deleted file mode 100644 index f409309a..00000000 --- a/controllers/front/apiModules.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ModuleDataProvider::class); - - $response = $this->handleDataSync($moduleDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiOrders.php b/controllers/front/apiOrders.php deleted file mode 100644 index deb0dd91..00000000 --- a/controllers/front/apiOrders.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(OrderDataProvider::class); - - $response = $this->handleDataSync($orderDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiProducts.php b/controllers/front/apiProducts.php deleted file mode 100644 index a8c835be..00000000 --- a/controllers/front/apiProducts.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ProductDataProvider::class); - - $response = $this->handleDataSync($productDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiSpecificPrices.php b/controllers/front/apiSpecificPrices.php deleted file mode 100644 index ead620c5..00000000 --- a/controllers/front/apiSpecificPrices.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CustomPriceDataProvider::class); - - $response = $this->handleDataSync($productDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiStocks.php b/controllers/front/apiStocks.php deleted file mode 100644 index 99cb7359..00000000 --- a/controllers/front/apiStocks.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(StockDataProvider::class); - - $response = $this->handleDataSync($stockDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiStores.php b/controllers/front/apiStores.php deleted file mode 100644 index 2de5cc70..00000000 --- a/controllers/front/apiStores.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(StoreDataProvider::class); - - $response = $this->handleDataSync($storeDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiSuppliers.php b/controllers/front/apiSuppliers.php deleted file mode 100644 index 46101b2a..00000000 --- a/controllers/front/apiSuppliers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(SupplierDataProvider::class); - - $response = $this->handleDataSync($supplierDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiThemes.php b/controllers/front/apiThemes.php deleted file mode 100644 index dc0e2e5d..00000000 --- a/controllers/front/apiThemes.php +++ /dev/null @@ -1,51 +0,0 @@ -module->getService(ThemeRepository::class); - - /** @var array $themeInfo */ - $themeInfo = $themeRepository->getThemes(); - - /** @var bool $initFullSync */ - $initFullSync = Tools::getValue('full', 0) == 1; - - try { - $response = $this->proxyService->upload($jobId, $themeInfo, $this->startTime, $initFullSync); - } catch (Exception $exception) { - $this->exitWithExceptionMessage($exception); - } - - $this->exitWithResponse( - array_merge( - [ - 'remaining_objects' => 0, - 'total_objects' => count($themeInfo), - 'job_id' => $jobId, - 'object_type' => $this->type, - 'syncType' => 'full', - ], - $response - ) - ); - } -} diff --git a/controllers/front/apiTranslations.php b/controllers/front/apiTranslations.php deleted file mode 100644 index 50e8dd5c..00000000 --- a/controllers/front/apiTranslations.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(TranslationDataProvider::class); - - $response = $this->handleDataSync($translationDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiWishlists.php b/controllers/front/apiWishlists.php deleted file mode 100644 index 42292c1a..00000000 --- a/controllers/front/apiWishlists.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(WishlistDataProvider::class); - - $response = $this->handleDataSync($wishlistDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/src/Controller/AbstractApiController.php b/src/Controller/AbstractApiController.php deleted file mode 100644 index a708d3c3..00000000 --- a/src/Controller/AbstractApiController.php +++ /dev/null @@ -1,358 +0,0 @@ -ajax = true; - $this->content_only = true; - $this->controller_type = 'module'; - - $this->errorHandler = $this->module->getService(ErrorHandler::class); - try { - $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); - $this->proxyService = $this->module->getService(ProxyService::class); - $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); - $this->synchronizationService = $this->module->getService(SynchronizationService::class); - } catch (\Exception $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } - - $this->eventbusSyncRepository = $this->module->getService(EventbusSyncRepository::class); - $this->languageRepository = $this->module->getService(LanguageRepository::class); - $this->incrementalSyncRepository = $this->module->getService(IncrementalSyncRepository::class); - } - - /** - * @return bool|void - * - * @throws UnauthorizedException - */ - public function init() - { - $this->startTime = time(); - - try { - $this->authorize(); - } catch (\Exception $exception) { - // For ApiHealthCheck, handle the error, and throw UnauthorizedException directly, to catch-up at top level. - if (strpos($this->page_name, 'apiHealthCheck') !== false) { - $this->errorHandler->handle($exception); - throw new UnauthorizedException('You are not allowed to access to this resource'); - } - - if ($exception instanceof \PrestaShopDatabaseException) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } elseif ($exception instanceof EnvVarException) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } elseif ($exception instanceof FirebaseException) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } - } - } - - /** - * @return void - * - * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException - */ - private function authorize() - { - /** @var string $jobId */ - $jobId = \Tools::getValue('job_id', 'empty_job_id'); - - $authorizationResponse = $this->authorizationService->authorizeCall($jobId); - - if (is_array($authorizationResponse)) { - $this->exitWithResponse($authorizationResponse); - } elseif (!$authorizationResponse) { - throw new \PrestaShopDatabaseException('Failed saving job id to database'); - } - - try { - $token = $this->psAccountsAdapterService->getOrRefreshToken(); - } catch (\Exception $exception) { - throw new FirebaseException($exception->getMessage()); - } - - if (!$token) { - throw new FirebaseException('Invalid token'); - } - } - - /** - * @param PaginatedApiDataProviderInterface $dataProvider - * - * @return array - */ - protected function handleDataSync(PaginatedApiDataProviderInterface $dataProvider) - { - /** @var bool $debug */ - $debug = \Tools::getValue('debug') == 1; - - /** @var string $jobId */ - $jobId = \Tools::getValue('job_id'); - /** @var string $langIso */ - $langIso = \Tools::getValue('lang_iso', $this->languageRepository->getDefaultLanguageIsoCode()); - /** @var int $limit */ - $limit = \Tools::getValue('limit', 50); - - if ($limit < 0) { - $this->exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); - } - - /** @var bool $initFullSync */ - $initFullSync = \Tools::getValue('full', 0) == 1; - - /** @var \PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService(\PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository::class); - $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); - - $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); - $offset = 0; - $incrementalSync = false; - $response = []; - - try { - $typeSync = $this->eventbusSyncRepository->findTypeSync($this->type, $langIso); - - if ($debug) { - $response = $dataProvider->getQueryForDebug($offset, $limit, $langIso); - - return array_merge( - [ - 'object_type' => $this->type, - ], - $response - ); - } - - if ($typeSync !== false && is_array($typeSync)) { - $offset = (int) $typeSync['offset']; - - if ((int) $typeSync['full_sync_finished'] === 1 && !$initFullSync) { - $incrementalSync = true; - } elseif ($initFullSync) { - $offset = 0; - $this->eventbusSyncRepository->updateTypeSync( - $this->type, - $offset, - $dateNow, - false, - $langIso - ); - - $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($this->type); - } - } else { - $this->eventbusSyncRepository->insertTypeSync($this->type, $offset, $dateNow, $langIso); - } - - if ($incrementalSync) { - $response = $this->synchronizationService->handleIncrementalSync( - $dataProvider, - $this->type, - $jobId, - $limit, - $langIso, - $this->startTime, - $initFullSync - ); - } else { - $response = $this->synchronizationService->handleFullSync( - $dataProvider, - $this->type, - $jobId, - $langIso, - $offset, - $limit, - $dateNow, - $this->startTime, - $initFullSync - ); - } - - return array_merge( - [ - 'job_id' => $jobId, - 'object_type' => $this->type, - 'syncType' => $incrementalSync ? 'incremental' : 'full', - ], - $response - ); - } catch (\PrestaShopDatabaseException $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } catch (EnvVarException $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } catch (FirebaseException $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } catch (\Exception $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } - - return $response; - } - - /** - * @param array|null $value - * @param string|null $controller - * @param string|null $method - * - * @return void - * - * @throws \PrestaShopException - */ - public function ajaxDie($value = null, $controller = null, $method = null) - { - parent::ajaxDie(json_encode($value) ?: null, $controller, $method); - } - - /** - * @param array $response - * - * @return void - */ - protected function exitWithResponse($response) - { - $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; - - $this->dieWithResponse($response, $httpCode); - } - - /** - * @param \Exception $exception - * - * @return void - */ - protected function exitWithExceptionMessage(\Exception $exception) - { - $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); - - if ($exception instanceof \PrestaShopDatabaseException) { - $code = Config::DATABASE_QUERY_ERROR_CODE; - } elseif ($exception instanceof EnvVarException) { - $code = Config::ENV_MISCONFIGURED_ERROR_CODE; - } elseif ($exception instanceof FirebaseException) { - $code = Config::REFRESH_TOKEN_ERROR_CODE; - } elseif ($exception instanceof QueryParamsException) { - $code = Config::INVALID_URL_QUERY; - } - - $response = [ - 'object_type' => $this->type, - 'status' => false, - 'httpCode' => $code, - 'message' => $exception->getMessage(), - ]; - - $this->dieWithResponse($response, (int) $code); - } - - /** - * @param array $response - * @param int $code - * - * @return void - */ - private function dieWithResponse($response, $code) - { - $httpStatusText = "HTTP/1.1 $code"; - - if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { - $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; - } elseif (isset($response['body']['statusText'])) { - $httpStatusText .= ' ' . $response['body']['statusText']; - } - - $response['httpCode'] = (int) $code; - - header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); - header('Content-Type: application/json;charset=utf-8'); - header($httpStatusText); - - echo json_encode($response, JSON_UNESCAPED_SLASHES); - - exit; - } -} diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index 5114a8eb..c6958554 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -17,7 +17,6 @@ parameters: - '#Cannot call method getOrRefreshToken\(\) on mixed.#' - '#Cannot call method getMetadata\(\) on mixed.#' - '#Method PrestaShop\\Module\\PsEventbus\\Api\\Post\\PostFileApi::getContent\(\) should return Psr\\Http\\Message\\StreamInterface but returns mixed.#' - - '#Property PrestaShop\\Module\\PsEventbus\\Controller\\AbstractApiController::[a-zA-Z0-9\\_\$\(\) ]+ does not accept mixed.#' - '#Cannot call method getShopUuid\(\) on mixed.#' - '#Cannot call method getPsAccountsService\(\) on mixed.#' - '#Cannot call method handle\(\) on mixed.#' From 56a8fbed18ecec58b93cff20987ed51e07323752 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 16:32:29 +0200 Subject: [PATCH 007/162] feat: rework orders for testing --- src/Repository/AbstractRepository.php | 55 ++++++++ src/Repository/OrderRepository.php | 155 ---------------------- src/Repository/OrdersRepository.php | 93 +++++++++++++ src/Service/ShopContent/OrdersService.php | 35 +++++ 4 files changed, 183 insertions(+), 155 deletions(-) create mode 100644 src/Repository/AbstractRepository.php delete mode 100644 src/Repository/OrderRepository.php create mode 100644 src/Repository/OrdersRepository.php create mode 100644 src/Service/ShopContent/OrdersService.php diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php new file mode 100644 index 00000000..3c178b32 --- /dev/null +++ b/src/Repository/AbstractRepository.php @@ -0,0 +1,55 @@ +context = $context; + $this->db = Db::getInstance(); + } + + public function getShopId() + { + if ($this->context->shop === null) { + throw new \PrestaShopException('No shop context'); + } + + return (int) $this->context->shop->id; + } + + protected function debugQuery() + { + $queryStringified = preg_replace('/\s+/', ' ', $this->query->build()); + + return array_merge( + (array) $this->query, + ['queryStringified' => $queryStringified] + ); + } + + protected function executeQuery() + { + return $this->db->executeS($this->query); + } +} diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php deleted file mode 100644 index a9d6a22b..00000000 --- a/src/Repository/OrderRepository.php +++ /dev/null @@ -1,155 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @param int $shopId - * - * @return \DbQuery - */ - public function getBaseQuery($shopId) - { - $query = new \DbQuery(); - $query->from(self::ORDERS_TABLE, 'o') - ->leftJoin('currency', 'c', 'o.id_currency = c.id_currency') - ->leftJoin('order_slip', 'os', 'o.id_order = os.id_order') - ->leftJoin('address', 'ad', 'ad.id_address = o.id_address_delivery') - ->leftJoin('address', 'ai', 'ai.id_address = o.id_address_invoice') - ->leftJoin('country', 'cntd', 'cntd.id_country = ad.id_country') - ->leftJoin('country', 'cnti', 'cnti.id_country = ai.id_country') - ->leftJoin('order_state_lang', 'osl', 'o.current_state = osl.id_order_state') - ->leftJoin('order_state', 'ost', 'o.current_state = ost.id_order_state') - ->where('o.id_shop = ' . (int) $shopId) - ->groupBy('o.id_order'); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * @param int $shopId - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getOrders($offset, $limit, $shopId) - { - $query = $this->getBaseQuery($shopId); - - $this->addSelectParameters($query); - - $query->limit((int) $limit, (int) $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $shopId - * - * @return int - */ - public function getRemainingOrderCount($offset, $shopId) - { - $orders = $this->getOrders($offset, 1, $shopId); - - if (!is_array($orders) || empty($orders)) { - return 0; - } - - return count($orders); - } - - /** - * @param int $limit - * @param int $shopId - * @param array $orderIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getOrdersIncremental($limit, $shopId, $orderIds) - { - $query = $this->getBaseQuery($shopId); - - $this->addSelectParameters($query); - - $query->where('o.id_order IN(' . implode(',', array_map('intval', $orderIds)) . ')') - ->limit($limit); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * @param int $limit - * @param int $shopId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $shopId) - { - $query = $this->getBaseQuery($shopId); - - $this->addSelectParameters($query); - - $query->limit((int) $limit, (int) $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('o.id_order, o.reference, o.id_customer, o.id_cart, o.current_state'); - $query->select('o.conversion_rate, o.total_paid_tax_excl, o.total_paid_tax_incl'); - $query->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer'); - $query->select('c.iso_code as currency, SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund'); - $query->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl, o.module as payment_module'); - $query->select('o.payment as payment_mode, o.total_paid_real, o.total_shipping as shipping_cost, o.date_add as created_at'); - $query->select('o.date_upd as updated_at, o.id_carrier'); - $query->select('o.payment as payment_name'); - $query->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso'); - $query->select('o.valid as is_validated'); - $query->select('ost.paid as is_paid'); - $query->select('ost.shipped as is_shipped'); - $query->select('osl.name as status_label'); - $query->select('o.module as payment_name'); - - $query->select('o.id_shop_group, o.id_shop, o.id_lang, o.id_currency, o.recyclable, o.gift'); - $query->select('o.total_discounts, o.total_discounts_tax_incl, o.total_discounts_tax_excl'); - $query->select('o.total_products, o.total_products_wt, o.total_shipping_tax_incl, o.total_shipping_tax_excl'); - $query->select('o.carrier_tax_rate, o.total_wrapping, o.total_wrapping_tax_incl, o.total_wrapping_tax_excl'); - $query->select('o.round_mode, o.round_type, o.invoice_number, o.delivery_number, o.invoice_date, o.delivery_date, o.valid'); - } -} diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php new file mode 100644 index 00000000..76dabd57 --- /dev/null +++ b/src/Repository/OrdersRepository.php @@ -0,0 +1,93 @@ +query = new \DbQuery(); + + $this->query->from(self::ORDERS_TABLE, 'o') + ->leftJoin('currency', 'c', 'o.id_currency = c.id_currency') + ->leftJoin('order_slip', 'os', 'o.id_order = os.id_order') + ->leftJoin('address', 'ad', 'ad.id_address = o.id_address_delivery') + ->leftJoin('address', 'ai', 'ai.id_address = o.id_address_invoice') + ->leftJoin('country', 'cntd', 'cntd.id_country = ad.id_country') + ->leftJoin('country', 'cnti', 'cnti.id_country = ai.id_country') + ->leftJoin('order_state_lang', 'osl', 'o.current_state = osl.id_order_state') + ->leftJoin('order_state', 'ost', 'o.current_state = ost.id_order_state') + ->where('o.id_shop = ' . (int) parent::getShopId()) + ->groupBy('o.id_order'); + + $this->query->select('o.id_order, o.reference, o.id_customer, o.id_cart, o.current_state'); + $this->query->select('o.conversion_rate, o.total_paid_tax_excl, o.total_paid_tax_incl'); + $this->query->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer'); + $this->query->select('c.iso_code as currency, SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund'); + $this->query->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl, o.module as payment_module'); + $this->query->select('o.payment as payment_mode, o.total_paid_real, o.total_shipping as shipping_cost, o.date_add as created_at'); + $this->query->select('o.date_upd as updated_at, o.id_carrier'); + $this->query->select('o.payment as payment_name'); + $this->query->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso'); + $this->query->select('o.valid as is_validated'); + $this->query->select('ost.paid as is_paid'); + $this->query->select('ost.shipped as is_shipped'); + $this->query->select('osl.name as status_label'); + $this->query->select('o.module as payment_name'); + + $this->query->select('o.id_shop_group, o.id_shop, o.id_lang, o.id_currency, o.recyclable, o.gift'); + $this->query->select('o.total_discounts, o.total_discounts_tax_incl, o.total_discounts_tax_excl'); + $this->query->select('o.total_products, o.total_products_wt, o.total_shipping_tax_incl, o.total_shipping_tax_excl'); + $this->query->select('o.carrier_tax_rate, o.total_wrapping, o.total_wrapping_tax_incl, o.total_wrapping_tax_excl'); + $this->query->select('o.round_mode, o.round_type, o.invoice_number, o.delivery_number, o.invoice_date, o.delivery_date, o.valid'); + } + + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + { + $this->generateBaseQuery(); + + $this->query->limit((int) $limit, (int) $offset); + + if ($debug) { + return $this->debugQuery(); + } else { + return $this->executeQuery(); + } + + } + + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + { + $this->generateBaseQuery(); + + $this->query->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit); + + if ($debug) { + return $this->debugQuery(); + } else { + return $this->executeQuery(); + } + } + + public function countFullSyncContentLeft($offset, $langIso = null, $debug = false) + { + $orders = $this->getContentsForFull($offset, 1, parent::getShopId()); + + if (!is_array($orders) || empty($orders)) { + return 0; + } + + return count($orders); + } +} diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php new file mode 100644 index 00000000..af345685 --- /dev/null +++ b/src/Service/ShopContent/OrdersService.php @@ -0,0 +1,35 @@ +ordersRepository = $ordersRepository; + } + + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { + $result = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + return $result; + } + + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { + $result = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); + + return $result; + } + + public function countFullSyncContentLeft($offset, $langIso = null) { + $result = $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + + return $result; + } +} From 5a2b6750437ab378a079844eb0bc93d7b183f4ad Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 17:26:40 +0200 Subject: [PATCH 008/162] fix: all hooks --- ps_eventbus.php | 2 +- src/Config/Config.php | 4 + src/Service/SynchronizationService.php | 45 +-- src/Traits/UseHooks.php | 393 +++++++++++++------------ 4 files changed, 227 insertions(+), 217 deletions(-) diff --git a/ps_eventbus.php b/ps_eventbus.php index 41b6c50b..b8b70c7f 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -37,7 +37,7 @@ class Ps_eventbus extends Module { // All hooks is here - use PrestaShop\Module\PsEventbus\UseHooks; + use PrestaShop\Module\PsEventbus\Traits\UseHooks; /** * @var array diff --git a/src/Config/Config.php b/src/Config/Config.php index 5b8be4ad..b68438e7 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -104,6 +104,10 @@ class Config self::COLLECTION_WISHLIST_PRODUCTS, ]; + const INCREMENTAL_TYPE_ADD = 'add'; + const INCREMENTAL_TYPE_UPDATE = 'update'; + const INCREMENTAL_TYPE_DELETE = 'delete'; + /** * @param mixed $message * diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index d7f632f8..3a05f604 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -263,13 +263,35 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, foreach ($allIsoCodes as $langIso) { foreach($contentTypesWithIds as $contentType => $contentIds) { - if ($this->isFullSyncDone($contentType, $langIso)) { + foreach ($contentIds as $contentId) { + if ($this->isFullSyncDone($contentType, $langIso)) { + array_push($contentToInsert, + [ + 'type' => $contentType, + 'id_object' => $contentId, + 'id_shop' => $shopId, + 'lang_iso' => $langIso, + 'action' => $actionType, + 'created_at' => $createdAt, + ] + ); + } + } + + } + } + } else { + $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + + foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentIds as $contentId) { + if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { array_push($contentToInsert, [ 'type' => $contentType, - 'id_object' => $contentIds, + 'id_object' => $contentId, 'id_shop' => $shopId, - 'lang_iso' => $langIso, + 'lang_iso' => $defaultIsoCode, 'action' => $actionType, 'created_at' => $createdAt, ] @@ -277,23 +299,6 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } } } - } else { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - - foreach($contentTypesWithIds as $contentType => $contentIds) { - if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { - array_push($contentToInsert, - [ - 'type' => $contentType, - 'id_object' => $contentIds, - 'id_shop' => $shopId, - 'lang_iso' => $defaultIsoCode, - 'action' => $actionType, - 'created_at' => $createdAt, - ] - ); - } - } } if (empty($contentToInsert) == false) { diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 99fd9fcb..11a9f02a 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -116,9 +116,9 @@ public function hookActionObjectImageDeleteAfter($parameters) if (isset($image->id_product)) { $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $image->id_product], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId, true @@ -139,9 +139,9 @@ public function hookActionObjectImageAddAfter($parameters) $image = $parameters['object']; if (isset($image->id_product)) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $image->id_product], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -162,9 +162,9 @@ public function hookActionObjectImageUpdateAfter($parameters) $image = $parameters['object']; if (isset($image->id_product)) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $image->id_product], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -185,9 +185,9 @@ public function hookActionObjectLanguageDeleteAfter($parameters) $language = $parameters['object']; if (isset($language->id)) { $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); - $synchronizationService->insertDeletedObject( - $language->id, - Config::COLLECTION_LANGUAGES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_LANGUAGES => $language->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -207,9 +207,9 @@ public function hookActionObjectLanguageAddAfter($parameters) $language = $parameters['object']; if (isset($language->id) && isset($language->id_product)) { $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_LANGUAGES => $language->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -230,9 +230,9 @@ public function hookActionObjectLanguageUpdateAfter($parameters) $language = $parameters['object']; if (isset($language->id) && isset($language->id_product)) { $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_LANGUAGES => $language->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -253,9 +253,9 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_MANUFACTURERS, $manufacturer->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -275,9 +275,9 @@ public function hookActionObjectManufacturerAddAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -298,9 +298,9 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -321,9 +321,9 @@ public function hookActionObjectSupplierDeleteAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); - $synchronizationService->insertDeletedObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SUPPLIERS, $supplier->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -343,9 +343,9 @@ public function hookActionObjectSupplierAddAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SUPPLIERS => $supplier->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -366,9 +366,9 @@ public function hookActionObjectSupplierUpdateAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SUPPLIERS => $supplier->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -390,9 +390,9 @@ public function hookActionObjectProductDeleteAfter($parameters) if (isset($product->id)) { $synchronizationService->sendLiveSync('products', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS, $product->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -415,9 +415,9 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $product->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -443,9 +443,9 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $product->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -466,9 +466,9 @@ public function hookActionObjectWishlistDeleteAfter($parameters) $wishlist = $parameters['object']; if (isset($wishlist->id)) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); - $synchronizationService->insertDeletedObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_WISHLISTS, $wishlist->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -488,9 +488,9 @@ public function hookActionObjectWishlistAddAfter($parameters) $wishlist = $parameters['object']; if (isset($wishlist->id)) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_WISHLISTS => $wishlist->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -511,9 +511,9 @@ public function hookActionObjectWishlistUpdateAfter($parameters) $wishlist = $parameters['object']; if (isset($wishlist->id)) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_WISHLISTS => $wishlist->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -534,9 +534,9 @@ public function hookActionObjectStockAddAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STOCKS => $stock->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -557,9 +557,9 @@ public function hookActionObjectStockUpdateAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STOCKS => $stock->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -580,9 +580,9 @@ public function hookActionObjectStoreDeleteAfter($parameters) $product = $parameters['object']; if (isset($product->id)) { $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_STORES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STORES, $product->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -602,9 +602,9 @@ public function hookActionObjectStoreAddAfter($parameters) $product = $parameters['object']; if (isset($product->id)) { $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_STORES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STORES => $product->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -625,9 +625,9 @@ public function hookActionObjectStoreUpdateAfter($parameters) $store = $parameters['object']; if (isset($store->id)) { $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $store->id, - Config::COLLECTION_STORES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STORES => $store->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -650,9 +650,9 @@ public function hookActionObjectCombinationDeleteAfter($parameters) if (isset($combination->id)) { $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); - $synchronizationService->insertDeletedObject( - $combination->id, - Config::COLLECTION_PRODUCT_ATTRIBUTES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCT_ATTRIBUTES, $combination->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -673,9 +673,9 @@ public function hookActionObjectCategoryAddAfter($parameters) if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CATEGORIES => $category->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -697,9 +697,9 @@ public function hookActionObjectCategoryUpdateAfter($parameters) if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CATEGORIES => $category->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -721,9 +721,9 @@ public function hookActionObjectCategoryDeleteAfter($parameters) if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); - $synchronizationService->insertDeletedObject( - $category->id, - Config::COLLECTION_CATEGORIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CATEGORIES, $category->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -744,9 +744,9 @@ public function hookActionObjectCustomerAddAfter($parameters) if (isset($customer->id)) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CUSTOMERS => $customer->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -768,9 +768,9 @@ public function hookActionObjectCustomerUpdateAfter($parameters) if (isset($customer->id)) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CUSTOMERS => $customer->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -792,9 +792,9 @@ public function hookActionObjectCustomerDeleteAfter($parameters) if (isset($customer->id)) { $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CUSTOMERS, $customer->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -815,9 +815,9 @@ public function hookActionObjectCurrencyAddAfter($parameters) if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CURRENCIES => $currency->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -839,9 +839,9 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CURRENCIES => $currency->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -863,9 +863,9 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); - $synchronizationService->insertDeletedObject( - $currency->id, - Config::COLLECTION_CURRENCIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CURRENCIES, $currency->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -886,9 +886,9 @@ public function hookActionObjectCartAddAfter($parameters) if (isset($cart->id)) { $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARTS => $cart->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -909,9 +909,9 @@ public function hookActionObjectCartUpdateAfter($parameters) if (isset($cart->id)) { $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARTS => $cart->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -932,9 +932,9 @@ public function hookActionObjectCartRuleAddAfter($parameters) if (isset($cartRule->id)) { $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CART_RULES => $cartRule->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -955,9 +955,9 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) if (isset($cartRule->id)) { $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CART_RULES => $cartRule->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -978,9 +978,9 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) if (isset($cartRule->id)) { $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CART_RULES => $cartRule->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1001,9 +1001,9 @@ public function hookActionObjectOrderAddAfter($parameters) if (isset($order->id)) { $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_ORDERS => $order->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1024,9 +1024,9 @@ public function hookActionObjectOrderUpdateAfter($parameters) if (isset($order->id)) { $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_ORDERS => $order->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1048,9 +1048,9 @@ public function hookActionObjectCarrierAddAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => $carrier->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1072,9 +1072,9 @@ public function hookActionObjectCarrierUpdateAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => $carrier->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1096,9 +1096,9 @@ public function hookActionObjectCarrierDeleteAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => $carrier->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1113,9 +1113,9 @@ public function hookActionObjectCountryAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1129,9 +1129,9 @@ public function hookActionObjectCountryUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1145,9 +1145,9 @@ public function hookActionObjectCountryDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1161,9 +1161,9 @@ public function hookActionObjectStateAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1177,9 +1177,9 @@ public function hookActionObjectStateUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1193,9 +1193,9 @@ public function hookActionObjectStateDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1209,9 +1209,9 @@ public function hookActionObjectZoneAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1225,9 +1225,9 @@ public function hookActionObjectZoneUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1241,9 +1241,9 @@ public function hookActionObjectZoneDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1257,9 +1257,9 @@ public function hookActionObjectTaxAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1273,9 +1273,9 @@ public function hookActionObjectTaxUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1289,9 +1289,9 @@ public function hookActionObjectTaxDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1305,9 +1305,9 @@ public function hookActionObjectTaxRulesGroupAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1321,9 +1321,9 @@ public function hookActionObjectTaxRulesGroupUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1337,9 +1337,9 @@ public function hookActionObjectTaxRulesGroupDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1353,9 +1353,9 @@ public function hookActionShippingPreferencesPageSave() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1369,9 +1369,9 @@ public function hookActionObjectEmployeeAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_EMPLOYEES => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1384,9 +1384,9 @@ public function hookActionObjectEmployeeDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertDeletedObject( - 0, - Config::COLLECTION_EMPLOYEES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_EMPLOYEES => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1400,9 +1400,9 @@ public function hookActionObjectEmployeeUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_EMPLOYEES => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1440,9 +1440,9 @@ public function hookActionDispatcherBefore($parameters) // when translation is edited or reset, add to incremental sync if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_TRANSLATIONS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_TRANSLATIONS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1469,9 +1469,9 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) if ($specificPrice instanceof SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1495,9 +1495,9 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) if ($specificPrice instanceof SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1521,9 +1521,10 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) if ($specificPrice instanceof SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); - $synchronizationService->insertDeletedObject( + $synchronizationService->insertContentIntoIncremental( $specificPrice->id, Config::COLLECTION_SPECIFIC_PRICES, + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); From 342ac893d3c79a16be38dde858a68e0a3166ae57 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 18:22:49 +0200 Subject: [PATCH 009/162] fix: common problems --- config/front/services.yml | 7 ++++++- controllers/front/apiFront.php | 6 +++--- src/Interfaces/RepositoryInterface.php | 16 ++++++++++++++++ src/Repository/AbstractRepository.php | 2 +- src/Repository/OrdersRepository.php | 4 ++-- src/Service/FrontApiService.php | 14 +++++++++----- src/Service/ShopContent/OrdersService.php | 4 ++-- src/Service/SynchronizationService.php | 6 +++--- 8 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 src/Interfaces/RepositoryInterface.php diff --git a/config/front/services.yml b/config/front/services.yml index b36538f0..0799a2b1 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -53,7 +53,6 @@ services: class: PrestaShop\Module\PsEventbus\Service\SynchronizationService public: true arguments: - - '@ps_eventbus' - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' @@ -71,3 +70,9 @@ services: PrestaShop\Module\PsEventbus\Service\PresenterService: class: PrestaShop\Module\PsEventbus\Service\PresenterService public: true + + PrestaShop\Module\PsEventbus\Service\FrontApiService: + class: PrestaShop\Module\PsEventbus\Service\FrontApiService + public: true + arguments: + - '@ps_eventbus' diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 02204b09..a29e93b9 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -1,6 +1,6 @@ module->getService('PrestaShop\Module\PsEventbusV4\Services\ApiService'); + $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); } diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php new file mode 100644 index 00000000..833be27a --- /dev/null +++ b/src/Interfaces/RepositoryInterface.php @@ -0,0 +1,16 @@ +module = $module; + $this->errorHandler = $this->module->getService(ErrorHandler::class); try { @@ -55,6 +58,7 @@ public function __construct() $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); $this->synchronizationService = $this->module->getService(SynchronizationService::class); + $this->eventbusSyncRepository = $this->module->getService(EventbusSyncRepository::class); $this->authorize(); } catch (\Exception $exception) { @@ -89,7 +93,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService('\PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index af345685..9bc5b491 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -1,8 +1,8 @@ module->getService($serviceId); /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); @@ -167,7 +167,7 @@ public function sendIncrementalSync( $serviceName = str_replace('-', '', ucwords($shopContent, "-")); /** @var ShopContentServiceInterface $shopContentApiService */ - $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Services\\' . $serviceName . 'Service'); + $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Service\\' . $serviceName . 'Service'); $contentIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($shopContent, $langIso, $limit); From 3af9abf81c050538733b51e0bca25af63eb00e23 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 31 Jul 2024 14:48:04 +0200 Subject: [PATCH 010/162] fix: common problems --- config/common.yml | 25 +++ config/front/provider.yml | 2 +- config/front/repository.yml | 4 +- config/front/services.yml | 44 ++--- ps_eventbus.php | 12 +- src/DependencyInjection/ServiceContainer.php | 12 ++ src/Interfaces/RepositoryInterface.php | 6 +- src/Provider/OrderDataProvider.php | 18 +-- src/Repository/AbstractRepository.php | 6 +- src/Repository/OrdersRepository.php | 7 +- src/Service/DeletedObjectsService.php | 93 ----------- src/Service/ShopContent/OrdersService.php | 161 ++++++++++++++++++- src/Service/SynchronizationService.php | 27 ++-- 13 files changed, 244 insertions(+), 173 deletions(-) delete mode 100644 src/Service/DeletedObjectsService.php diff --git a/config/common.yml b/config/common.yml index bfabce66..0f4f6771 100644 --- a/config/common.yml +++ b/config/common.yml @@ -25,4 +25,29 @@ services: arguments: - '@ps_eventbus.helper.module' + PrestaShop\Module\PsEventbus\Formatter\JsonFormatter: + class: PrestaShop\Module\PsEventbus\Formatter\JsonFormatter + public: true + + PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter: + class: PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter + public: true + + PrestaShop\Module\PsEventbus\Service\CacheService: + class: PrestaShop\Module\PsEventbus\Service\CacheService + public: true + + PrestaShop\Module\PsEventbus\Service\CompressionService: + class: PrestaShop\Module\PsEventbus\Service\CompressionService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' + + PrestaShop\Module\PsEventbus\Service\ProxyService: + class: PrestaShop\Module\PsEventbus\Service\ProxyService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Api\CollectorApiClient' + - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' diff --git a/config/front/provider.yml b/config/front/provider.yml index f531a0eb..bc6d0faf 100644 --- a/config/front/provider.yml +++ b/config/front/provider.yml @@ -48,7 +48,7 @@ services: public: true arguments: - "@ps_eventbus.context" - - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' diff --git a/config/front/repository.yml b/config/front/repository.yml index a26fee3e..04522bb3 100644 --- a/config/front/repository.yml +++ b/config/front/repository.yml @@ -68,8 +68,8 @@ services: arguments: - '@ps_eventbus.context' - PrestaShop\Module\PsEventbus\Repository\OrderRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderRepository + PrestaShop\Module\PsEventbus\Repository\OrdersRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrdersRepository public: true PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository: diff --git a/config/front/services.yml b/config/front/services.yml index 0799a2b1..2b5e2ecc 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -8,32 +8,6 @@ imports: - { resource: context.yml } services: - PrestaShop\Module\PsEventbus\Formatter\JsonFormatter: - class: PrestaShop\Module\PsEventbus\Formatter\JsonFormatter - public: true - - PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter: - class: PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter - public: true - - PrestaShop\Module\PsEventbus\Service\CacheService: - class: PrestaShop\Module\PsEventbus\Service\CacheService - public: true - - PrestaShop\Module\PsEventbus\Service\CompressionService: - class: PrestaShop\Module\PsEventbus\Service\CompressionService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - - PrestaShop\Module\PsEventbus\Service\ProxyService: - class: PrestaShop\Module\PsEventbus\Service\ProxyService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Api\CollectorApiClient' - - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' - PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: class: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService public: true @@ -41,14 +15,6 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Api\SyncApiClient' - PrestaShop\Module\PsEventbus\Service\DeletedObjectsService: - class: PrestaShop\Module\PsEventbus\Service\DeletedObjectsService - public: true - arguments: - - "@ps_eventbus.context" - - '@PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository' - - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - PrestaShop\Module\PsEventbus\Service\SynchronizationService: class: PrestaShop\Module\PsEventbus\Service\SynchronizationService public: true @@ -56,7 +22,6 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - - '@PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - '@PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator' @@ -76,3 +41,12 @@ services: public: true arguments: - '@ps_eventbus' + + # SHOP CONTENT SERVICES + PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' diff --git a/ps_eventbus.php b/ps_eventbus.php index b8b70c7f..dd652df3 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -225,10 +225,20 @@ public function getServiceContainer() * @return mixed */ public function getService($serviceName) - { + { return $this->getServiceContainer()->getService($serviceName); } + /** + * @param string $serviceName + * + * @return mixed + */ + public function hasService($serviceName) + { + return $this->getServiceContainer()->hasService($serviceName); + } + /** * Set PHP compatibility to 7.1 * diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php index 231e917d..40fffb94 100644 --- a/src/DependencyInjection/ServiceContainer.php +++ b/src/DependencyInjection/ServiceContainer.php @@ -73,6 +73,18 @@ public function getService($serviceName) return $this->getContainer()->get($serviceName); } + /** + * @param string $serviceName + * + * @return bool + * + * @throws \Exception + */ + public function hasService($serviceName) + { + return $this->getContainer()->has($serviceName); + } + /** * @return ContainerInterface * diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php index 833be27a..7c350f33 100644 --- a/src/Interfaces/RepositoryInterface.php +++ b/src/Interfaces/RepositoryInterface.php @@ -4,11 +4,11 @@ use DbQuery; +/** + * @property DbQuery $query + */ interface RepositoryInterface { - /** @var DbQuery */ - public $query; - public function generateBaseQuery(); public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); diff --git a/src/Provider/OrderDataProvider.php b/src/Provider/OrderDataProvider.php index 1cdef93b..4dc4a478 100644 --- a/src/Provider/OrderDataProvider.php +++ b/src/Provider/OrderDataProvider.php @@ -7,14 +7,14 @@ use PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository; use PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository; use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; -use PrestaShop\Module\PsEventbus\Repository\OrderRepository; +use PrestaShop\Module\PsEventbus\Repository\OrdersRepository; class OrderDataProvider implements PaginatedApiDataProviderInterface { /** - * @var OrderRepository + * @var OrdersRepository */ - private $orderRepository; + private $ordersRepository; /** * @var \Context */ @@ -43,13 +43,13 @@ class OrderDataProvider implements PaginatedApiDataProviderInterface public function __construct( \Context $context, - OrderRepository $orderRepository, + OrdersRepository $ordersRepository, OrderDetailsRepository $orderDetailsRepository, ArrayFormatter $arrayFormatter, OrderHistoryRepository $orderHistoryRepository, OrderCartRuleRepository $orderCartRuleRepository ) { - $this->orderRepository = $orderRepository; + $this->ordersRepository = $ordersRepository; $this->context = $context; $this->arrayFormatter = $arrayFormatter; $this->orderDetailsRepository = $orderDetailsRepository; @@ -74,7 +74,7 @@ public function __construct( */ public function getFormattedData($offset, $limit, $langIso) { - $orders = $this->orderRepository->getOrders($offset, $limit, $this->shopId); + $orders = $this->ordersRepository->getOrders($offset, $limit, $this->shopId); if (empty($orders)) { return []; @@ -106,7 +106,7 @@ public function getFormattedData($offset, $limit, $langIso) */ public function getRemainingObjectsCount($offset, $langIso) { - return (int) $this->orderRepository->getRemainingOrderCount($offset, $this->shopId); + return (int) $this->ordersRepository->getRemainingOrderCount($offset, $this->shopId); } /** @@ -120,7 +120,7 @@ public function getRemainingObjectsCount($offset, $langIso) public function getFormattedDataIncremental($limit, $langIso, $objectIds) { $langId = (int) \Language::getIdByIso($langIso); - $orders = $this->orderRepository->getOrdersIncremental($limit, $this->shopId, $objectIds); + $orders = $this->ordersRepository->getOrdersIncremental($limit, $this->shopId, $objectIds); if (!is_array($orders) || empty($orders)) { return []; @@ -154,7 +154,7 @@ public function getFormattedDataIncremental($limit, $langIso, $objectIds) */ public function getQueryForDebug($offset, $limit, $langIso) { - return $this->orderRepository->getQueryForDebug($offset, $limit, $this->shopId); + return $this->ordersRepository->getQueryForDebug($offset, $limit, $this->shopId); } /** diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index d0cb2c81..124f75e3 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -21,11 +21,11 @@ abstract class AbstractRepository /** * @var DbQuery */ - private $query; + protected $query; - public function __construct(Context $context) + public function __construct() { - $this->context = $context; + $this->context = Context::getContext(); $this->db = Db::getInstance(); } diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index 7af8f689..e4b8509e 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -9,11 +9,6 @@ class OrdersRepository extends AbstractRepository implements RepositoryInterface { public const ORDERS_TABLE = 'orders'; - public function __construct(\Context $context) - { - parent::__construct($context); - } - public function generateBaseQuery() { $this->query = new \DbQuery(); @@ -61,6 +56,8 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa if ($debug) { return $this->debugQuery(); } else { + dump("test"); + die; return $this->executeQuery(); } diff --git a/src/Service/DeletedObjectsService.php b/src/Service/DeletedObjectsService.php deleted file mode 100644 index ad772ed2..00000000 --- a/src/Service/DeletedObjectsService.php +++ /dev/null @@ -1,93 +0,0 @@ -context = $context; - $this->deletedObjectsRepository = $deletedObjectsRepository; - $this->proxyService = $proxyService; - } - - /** - * @param string $jobId - * @param int $scriptStartTime - * - * @return array - * - * @@throws \PrestaShopDatabaseException|EnvVarException - */ - public function handleDeletedObjectsSync($jobId, $scriptStartTime) - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $deletedObjects = $this->deletedObjectsRepository->getDeletedObjectsGrouped($shopId); - - if (empty($deletedObjects)) { - return [ - 'job_id' => $jobId, - 'total_objects' => 0, - 'syncType' => 'full', - ]; - } - - $data = $this->formatData($deletedObjects); - - $response = $this->proxyService->delete($jobId, $data, $scriptStartTime); - - if ($response['httpCode'] == 200) { - foreach ($data as $dataItem) { - $this->deletedObjectsRepository->removeDeletedObjects( - $dataItem['collection'], - $dataItem['deleteIds'], - $shopId - ); - } - } - - return array_merge( - [ - 'job_id' => $jobId, - 'total_objects' => count($data), - 'syncType' => 'full', - ], - $response - ); - } - - /** - * @param array $data - * - * @return array - */ - private function formatData($data) - { - return array_map(function ($dataItem) { - return [ - 'collection' => $dataItem['type'], - 'deleteIds' => explode(';', $dataItem['ids']), - ]; - }, $data); - } -} diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 9bc5b491..13dc7727 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -1,8 +1,11 @@ ordersRepository = $ordersRepository; + $this->orderHistoryRepository = $orderHistoryRepository; + $this->arrayFormatter = $arrayFormatter; } public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { $result = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); - return $result; + if (empty($result)) { + return []; + } + + $this->castOrders($orders, $langIso); + + return array_map(function ($order) { + return [ + 'id' => $order['id_order'], + 'collection' => Config::COLLECTION_ORDERS, + 'properties' => $order, + ]; + }, $orders); } public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { $result = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); - return $result; + if (empty($result)) { + return []; + } + + $this->castOrders($orders, $langIso); + + return array_map(function ($order) { + return [ + 'id' => $order['id_order'], + 'collection' => Config::COLLECTION_ORDERS, + 'properties' => $order, + ]; + }, $orders); } public function countFullSyncContentLeft($offset, $langIso = null) { - $result = $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + } + + public function castOrders(&$orders, $langIso) + { + $langId = (int) \Language::getIdByIso($langIso); + + foreach ($orders as &$order) { + $order['id_order'] = (int) $order['id_order']; + $order['id_customer'] = (int) $order['id_customer']; + $order['current_state'] = (int) $order['current_state']; + $order['conversion_rate'] = (float) $order['conversion_rate']; + $order['total_paid_tax_incl'] = (float) $order['total_paid_tax_incl']; + $order['total_paid_tax_excl'] = (float) $order['total_paid_tax_excl']; + $order['refund'] = (float) $order['refund']; + $order['refund_tax_excl'] = (float) $order['refund_tax_excl']; + $order['new_customer'] = $order['new_customer'] == 1; + $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langId); + $order['shipping_cost'] = (float) $order['shipping_cost']; + $order['total_paid_tax'] = $order['total_paid_tax_incl'] - $order['total_paid_tax_excl']; + $order['id_carrier'] = (int) $order['id_carrier']; + + $order['id_shop_group'] = (int) $order['id_shop_group']; + $order['id_shop'] = (int) $order['id_shop']; + $order['id_lang'] = (int) $order['id_lang']; + $order['id_currency'] = (int) $order['id_currency']; + $order['recyclable'] = (bool) $order['recyclable']; + $order['gift'] = (bool) $order['gift']; + + $order['total_discounts'] = (int) $order['total_discounts']; + $order['total_discounts_tax_incl'] = (int) $order['total_discounts_tax_incl']; + $order['total_discounts_tax_excl'] = (int) $order['total_discounts_tax_excl']; + $order['total_products'] = (int) $order['total_products']; + $order['total_products_wt'] = (int) $order['total_products_wt']; + $order['total_shipping_tax_incl'] = (int) $order['total_shipping_tax_incl']; + $order['total_shipping_tax_excl'] = (int) $order['total_shipping_tax_excl']; + + $order['carrier_tax_rate'] = (int) $order['carrier_tax_rate']; + $order['total_wrapping'] = (int) $order['total_wrapping']; + $order['total_wrapping_tax_incl'] = (int) $order['total_wrapping_tax_incl']; + $order['total_wrapping_tax_excl'] = (int) $order['total_wrapping_tax_excl']; + $order['round_mode'] = (int) $order['round_mode']; + $order['round_type'] = (int) $order['round_type']; + $order['invoice_number'] = (int) $order['invoice_number']; + $order['delivery_number'] = (int) $order['delivery_number']; + $order['valid'] = (bool) $order['valid']; - return $result; + $this->castAddressIsoCodes($order); + unset($order['address_iso']); + } } + + /** + * @param array $orders + * @param array $order + * @param int $langId + * + * @return bool + * + * @@throws \PrestaShopDatabaseException + */ + private function castIsPaidValue($orders, $order, $langId) + { + $isPaid = $dateAdd = 0; + $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); + /** @var array $orderHistoryStatuses */ + $orderHistoryStatuses = $this->orderHistoryRepository->getOrderHistoryStatuses($orderIds, $langId); + + foreach ($orderHistoryStatuses as &$orderHistoryStatus) { + if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { + $isPaid = (bool) $orderHistoryStatus['paid']; + $dateAdd = $orderHistoryStatus['date_add']; + } + } + + return (bool) $isPaid; + } + + /** + * @param array $orderDetail + * + * @return void + */ + private function castAddressIsoCodes(&$orderDetail) + { + if (!$orderDetail['address_iso']) { + $orderDetail['invoice_country_code'] = null; + $orderDetail['delivery_country_code'] = null; + + return; + } + + $addressAndIsoCodes = explode(',', $orderDetail['address_iso']); + if (count($addressAndIsoCodes) === 1) { + $addressAndIsoCode = explode(':', $addressAndIsoCodes[0]); + $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; + $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; + + return; + } + + foreach ($addressAndIsoCodes as $addressAndIsoCodeString) { + $addressAndIsoCode = explode(':', $addressAndIsoCodeString); + if ($addressAndIsoCode[0] === 'delivery') { + $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; + } elseif ($addressAndIsoCode[0] === 'invoice') { + $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; + } + } + } + } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 3bd6de01..a3e6f74a 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -6,7 +6,6 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; -use PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; @@ -34,11 +33,6 @@ class SynchronizationService */ private $liveSyncRepository; - /** - * @var DeletedObjectsRepository - */ - private $deletedObjectsRepository; - /** * @var LanguageRepository */ @@ -59,7 +53,6 @@ public function __construct( EventbusSyncRepository $eventbusSyncRepository, IncrementalSyncRepository $incrementalSyncRepository, LiveSyncRepository $liveSyncRepository, - DeletedObjectsRepository $deletedObjectsRepository, LanguageRepository $languageRepository, ProxyServiceInterface $proxyService, PayloadDecorator $payloadDecorator @@ -67,7 +60,6 @@ public function __construct( $this->eventbusSyncRepository = $eventbusSyncRepository; $this->incrementalSyncRepository = $incrementalSyncRepository; $this->liveSyncRepository = $liveSyncRepository; - $this->deletedObjectsRepository = $deletedObjectsRepository; $this->languageRepository = $languageRepository; $this->proxyService = $proxyService; $this->payloadDecorator = $payloadDecorator; @@ -100,9 +92,9 @@ public function sendFullSync( $response = []; $serviceName = str_replace('-', '', ucwords($shopContent, "-")); - $serviceId = 'PrestaShop\Module\PsEventbus\Service\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent + $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent - /** @var Ps_eventbus */ + /** @var \Ps_eventbus */ $module = \Module::getInstanceByName('ps_eventbus'); if (!$module->hasService($serviceId)) { @@ -110,10 +102,10 @@ public function sendFullSync( } /** @var ShopContentServiceInterface $shopContentApiService */ - $shopContentApiService = $this->module->getService($serviceId); + $shopContentApiService = $module->getService($serviceId); /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); + $configurationRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); @@ -165,9 +157,18 @@ public function sendIncrementalSync( $response = []; $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; + + + /** @var \Ps_eventbus */ + $module = \Module::getInstanceByName('ps_eventbus'); + + if (!$module->hasService($serviceId)) { + throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + } /** @var ShopContentServiceInterface $shopContentApiService */ - $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Service\\' . $serviceName . 'Service'); + $shopContentApiService = $module->getService($serviceId); $contentIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($shopContent, $langIso, $limit); From 52565b1399fc80fb7590f315472a3672754b5d18 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 31 Jul 2024 18:04:12 +0200 Subject: [PATCH 011/162] fix: debug mode --- config/common.yml | 10 -- config/front/services.yml | 1 - controllers/front/apiFront.php | 2 +- .../ProxyServiceInterface.php | 2 +- src/Repository/AbstractRepository.php | 19 ++- src/Repository/OrdersRepository.php | 19 +-- src/Service/CacheService.php | 35 ----- src/Service/CommonService.php | 78 ++++++++++ src/Service/CompressionService.php | 42 ------ src/Service/FrontApiService.php | 133 ++++++------------ src/Service/ProxyService.php | 1 + src/Service/ShopContent/OrdersService.php | 4 +- src/Service/SynchronizationService.php | 6 +- 13 files changed, 146 insertions(+), 206 deletions(-) rename src/{Service => Interfaces}/ProxyServiceInterface.php (90%) delete mode 100644 src/Service/CacheService.php create mode 100644 src/Service/CommonService.php delete mode 100644 src/Service/CompressionService.php diff --git a/config/common.yml b/config/common.yml index 0f4f6771..f81002e9 100644 --- a/config/common.yml +++ b/config/common.yml @@ -33,16 +33,6 @@ services: class: PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter public: true - PrestaShop\Module\PsEventbus\Service\CacheService: - class: PrestaShop\Module\PsEventbus\Service\CacheService - public: true - - PrestaShop\Module\PsEventbus\Service\CompressionService: - class: PrestaShop\Module\PsEventbus\Service\CompressionService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - PrestaShop\Module\PsEventbus\Service\ProxyService: class: PrestaShop\Module\PsEventbus\Service\ProxyService public: true diff --git a/config/front/services.yml b/config/front/services.yml index 2b5e2ecc..e47174b5 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -5,7 +5,6 @@ imports: - { resource: provider.yml } - { resource: repository.yml } - { resource: builder.yml } - - { resource: context.yml } services: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index a29e93b9..2c9e06fe 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -18,7 +18,7 @@ public function postProcess() $jobId = \Tools::getValue('job_id'); /** @var string $langIso */ - $langIso = \Tools::getValue('lang_iso'); + $langIso = \Tools::getValue('lang_iso'); /** @var int $limit */ $limit = \Tools::getValue('limit', 50); diff --git a/src/Service/ProxyServiceInterface.php b/src/Interfaces/ProxyServiceInterface.php similarity index 90% rename from src/Service/ProxyServiceInterface.php rename to src/Interfaces/ProxyServiceInterface.php index 4ea84e07..10c319bc 100644 --- a/src/Service/ProxyServiceInterface.php +++ b/src/Interfaces/ProxyServiceInterface.php @@ -1,6 +1,6 @@ context->shop->id; } - protected function debugQuery() + protected function runQuery($debug) + { + if ($debug) { + $this->debugQuery(); + } + + return $this->db->executeS($this->query); + } + + private function debugQuery() { $queryStringified = preg_replace('/\s+/', ' ', $this->query->build()); - return array_merge( + $response = array_merge( (array) $this->query, ['queryStringified' => $queryStringified] ); - } - protected function executeQuery() - { - return $this->db->executeS($this->query); + CommonService::exitWithResponse($response); } } diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index e4b8509e..76aa1fed 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -53,14 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa $this->query->limit((int) $limit, (int) $offset); - if ($debug) { - return $this->debugQuery(); - } else { - dump("test"); - die; - return $this->executeQuery(); - } - + return $this->runQuery($debug); } public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) @@ -69,17 +62,13 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, $this->query->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - - if ($debug) { - return $this->debugQuery(); - } else { - return $this->executeQuery(); - } + + return $this->runQuery($debug); } public function countFullSyncContentLeft($offset, $langIso = null, $debug = false) { - $orders = $this->getContentsForFull($offset, 1, parent::getShopId()); + $orders = $this->getContentsForFull($offset, 1, parent::getShopId(), $debug); if (!is_array($orders) || empty($orders)) { return 0; diff --git a/src/Service/CacheService.php b/src/Service/CacheService.php deleted file mode 100644 index 858354a3..00000000 --- a/src/Service/CacheService.php +++ /dev/null @@ -1,35 +0,0 @@ -getItem($key); - $cacheItem->set($value); - $cache->save($cacheItem); - } - - /** - * @param string $key - * - * @return mixed - */ - public function getCacheProperty($key) - { - $cache = new FilesystemAdapter(); - $cacheItem = $cache->getItem($key); - - return $cacheItem->get(); - } -} diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php new file mode 100644 index 00000000..9e72ec79 --- /dev/null +++ b/src/Service/CommonService.php @@ -0,0 +1,78 @@ +getCode() == 0 ? 500 : $exception->getCode(); + + if ($exception instanceof \PrestaShopDatabaseException) { + $code = Config::DATABASE_QUERY_ERROR_CODE; + } elseif ($exception instanceof EnvVarException) { + $code = Config::ENV_MISCONFIGURED_ERROR_CODE; + } elseif ($exception instanceof FirebaseException) { + $code = Config::REFRESH_TOKEN_ERROR_CODE; + } elseif ($exception instanceof QueryParamsException) { + $code = Config::INVALID_URL_QUERY; + } + + $response = [ + 'object_type' => \Tools::getValue('shopContent'), + 'status' => false, + 'httpCode' => $code, + 'message' => $exception->getMessage(), + ]; + + self::dieWithResponse($response, (int) $code); + } + + /** + * @param array $response + * @param int $code + * + * @return void + */ + public static function dieWithResponse(array $response, $code) + { + $httpStatusText = "HTTP/1.1 $code"; + + if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { + $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; + } elseif (isset($response['body']['statusText'])) { + $httpStatusText .= ' ' . $response['body']['statusText']; + } + + $response['httpCode'] = (int) $code; + + header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); + header('Content-Type: application/json;charset=utf-8'); + header($httpStatusText); + + echo json_encode($response, JSON_UNESCAPED_SLASHES); + + exit; + } +} diff --git a/src/Service/CompressionService.php b/src/Service/CompressionService.php deleted file mode 100644 index c4763a13..00000000 --- a/src/Service/CompressionService.php +++ /dev/null @@ -1,42 +0,0 @@ -jsonFormatter = $jsonFormatter; - } - - /** - * Compresses data with gzip - * - * @param array $data - * - * @return string - * - * @@throws \Exception - */ - public function gzipCompressData($data) - { - if (!extension_loaded('zlib')) { - throw new \Exception('Zlib extension for PHP is not enabled'); - } - - $dataJson = $this->jsonFormatter->formatNewlineJsonString($data); - - if (!$encodedData = gzencode($dataJson)) { - throw new \Exception('Failed encoding data to GZIP'); - } - - return $encodedData; - } -} diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 02c6817c..b168c391 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -8,6 +8,8 @@ use PrestaShop\Module\PsEventbus\Exception\UnauthorizedException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; +use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; +use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; use PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService; @@ -70,13 +72,13 @@ public function __construct(\Ps_eventbus $module) if ($exception instanceof \PrestaShopDatabaseException) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } elseif ($exception instanceof EnvVarException) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } elseif ($exception instanceof FirebaseException) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } } } @@ -85,27 +87,48 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, { try { if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { - $this->exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); + CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } if ($limit < 0) { - $this->exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); + CommonService::exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); } /** @var ConfigurationRepository $configurationRepository */ $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); + /** @var LanguageRepository $languageRepository */ + $languageRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\LanguageRepository'); + /** @var IncrementalSyncRepository $incrementalSyncRepository */ + $incrementalSyncRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); + $langIso = $langIso ? $langIso : $languageRepository->getDefaultLanguageIsoCode(); + $offset = 0; - $incrementalSync = false; $response = []; $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); - if ($typeSync == false) { + if (is_array($typeSync)) { + if (!$isFull) { + $offset = (int) $typeSync['offset']; + } else { + $this->eventbusSyncRepository->updateTypeSync( + $shopContent, + $offset, + $dateNow, + false, + $langIso + ); + + $incrementalSyncRepository->removeIncrementaSyncObjectByType($shopContent); + } + } else { $this->eventbusSyncRepository->insertTypeSync($shopContent, $offset, $dateNow, $langIso); + + $isFull = true; } if ($isFull) { @@ -129,27 +152,29 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug ); } - - $this->exitWithResponse( - [ - 'job_id' => $jobId, - 'object_type' => $shopContent, - 'syncType' => $incrementalSync ? 'incremental' : 'full', - ], - $response + + CommonService::exitWithResponse( + array_merge( + [ + 'job_id' => $jobId, + 'object_type' => $shopContent, + 'syncType' => $isFull ? 'full' : 'incremental', + ], + $response + ) ); } catch (\PrestaShopDatabaseException $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } catch (EnvVarException $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } catch (FirebaseException $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } catch (\Exception $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } } @@ -166,7 +191,7 @@ private function authorize() $authorizationResponse = $this->authorizationService->authorizeCall($jobId); if (is_array($authorizationResponse)) { - $this->exitWithResponse($authorizationResponse); + CommonService::exitWithResponse($authorizationResponse); } elseif (!$authorizationResponse) { throw new \PrestaShopDatabaseException('Failed saving job id to database'); } @@ -181,72 +206,4 @@ private function authorize() throw new FirebaseException('Invalid token'); } } - - /** - * @param array $response - * - * @return void - */ - private function exitWithResponse(array $response) - { - $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; - - $this->dieWithResponse($response, $httpCode); - } - - /** - * @param \Exception $exception - * - * @return void - */ - private function exitWithExceptionMessage(\Exception $exception) - { - $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); - - if ($exception instanceof \PrestaShopDatabaseException) { - $code = Config::DATABASE_QUERY_ERROR_CODE; - } elseif ($exception instanceof EnvVarException) { - $code = Config::ENV_MISCONFIGURED_ERROR_CODE; - } elseif ($exception instanceof FirebaseException) { - $code = Config::REFRESH_TOKEN_ERROR_CODE; - } elseif ($exception instanceof QueryParamsException) { - $code = Config::INVALID_URL_QUERY; - } - - $response = [ - 'object_type' => \Tools::getValue('shopContent'), - 'status' => false, - 'httpCode' => $code, - 'message' => $exception->getMessage(), - ]; - - $this->dieWithResponse($response, (int) $code); - } - - /** - * @param array $response - * @param int $code - * - * @return void - */ - private function dieWithResponse(array $response, $code) - { - $httpStatusText = "HTTP/1.1 $code"; - - if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { - $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; - } elseif (isset($response['body']['statusText'])) { - $httpStatusText .= ' ' . $response['body']['statusText']; - } - - $response['httpCode'] = (int) $code; - - header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); - header('Content-Type: application/json;charset=utf-8'); - header($httpStatusText); - - echo json_encode($response, JSON_UNESCAPED_SLASHES); - - exit; - } } diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index adf65316..a0905857 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -8,6 +8,7 @@ use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Formatter\JsonFormatter; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +use PrestaShop\Module\PsEventbus\Interfaces\ProxyServiceInterface; class ProxyService implements ProxyServiceInterface { diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 13dc7727..ccdfdbcf 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -30,7 +30,7 @@ public function __construct( } public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { - $result = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $orders = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -48,7 +48,7 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa } public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { - $result = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); + $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); if (empty($result)) { return []; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index a3e6f74a..36185ceb 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -5,6 +5,7 @@ use Behat\Behat\HelperContainer\Exception\ServiceNotFoundException; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; +use PrestaShop\Module\PsEventbus\Interfaces\ProxyServiceInterface; use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; @@ -13,11 +14,6 @@ class SynchronizationService { - /** - * @var \Ps_eventbus - */ - private $module; - /** * @var EventbusSyncRepository */ From 094c2640bb729f098fa84b61ffcbb49ab51a6b6f Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 15:06:33 +0200 Subject: [PATCH 012/162] fix: update services and error handler --- config/admin/services.yml | 6 +-- config/{front => common}/builder.yml | 0 config/{ => common}/common.yml | 18 ++++++++- config/{front => common}/decorator.yml | 4 +- config/common/handler.yml | 11 ------ config/{front => common}/provider.yml | 5 +-- config/{front => common}/repository.yml | 46 +++++++++++------------ config/front/context.yml | 40 -------------------- config/front/services.yml | 10 ++--- ps_eventbus.php | 7 +++- src/Handler/ErrorHandler/ErrorHandler.php | 16 +++++++- src/Service/FrontApiService.php | 5 ++- 12 files changed, 75 insertions(+), 93 deletions(-) rename config/{front => common}/builder.yml (100%) rename config/{ => common}/common.yml (64%) rename config/{front => common}/decorator.yml (95%) delete mode 100644 config/common/handler.yml rename config/{front => common}/provider.yml (98%) rename config/{front => common}/repository.yml (82%) delete mode 100644 config/front/context.yml diff --git a/config/admin/services.yml b/config/admin/services.yml index 64714c35..94c72e8f 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1,7 +1,7 @@ imports: - - { resource: ../common.yml } - - { resource: ../front/repository.yml } - - { resource: ../front/services.yml } + - { resource: ../common/common.yml } + - { resource: ../common/repository.yml } + - { resource: ../common/services.yml } services: ps_eventbus.service.presenter: diff --git a/config/front/builder.yml b/config/common/builder.yml similarity index 100% rename from config/front/builder.yml rename to config/common/builder.yml diff --git a/config/common.yml b/config/common/common.yml similarity index 64% rename from config/common.yml rename to config/common/common.yml index f81002e9..3d024759 100644 --- a/config/common.yml +++ b/config/common/common.yml @@ -1,6 +1,5 @@ imports: - - { resource: parameters.yml } - - { resource: common/handler.yml } + - { resource: ../parameters.yml } services: ps_eventbus.db: @@ -15,6 +14,11 @@ services: arguments: - 'ps_eventbus' + ps_eventbus.context: + class: 'Context' + public: true + factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getContext'] + ps_eventbus.helper.module: class: 'PrestaShop\Module\PsEventbus\Helper\ModuleHelper' public: true @@ -41,3 +45,13 @@ services: - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' + PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface: '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' + + PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler: + class: PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler + public: true + arguments: + - '@ps_eventbus' + - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' + - '%ps_eventbus.sentry_dsn%' + - '%ps_eventbus.sentry_env%' diff --git a/config/front/decorator.yml b/config/common/decorator.yml similarity index 95% rename from config/front/decorator.yml rename to config/common/decorator.yml index 24bde51d..690012ea 100644 --- a/config/front/decorator.yml +++ b/config/common/decorator.yml @@ -3,7 +3,7 @@ services: class: PrestaShop\Module\PsEventbus\Decorator\ProductDecorator public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' @@ -32,7 +32,7 @@ services: class: PrestaShop\Module\PsEventbus\Decorator\CustomPriceDecorator public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Service\SpecificPriceService' PrestaShop\Module\PsEventbus\Decorator\WishlistDecorator: diff --git a/config/common/handler.yml b/config/common/handler.yml deleted file mode 100644 index 7dd3eea9..00000000 --- a/config/common/handler.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface: '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - - PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler: - class: PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler - public: true - arguments: - - '@ps_eventbus' - - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - - '%ps_eventbus.sentry_dsn%' - - '%ps_eventbus.sentry_env%' diff --git a/config/front/provider.yml b/config/common/provider.yml similarity index 98% rename from config/front/provider.yml rename to config/common/provider.yml index bc6d0faf..1e1a6628 100644 --- a/config/front/provider.yml +++ b/config/common/provider.yml @@ -47,7 +47,7 @@ services: class: PrestaShop\Module\PsEventbus\Provider\OrderDataProvider public: true arguments: - - "@ps_eventbus.context" + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' @@ -72,7 +72,7 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository' - - "@ps_eventbus.context" + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Provider\CarrierDataProvider: class: PrestaShop\Module\PsEventbus\Provider\CarrierDataProvider @@ -149,7 +149,6 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Decorator\LanguageDecorator' - PrestaShop\Module\PsEventbus\Provider\ImageDataProvider: class: PrestaShop\Module\PsEventbus\Provider\ImageDataProvider public: true diff --git a/config/front/repository.yml b/config/common/repository.yml similarity index 82% rename from config/front/repository.yml rename to config/common/repository.yml index 04522bb3..29b84a81 100644 --- a/config/front/repository.yml +++ b/config/common/repository.yml @@ -3,7 +3,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\LanguageRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository: class: PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository @@ -13,19 +13,19 @@ services: class: PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CategoryRepository: class: PrestaShop\Module\PsEventbus\Repository\CategoryRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CustomerRepository: class: PrestaShop\Module\PsEventbus\Repository\CustomerRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CurrencyRepository: class: PrestaShop\Module\PsEventbus\Repository\CurrencyRepository @@ -39,19 +39,19 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ProductRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository: class: PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - '@PrestaShop\Module\PsEventbus\Repository\CurrencyRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' @@ -66,7 +66,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ThemeRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\OrdersRepository: class: PrestaShop\Module\PsEventbus\Repository\OrdersRepository @@ -76,7 +76,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository: class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository @@ -90,13 +90,13 @@ services: class: PrestaShop\Module\PsEventbus\Repository\CartRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CartProductRepository: class: PrestaShop\Module\PsEventbus\Repository\CartProductRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CartRuleRepository: class: PrestaShop\Module\PsEventbus\Repository\CartRuleRepository @@ -116,7 +116,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' PrestaShop\Module\PsEventbus\Repository\ShopRepository: @@ -127,7 +127,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\CountryRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\StateRepository: class: PrestaShop\Module\PsEventbus\Repository\StateRepository @@ -137,19 +137,19 @@ services: class: PrestaShop\Module\PsEventbus\Repository\TaxRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\CarrierRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository: class: PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\BundleRepository: class: PrestaShop\Module\PsEventbus\Repository\BundleRepository @@ -159,7 +159,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\WishlistRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository: class: PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository @@ -173,13 +173,13 @@ services: class: PrestaShop\Module\PsEventbus\Repository\StoreRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\StockRepository: class: PrestaShop\Module\PsEventbus\Repository\StockRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\StockMvtRepository: class: PrestaShop\Module\PsEventbus\Repository\StockMvtRepository @@ -189,13 +189,13 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\SupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\SupplierRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository @@ -205,7 +205,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\EmployeeRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ImageRepository: class: PrestaShop\Module\PsEventbus\Repository\ImageRepository @@ -219,7 +219,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\TranslationRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository diff --git a/config/front/context.yml b/config/front/context.yml deleted file mode 100644 index 85b9c6ea..00000000 --- a/config/front/context.yml +++ /dev/null @@ -1,40 +0,0 @@ -services: - ps_eventbus.context: - class: 'Context' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getContext'] - - ps_eventbus.controller: - class: 'Controller' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getController'] - - ps_eventbus.cookie: - class: 'Cookie' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getCookie'] - - ps_eventbus.language: - class: 'Language' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getLanguage'] - - ps_eventbus.currency: - class: 'Currency' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getCurrency'] - - ps_eventbus.smarty: - class: 'Smarty' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getSmarty'] - - ps_eventbus.shop: - class: 'Shop' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getShop'] - - ps_eventbus.link: - class: 'Link' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getLink'] diff --git a/config/front/services.yml b/config/front/services.yml index e47174b5..c4482c20 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -1,10 +1,10 @@ imports: - - { resource: ../common.yml } - { resource: api.yml } - - { resource: decorator.yml } - - { resource: provider.yml } - - { resource: repository.yml } - - { resource: builder.yml } + - { resource: ../common/common.yml } + - { resource: ../common/decorator.yml } + - { resource: ../common/provider.yml } + - { resource: ../common/repository.yml } + - { resource: ../common/builder.yml } services: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: diff --git a/ps_eventbus.php b/ps_eventbus.php index dd652df3..1861d93c 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -27,6 +27,7 @@ use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; if (!defined('_PS_VERSION_')) { exit; @@ -226,7 +227,11 @@ public function getServiceContainer() */ public function getService($serviceName) { - return $this->getServiceContainer()->getService($serviceName); + try { + return $this->getServiceContainer()->getService($serviceName); + } catch (ServiceNotFoundException $exception) { + return $this->get($serviceName); + } } /** diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 506af5a6..c4a1ebae 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -21,7 +21,10 @@ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; +use Exception; +use Module; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; +use PrestaShopLogger; /** * Handle Error. @@ -68,7 +71,7 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc } /** - * @param \Exception $error + * @param Exception $error * @param mixed $code * @param bool|null $throw * @param array|null $data @@ -86,7 +89,18 @@ public function handle($error, $code = null, $throw = null, $data = null) if (!$this->client) { return; } + $this->client->captureException($error, $data); + + PrestaShopLogger::addLog( + $error->getMessage() . ' : ' . $error->getFile() . ':' . $error->getLine() . ' | ' . $error->getTraceAsString(), + 3, + $error->getCode(), + 'Module', + Module::getModuleIdByName('ps_eventbus'), + true + ); + if (is_int($code) && true === $throw) { http_response_code($code); throw $error; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index b168c391..3a0b1c6f 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -152,7 +152,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug ); } - + CommonService::exitWithResponse( array_merge( [ @@ -174,7 +174,8 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, CommonService::exitWithExceptionMessage($exception); } catch (\Exception $exception) { $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + + CommonService::dieWithResponse(["message" => "An error occured. Please check logs for more information"], 500); } } From 9468ad9af0a7927bf4ec697b95953e09f04ab708 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 15:06:57 +0200 Subject: [PATCH 013/162] fix: service --- config/admin/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/admin/services.yml b/config/admin/services.yml index 94c72e8f..521fb78a 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1,7 +1,7 @@ imports: - { resource: ../common/common.yml } - { resource: ../common/repository.yml } - - { resource: ../common/services.yml } + - { resource: ../front/services.yml } services: ps_eventbus.service.presenter: From 434a5204639ac3792512cf46a109dc73d34e6ce4 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 16:16:01 +0200 Subject: [PATCH 014/162] feat: add healthcheck mecanic --- config/front/services.yml | 11 +++ controllers/front/apiFront.php | 12 +-- src/Service/FrontApiService.php | 114 ++++++++++++++++------------- src/Service/HealthCheckService.php | 38 ++++++++++ 4 files changed, 118 insertions(+), 57 deletions(-) create mode 100644 src/Service/HealthCheckService.php diff --git a/config/front/services.yml b/config/front/services.yml index c4482c20..fdc84893 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -40,6 +40,17 @@ services: public: true arguments: - '@ps_eventbus' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' + - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' + - '@PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService' + - '@PrestaShop\Module\PsEventbus\Service\SynchronizationService' + - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' + + PrestaShop\Module\PsEventbus\Service\HealthCheckService: + class: PrestaShop\Module\PsEventbus\Service\HealthCheckService + public: true + arguments: + - '@ps_eventbus' # SHOP CONTENT SERVICES PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 2c9e06fe..fd6ade0f 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -12,22 +12,22 @@ class ps_EventbusApiFrontModuleFrontController extends ModuleFrontController public function postProcess() { /** @var string $shopContent */ - $shopContent = \Tools::getValue('shop_content'); + $shopContent = Tools::getValue('shop_content'); /** @var string $jobId */ - $jobId = \Tools::getValue('job_id'); + $jobId = Tools::getValue('job_id'); /** @var string $langIso */ - $langIso = \Tools::getValue('lang_iso'); + $langIso = Tools::getValue('lang_iso'); /** @var int $limit */ - $limit = \Tools::getValue('limit', 50); + $limit = Tools::getValue('limit', 50); /** @var bool $initFullSync */ - $isFull = \Tools::getValue('full', 0) == 1; + $isFull = Tools::getValue('full', 0) == 1; /** @var bool $debug */ - $debug = \Tools::getValue('debug') == 1; + $debug = Tools::getValue('debug') == 1; /** @var FrontApiService $frontApiService */ $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 3a0b1c6f..55e7ba47 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -1,6 +1,7 @@ module = $module; - - $this->errorHandler = $this->module->getService(ErrorHandler::class); - - try { - $this->startTime = time(); - - $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); - $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); - $this->synchronizationService = $this->module->getService(SynchronizationService::class); - $this->eventbusSyncRepository = $this->module->getService(EventbusSyncRepository::class); + public function __construct( + Ps_eventbus $module, + ErrorHandler $errorHandler, + PsAccountsAdapterService $psAccountsAdapterService, + ApiAuthorizationService $apiAuthorizationService, + SynchronizationService $synchronizationService, + EventbusSyncRepository $eventbusSyncRepository + ) { + $this->startTime = time(); - $this->authorize(); - } catch (\Exception $exception) { - // For ApiHealthCheck, handle the error, and throw UnauthorizedException directly, to catch-up at top level. - if (strpos(get_class($this), 'apiHealthCheckController') !== false) { - $this->errorHandler->handle($exception); - throw new UnauthorizedException('You are not allowed to access to this resource'); - } - - if ($exception instanceof \PrestaShopDatabaseException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); - } elseif ($exception instanceof EnvVarException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); - } elseif ($exception instanceof FirebaseException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); - } - } + $this->module = $module; + $this->errorHandler = $errorHandler; + $this->psAccountsAdapterService = $psAccountsAdapterService; + $this->apiAuthorizationService = $apiAuthorizationService; + $this->synchronizationService = $synchronizationService; + $this->eventbusSyncRepository = $eventbusSyncRepository; } public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) - { + { + $isAuthentified = $this->authorize($jobId, $shopContent == 'HealthCheck'); + + if ($shopContent == 'HealthCheck') { + /** @var HealthCheckService $healthCheckService */ + $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); + return $healthCheckService->getHealthCheck($isAuthentified); + } + try { if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); @@ -163,7 +158,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $response ) ); - } catch (\PrestaShopDatabaseException $exception) { + } catch (PrestaShopDatabaseException $exception) { $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } catch (EnvVarException $exception) { @@ -180,31 +175,48 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } /** - * @return void + * @return bool|void * * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException */ - private function authorize() + private function authorize($jobId, $isHealthCheck = null) { - /** @var string $jobId */ - $jobId = \Tools::getValue('job_id', 'empty_job_id'); + try { + $authorizationResponse = $this->apiAuthorizationService->authorizeCall($jobId); - $authorizationResponse = $this->authorizationService->authorizeCall($jobId); + if (is_array($authorizationResponse)) { + CommonService::exitWithResponse($authorizationResponse); + } elseif (!$authorizationResponse) { + throw new PrestaShopDatabaseException('Failed saving job id to database'); + } - if (is_array($authorizationResponse)) { - CommonService::exitWithResponse($authorizationResponse); - } elseif (!$authorizationResponse) { - throw new \PrestaShopDatabaseException('Failed saving job id to database'); - } + try { + $token = $this->psAccountsAdapterService->getOrRefreshToken(); + } catch (Exception $exception) { + throw new FirebaseException($exception->getMessage()); + } - try { - $token = $this->psAccountsAdapterService->getOrRefreshToken(); + if (!$token) { + throw new FirebaseException('Invalid token'); + } + + return true; } catch (\Exception $exception) { - throw new FirebaseException($exception->getMessage()); - } + // For ApiHealthCheck, handle the error, and return false + if ($isHealthCheck) { + return false; + } - if (!$token) { - throw new FirebaseException('Invalid token'); + if ($exception instanceof PrestaShopDatabaseException) { + $this->errorHandler->handle($exception); + CommonService::exitWithExceptionMessage($exception); + } elseif ($exception instanceof EnvVarException) { + $this->errorHandler->handle($exception); + CommonService::exitWithExceptionMessage($exception); + } elseif ($exception instanceof FirebaseException) { + $this->errorHandler->handle($exception); + CommonService::exitWithExceptionMessage($exception); + } } } } diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php new file mode 100644 index 00000000..595a58b6 --- /dev/null +++ b/src/Service/HealthCheckService.php @@ -0,0 +1,38 @@ +module = $module; + } + + /** + * @return void + * + * @throws PrestaShopException + */ + public function getHealthCheck($isAuthentified = null) + { + if ($isAuthentified == null) { + $isAuthentified = false; + } + + /** @var ServerInformationRepository $serverInformationRepository */ + $serverInformationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository'); + + $status = $serverInformationRepository->getHealthCheckData($isAuthentified); + + CommonService::exitWithResponse($status); + } + +} From 9f1aef15bae152c2754390235801d261922a6a77 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 16:20:08 +0200 Subject: [PATCH 015/162] chore: set healhcheck to shopcontent --- src/Config/Config.php | 2 ++ src/Service/FrontApiService.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index b68438e7..8c60a6cd 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -43,6 +43,7 @@ class Config const COLLECTION_CUSTOMERS = 'customers'; const COLLECTION_DELETED = 'deleted'; const COLLECTION_EMPLOYEES = 'employees'; + const COLLECTION_HEALTHCHECK = 'healthcheck'; const COLLECTION_IMAGES = 'images'; const COLLECTION_IMAGE_TYPES = 'image_types'; const COLLECTION_LANGUAGES = 'languages'; @@ -81,6 +82,7 @@ class Config self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, + self::COLLECTION_HEALTHCHECK, self::COLLECTION_LANGUAGES, self::COLLECTION_MANUFACTURERS, self::COLLECTION_MODULES, diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 55e7ba47..a071b545 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -72,19 +72,21 @@ public function __construct( public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) { - $isAuthentified = $this->authorize($jobId, $shopContent == 'HealthCheck'); - - if ($shopContent == 'HealthCheck') { - /** @var HealthCheckService $healthCheckService */ - $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); - return $healthCheckService->getHealthCheck($isAuthentified); - } - try { if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } + $isHealthCheck = $shopContent == Config::COLLECTION_HEALTHCHECK; + + $isAuthentified = $this->authorize($jobId, $isHealthCheck); + + if ($isHealthCheck) { + /** @var HealthCheckService $healthCheckService */ + $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); + return $healthCheckService->getHealthCheck($isAuthentified); + } + if ($limit < 0) { CommonService::exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); } From cafb6f5c31a30b526ebf3da0bb005bacd588b63b Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 16:29:49 +0200 Subject: [PATCH 016/162] fix: problem with service declaration --- src/Service/FrontApiService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index a071b545..bf326437 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -14,7 +14,7 @@ use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; use PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService; -use PrestaShop\Module\PsEventbus\Service\ShopContent\HealthCheckService; +use PrestaShop\Module\PsEventbus\Service\HealthCheckService; use PrestaShopDatabaseException; use Ps_eventbus; From df11e8d6ae526f053810a47ebbbfa8b96dc0cba3 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 2 Aug 2024 15:52:52 +0200 Subject: [PATCH 017/162] fix: config --- src/Config/Config.php | 1 - src/Service/FrontApiService.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 8c60a6cd..d5bd74af 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -82,7 +82,6 @@ class Config self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, - self::COLLECTION_HEALTHCHECK, self::COLLECTION_LANGUAGES, self::COLLECTION_MANUFACTURERS, self::COLLECTION_MODULES, diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index bf326437..748bdd61 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -6,7 +6,6 @@ use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; -use PrestaShop\Module\PsEventbus\Exception\UnauthorizedException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; @@ -73,7 +72,7 @@ public function __construct( public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) { try { - if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { + if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [CONFIG::COLLECTION_HEALTHCHECK]), true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } From addcc45510f92867aacb5f7dcd69ccc91a5494b1 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 2 Aug 2024 16:49:17 +0200 Subject: [PATCH 018/162] e2e: change all endpoint and rename controller into shoContent --- e2e/README.md | 10 ++--- e2e/src/full-sync.spec.ts | 60 +++++++++++++-------------- e2e/src/helpers/controllers.ts | 47 --------------------- e2e/src/helpers/data-helper.ts | 16 +++---- e2e/src/helpers/log-helper.ts | 1 + e2e/src/helpers/mock-probe.ts | 6 +-- e2e/src/helpers/shop-contents.ts | 47 +++++++++++++++++++++ e2e/src/reject-invalid-job-id.spec.ts | 8 ++-- 8 files changed, 98 insertions(+), 97 deletions(-) delete mode 100644 e2e/src/helpers/controllers.ts create mode 100644 e2e/src/helpers/shop-contents.ts diff --git a/e2e/README.md b/e2e/README.md index 7d90455f..1ae8fee1 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -17,13 +17,13 @@ import { MockProbe } from './helpers/mock-probe'; import testConfig from './helpers/test.config'; import request from 'supertest'; -const controller = 'apiCategories'; -const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5`; +const controller = 'categories'; +const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5`; -describe('CategoriesController', () => { - it(`${controller} should upload to collector`, async () => { +describe('CategoriesShopContent', () => { + it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; // jobId starting with "valid-job-" will be considered valid by the mock sync-api and will always return 201; // other values will be rejected by the mock const jobId = 'valid-job-1' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index de6db3d0..77faa06e 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -10,19 +10,19 @@ import { omitProperties, sortUploadData, } from "./helpers/data-helper"; -import { Controller, controllerList } from "./helpers/controllers"; +import { ShopContent, shopContentList } from "./helpers/shop-contents"; expect.extend(matchers); -// these controllers will be excluded from the following test suite -const EXCLUDED_API: Controller[] = ["apiGoogleTaxonomies"]; +// these ShopContent will be excluded from the following test suite +const EXCLUDED_API: ShopContent[] = ["google-taxonomies"]; // FIXME : these api can't send anything to the mock api because the database is empty from the factory -const MISSING_TEST_DATA: Controller[] = [ - "apiCartRules", - "apiCustomProductCarriers", - "apiTranslations", - "apiWishlists", +const MISSING_TEST_DATA: ShopContent[] = [ + "cart-rules", + "custom-product-carriers", + "translations", + "wishlists", ]; // these fields change from test run to test run, so we replace them with a matcher to only ensure the type and format are correct @@ -53,7 +53,7 @@ describe('Full Sync', () => { let testIndex = 0; // gérer les cas ou un shopContent n'existe pas (pas de fixture du coup) - const controllers: Controller[] = controllerList.filter( + const shopContents: ShopContent[] = shopContentList.filter( (it) => !EXCLUDED_API.includes(it) ); @@ -64,17 +64,17 @@ describe('Full Sync', () => { }); // TODO : some versions of prestashop include ps_facebook out of the box, this test can't reliably be run for all versions - describe.skip("apiGoogleTaxonomies", () => { - const controller = "apiGoogleTaxonomies"; + describe.skip("google-taxonomies", () => { + const shoContent = "google-taxonomies"; // TODO : apiGoogleTaxonomies requires an additional module to be present : devise a specific test setup for this endpoint - it.skip(`${controller} should accept full sync`, async () => {}); + it.skip(`${shoContent} should accept full sync`, async () => {}); - it.skip(`${controller} should upload to collector`, async () => {}); + it.skip(`${shoContent} should upload to collector`, async () => {}); - it(`${controller} should reject full sync when ps_facebook is not installed`, async () => { + it(`${shoContent} should reject full sync when ps_facebook is not installed`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -98,10 +98,10 @@ describe('Full Sync', () => { }); }); - describe.each(controllers)("%s", (controller) => { - it(`${controller} should accept full sync`, async () => { + describe.each(shopContents)("%s", (shopContent) => { + it(`${shopContent} should accept full sync`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -128,12 +128,12 @@ describe('Full Sync', () => { }); }); - if (MISSING_TEST_DATA.includes(controller)) { - it.skip(`${controller} should upload to collector`, () => {}); + if (MISSING_TEST_DATA.includes(shopContent)) { + it.skip(`${shopContent} should upload to collector`, () => {}); } else { - it(`${controller} should upload to collector`, async () => { + it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const message$ = probe({ url: `/upload/${jobId}` }); const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -168,13 +168,13 @@ describe('Full Sync', () => { } - if (MISSING_TEST_DATA.includes(controller)) { - it.skip(`${controller} should upload complete dataset to collector`, () => {}); + if (MISSING_TEST_DATA.includes(shopContent)) { + it.skip(`${shopContent} should upload complete dataset to collector`, () => {}); } else { - it(`${controller} should upload complete dataset collector`, async () => { + it(`${shopContent} should upload complete dataset collector`, async () => { // arrange - const fullSync$ = doFullSync(jobId, controller, { timeout: 4000 }); + const fullSync$ = doFullSync(jobId, shopContent, { timeout: 4000 }); const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); // act @@ -187,18 +187,18 @@ describe('Full Sync', () => { toArray() ) ); - + console.log('test', testConfig.dumpFullSyncData); // dump data for easier debugging or updating fixtures if (testConfig.dumpFullSyncData) { - await dumpUploadData(syncedData, controller); + await dumpUploadData(syncedData, shopContent); } - const fixture = await loadFixture(controller); + const fixture = await loadFixture(shopContent); // we need to process fixtures and data returned from ps_eventbus to make them easier to compare let processedData = syncedData; let processedFixture = fixture; - if (controller === "apiModules") { + if (shopContent === "modules") { processedData = generatePredictableModuleId(processedData); processedFixture = generatePredictableModuleId(processedFixture); } diff --git a/e2e/src/helpers/controllers.ts b/e2e/src/helpers/controllers.ts deleted file mode 100644 index 73103286..00000000 --- a/e2e/src/helpers/controllers.ts +++ /dev/null @@ -1,47 +0,0 @@ -import R from "ramda"; - -export const contentControllerMapping = { - 'carriers': 'apiCarriers', - 'carrier_details': 'apiCarriers', - 'carts' : 'apiCarts', - 'cart_products': 'apiCarts', - 'cart_rules' : 'apiCartRules', - 'categories' : 'apiCategories', - 'currencies' : 'apiCurrencies', - 'specific_prices': 'apiSpecificPrices', - 'custom_product_carriers' : 'apiCustomProductCarriers', - 'customers': 'apiCustomers', - 'taxonomies': 'apiGoogleTaxonomies', - 'modules': 'apiModules', - 'orders': 'apiOrders', - 'order_details': 'apiOrders', - 'order_status_history': 'apiOrders', - 'order_cart_rules': 'apiOrders', - 'products': 'apiProducts', - 'shops': 'apiInfo', - 'stores': 'apiStores', - 'themes': 'apiThemes', - 'bundles': 'apiProducts', - 'wishlists': 'apiWishlists', - 'wishlist_products': 'apiWishlists', - 'stocks': 'apiStocks', - 'stock_movements': 'apiStocks', - 'manufacturers': 'apiManufacturers', - 'suppliers': 'apiSuppliers', - 'product_suppliers': 'apiProducts', - 'languages': 'apiLanguages', - 'employees': 'apiEmployees', - 'translations': 'apiTranslations', - 'images': 'apiImages', - 'image_types': 'apiImageTypes' -} as const; - -type ContentControllerMapping = typeof contentControllerMapping; - -export type Content = keyof ContentControllerMapping; -export const contentList = Object.keys(contentControllerMapping) as Content[]; - -export type Controller = ContentControllerMapping[Content]; -export const controllerList = R.uniq(Object.values(contentControllerMapping)) as Controller[]; - - diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 3e08261c..94fa82ff 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -1,7 +1,7 @@ import R from "ramda"; import { PsEventbusSyncUpload } from "./mock-probe"; import fs from "fs"; -import { Content, contentControllerMapping, Controller } from "./controllers"; +import { Content, shopContentMapping, ShopContent } from "./shop-contents"; import axios from "axios"; import testConfig from "./test.config"; import { HealthCheck } from "../type/health-check"; @@ -39,9 +39,9 @@ export function omitProperties( })); } -export function getControllerContent(controller: Controller): Content[] { - return Object.entries(contentControllerMapping) - .filter((it) => it[1] === controller) +export function getControllerContent(shopContent: ShopContent): Content[] { + return Object.entries(shopContentMapping) + .filter((it) => it[1] === shopContent) .map((it) => it[0]) as Content[]; } @@ -56,7 +56,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-healthcheck` + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=helathcheck&job_id=valid-job-healthcheck` ); healthCheck = res.data; cachedHealthCheck = healthCheck; @@ -67,9 +67,9 @@ export async function getShopHealthCheck(options?: { const FIXTURE_DIR = "./src/fixtures"; export async function loadFixture( - controller: Controller + shopContent: ShopContent ): Promise { - const contents = getControllerContent(controller); + const contents = getControllerContent(shopContent); const shopVersion = (await getShopHealthCheck()).prestashop_version; const shopSemver = semver.coerce(shopVersion); const fixture = []; @@ -95,7 +95,7 @@ export async function loadFixture( const files = contents.map((content) => fs.promises.readFile( - `${FIXTURE_DIR}/${useFixture}/${controller}/${content}.json`, + `${FIXTURE_DIR}/${useFixture}/${shopContent}/${content}.json`, "utf-8" ) ); diff --git a/e2e/src/helpers/log-helper.ts b/e2e/src/helpers/log-helper.ts index f359289a..917216db 100644 --- a/e2e/src/helpers/log-helper.ts +++ b/e2e/src/helpers/log-helper.ts @@ -14,6 +14,7 @@ export function logAxiosError(err: Error) { export async function dumpUploadData(data: PsEventbusSyncUpload[], filename: string) { const shopVersion = (await getShopHealthCheck()).prestashop_version; const dir = `./dumps/${testConfig.testRunTime}/${shopVersion}/${filename}`; + await fs.promises.mkdir(dir, {recursive: true}); const groupedData = R.groupBy( el => el.collection, data ) const files = Object.keys(groupedData).map(collection => { diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index eb9d66c4..cae8710a 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -13,7 +13,7 @@ import { import R from 'ramda'; import testConfig from "./test.config"; import axios from "axios"; -import {Controller} from "./controllers"; +import {ShopContent} from "./shop-contents"; import {anyBoolean} from "jest-mock-extended"; const DEFAULT_OPTIONS = { @@ -77,13 +77,13 @@ export type PsEventbusSyncUpload = { collection: Collection, id: string, properties: any } -export function doFullSync(jobId: string, controller: Controller, options?: MockClientOptions): Observable { +export function doFullSync(jobId: string, shopContent: ShopContent, options?: MockClientOptions): Observable { options = R.mergeLeft(options, DEFAULT_OPTIONS); const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; const requestNext = (full: number) => axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=${full}&job_id=${jobId}`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, callId, { headers: { diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts new file mode 100644 index 00000000..37bbbd9b --- /dev/null +++ b/e2e/src/helpers/shop-contents.ts @@ -0,0 +1,47 @@ +import R from "ramda"; + +export const shopContentMapping = { + 'carriers': 'carriers', + 'carrier_details': 'carriers-details', + 'carts' : 'carts', + 'cart_products': 'carts', + 'cart_rules' : 'cart-rules', + 'categories' : 'categories', + 'currencies' : 'currencies', + 'specific_prices': 'specific-prices', + 'custom_product_carriers' : 'custom-product-carriers', + 'customers': 'customers', + 'taxonomies': 'google-taxonomies', + 'modules': 'modules', + 'orders': 'orders', + 'order_details': 'order-details', + 'order_status_histories': 'order-status-histories', + 'order_cart_rules': 'order-cart-rules', + 'products': 'products', + 'shops': 'info', + 'stores': 'stores', + 'themes': 'themes', + 'product_bundles': 'product-bundles', + 'wishlists': 'wishlists', + 'wishlist_products': 'wishlist-products', + 'stocks': 'stocks', + 'stock_movements': 'stock_movements', + 'manufacturers': 'manufacturers', + 'suppliers': 'suppliers', + 'product_suppliers': 'product_suppliers', + 'languages': 'languages', + 'employees': 'employees', + 'translations': 'translations', + 'images': 'images', + 'image_types': 'image-types' +} as const; + +type ShopContentMapping = typeof shopContentMapping; + +export type Content = keyof ShopContentMapping; +export const contentList = Object.keys(shopContentMapping) as Content[]; + +export type ShopContent = ShopContentMapping[Content]; +export const shopContentList = R.uniq(Object.values(shopContentMapping)) as ShopContent[]; + + diff --git a/e2e/src/reject-invalid-job-id.spec.ts b/e2e/src/reject-invalid-job-id.spec.ts index 9a15dc99..ecd7472e 100644 --- a/e2e/src/reject-invalid-job-id.spec.ts +++ b/e2e/src/reject-invalid-job-id.spec.ts @@ -3,12 +3,12 @@ import {beforeEach, describe, expect} from "@jest/globals"; import axios from "axios"; import {from, lastValueFrom, map, toArray, zip} from "rxjs"; import {probe} from "./helpers/mock-probe"; -import {Controller, controllerList} from "./helpers/controllers"; +import { ShopContent, shopContentList } from "./helpers/shop-contents"; describe('Reject invalid job-id', () => { let testIndex = 0; - const controllers: Controller[] = controllerList + const shopContents: ShopContent[] = shopContentList let jobId: string; @@ -16,10 +16,10 @@ describe('Reject invalid job-id', () => { jobId = `invalid-job-id-${testIndex++}` }); - it.each(controllers)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (controller) => { + it.each(shopContents)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&job_id=${jobId}` + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&job_id=${jobId}` const message$ = probe({params: {id: jobId}}); //act From 99d8fc08c84c72db739896d80ef54c3861c3b0f9 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 6 Aug 2024 16:23:33 +0200 Subject: [PATCH 019/162] fix: healtcheck --- e2e/src/helpers/data-helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 94fa82ff..75cc60f8 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -56,7 +56,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=helathcheck&job_id=valid-job-healthcheck` + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-healthcheck` ); healthCheck = res.data; cachedHealthCheck = healthCheck; From 7a08f68bd70fe9eb1b76b2e450f7bb74832f870f Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 6 Aug 2024 16:29:27 +0200 Subject: [PATCH 020/162] fix: phpcs-fixer --- controllers/front/apiFront.php | 3 +- ps_eventbus.php | 8 +-- src/Handler/ErrorHandler/ErrorHandler.php | 8 +-- src/Interfaces/RepositoryInterface.php | 7 +- .../ShopContentServiceInterface.php | 2 + src/Repository/AbstractRepository.php | 13 ++-- src/Repository/OrdersRepository.php | 3 +- src/Service/CommonService.php | 1 + src/Service/FrontApiService.php | 29 ++++---- src/Service/HealthCheckService.php | 7 +- src/Service/ShopContent/OrdersService.php | 14 ++-- src/Service/SynchronizationService.php | 17 ++--- src/Traits/UseHooks.php | 70 +++++++++---------- upgrade/Upgrade-4.0.0.php | 6 +- 14 files changed, 87 insertions(+), 101 deletions(-) diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index fd6ade0f..2ea96b0c 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -30,9 +30,8 @@ public function postProcess() $debug = Tools::getValue('debug') == 1; /** @var FrontApiService $frontApiService */ - $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); + $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); } } - diff --git a/ps_eventbus.php b/ps_eventbus.php index 1861d93c..59dba4a6 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -24,9 +24,9 @@ * International Registered Trademark & Property of PrestaShop SA */ +use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; -use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; if (!defined('_PS_VERSION_')) { @@ -199,7 +199,7 @@ public function getModuleEnv($default = null) } /** - * @return PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer + * @return ServiceContainer * * @throws Exception */ @@ -207,7 +207,7 @@ public function getServiceContainer() { if (null === $this->serviceContainer) { // append version number to force cache generation (1.6 Core won't clear it) - $this->serviceContainer = new PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer( + $this->serviceContainer = new ServiceContainer( $this->name . str_replace(['.', '-', '+'], '', $this->version), $this->getLocalPath(), $this->getModuleEnv() @@ -226,7 +226,7 @@ public function getServiceContainer() * @return mixed */ public function getService($serviceName) - { + { try { return $this->getServiceContainer()->getService($serviceName); } catch (ServiceNotFoundException $exception) { diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index c4a1ebae..294d2a2e 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -22,9 +22,7 @@ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; use Exception; -use Module; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; -use PrestaShopLogger; /** * Handle Error. @@ -71,7 +69,7 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc } /** - * @param Exception $error + * @param \Exception $error * @param mixed $code * @param bool|null $throw * @param array|null $data @@ -92,12 +90,12 @@ public function handle($error, $code = null, $throw = null, $data = null) $this->client->captureException($error, $data); - PrestaShopLogger::addLog( + \PrestaShopLogger::addLog( $error->getMessage() . ' : ' . $error->getFile() . ':' . $error->getLine() . ' | ' . $error->getTraceAsString(), 3, $error->getCode(), 'Module', - Module::getModuleIdByName('ps_eventbus'), + \Module::getModuleIdByName('ps_eventbus'), true ); diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php index 7c350f33..7c696bd7 100644 --- a/src/Interfaces/RepositoryInterface.php +++ b/src/Interfaces/RepositoryInterface.php @@ -2,15 +2,16 @@ namespace PrestaShop\Module\PsEventbus\Interfaces; -use DbQuery; - /** - * @property DbQuery $query + * @property \DbQuery $query */ interface RepositoryInterface { public function generateBaseQuery(); + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + public function countFullSyncContentLeft($offset, $langIso = null); } diff --git a/src/Interfaces/ShopContentServiceInterface.php b/src/Interfaces/ShopContentServiceInterface.php index b52c7760..d2404dc5 100644 --- a/src/Interfaces/ShopContentServiceInterface.php +++ b/src/Interfaces/ShopContentServiceInterface.php @@ -5,6 +5,8 @@ interface ShopContentServiceInterface { public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + public function countFullSyncContentLeft($offset, $langIso = null); } diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 16e5fd29..0727c0ae 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -2,32 +2,29 @@ namespace PrestaShop\Module\PsEventbus\Repository; -use Context; -use Db; -use DbQuery; use PrestaShop\Module\PsEventbus\Service\CommonService; abstract class AbstractRepository { /** - * @var Context + * @var \Context */ private $context; /** - * @var Db + * @var \Db */ private $db; /** - * @var DbQuery + * @var \DbQuery */ protected $query; public function __construct() { - $this->context = Context::getContext(); - $this->db = Db::getInstance(); + $this->context = \Context::getContext(); + $this->db = \Db::getInstance(); } public function getShopId() diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index 76aa1fed..4c4b41e6 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -3,7 +3,6 @@ namespace PrestaShop\Module\PsEventbus\Repository; use PrestaShop\Module\PsEventbus\Interfaces\RepositoryInterface; -use PrestaShop\Module\PsEventbus\Repository\AbstractRepository; class OrdersRepository extends AbstractRepository implements RepositoryInterface { @@ -62,7 +61,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, $this->query->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - + return $this->runQuery($debug); } diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 9e72ec79..9666be7e 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -1,4 +1,5 @@ startTime = time(); $this->module = $module; @@ -70,9 +64,9 @@ public function __construct( } public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) - { + { try { - if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [CONFIG::COLLECTION_HEALTHCHECK]), true)) { + if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } @@ -83,6 +77,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, if ($isHealthCheck) { /** @var HealthCheckService $healthCheckService */ $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); + return $healthCheckService->getHealthCheck($isAuthentified); } @@ -99,7 +94,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); - + $langIso = $langIso ? $langIso : $languageRepository->getDefaultLanguageIsoCode(); $offset = 0; @@ -159,7 +154,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $response ) ); - } catch (PrestaShopDatabaseException $exception) { + } catch (\PrestaShopDatabaseException $exception) { $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } catch (EnvVarException $exception) { @@ -171,7 +166,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } catch (\Exception $exception) { $this->errorHandler->handle($exception); - CommonService::dieWithResponse(["message" => "An error occured. Please check logs for more information"], 500); + CommonService::dieWithResponse(['message' => 'An error occured. Please check logs for more information'], 500); } } @@ -188,12 +183,12 @@ private function authorize($jobId, $isHealthCheck = null) if (is_array($authorizationResponse)) { CommonService::exitWithResponse($authorizationResponse); } elseif (!$authorizationResponse) { - throw new PrestaShopDatabaseException('Failed saving job id to database'); + throw new \PrestaShopDatabaseException('Failed saving job id to database'); } try { $token = $this->psAccountsAdapterService->getOrRefreshToken(); - } catch (Exception $exception) { + } catch (\Exception $exception) { throw new FirebaseException($exception->getMessage()); } @@ -208,7 +203,7 @@ private function authorize($jobId, $isHealthCheck = null) return false; } - if ($exception instanceof PrestaShopDatabaseException) { + if ($exception instanceof \PrestaShopDatabaseException) { $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } elseif ($exception instanceof EnvVarException) { diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 595a58b6..9737eca1 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -3,15 +3,13 @@ namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository; -use PrestaShop\Module\PsEventbus\Service\CommonService; -use Ps_eventbus; class HealthCheckService { - /** @var Ps_Eventbus $module */ + /** @var \Ps_eventbus */ private $module; - public function __construct(Ps_eventbus $module) + public function __construct(\Ps_eventbus $module) { $this->module = $module; } @@ -34,5 +32,4 @@ public function getHealthCheck($isAuthentified = null) CommonService::exitWithResponse($status); } - } diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index ccdfdbcf..2a66e13d 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -10,7 +10,7 @@ class OrdersService implements ShopContentServiceInterface { - /** @var OrdersRepository $ordersRepository */ + /** @var OrdersRepository */ private $ordersRepository; /** @var OrderHistoryRepository */ @@ -29,7 +29,8 @@ public function __construct( $this->arrayFormatter = $arrayFormatter; } - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + { $orders = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { @@ -47,7 +48,8 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa }, $orders); } - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + { $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); if (empty($result)) { @@ -65,14 +67,15 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, }, $orders); } - public function countFullSyncContentLeft($offset, $langIso = null) { + public function countFullSyncContentLeft($offset, $langIso = null) + { return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); } public function castOrders(&$orders, $langIso) { $langId = (int) \Language::getIdByIso($langIso); - + foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; $order['id_customer'] = (int) $order['id_customer']; @@ -176,5 +179,4 @@ private function castAddressIsoCodes(&$orderDetail) } } } - } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 36185ceb..315897e5 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -44,7 +44,6 @@ class SynchronizationService */ private $proxyService; - public function __construct( EventbusSyncRepository $eventbusSyncRepository, IncrementalSyncRepository $incrementalSyncRepository, @@ -87,9 +86,9 @@ public function sendFullSync( ) { $response = []; - $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceName = str_replace('-', '', ucwords($shopContent, '-')); $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent - + /** @var \Ps_eventbus */ $module = \Module::getInstanceByName('ps_eventbus'); @@ -152,10 +151,9 @@ public function sendIncrementalSync( ) { $response = []; - $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceName = str_replace('-', '', ucwords($shopContent, '-')); $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; - /** @var \Ps_eventbus */ $module = \Module::getInstanceByName('ps_eventbus'); @@ -232,9 +230,9 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, * If count > 100 000, we removed all entry corresponding to this shop content, and we enable full sync for this */ if (mt_rand() % Config::RANDOM_SYNC_CHECK_MAX == 0) { - foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($contentType); - + if ($count > Config::INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT) { $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); @@ -259,7 +257,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $allIsoCodes = $this->languageRepository->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { - foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { foreach ($contentIds as $contentId) { if ($this->isFullSyncDone($contentType, $langIso)) { array_push($contentToInsert, @@ -274,13 +272,12 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, ); } } - } } } else { $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { foreach ($contentIds as $contentId) { if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { array_push($contentToInsert, diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 11a9f02a..54005323 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -2,102 +2,102 @@ namespace PrestaShop\Module\PsEventbus\Traits; -use Exception; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; -use SpecificPrice; -trait UseHooks { - public function getHooks() { +trait UseHooks +{ + public function getHooks() + { // Retourne la liste des hooks a register return [ 'actionObjectCarrierAddAfter', 'actionObjectCarrierDeleteAfter', 'actionObjectCarrierUpdateAfter', - + 'actionObjectCartAddAfter', 'actionObjectCartUpdateAfter', - + 'actionObjectCartRuleAddAfter', 'actionObjectCartRuleDeleteAfter', 'actionObjectCartRuleUpdateAfter', - + 'actionObjectCategoryAddAfter', 'actionObjectCategoryDeleteAfter', 'actionObjectCategoryUpdateAfter', - + 'actionObjectCombinationDeleteAfter', - + 'actionObjectCountryAddAfter', 'actionObjectCountryDeleteAfter', 'actionObjectCountryUpdateAfter', - + 'actionObjectCurrencyAddAfter', 'actionObjectCurrencyUpdateAfter', - + 'actionObjectCustomerAddAfter', 'actionObjectCustomerDeleteAfter', 'actionObjectCustomerUpdateAfter', - + 'actionObjectImageAddAfter', 'actionObjectImageDeleteAfter', 'actionObjectImageUpdateAfter', - + 'actionObjectLanguageAddAfter', 'actionObjectLanguageDeleteAfter', 'actionObjectLanguageUpdateAfter', - + 'actionObjectManufacturerAddAfter', 'actionObjectManufacturerDeleteAfter', 'actionObjectManufacturerUpdateAfter', - + 'actionObjectOrderAddAfter', 'actionObjectOrderUpdateAfter', - + 'actionObjectProductAddAfter', 'actionObjectProductDeleteAfter', 'actionObjectProductUpdateAfter', - + 'actionObjectSpecificPriceAddAfter', 'actionObjectSpecificPriceDeleteAfter', 'actionObjectSpecificPriceUpdateAfter', - + 'actionObjectStateAddAfter', 'actionObjectStateDeleteAfter', 'actionObjectStateUpdateAfter', - + 'actionObjectStockAddAfter', 'actionObjectStockUpdateAfter', - + 'actionObjectStoreAddAfter', 'actionObjectStoreDeleteAfter', 'actionObjectStoreUpdateAfter', - + 'actionObjectSupplierAddAfter', 'actionObjectSupplierDeleteAfter', 'actionObjectSupplierUpdateAfter', - + 'actionObjectTaxAddAfter', 'actionObjectTaxDeleteAfter', 'actionObjectTaxRulesGroupAddAfter', 'actionObjectTaxRulesGroupDeleteAfter', 'actionObjectTaxRulesGroupUpdateAfter', 'actionObjectTaxUpdateAfter', - + 'actionObjectWishlistAddAfter', 'actionObjectWishlistDeleteAfter', 'actionObjectWishlistUpdateAfter', - + 'actionObjectZoneAddAfter', 'actionObjectZoneDeleteAfter', 'actionObjectZoneUpdateAfter', - + 'actionShippingPreferencesPageSave', - + 'actionObjectEmployeeAddAfter', 'actionObjectEmployeeDeleteAfter', 'actionObjectEmployeeUpdateAfter', - + 'actionDispatcherBefore', ]; } @@ -1441,14 +1441,14 @@ public function hookActionDispatcherBefore($parameters) // when translation is edited or reset, add to incremental sync if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_TRANSLATIONS => 0], + [Config::COLLECTION_TRANSLATIONS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); } } - } catch (Exception $e) { + } catch (\Exception $e) { return; } } @@ -1463,10 +1463,10 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var SpecificPrice $specificPrice */ + /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof SpecificPrice) { + if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -1489,10 +1489,10 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var SpecificPrice $specificPrice */ + /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof SpecificPrice) { + if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -1515,10 +1515,10 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var SpecificPrice $specificPrice */ + /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof SpecificPrice) { + if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); $synchronizationService->insertContentIntoIncremental( diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index 20cfed1c..8ee106b3 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -1,18 +1,16 @@ query($editIncrementalTable); - + // If ALTER is failed, stop update process if (!$editIncrementalTableResult) { return false; From 98b9c008c37f86451fa1c3febe612e36dbc22e2b Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 7 Aug 2024 17:17:32 +0200 Subject: [PATCH 021/162] fix: phpcs-fixer and phpstan --- controllers/front/apiFront.php | 7 +- src/Builder/CarrierBuilder.php | 6 +- src/Interfaces/ProxyServiceInterface.php | 2 +- src/Interfaces/RepositoryInterface.php | 32 +- .../ShopContentServiceInterface.php | 29 +- src/Provider/OrderDataProvider.php | 429 ------------------ src/Repository/AbstractRepository.php | 32 +- src/Repository/CountryRepository.php | 6 +- src/Repository/OrderHistoryRepository.php | 2 +- src/Repository/OrdersRepository.php | 45 +- src/Repository/StateRepository.php | 6 +- src/Repository/TaxRepository.php | 6 +- src/Service/CommonService.php | 8 +- src/Service/FrontApiService.php | 26 +- src/Service/HealthCheckService.php | 10 +- src/Service/ProxyService.php | 2 +- src/Service/ShopContent/OrdersService.php | 47 +- src/Service/SynchronizationService.php | 67 ++- src/Traits/UseHooks.php | 264 +++++++---- 19 files changed, 421 insertions(+), 605 deletions(-) delete mode 100644 src/Provider/OrderDataProvider.php diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 2ea96b0c..01c07340 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -23,14 +23,17 @@ public function postProcess() /** @var int $limit */ $limit = Tools::getValue('limit', 50); - /** @var bool $initFullSync */ + /** @var bool $isFull */ $isFull = Tools::getValue('full', 0) == 1; /** @var bool $debug */ $debug = Tools::getValue('debug') == 1; + /** @var Ps_eventbus $module */ + $module = Module::getInstanceByName('ps_eventbus'); + /** @var FrontApiService $frontApiService */ - $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); + $frontApiService = $module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); } diff --git a/src/Builder/CarrierBuilder.php b/src/Builder/CarrierBuilder.php index 9139eca2..aeb65fed 100644 --- a/src/Builder/CarrierBuilder.php +++ b/src/Builder/CarrierBuilder.php @@ -186,14 +186,14 @@ private function buildCarrierDetails(\Carrier $carrier, $range, $zone) $carrierDetail->setRangeId($rangeId); /** @var array $countryIsoCodes */ - $countryIsoCodes = $this->countryRepository->getCountyIsoCodesByZoneId($zone['id_zone']); + $countryIsoCodes = $this->countryRepository->getCountyIsoCodesByZoneId($zone['id_zone'], true); if (!$countryIsoCodes) { return false; } $carrierDetail->setCountryIsoCodes($countryIsoCodes); /** @var array $stateIsoCodes */ - $stateIsoCodes = $this->stateRepository->getStateIsoCodesByZoneId($zone['id_zone']); + $stateIsoCodes = $this->stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); $carrierDetail->setStateIsoCodes($stateIsoCodes); return $carrierDetail; @@ -212,7 +212,7 @@ private function buildCarrierTaxes(\Carrier $carrier, $zoneId, $rangeId) { $taxRulesGroupId = (int) $carrier->getIdTaxRulesGroup(); /** @var array $carrierTaxesByZone */ - $carrierTaxesByZone = $this->taxRepository->getCarrierTaxesByZone($zoneId, $taxRulesGroupId); + $carrierTaxesByZone = $this->taxRepository->getCarrierTaxesByZone($zoneId, $taxRulesGroupId, true); if (!$carrierTaxesByZone[0]['country_iso_code']) { return null; diff --git a/src/Interfaces/ProxyServiceInterface.php b/src/Interfaces/ProxyServiceInterface.php index 10c319bc..528ff932 100644 --- a/src/Interfaces/ProxyServiceInterface.php +++ b/src/Interfaces/ProxyServiceInterface.php @@ -12,7 +12,7 @@ interface ProxyServiceInterface * * @return array */ - public function upload($jobId, $data, $scriptStartTime, $isFull = null); + public function upload($jobId, $data, $scriptStartTime, $isFull); /** * @param string $jobId diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php index 7c696bd7..9723ab2d 100644 --- a/src/Interfaces/RepositoryInterface.php +++ b/src/Interfaces/RepositoryInterface.php @@ -7,11 +7,37 @@ */ interface RepositoryInterface { + /** + * @return mixed + */ public function generateBaseQuery(); - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug); - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug); - public function countFullSyncContentLeft($offset, $langIso = null); + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug); } diff --git a/src/Interfaces/ShopContentServiceInterface.php b/src/Interfaces/ShopContentServiceInterface.php index d2404dc5..9223815c 100644 --- a/src/Interfaces/ShopContentServiceInterface.php +++ b/src/Interfaces/ShopContentServiceInterface.php @@ -4,9 +4,32 @@ interface ShopContentServiceInterface { - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug); - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + /** + * @param int $limit + * @param mixed $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug); - public function countFullSyncContentLeft($offset, $langIso = null); + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug); } diff --git a/src/Provider/OrderDataProvider.php b/src/Provider/OrderDataProvider.php deleted file mode 100644 index 4dc4a478..00000000 --- a/src/Provider/OrderDataProvider.php +++ /dev/null @@ -1,429 +0,0 @@ -ordersRepository = $ordersRepository; - $this->context = $context; - $this->arrayFormatter = $arrayFormatter; - $this->orderDetailsRepository = $orderDetailsRepository; - $this->orderHistoryRepository = $orderHistoryRepository; - $this->orderCartRuleRepository = $orderCartRuleRepository; - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $orders = $this->ordersRepository->getOrders($offset, $limit, $this->shopId); - - if (empty($orders)) { - return []; - } - - $langId = (int) \Language::getIdByIso($langIso); - $this->castOrderValues($orders, $langId); - - $orderDetails = $this->getOrderDetails($orders); - $orderStatuses = $this->getOrderStatuses($orders, $langId); - $orderCartRules = $this->getOrderCartRules($orders); - - $orders = array_map(function ($order) { - return [ - 'id' => $order['id_order'], - 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, - ]; - }, $orders); - - return array_merge($orders, $orderDetails, $orderStatuses, $orderCartRules); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->ordersRepository->getRemainingOrderCount($offset, $this->shopId); - } - - /** - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $langId = (int) \Language::getIdByIso($langIso); - $orders = $this->ordersRepository->getOrdersIncremental($limit, $this->shopId, $objectIds); - - if (!is_array($orders) || empty($orders)) { - return []; - } - - $orderDetails = $this->getOrderDetails($orders); - $orderStatuses = $this->getOrderStatuses($orders, $langId); - $orderCartRules = $this->getOrderCartRules($orders); - - $this->castOrderValues($orders, (int) \Language::getIdByIso($langIso)); - - $orders = array_map(function ($order) { - return [ - 'id' => $order['id_order'], - 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, - ]; - }, $orders); - - return array_merge($orders, $orderDetails, $orderStatuses, $orderCartRules); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->ordersRepository->getQueryForDebug($offset, $limit, $this->shopId); - } - - /** - * @param array $orders - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getOrderDetails($orders) - { - if (empty($orders)) { - return []; - } - - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - - $orderDetails = $this->orderDetailsRepository->getOrderDetails($orderIds, $this->shopId); - - if (!is_array($orderDetails) || empty($orderDetails)) { - return []; - } - - $this->castOrderDetailValues($orderDetails); - - $orderDetails = array_map(function ($orderDetail) { - return [ - 'id' => $orderDetail['id_order_detail'], - 'collection' => Config::COLLECTION_ORDER_DETAILS, - 'properties' => $orderDetail, - ]; - }, $orderDetails); - - return $orderDetails; - } - - /** - * @param array $orders - * @param int $langId - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getOrderStatuses($orders, $langId) - { - if (empty($orders)) { - return []; - } - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - $orderHistoryStatuses = $this->orderHistoryRepository->getOrderHistoryStatuses($orderIds, $langId); - $orderHistoryStatuses = $this->castOrderStatuses($orderHistoryStatuses); - - return array_map(function ($orderHistoryStatus) { - return [ - 'id' => $orderHistoryStatus['id_order_history'], - 'collection' => Config::COLLECTION_ORDER_STATUS_HISTORY, - 'properties' => $orderHistoryStatus, - ]; - }, $orderHistoryStatuses); - } - - /** - * @param array $orders - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getOrderCartRules($orders) - { - if (empty($orders)) { - return []; - } - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - $orderCartRules = $this->orderCartRuleRepository->getOrderCartRules($orderIds); - $this->castOrderCartRulesValues($orderCartRules); - - return array_map(function ($orderCartRule) { - return [ - 'id' => $orderCartRule['id_order_cart_rule'], - 'collection' => Config::COLLECTION_ORDER_CART_RULES, - 'properties' => $orderCartRule, - ]; - }, $orderCartRules); - } - - /** - * @param array $orders - * @param int $langId - * - * @return void - * - * @@throws \PrestaShopDatabaseException - */ - private function castOrderValues(&$orders, $langId) - { - foreach ($orders as &$order) { - $order['id_order'] = (int) $order['id_order']; - $order['id_customer'] = (int) $order['id_customer']; - $order['current_state'] = (int) $order['current_state']; - $order['conversion_rate'] = (float) $order['conversion_rate']; - $order['total_paid_tax_incl'] = (float) $order['total_paid_tax_incl']; - $order['total_paid_tax_excl'] = (float) $order['total_paid_tax_excl']; - $order['refund'] = (float) $order['refund']; - $order['refund_tax_excl'] = (float) $order['refund_tax_excl']; - $order['new_customer'] = $order['new_customer'] == 1; - $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langId); - $order['shipping_cost'] = (float) $order['shipping_cost']; - $order['total_paid_tax'] = $order['total_paid_tax_incl'] - $order['total_paid_tax_excl']; - $order['id_carrier'] = (int) $order['id_carrier']; - - $order['id_shop_group'] = (int) $order['id_shop_group']; - $order['id_shop'] = (int) $order['id_shop']; - $order['id_lang'] = (int) $order['id_lang']; - $order['id_currency'] = (int) $order['id_currency']; - $order['recyclable'] = (bool) $order['recyclable']; - $order['gift'] = (bool) $order['gift']; - - $order['total_discounts'] = (int) $order['total_discounts']; - $order['total_discounts_tax_incl'] = (int) $order['total_discounts_tax_incl']; - $order['total_discounts_tax_excl'] = (int) $order['total_discounts_tax_excl']; - $order['total_products'] = (int) $order['total_products']; - $order['total_products_wt'] = (int) $order['total_products_wt']; - $order['total_shipping_tax_incl'] = (int) $order['total_shipping_tax_incl']; - $order['total_shipping_tax_excl'] = (int) $order['total_shipping_tax_excl']; - - $order['carrier_tax_rate'] = (int) $order['carrier_tax_rate']; - $order['total_wrapping'] = (int) $order['total_wrapping']; - $order['total_wrapping_tax_incl'] = (int) $order['total_wrapping_tax_incl']; - $order['total_wrapping_tax_excl'] = (int) $order['total_wrapping_tax_excl']; - $order['round_mode'] = (int) $order['round_mode']; - $order['round_type'] = (int) $order['round_type']; - $order['invoice_number'] = (int) $order['invoice_number']; - $order['delivery_number'] = (int) $order['delivery_number']; - $order['valid'] = (bool) $order['valid']; - - $this->castAddressIsoCodes($order); - unset($order['address_iso']); - } - } - - /** - * @param array $orders - * @param array $order - * @param int $langId - * - * @return bool - * - * @@throws \PrestaShopDatabaseException - */ - private function castIsPaidValue($orders, $order, $langId) - { - $isPaid = $dateAdd = 0; - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - /** @var array $orderHistoryStatuses */ - $orderHistoryStatuses = $this->orderHistoryRepository->getOrderHistoryStatuses($orderIds, $langId); - - foreach ($orderHistoryStatuses as &$orderHistoryStatus) { - if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { - $isPaid = (bool) $orderHistoryStatus['paid']; - $dateAdd = $orderHistoryStatus['date_add']; - } - } - - return (bool) $isPaid; - } - - /** - * @param array $orderDetails - * - * @return void - */ - private function castOrderDetailValues(&$orderDetails) - { - foreach ($orderDetails as &$orderDetail) { - $orderDetail['id_order_detail'] = (int) $orderDetail['id_order_detail']; - $orderDetail['id_order'] = (int) $orderDetail['id_order']; - $orderDetail['product_id'] = (int) $orderDetail['product_id']; - $orderDetail['product_attribute_id'] = (int) $orderDetail['product_attribute_id']; - $orderDetail['product_quantity'] = (int) $orderDetail['product_quantity']; - $orderDetail['unit_price_tax_incl'] = (float) $orderDetail['unit_price_tax_incl']; - $orderDetail['unit_price_tax_excl'] = (float) $orderDetail['unit_price_tax_excl']; - $orderDetail['refund'] = (float) $orderDetail['refund'] > 0 ? -1 * (float) $orderDetail['refund'] : 0; - $orderDetail['refund_tax_excl'] = (float) $orderDetail['refund_tax_excl'] > 0 ? -1 * (float) $orderDetail['refund_tax_excl'] : 0; - $orderDetail['category'] = (int) $orderDetail['category']; - $orderDetail['unique_product_id'] = "{$orderDetail['product_id']}-{$orderDetail['product_attribute_id']}-{$orderDetail['iso_code']}"; - $orderDetail['conversion_rate'] = (float) $orderDetail['conversion_rate']; - } - } - - /** - * @param array $orderStatuses - * - * @return array - */ - private function castOrderStatuses(&$orderStatuses) - { - $castedOrderStatuses = []; - foreach ($orderStatuses as $orderStatus) { - $castedOrderStatus = []; - $castedOrderStatus['id_order_state'] = (int) $orderStatus['id_order_state']; - $castedOrderStatus['id_order'] = (int) $orderStatus['id_order']; - $castedOrderStatus['id_order_history'] = (int) $orderStatus['id_order_history']; - $castedOrderStatus['name'] = (string) $orderStatus['name']; - $castedOrderStatus['template'] = (string) $orderStatus['template']; - $castedOrderStatus['date_add'] = $orderStatus['date_add']; - $castedOrderStatus['is_validated'] = (bool) $orderStatus['logable']; - $castedOrderStatus['is_delivered'] = (bool) $orderStatus['delivery']; - $castedOrderStatus['is_shipped'] = (bool) $orderStatus['shipped']; - $castedOrderStatus['is_paid'] = (bool) $orderStatus['paid']; - $castedOrderStatus['is_deleted'] = (bool) $orderStatus['deleted']; - $castedOrderStatus['created_at'] = $castedOrderStatus['date_add']; - $castedOrderStatus['updated_at'] = $castedOrderStatus['date_add']; - $castedOrderStatuses[] = $castedOrderStatus; - } - - return $castedOrderStatuses; - } - - /** - * @param array $orderDetail - * - * @return void - */ - private function castAddressIsoCodes(&$orderDetail) - { - if (!$orderDetail['address_iso']) { - $orderDetail['invoice_country_code'] = null; - $orderDetail['delivery_country_code'] = null; - - return; - } - - $addressAndIsoCodes = explode(',', $orderDetail['address_iso']); - if (count($addressAndIsoCodes) === 1) { - $addressAndIsoCode = explode(':', $addressAndIsoCodes[0]); - $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; - $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; - - return; - } - - foreach ($addressAndIsoCodes as $addressAndIsoCodeString) { - $addressAndIsoCode = explode(':', $addressAndIsoCodeString); - if ($addressAndIsoCode[0] === 'delivery') { - $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; - } elseif ($addressAndIsoCode[0] === 'invoice') { - $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; - } - } - } - - /** - * @param array $orderCartRules - * - * @return void - */ - private function castOrderCartRulesValues(&$orderCartRules) - { - foreach ($orderCartRules as &$orderCartRule) { - $orderCartRule['id_order_cart_rule'] = (int) $orderCartRule['id_order_cart_rule']; - $orderCartRule['id_order'] = (int) $orderCartRule['id_order']; - $orderCartRule['id_cart_rule'] = (int) $orderCartRule['id_cart_rule']; - $orderCartRule['id_order_invoice'] = (int) $orderCartRule['id_order_invoice']; - $orderCartRule['value'] = (float) $orderCartRule['value']; - $orderCartRule['value_tax_excl'] = (float) $orderCartRule['value_tax_excl']; - $orderCartRule['free_shipping'] = (bool) $orderCartRule['free_shipping']; - $orderCartRule['deleted'] = isset($orderCartRule['deleted']) ? (bool) $orderCartRule['deleted'] : false; - } - } -} diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 0727c0ae..364e2c87 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -23,10 +23,21 @@ abstract class AbstractRepository public function __construct() { - $this->context = \Context::getContext(); + $context = \Context::getContext(); + + if ($context == null) { + throw new \PrestaShopException('Context not found'); + } + + $this->context = $context; $this->db = \Db::getInstance(); } + /** + * @return int + * + * @throws \PrestaShopException + */ public function getShopId() { if ($this->context->shop === null) { @@ -36,15 +47,30 @@ public function getShopId() return (int) $this->context->shop->id; } + /** + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ protected function runQuery($debug) { - if ($debug) { + if ($debug != null && $debug === true) { $this->debugQuery(); } - return $this->db->executeS($this->query); + $result = $this->db->executeS($this->query); + + return is_array($result) ? $result : []; } + /** + * @return void + * + * @throws \PrestaShopException + */ private function debugQuery() { $queryStringified = preg_replace('/\s+/', ' ', $this->query->build()); diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index 43e637d8..1c34582d 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -57,12 +57,8 @@ private function getBaseQuery() * * @throws \PrestaShopDatabaseException */ - public function getCountyIsoCodesByZoneId($zoneId, $active = null) + public function getCountyIsoCodesByZoneId($zoneId, $active) { - if ($active == null) { - $active = true; - } - $cacheKey = $zoneId . '-' . (int) $active; if (!isset($this->countryIsoCodeCache[$cacheKey])) { diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php index 9cf0d31d..99385541 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -30,7 +30,7 @@ public function getBaseQuery() /** * @param array $orderIds - * @param int $langId + * @param int|null $langId * * @return array|bool|\mysqli_result|\PDOStatement|resource|null * diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index 4c4b41e6..a699cdf9 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -8,6 +8,11 @@ class OrdersRepository extends AbstractRepository implements RepositoryInterface { public const ORDERS_TABLE = 'orders'; + /** + * @return mixed + * + * @throws \PrestaShopException + */ public function generateBaseQuery() { $this->query = new \DbQuery(); @@ -46,7 +51,18 @@ public function generateBaseQuery() $this->query->select('o.round_mode, o.round_type, o.invoice_number, o.delivery_number, o.invoice_date, o.delivery_date, o.valid'); } - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) { $this->generateBaseQuery(); @@ -55,7 +71,18 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa return $this->runQuery($debug); } - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { $this->generateBaseQuery(); @@ -65,9 +92,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, return $this->runQuery($debug); } - public function countFullSyncContentLeft($offset, $langIso = null, $debug = false) + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) { - $orders = $this->getContentsForFull($offset, 1, parent::getShopId(), $debug); + $orders = $this->getContentsForFull($offset, 1, $langIso, $debug); if (!is_array($orders) || empty($orders)) { return 0; diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index c7e92b73..372cc239 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -39,12 +39,8 @@ private function getBaseQuery() * * @throws \PrestaShopDatabaseException */ - public function getStateIsoCodesByZoneId($zoneId, $active = null) + public function getStateIsoCodesByZoneId($zoneId, $active) { - if ($active == null) { - $active = true; - } - $cacheKey = $zoneId . '-' . (int) $active; if (!isset($this->stateIsoCodeCache[$cacheKey])) { diff --git a/src/Repository/TaxRepository.php b/src/Repository/TaxRepository.php index 0ccb78c3..a0fbd029 100644 --- a/src/Repository/TaxRepository.php +++ b/src/Repository/TaxRepository.php @@ -64,12 +64,8 @@ private function getBaseQuery() * * @throws \PrestaShopDatabaseException */ - public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active = null) + public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active) { - if ($active == null) { - $active = true; - } - $cacheKey = $zoneId . '-' . (int) $active; if (!isset($this->countryIsoCodeCache[$cacheKey])) { diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 9666be7e..35756687 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -10,11 +10,11 @@ class CommonService { /** - * @param array $response + * @param array $response * * @return void */ - public static function exitWithResponse(array $response) + public static function exitWithResponse($response) { $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; @@ -51,12 +51,12 @@ public static function exitWithExceptionMessage(\Exception $exception) } /** - * @param array $response + * @param array $response * @param int $code * * @return void */ - public static function dieWithResponse(array $response, $code) + public static function dieWithResponse($response, $code) { $httpStatusText = "HTTP/1.1 $code"; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index c2ae71aa..ddec1fa0 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -7,6 +7,7 @@ use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; +use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; @@ -63,7 +64,17 @@ public function __construct( $this->eventbusSyncRepository = $eventbusSyncRepository; } - public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) + /** + * @param string $shopContent + * @param string $jobId + * @param string $langIso + * @param int $limit + * @param bool $isFull + * @param bool $debug + * + * @return void + */ + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug) { try { if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { @@ -78,7 +89,9 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, /** @var HealthCheckService $healthCheckService */ $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); - return $healthCheckService->getHealthCheck($isAuthentified); + $healthCheckService->getHealthCheck($isAuthentified); + + return; } if ($limit < 0) { @@ -171,11 +184,14 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } /** - * @return bool|void + * @param string $jobId + * @param bool $isHealthCheck + * + * @return bool * * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException */ - private function authorize($jobId, $isHealthCheck = null) + private function authorize($jobId, $isHealthCheck) { try { $authorizationResponse = $this->apiAuthorizationService->authorizeCall($jobId); @@ -213,6 +229,8 @@ private function authorize($jobId, $isHealthCheck = null) $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } + + return false; } } } diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 9737eca1..19d0d8d9 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -15,16 +15,14 @@ public function __construct(\Ps_eventbus $module) } /** + * @param bool $isAuthentified + * * @return void * - * @throws PrestaShopException + * @throws \PrestaShopException */ - public function getHealthCheck($isAuthentified = null) + public function getHealthCheck($isAuthentified) { - if ($isAuthentified == null) { - $isAuthentified = false; - } - /** @var ServerInformationRepository $serverInformationRepository */ $serverInformationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository'); diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index a0905857..2f8e9091 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -42,7 +42,7 @@ public function __construct(CollectorApiClient $eventBusProxyClient, JsonFormatt * * @throws EnvVarException */ - public function upload($jobId, $data, $scriptStartTime, $isFull = null) + public function upload($jobId, $data, $scriptStartTime, $isFull) { $dataJson = $this->jsonFormatter->formatNewlineJsonString($data); diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 2a66e13d..a1680a5b 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -29,11 +29,19 @@ public function __construct( $this->arrayFormatter = $arrayFormatter; } - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) { $orders = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); - if (empty($result)) { + if (empty($orders)) { return []; } @@ -48,11 +56,19 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa }, $orders); } - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); + $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); - if (empty($result)) { + if (empty($orders)) { return []; } @@ -67,14 +83,27 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, }, $orders); } - public function countFullSyncContentLeft($offset, $langIso = null) + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) { - return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso, $debug); } + /** + * @param array $orders + * @param string $langIso + * + * @return void + */ public function castOrders(&$orders, $langIso) { - $langId = (int) \Language::getIdByIso($langIso); + $langId = \Language::getIdByIso($langIso); foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; @@ -124,7 +153,7 @@ public function castOrders(&$orders, $langIso) /** * @param array $orders * @param array $order - * @param int $langId + * @param int|null $langId * * @return bool * diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 315897e5..b0d7718b 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -2,15 +2,16 @@ namespace PrestaShop\Module\PsEventbus\Service; -use Behat\Behat\HelperContainer\Exception\ServiceNotFoundException; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; use PrestaShop\Module\PsEventbus\Interfaces\ProxyServiceInterface; use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; +use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; class SynchronizationService { @@ -70,7 +71,7 @@ public function __construct( * @param string $dateNow * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException|ApiException */ @@ -117,7 +118,7 @@ public function sendFullSync( } } - $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $langIso); + $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $langIso, $debug); if ($remainingObjects <= 0) { $remainingObjects = 0; @@ -130,14 +131,14 @@ public function sendFullSync( } /** - * @param string $type + * @param string $shopContent * @param string $jobId * @param string $langIso * @param int $limit * @param int $startTime * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException */ @@ -204,21 +205,21 @@ public function sendIncrementalSync( */ public function sendLiveSync($shopContent, $shopContentId, $action) { - if ($this->isFullSyncDone($shopContent)) { + if ($this->isFullSyncDone($shopContent, '')) { // $this->debounceLiveSync($shopContent); } } /** - * @param array> $contentTypesWithIds - * @param string actionType + * @param array $contentTypesWithIds + * @param string $actionType * @param string $createdAt * @param int $shopId * @param bool $hasMultiLang * * @return void */ - public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $createdAt, $shopId, $hasMultiLang = null) + public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $createdAt, $shopId, $hasMultiLang) { if (count($contentTypesWithIds) == 0) { return; @@ -257,35 +258,14 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $allIsoCodes = $this->languageRepository->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { - foreach ($contentTypesWithIds as $contentType => $contentIds) { - foreach ($contentIds as $contentId) { - if ($this->isFullSyncDone($contentType, $langIso)) { - array_push($contentToInsert, - [ - 'type' => $contentType, - 'id_object' => $contentId, - 'id_shop' => $shopId, - 'lang_iso' => $langIso, - 'action' => $actionType, - 'created_at' => $createdAt, - ] - ); - } - } - } - } - } else { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - - foreach ($contentTypesWithIds as $contentType => $contentIds) { - foreach ($contentIds as $contentId) { - if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { + foreach ($contentTypesWithIds as $contentType => $contentId) { + if ($this->isFullSyncDone($contentType, $langIso)) { array_push($contentToInsert, [ 'type' => $contentType, 'id_object' => $contentId, 'id_shop' => $shopId, - 'lang_iso' => $defaultIsoCode, + 'lang_iso' => $langIso, 'action' => $actionType, 'created_at' => $createdAt, ] @@ -293,6 +273,23 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } } } + } else { + $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + + foreach ($contentTypesWithIds as $contentType => $contentId) { + if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { + array_push($contentToInsert, + [ + 'type' => $contentType, + 'id_object' => $contentId, + 'id_shop' => $shopId, + 'lang_iso' => $defaultIsoCode, + 'action' => $actionType, + 'created_at' => $createdAt, + ] + ); + } + } } if (empty($contentToInsert) == false) { @@ -329,11 +326,11 @@ private function debounceLiveSync($shopContentName) // @phpstan-ignore method.un * Return true if full sync is done for this shop content * * @param string $shopContent - * @param string|null $langIso + * @param string $langIso * * @return bool */ - private function isFullSyncDone($shopContent, $langIso = null) + private function isFullSyncDone($shopContent, $langIso) { return $this->eventbusSyncRepository->isFullSyncDoneForThisTypeSync($shopContent, $langIso); } diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 54005323..35ea2848 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -4,9 +4,13 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; +use Product; trait UseHooks { + /** + * @return array + */ public function getHooks() { // Retourne la liste des hooks a register @@ -112,9 +116,10 @@ public function hookActionObjectImageDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Image $image */ $image = $parameters['object']; - if (isset($image->id_product)) { + if ($image->id_product) { $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], @@ -136,8 +141,10 @@ public function hookActionObjectImageAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Image $image */ $image = $parameters['object']; - if (isset($image->id_product)) { + + if ($image->id_product) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], @@ -159,8 +166,10 @@ public function hookActionObjectImageUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Image $image */ $image = $parameters['object']; - if (isset($image->id_product)) { + + if ($image->id_product) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], @@ -182,14 +191,17 @@ public function hookActionObjectLanguageDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Language $language */ $language = $parameters['object']; - if (isset($language->id)) { + + if ($language->id) { $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -204,9 +216,11 @@ public function hookActionObjectLanguageAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Language $language */ $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + + if ($language->id) { + $synchronizationService->sendLiveSync('languages', $language->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_ADD, @@ -227,9 +241,11 @@ public function hookActionObjectLanguageUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Language $language */ $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + + if ($language->id) { + $synchronizationService->sendLiveSync('languages', $language->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -250,14 +266,17 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_MANUFACTURERS, $manufacturer->id], + [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -272,7 +291,9 @@ public function hookActionObjectManufacturerAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -295,7 +316,9 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -318,14 +341,17 @@ public function hookActionObjectSupplierDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Supplier $supplier */ $supplier = $parameters['object']; + if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_SUPPLIERS, $supplier->id], + [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -340,7 +366,9 @@ public function hookActionObjectSupplierAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Supplier $supplier */ $supplier = $parameters['object']; + if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -363,7 +391,9 @@ public function hookActionObjectSupplierUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Supplier $supplier */ $supplier = $parameters['object']; + if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -386,15 +416,17 @@ public function hookActionObjectProductDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Product $product */ $product = $parameters['object']; if (isset($product->id)) { $synchronizationService->sendLiveSync('products', $product->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS, $product->id], + [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -409,12 +441,16 @@ public function hookActionObjectProductAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Product $product */ $product = $parameters['object']; + if (isset($product->id)) { $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + // TODO: Need to insertContentIntoIncremental custom-product-carriers and stocks + $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_ADD, @@ -435,7 +471,7 @@ public function hookActionObjectProductUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Product $product */ + /** @var \Product $product */ $product = $parameters['object']; if (isset($product->id)) { @@ -443,6 +479,8 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + // TODO: Need to insertContentIntoIncremental custom-product-carriers and stocks + $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -463,14 +501,17 @@ public function hookActionObjectWishlistDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \WishList $wishlist */ $wishlist = $parameters['object']; - if (isset($wishlist->id)) { + + if ($wishlist->id) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_WISHLISTS, $wishlist->id], + [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -485,8 +526,10 @@ public function hookActionObjectWishlistAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \WishList $wishlist */ $wishlist = $parameters['object']; - if (isset($wishlist->id)) { + + if ($wishlist->id) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], @@ -508,8 +551,10 @@ public function hookActionObjectWishlistUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \WishList $wishlist */ $wishlist = $parameters['object']; - if (isset($wishlist->id)) { + + if ($wishlist->id) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], @@ -531,7 +576,9 @@ public function hookActionObjectStockAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Stock $stock */ $stock = $parameters['object']; + if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -554,7 +601,9 @@ public function hookActionObjectStockUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Stock $stock */ $stock = $parameters['object']; + if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -577,14 +626,17 @@ public function hookActionObjectStoreDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); + /** @var \Store $store */ + $store = $parameters['object']; + + if ($store->id) { + $synchronizationService->sendLiveSync('stores', $store->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_STORES, $product->id], + [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -599,11 +651,13 @@ public function hookActionObjectStoreAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); + /** @var \Store $store */ + $store = $parameters['object']; + + if ($store->id) { + $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_STORES => $product->id], + [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, @@ -622,8 +676,10 @@ public function hookActionObjectStoreUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Store $store */ $store = $parameters['object']; - if (isset($store->id)) { + + if ($store->id) { $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], @@ -645,16 +701,17 @@ public function hookActionObjectCombinationDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Combination $combination */ + /** @var \Combination $combination */ $combination = $parameters['object']; if (isset($combination->id)) { $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCT_ATTRIBUTES, $combination->id], + [Config::COLLECTION_PRODUCT_ATTRIBUTES => $combination->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -669,6 +726,7 @@ public function hookActionObjectCategoryAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Category $category * */ $category = $parameters['object']; if (isset($category->id)) { @@ -693,6 +751,7 @@ public function hookActionObjectCategoryUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Category $category * */ $category = $parameters['object']; if (isset($category->id)) { @@ -717,15 +776,17 @@ public function hookActionObjectCategoryDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Category $category * */ $category = $parameters['object']; if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CATEGORIES, $category->id], + [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -740,9 +801,10 @@ public function hookActionObjectCustomerAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Customer $customer * */ $customer = $parameters['object']; - if (isset($customer->id)) { + if ($customer->id) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], @@ -764,9 +826,10 @@ public function hookActionObjectCustomerUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Customer $customer * */ $customer = $parameters['object']; - if (isset($customer->id)) { + if ($customer->id) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], @@ -788,15 +851,17 @@ public function hookActionObjectCustomerDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Customer $customer * */ $customer = $parameters['object']; - if (isset($customer->id)) { + if ($customer->id) { $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CUSTOMERS, $customer->id], + [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -811,6 +876,7 @@ public function hookActionObjectCurrencyAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Currency $currency * */ $currency = $parameters['object']; if (isset($currency->id)) { @@ -835,6 +901,7 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Currency $currency * */ $currency = $parameters['object']; if (isset($currency->id)) { @@ -859,15 +926,17 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Currency $currency * */ $currency = $parameters['object']; if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CURRENCIES, $currency->id], + [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -890,7 +959,8 @@ public function hookActionObjectCartAddAfter($parameters) [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -913,7 +983,8 @@ public function hookActionObjectCartUpdateAfter($parameters) [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -936,7 +1007,8 @@ public function hookActionObjectCartRuleAddAfter($parameters) [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -959,7 +1031,8 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -982,7 +1055,8 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1005,7 +1079,8 @@ public function hookActionObjectOrderAddAfter($parameters) [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1028,7 +1103,8 @@ public function hookActionObjectOrderUpdateAfter($parameters) [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1043,7 +1119,7 @@ public function hookActionObjectCarrierAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Carrier $carrier */ + /** @var \Carrier $carrier */ $carrier = $parameters['object']; if (isset($carrier->id)) { @@ -1052,7 +1128,8 @@ public function hookActionObjectCarrierAddAfter($parameters) [Config::COLLECTION_CARRIERS => $carrier->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1067,7 +1144,7 @@ public function hookActionObjectCarrierUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Carrier $carrier */ + /** @var \Carrier $carrier */ $carrier = $parameters['object']; if (isset($carrier->id)) { @@ -1076,7 +1153,8 @@ public function hookActionObjectCarrierUpdateAfter($parameters) [Config::COLLECTION_CARRIERS => $carrier->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1090,8 +1168,7 @@ public function hookActionObjectCarrierDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ + /** @var \Carrier $carrier */ $carrier = $parameters['object']; if (isset($carrier->id)) { @@ -1100,7 +1177,8 @@ public function hookActionObjectCarrierDeleteAfter($parameters) [Config::COLLECTION_CARRIERS => $carrier->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1117,7 +1195,8 @@ public function hookActionObjectCountryAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1133,7 +1212,8 @@ public function hookActionObjectCountryUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1149,7 +1229,8 @@ public function hookActionObjectCountryDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1165,7 +1246,8 @@ public function hookActionObjectStateAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1181,7 +1263,8 @@ public function hookActionObjectStateUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1197,7 +1280,8 @@ public function hookActionObjectStateDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1213,7 +1297,8 @@ public function hookActionObjectZoneAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1229,7 +1314,8 @@ public function hookActionObjectZoneUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1245,7 +1331,8 @@ public function hookActionObjectZoneDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1261,7 +1348,8 @@ public function hookActionObjectTaxAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1277,7 +1365,8 @@ public function hookActionObjectTaxUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1293,7 +1382,8 @@ public function hookActionObjectTaxDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1309,7 +1399,8 @@ public function hookActionObjectTaxRulesGroupAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1325,7 +1416,8 @@ public function hookActionObjectTaxRulesGroupUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1341,7 +1433,8 @@ public function hookActionObjectTaxRulesGroupDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1357,7 +1450,8 @@ public function hookActionShippingPreferencesPageSave() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1373,7 +1467,8 @@ public function hookActionObjectEmployeeAddAfter() [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1388,7 +1483,8 @@ public function hookActionObjectEmployeeDeleteAfter() [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1404,7 +1500,8 @@ public function hookActionObjectEmployeeUpdateAfter() [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1444,7 +1541,8 @@ public function hookActionDispatcherBefore($parameters) [Config::COLLECTION_TRANSLATIONS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1473,7 +1571,8 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1499,7 +1598,8 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1522,11 +1622,11 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } From 36a8d76b4ba2f6fe1307688b9c95695e80e09f28 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 09:56:48 +0200 Subject: [PATCH 022/162] fix: compat 5.6 --- src/Config/Config.php | 2 +- src/Repository/OrdersRepository.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index d5bd74af..15848fd8 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -68,7 +68,7 @@ class Config const COLLECTION_WISHLISTS = 'wishlists'; const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; - public const SHOP_CONTENTS = [ + const SHOP_CONTENTS = [ self::COLLECTION_BUNDLES, self::COLLECTION_CARRIERS, self::COLLECTION_CARTS, diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index a699cdf9..8a2d391a 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -6,7 +6,7 @@ class OrdersRepository extends AbstractRepository implements RepositoryInterface { - public const ORDERS_TABLE = 'orders'; + const ORDERS_TABLE = 'orders'; /** * @return mixed From 1f657d6133be9d8c947079f00b82c29bc07983e1 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 10:09:31 +0200 Subject: [PATCH 023/162] fix: compat ps 1.6.1.11 --- ps_eventbus.php | 6 +++++- src/Service/ShopContent/OrdersService.php | 2 +- src/Traits/UseHooks.php | 4 +--- tests/phpstan/phpstan-1-6.neon | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ps_eventbus.php b/ps_eventbus.php index 59dba4a6..d2a42027 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -230,7 +230,11 @@ public function getService($serviceName) try { return $this->getServiceContainer()->getService($serviceName); } catch (ServiceNotFoundException $exception) { - return $this->get($serviceName); + if (method_exists($this, 'get')) { + return $this->get($serviceName); + } + + throw new ServiceNotFoundException('Service not found'); } } diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index a1680a5b..255298e3 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -103,7 +103,7 @@ public function countFullSyncContentLeft($offset, $langIso, $debug) */ public function castOrders(&$orders, $langIso) { - $langId = \Language::getIdByIso($langIso); + $langId = (int) \Language::getIdByIso($langIso); foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 35ea2848..97f62ea0 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -501,7 +501,7 @@ public function hookActionObjectWishlistDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \WishList $wishlist */ + $wishlist = $parameters['object']; if ($wishlist->id) { @@ -526,7 +526,6 @@ public function hookActionObjectWishlistAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \WishList $wishlist */ $wishlist = $parameters['object']; if ($wishlist->id) { @@ -551,7 +550,6 @@ public function hookActionObjectWishlistUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \WishList $wishlist */ $wishlist = $parameters['object']; if ($wishlist->id) { diff --git a/tests/phpstan/phpstan-1-6.neon b/tests/phpstan/phpstan-1-6.neon index be2d56ce..050c969a 100644 --- a/tests/phpstan/phpstan-1-6.neon +++ b/tests/phpstan/phpstan-1-6.neon @@ -1,6 +1,6 @@ parameters: ignoreErrors: - - '#Parameter \#1 \$hook_name of method ModuleCore::registerHook\(\) expects string, array given#' + - '#Parameter \#1 \$hook_name of method ModuleCore::registerHook\(\) expects string, array given#' - '#Access to undefined constant Module::MULTISTORE_COMPATIBILITY_YES#' - '#Property ObjectModelCore::\$id \(int\) in isset\(\) is not nullable#' - '#Call to method buildRepository\(\) on an unknown class PrestaShop\\PrestaShop\\Core\\Addon\\Theme\\ThemeManagerBuilder.#' From 7da1ef8558b151e73e79a152f70ee62b94a68ef0 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 10:11:45 +0200 Subject: [PATCH 024/162] fix: php-cs-fixer --- src/Traits/UseHooks.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 97f62ea0..a465a352 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -501,7 +501,6 @@ public function hookActionObjectWishlistDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $wishlist = $parameters['object']; if ($wishlist->id) { From 1c4bca049cf7fba355dd14ea3be770a3d7871af1 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 11:28:49 +0200 Subject: [PATCH 025/162] fix: e2e env --- README.md | 4 ++-- e2e-env/docker-compose.yml | 2 +- e2e/src/fixtures/1.6/{apiProducts => }/bundles.json | 0 e2e/src/fixtures/1.6/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/1.6/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/1.6/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/1.6/{apiCarts => }/carts.json | 0 e2e/src/fixtures/1.6/{apiCategories => }/categories.json | 0 e2e/src/fixtures/1.6/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/1.6/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/1.6/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/1.6/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/1.6/{apiImages => }/images.json | 0 e2e/src/fixtures/1.6/{apiLanguages => }/languages.json | 0 .../fixtures/1.6/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/1.6/{apiModules => }/modules.json | 0 e2e/src/fixtures/1.6/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/1.6/{apiOrders => }/order_details.json | 0 .../fixtures/1.6/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/1.6/{apiOrders => }/orders.json | 0 e2e/src/fixtures/1.6/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/1.6/{apiProducts => }/products.json | 0 e2e/src/fixtures/1.6/{apiInfo => }/shops.json | 0 .../fixtures/1.6/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/1.6/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/1.6/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/1.6/{apiStores => }/stores.json | 0 e2e/src/fixtures/1.6/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/1.6/{apiThemes => }/themes.json | 0 e2e/src/fixtures/1.7/{apiProducts => }/bundles.json | 0 e2e/src/fixtures/1.7/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/1.7/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/1.7/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/1.7/{apiCarts => }/carts.json | 0 e2e/src/fixtures/1.7/{apiCategories => }/categories.json | 0 e2e/src/fixtures/1.7/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/1.7/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/1.7/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/1.7/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/1.7/{apiImages => }/images.json | 0 e2e/src/fixtures/1.7/{apiLanguages => }/languages.json | 0 .../fixtures/1.7/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/1.7/{apiModules => }/modules.json | 0 e2e/src/fixtures/1.7/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/1.7/{apiOrders => }/order_details.json | 0 .../fixtures/1.7/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/1.7/{apiOrders => }/orders.json | 0 e2e/src/fixtures/1.7/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/1.7/{apiProducts => }/products.json | 0 e2e/src/fixtures/1.7/{apiInfo => }/shops.json | 0 .../fixtures/1.7/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/1.7/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/1.7/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/1.7/{apiStores => }/stores.json | 0 e2e/src/fixtures/1.7/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/1.7/{apiThemes => }/themes.json | 0 e2e/src/fixtures/8/{apiProducts => }/bundles.json | 0 e2e/src/fixtures/8/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/8/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/8/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/8/{apiCarts => }/carts.json | 0 e2e/src/fixtures/8/{apiCategories => }/categories.json | 0 e2e/src/fixtures/8/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/8/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/8/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/8/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/8/{apiImages => }/images.json | 0 e2e/src/fixtures/8/{apiLanguages => }/languages.json | 0 e2e/src/fixtures/8/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/8/{apiModules => }/modules.json | 0 e2e/src/fixtures/8/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/8/{apiOrders => }/order_details.json | 0 e2e/src/fixtures/8/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/8/{apiOrders => }/orders.json | 0 e2e/src/fixtures/8/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/8/{apiProducts => }/products.json | 0 e2e/src/fixtures/8/{apiInfo => }/shops.json | 0 .../fixtures/8/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/8/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/8/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/8/{apiStores => }/stores.json | 0 e2e/src/fixtures/8/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/8/{apiThemes => }/themes.json | 0 e2e/src/fixtures/9/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/9/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/9/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/9/{apiCarts => }/carts.json | 0 e2e/src/fixtures/9/{apiCategories => }/categories.json | 0 e2e/src/fixtures/9/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/9/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/9/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/9/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/9/{apiImages => }/images.json | 0 e2e/src/fixtures/9/{apiLanguages => }/languages.json | 0 e2e/src/fixtures/9/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/9/{apiModules => }/modules.json | 0 e2e/src/fixtures/9/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/9/{apiOrders => }/order_details.json | 0 e2e/src/fixtures/9/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/9/{apiOrders => }/orders.json | 0 .../9/{apiProducts/bundles.json => product_bundles.json} | 0 e2e/src/fixtures/9/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/9/{apiProducts => }/products.json | 0 e2e/src/fixtures/9/{apiInfo => }/shops.json | 0 .../fixtures/9/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/9/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/9/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/9/{apiStores => }/stores.json | 0 e2e/src/fixtures/9/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/9/{apiThemes => }/themes.json | 0 e2e/src/helpers/data-helper.ts | 2 +- 111 files changed, 4 insertions(+), 4 deletions(-) rename e2e/src/fixtures/1.6/{apiProducts => }/bundles.json (100%) rename e2e/src/fixtures/1.6/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/1.6/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/1.6/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/1.6/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/1.6/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/1.6/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/1.6/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/1.6/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/1.6/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/1.6/{apiImages => }/images.json (100%) rename e2e/src/fixtures/1.6/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/1.6/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/1.6/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/1.6/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/1.6/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/1.6/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/1.6/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/1.6/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/1.6/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/1.6/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/1.6/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/1.6/{apiThemes => }/themes.json (100%) rename e2e/src/fixtures/1.7/{apiProducts => }/bundles.json (100%) rename e2e/src/fixtures/1.7/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/1.7/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/1.7/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/1.7/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/1.7/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/1.7/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/1.7/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/1.7/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/1.7/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/1.7/{apiImages => }/images.json (100%) rename e2e/src/fixtures/1.7/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/1.7/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/1.7/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/1.7/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/1.7/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/1.7/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/1.7/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/1.7/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/1.7/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/1.7/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/1.7/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/1.7/{apiThemes => }/themes.json (100%) rename e2e/src/fixtures/8/{apiProducts => }/bundles.json (100%) rename e2e/src/fixtures/8/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/8/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/8/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/8/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/8/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/8/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/8/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/8/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/8/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/8/{apiImages => }/images.json (100%) rename e2e/src/fixtures/8/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/8/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/8/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/8/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/8/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/8/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/8/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/8/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/8/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/8/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/8/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/8/{apiThemes => }/themes.json (100%) rename e2e/src/fixtures/9/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/9/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/9/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/9/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/9/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/9/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/9/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/9/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/9/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/9/{apiImages => }/images.json (100%) rename e2e/src/fixtures/9/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/9/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/9/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/9/{apiProducts/bundles.json => product_bundles.json} (100%) rename e2e/src/fixtures/9/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/9/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/9/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/9/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/9/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/9/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/9/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/9/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/9/{apiThemes => }/themes.json (100%) diff --git a/README.md b/README.md index a55ea0f4..ac254564 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ To check the module healthiness (authentified route): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-stuff" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-stuff" | jq . { "prestashop_version": "1.6.1.24", "ps_eventbus_version": "0.0.0", @@ -66,7 +66,7 @@ To check the fallback route (unauthentified): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck" | jq . { "ps_account": true, "is_valid_jwt": true, diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index e8128be5..33e1e1b3 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -12,7 +12,7 @@ services: "-sI", "-H", "Host: localhost:8000", - "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck", + "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck", ] interval: 30s volumes: diff --git a/e2e/src/fixtures/1.6/apiProducts/bundles.json b/e2e/src/fixtures/1.6/bundles.json similarity index 100% rename from e2e/src/fixtures/1.6/apiProducts/bundles.json rename to e2e/src/fixtures/1.6/bundles.json diff --git a/e2e/src/fixtures/1.6/apiCarriers/carrier_details.json b/e2e/src/fixtures/1.6/carrier_details.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarriers/carrier_details.json rename to e2e/src/fixtures/1.6/carrier_details.json diff --git a/e2e/src/fixtures/1.6/apiCarriers/carriers.json b/e2e/src/fixtures/1.6/carriers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarriers/carriers.json rename to e2e/src/fixtures/1.6/carriers.json diff --git a/e2e/src/fixtures/1.6/apiCarts/cart_products.json b/e2e/src/fixtures/1.6/cart_products.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarts/cart_products.json rename to e2e/src/fixtures/1.6/cart_products.json diff --git a/e2e/src/fixtures/1.6/apiCarts/carts.json b/e2e/src/fixtures/1.6/carts.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarts/carts.json rename to e2e/src/fixtures/1.6/carts.json diff --git a/e2e/src/fixtures/1.6/apiCategories/categories.json b/e2e/src/fixtures/1.6/categories.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCategories/categories.json rename to e2e/src/fixtures/1.6/categories.json diff --git a/e2e/src/fixtures/1.6/apiCurrencies/currencies.json b/e2e/src/fixtures/1.6/currencies.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCurrencies/currencies.json rename to e2e/src/fixtures/1.6/currencies.json diff --git a/e2e/src/fixtures/1.6/apiCustomers/customers.json b/e2e/src/fixtures/1.6/customers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCustomers/customers.json rename to e2e/src/fixtures/1.6/customers.json diff --git a/e2e/src/fixtures/1.6/apiEmployees/employees.json b/e2e/src/fixtures/1.6/employees.json similarity index 100% rename from e2e/src/fixtures/1.6/apiEmployees/employees.json rename to e2e/src/fixtures/1.6/employees.json diff --git a/e2e/src/fixtures/1.6/apiImageTypes/image_types.json b/e2e/src/fixtures/1.6/image_types.json similarity index 100% rename from e2e/src/fixtures/1.6/apiImageTypes/image_types.json rename to e2e/src/fixtures/1.6/image_types.json diff --git a/e2e/src/fixtures/1.6/apiImages/images.json b/e2e/src/fixtures/1.6/images.json similarity index 100% rename from e2e/src/fixtures/1.6/apiImages/images.json rename to e2e/src/fixtures/1.6/images.json diff --git a/e2e/src/fixtures/1.6/apiLanguages/languages.json b/e2e/src/fixtures/1.6/languages.json similarity index 100% rename from e2e/src/fixtures/1.6/apiLanguages/languages.json rename to e2e/src/fixtures/1.6/languages.json diff --git a/e2e/src/fixtures/1.6/apiManufacturers/manufacturers.json b/e2e/src/fixtures/1.6/manufacturers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/1.6/manufacturers.json diff --git a/e2e/src/fixtures/1.6/apiModules/modules.json b/e2e/src/fixtures/1.6/modules.json similarity index 100% rename from e2e/src/fixtures/1.6/apiModules/modules.json rename to e2e/src/fixtures/1.6/modules.json diff --git a/e2e/src/fixtures/1.6/apiOrders/order_cart_rules.json b/e2e/src/fixtures/1.6/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/1.6/order_cart_rules.json diff --git a/e2e/src/fixtures/1.6/apiOrders/order_details.json b/e2e/src/fixtures/1.6/order_details.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/order_details.json rename to e2e/src/fixtures/1.6/order_details.json diff --git a/e2e/src/fixtures/1.6/apiOrders/order_status_history.json b/e2e/src/fixtures/1.6/order_status_history.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/order_status_history.json rename to e2e/src/fixtures/1.6/order_status_history.json diff --git a/e2e/src/fixtures/1.6/apiOrders/orders.json b/e2e/src/fixtures/1.6/orders.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/orders.json rename to e2e/src/fixtures/1.6/orders.json diff --git a/e2e/src/fixtures/1.6/apiProducts/product_suppliers.json b/e2e/src/fixtures/1.6/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiProducts/product_suppliers.json rename to e2e/src/fixtures/1.6/product_suppliers.json diff --git a/e2e/src/fixtures/1.6/apiProducts/products.json b/e2e/src/fixtures/1.6/products.json similarity index 100% rename from e2e/src/fixtures/1.6/apiProducts/products.json rename to e2e/src/fixtures/1.6/products.json diff --git a/e2e/src/fixtures/1.6/apiInfo/shops.json b/e2e/src/fixtures/1.6/shops.json similarity index 100% rename from e2e/src/fixtures/1.6/apiInfo/shops.json rename to e2e/src/fixtures/1.6/shops.json diff --git a/e2e/src/fixtures/1.6/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/1.6/specific_prices.json similarity index 100% rename from e2e/src/fixtures/1.6/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/1.6/specific_prices.json diff --git a/e2e/src/fixtures/1.6/apiStocks/stock_movements.json b/e2e/src/fixtures/1.6/stock_movements.json similarity index 100% rename from e2e/src/fixtures/1.6/apiStocks/stock_movements.json rename to e2e/src/fixtures/1.6/stock_movements.json diff --git a/e2e/src/fixtures/1.6/apiStocks/stocks.json b/e2e/src/fixtures/1.6/stocks.json similarity index 100% rename from e2e/src/fixtures/1.6/apiStocks/stocks.json rename to e2e/src/fixtures/1.6/stocks.json diff --git a/e2e/src/fixtures/1.6/apiStores/stores.json b/e2e/src/fixtures/1.6/stores.json similarity index 100% rename from e2e/src/fixtures/1.6/apiStores/stores.json rename to e2e/src/fixtures/1.6/stores.json diff --git a/e2e/src/fixtures/1.6/apiSuppliers/suppliers.json b/e2e/src/fixtures/1.6/suppliers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiSuppliers/suppliers.json rename to e2e/src/fixtures/1.6/suppliers.json diff --git a/e2e/src/fixtures/1.6/apiThemes/themes.json b/e2e/src/fixtures/1.6/themes.json similarity index 100% rename from e2e/src/fixtures/1.6/apiThemes/themes.json rename to e2e/src/fixtures/1.6/themes.json diff --git a/e2e/src/fixtures/1.7/apiProducts/bundles.json b/e2e/src/fixtures/1.7/bundles.json similarity index 100% rename from e2e/src/fixtures/1.7/apiProducts/bundles.json rename to e2e/src/fixtures/1.7/bundles.json diff --git a/e2e/src/fixtures/1.7/apiCarriers/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarriers/carrier_details.json rename to e2e/src/fixtures/1.7/carrier_details.json diff --git a/e2e/src/fixtures/1.7/apiCarriers/carriers.json b/e2e/src/fixtures/1.7/carriers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarriers/carriers.json rename to e2e/src/fixtures/1.7/carriers.json diff --git a/e2e/src/fixtures/1.7/apiCarts/cart_products.json b/e2e/src/fixtures/1.7/cart_products.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarts/cart_products.json rename to e2e/src/fixtures/1.7/cart_products.json diff --git a/e2e/src/fixtures/1.7/apiCarts/carts.json b/e2e/src/fixtures/1.7/carts.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarts/carts.json rename to e2e/src/fixtures/1.7/carts.json diff --git a/e2e/src/fixtures/1.7/apiCategories/categories.json b/e2e/src/fixtures/1.7/categories.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCategories/categories.json rename to e2e/src/fixtures/1.7/categories.json diff --git a/e2e/src/fixtures/1.7/apiCurrencies/currencies.json b/e2e/src/fixtures/1.7/currencies.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCurrencies/currencies.json rename to e2e/src/fixtures/1.7/currencies.json diff --git a/e2e/src/fixtures/1.7/apiCustomers/customers.json b/e2e/src/fixtures/1.7/customers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCustomers/customers.json rename to e2e/src/fixtures/1.7/customers.json diff --git a/e2e/src/fixtures/1.7/apiEmployees/employees.json b/e2e/src/fixtures/1.7/employees.json similarity index 100% rename from e2e/src/fixtures/1.7/apiEmployees/employees.json rename to e2e/src/fixtures/1.7/employees.json diff --git a/e2e/src/fixtures/1.7/apiImageTypes/image_types.json b/e2e/src/fixtures/1.7/image_types.json similarity index 100% rename from e2e/src/fixtures/1.7/apiImageTypes/image_types.json rename to e2e/src/fixtures/1.7/image_types.json diff --git a/e2e/src/fixtures/1.7/apiImages/images.json b/e2e/src/fixtures/1.7/images.json similarity index 100% rename from e2e/src/fixtures/1.7/apiImages/images.json rename to e2e/src/fixtures/1.7/images.json diff --git a/e2e/src/fixtures/1.7/apiLanguages/languages.json b/e2e/src/fixtures/1.7/languages.json similarity index 100% rename from e2e/src/fixtures/1.7/apiLanguages/languages.json rename to e2e/src/fixtures/1.7/languages.json diff --git a/e2e/src/fixtures/1.7/apiManufacturers/manufacturers.json b/e2e/src/fixtures/1.7/manufacturers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/1.7/manufacturers.json diff --git a/e2e/src/fixtures/1.7/apiModules/modules.json b/e2e/src/fixtures/1.7/modules.json similarity index 100% rename from e2e/src/fixtures/1.7/apiModules/modules.json rename to e2e/src/fixtures/1.7/modules.json diff --git a/e2e/src/fixtures/1.7/apiOrders/order_cart_rules.json b/e2e/src/fixtures/1.7/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/1.7/order_cart_rules.json diff --git a/e2e/src/fixtures/1.7/apiOrders/order_details.json b/e2e/src/fixtures/1.7/order_details.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/order_details.json rename to e2e/src/fixtures/1.7/order_details.json diff --git a/e2e/src/fixtures/1.7/apiOrders/order_status_history.json b/e2e/src/fixtures/1.7/order_status_history.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/order_status_history.json rename to e2e/src/fixtures/1.7/order_status_history.json diff --git a/e2e/src/fixtures/1.7/apiOrders/orders.json b/e2e/src/fixtures/1.7/orders.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/orders.json rename to e2e/src/fixtures/1.7/orders.json diff --git a/e2e/src/fixtures/1.7/apiProducts/product_suppliers.json b/e2e/src/fixtures/1.7/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiProducts/product_suppliers.json rename to e2e/src/fixtures/1.7/product_suppliers.json diff --git a/e2e/src/fixtures/1.7/apiProducts/products.json b/e2e/src/fixtures/1.7/products.json similarity index 100% rename from e2e/src/fixtures/1.7/apiProducts/products.json rename to e2e/src/fixtures/1.7/products.json diff --git a/e2e/src/fixtures/1.7/apiInfo/shops.json b/e2e/src/fixtures/1.7/shops.json similarity index 100% rename from e2e/src/fixtures/1.7/apiInfo/shops.json rename to e2e/src/fixtures/1.7/shops.json diff --git a/e2e/src/fixtures/1.7/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/1.7/specific_prices.json similarity index 100% rename from e2e/src/fixtures/1.7/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/1.7/specific_prices.json diff --git a/e2e/src/fixtures/1.7/apiStocks/stock_movements.json b/e2e/src/fixtures/1.7/stock_movements.json similarity index 100% rename from e2e/src/fixtures/1.7/apiStocks/stock_movements.json rename to e2e/src/fixtures/1.7/stock_movements.json diff --git a/e2e/src/fixtures/1.7/apiStocks/stocks.json b/e2e/src/fixtures/1.7/stocks.json similarity index 100% rename from e2e/src/fixtures/1.7/apiStocks/stocks.json rename to e2e/src/fixtures/1.7/stocks.json diff --git a/e2e/src/fixtures/1.7/apiStores/stores.json b/e2e/src/fixtures/1.7/stores.json similarity index 100% rename from e2e/src/fixtures/1.7/apiStores/stores.json rename to e2e/src/fixtures/1.7/stores.json diff --git a/e2e/src/fixtures/1.7/apiSuppliers/suppliers.json b/e2e/src/fixtures/1.7/suppliers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiSuppliers/suppliers.json rename to e2e/src/fixtures/1.7/suppliers.json diff --git a/e2e/src/fixtures/1.7/apiThemes/themes.json b/e2e/src/fixtures/1.7/themes.json similarity index 100% rename from e2e/src/fixtures/1.7/apiThemes/themes.json rename to e2e/src/fixtures/1.7/themes.json diff --git a/e2e/src/fixtures/8/apiProducts/bundles.json b/e2e/src/fixtures/8/bundles.json similarity index 100% rename from e2e/src/fixtures/8/apiProducts/bundles.json rename to e2e/src/fixtures/8/bundles.json diff --git a/e2e/src/fixtures/8/apiCarriers/carrier_details.json b/e2e/src/fixtures/8/carrier_details.json similarity index 100% rename from e2e/src/fixtures/8/apiCarriers/carrier_details.json rename to e2e/src/fixtures/8/carrier_details.json diff --git a/e2e/src/fixtures/8/apiCarriers/carriers.json b/e2e/src/fixtures/8/carriers.json similarity index 100% rename from e2e/src/fixtures/8/apiCarriers/carriers.json rename to e2e/src/fixtures/8/carriers.json diff --git a/e2e/src/fixtures/8/apiCarts/cart_products.json b/e2e/src/fixtures/8/cart_products.json similarity index 100% rename from e2e/src/fixtures/8/apiCarts/cart_products.json rename to e2e/src/fixtures/8/cart_products.json diff --git a/e2e/src/fixtures/8/apiCarts/carts.json b/e2e/src/fixtures/8/carts.json similarity index 100% rename from e2e/src/fixtures/8/apiCarts/carts.json rename to e2e/src/fixtures/8/carts.json diff --git a/e2e/src/fixtures/8/apiCategories/categories.json b/e2e/src/fixtures/8/categories.json similarity index 100% rename from e2e/src/fixtures/8/apiCategories/categories.json rename to e2e/src/fixtures/8/categories.json diff --git a/e2e/src/fixtures/8/apiCurrencies/currencies.json b/e2e/src/fixtures/8/currencies.json similarity index 100% rename from e2e/src/fixtures/8/apiCurrencies/currencies.json rename to e2e/src/fixtures/8/currencies.json diff --git a/e2e/src/fixtures/8/apiCustomers/customers.json b/e2e/src/fixtures/8/customers.json similarity index 100% rename from e2e/src/fixtures/8/apiCustomers/customers.json rename to e2e/src/fixtures/8/customers.json diff --git a/e2e/src/fixtures/8/apiEmployees/employees.json b/e2e/src/fixtures/8/employees.json similarity index 100% rename from e2e/src/fixtures/8/apiEmployees/employees.json rename to e2e/src/fixtures/8/employees.json diff --git a/e2e/src/fixtures/8/apiImageTypes/image_types.json b/e2e/src/fixtures/8/image_types.json similarity index 100% rename from e2e/src/fixtures/8/apiImageTypes/image_types.json rename to e2e/src/fixtures/8/image_types.json diff --git a/e2e/src/fixtures/8/apiImages/images.json b/e2e/src/fixtures/8/images.json similarity index 100% rename from e2e/src/fixtures/8/apiImages/images.json rename to e2e/src/fixtures/8/images.json diff --git a/e2e/src/fixtures/8/apiLanguages/languages.json b/e2e/src/fixtures/8/languages.json similarity index 100% rename from e2e/src/fixtures/8/apiLanguages/languages.json rename to e2e/src/fixtures/8/languages.json diff --git a/e2e/src/fixtures/8/apiManufacturers/manufacturers.json b/e2e/src/fixtures/8/manufacturers.json similarity index 100% rename from e2e/src/fixtures/8/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/8/manufacturers.json diff --git a/e2e/src/fixtures/8/apiModules/modules.json b/e2e/src/fixtures/8/modules.json similarity index 100% rename from e2e/src/fixtures/8/apiModules/modules.json rename to e2e/src/fixtures/8/modules.json diff --git a/e2e/src/fixtures/8/apiOrders/order_cart_rules.json b/e2e/src/fixtures/8/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/8/order_cart_rules.json diff --git a/e2e/src/fixtures/8/apiOrders/order_details.json b/e2e/src/fixtures/8/order_details.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/order_details.json rename to e2e/src/fixtures/8/order_details.json diff --git a/e2e/src/fixtures/8/apiOrders/order_status_history.json b/e2e/src/fixtures/8/order_status_history.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/order_status_history.json rename to e2e/src/fixtures/8/order_status_history.json diff --git a/e2e/src/fixtures/8/apiOrders/orders.json b/e2e/src/fixtures/8/orders.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/orders.json rename to e2e/src/fixtures/8/orders.json diff --git a/e2e/src/fixtures/8/apiProducts/product_suppliers.json b/e2e/src/fixtures/8/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/8/apiProducts/product_suppliers.json rename to e2e/src/fixtures/8/product_suppliers.json diff --git a/e2e/src/fixtures/8/apiProducts/products.json b/e2e/src/fixtures/8/products.json similarity index 100% rename from e2e/src/fixtures/8/apiProducts/products.json rename to e2e/src/fixtures/8/products.json diff --git a/e2e/src/fixtures/8/apiInfo/shops.json b/e2e/src/fixtures/8/shops.json similarity index 100% rename from e2e/src/fixtures/8/apiInfo/shops.json rename to e2e/src/fixtures/8/shops.json diff --git a/e2e/src/fixtures/8/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/8/specific_prices.json similarity index 100% rename from e2e/src/fixtures/8/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/8/specific_prices.json diff --git a/e2e/src/fixtures/8/apiStocks/stock_movements.json b/e2e/src/fixtures/8/stock_movements.json similarity index 100% rename from e2e/src/fixtures/8/apiStocks/stock_movements.json rename to e2e/src/fixtures/8/stock_movements.json diff --git a/e2e/src/fixtures/8/apiStocks/stocks.json b/e2e/src/fixtures/8/stocks.json similarity index 100% rename from e2e/src/fixtures/8/apiStocks/stocks.json rename to e2e/src/fixtures/8/stocks.json diff --git a/e2e/src/fixtures/8/apiStores/stores.json b/e2e/src/fixtures/8/stores.json similarity index 100% rename from e2e/src/fixtures/8/apiStores/stores.json rename to e2e/src/fixtures/8/stores.json diff --git a/e2e/src/fixtures/8/apiSuppliers/suppliers.json b/e2e/src/fixtures/8/suppliers.json similarity index 100% rename from e2e/src/fixtures/8/apiSuppliers/suppliers.json rename to e2e/src/fixtures/8/suppliers.json diff --git a/e2e/src/fixtures/8/apiThemes/themes.json b/e2e/src/fixtures/8/themes.json similarity index 100% rename from e2e/src/fixtures/8/apiThemes/themes.json rename to e2e/src/fixtures/8/themes.json diff --git a/e2e/src/fixtures/9/apiCarriers/carrier_details.json b/e2e/src/fixtures/9/carrier_details.json similarity index 100% rename from e2e/src/fixtures/9/apiCarriers/carrier_details.json rename to e2e/src/fixtures/9/carrier_details.json diff --git a/e2e/src/fixtures/9/apiCarriers/carriers.json b/e2e/src/fixtures/9/carriers.json similarity index 100% rename from e2e/src/fixtures/9/apiCarriers/carriers.json rename to e2e/src/fixtures/9/carriers.json diff --git a/e2e/src/fixtures/9/apiCarts/cart_products.json b/e2e/src/fixtures/9/cart_products.json similarity index 100% rename from e2e/src/fixtures/9/apiCarts/cart_products.json rename to e2e/src/fixtures/9/cart_products.json diff --git a/e2e/src/fixtures/9/apiCarts/carts.json b/e2e/src/fixtures/9/carts.json similarity index 100% rename from e2e/src/fixtures/9/apiCarts/carts.json rename to e2e/src/fixtures/9/carts.json diff --git a/e2e/src/fixtures/9/apiCategories/categories.json b/e2e/src/fixtures/9/categories.json similarity index 100% rename from e2e/src/fixtures/9/apiCategories/categories.json rename to e2e/src/fixtures/9/categories.json diff --git a/e2e/src/fixtures/9/apiCurrencies/currencies.json b/e2e/src/fixtures/9/currencies.json similarity index 100% rename from e2e/src/fixtures/9/apiCurrencies/currencies.json rename to e2e/src/fixtures/9/currencies.json diff --git a/e2e/src/fixtures/9/apiCustomers/customers.json b/e2e/src/fixtures/9/customers.json similarity index 100% rename from e2e/src/fixtures/9/apiCustomers/customers.json rename to e2e/src/fixtures/9/customers.json diff --git a/e2e/src/fixtures/9/apiEmployees/employees.json b/e2e/src/fixtures/9/employees.json similarity index 100% rename from e2e/src/fixtures/9/apiEmployees/employees.json rename to e2e/src/fixtures/9/employees.json diff --git a/e2e/src/fixtures/9/apiImageTypes/image_types.json b/e2e/src/fixtures/9/image_types.json similarity index 100% rename from e2e/src/fixtures/9/apiImageTypes/image_types.json rename to e2e/src/fixtures/9/image_types.json diff --git a/e2e/src/fixtures/9/apiImages/images.json b/e2e/src/fixtures/9/images.json similarity index 100% rename from e2e/src/fixtures/9/apiImages/images.json rename to e2e/src/fixtures/9/images.json diff --git a/e2e/src/fixtures/9/apiLanguages/languages.json b/e2e/src/fixtures/9/languages.json similarity index 100% rename from e2e/src/fixtures/9/apiLanguages/languages.json rename to e2e/src/fixtures/9/languages.json diff --git a/e2e/src/fixtures/9/apiManufacturers/manufacturers.json b/e2e/src/fixtures/9/manufacturers.json similarity index 100% rename from e2e/src/fixtures/9/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/9/manufacturers.json diff --git a/e2e/src/fixtures/9/apiModules/modules.json b/e2e/src/fixtures/9/modules.json similarity index 100% rename from e2e/src/fixtures/9/apiModules/modules.json rename to e2e/src/fixtures/9/modules.json diff --git a/e2e/src/fixtures/9/apiOrders/order_cart_rules.json b/e2e/src/fixtures/9/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/9/order_cart_rules.json diff --git a/e2e/src/fixtures/9/apiOrders/order_details.json b/e2e/src/fixtures/9/order_details.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/order_details.json rename to e2e/src/fixtures/9/order_details.json diff --git a/e2e/src/fixtures/9/apiOrders/order_status_history.json b/e2e/src/fixtures/9/order_status_history.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/order_status_history.json rename to e2e/src/fixtures/9/order_status_history.json diff --git a/e2e/src/fixtures/9/apiOrders/orders.json b/e2e/src/fixtures/9/orders.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/orders.json rename to e2e/src/fixtures/9/orders.json diff --git a/e2e/src/fixtures/9/apiProducts/bundles.json b/e2e/src/fixtures/9/product_bundles.json similarity index 100% rename from e2e/src/fixtures/9/apiProducts/bundles.json rename to e2e/src/fixtures/9/product_bundles.json diff --git a/e2e/src/fixtures/9/apiProducts/product_suppliers.json b/e2e/src/fixtures/9/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/9/apiProducts/product_suppliers.json rename to e2e/src/fixtures/9/product_suppliers.json diff --git a/e2e/src/fixtures/9/apiProducts/products.json b/e2e/src/fixtures/9/products.json similarity index 100% rename from e2e/src/fixtures/9/apiProducts/products.json rename to e2e/src/fixtures/9/products.json diff --git a/e2e/src/fixtures/9/apiInfo/shops.json b/e2e/src/fixtures/9/shops.json similarity index 100% rename from e2e/src/fixtures/9/apiInfo/shops.json rename to e2e/src/fixtures/9/shops.json diff --git a/e2e/src/fixtures/9/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/9/specific_prices.json similarity index 100% rename from e2e/src/fixtures/9/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/9/specific_prices.json diff --git a/e2e/src/fixtures/9/apiStocks/stock_movements.json b/e2e/src/fixtures/9/stock_movements.json similarity index 100% rename from e2e/src/fixtures/9/apiStocks/stock_movements.json rename to e2e/src/fixtures/9/stock_movements.json diff --git a/e2e/src/fixtures/9/apiStocks/stocks.json b/e2e/src/fixtures/9/stocks.json similarity index 100% rename from e2e/src/fixtures/9/apiStocks/stocks.json rename to e2e/src/fixtures/9/stocks.json diff --git a/e2e/src/fixtures/9/apiStores/stores.json b/e2e/src/fixtures/9/stores.json similarity index 100% rename from e2e/src/fixtures/9/apiStores/stores.json rename to e2e/src/fixtures/9/stores.json diff --git a/e2e/src/fixtures/9/apiSuppliers/suppliers.json b/e2e/src/fixtures/9/suppliers.json similarity index 100% rename from e2e/src/fixtures/9/apiSuppliers/suppliers.json rename to e2e/src/fixtures/9/suppliers.json diff --git a/e2e/src/fixtures/9/apiThemes/themes.json b/e2e/src/fixtures/9/themes.json similarity index 100% rename from e2e/src/fixtures/9/apiThemes/themes.json rename to e2e/src/fixtures/9/themes.json diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 75cc60f8..04cae9fc 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -95,7 +95,7 @@ export async function loadFixture( const files = contents.map((content) => fs.promises.readFile( - `${FIXTURE_DIR}/${useFixture}/${shopContent}/${content}.json`, + `${FIXTURE_DIR}/${useFixture}/${content}.json`, "utf-8" ) ); From 96652587a56d248b5b4b9b6236ab1b5a3f4965e0 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 14:14:58 +0200 Subject: [PATCH 026/162] fix: rename json dump --- e2e/src/fixtures/1.6/{bundles.json => product_bundles.json} | 0 e2e/src/fixtures/1.7/{bundles.json => product_bundles.json} | 0 e2e/src/fixtures/8/{bundles.json => product_bundles.json} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename e2e/src/fixtures/1.6/{bundles.json => product_bundles.json} (100%) rename e2e/src/fixtures/1.7/{bundles.json => product_bundles.json} (100%) rename e2e/src/fixtures/8/{bundles.json => product_bundles.json} (100%) diff --git a/e2e/src/fixtures/1.6/bundles.json b/e2e/src/fixtures/1.6/product_bundles.json similarity index 100% rename from e2e/src/fixtures/1.6/bundles.json rename to e2e/src/fixtures/1.6/product_bundles.json diff --git a/e2e/src/fixtures/1.7/bundles.json b/e2e/src/fixtures/1.7/product_bundles.json similarity index 100% rename from e2e/src/fixtures/1.7/bundles.json rename to e2e/src/fixtures/1.7/product_bundles.json diff --git a/e2e/src/fixtures/8/bundles.json b/e2e/src/fixtures/8/product_bundles.json similarity index 100% rename from e2e/src/fixtures/8/bundles.json rename to e2e/src/fixtures/8/product_bundles.json From 10e1367d7136b242a814370b9da6e4c0f72aa816 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 15:30:02 +0200 Subject: [PATCH 027/162] fix: bug e2e --- e2e/src/full-sync.spec.ts | 2 +- e2e/src/helpers/log-helper.ts | 8 +++++++- src/Service/FrontApiService.php | 5 +++-- src/Service/SynchronizationService.php | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 77faa06e..737ecd94 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -187,7 +187,7 @@ describe('Full Sync', () => { toArray() ) ); - console.log('test', testConfig.dumpFullSyncData); + // dump data for easier debugging or updating fixtures if (testConfig.dumpFullSyncData) { await dumpUploadData(syncedData, shopContent); diff --git a/e2e/src/helpers/log-helper.ts b/e2e/src/helpers/log-helper.ts index 917216db..dd88a31b 100644 --- a/e2e/src/helpers/log-helper.ts +++ b/e2e/src/helpers/log-helper.ts @@ -7,7 +7,13 @@ import {getShopHealthCheck} from "./data-helper"; export function logAxiosError(err: Error) { if(err instanceof AxiosError) { - console.log(R.pick(['status', 'statusText' ,'data',], err.response)) + const data = { + + ...R.pick(['url'], err.response.config), + ...R.pick(['status', 'statusText' ,'data'], err.response) + } + + console.log(data) } } diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index ddec1fa0..5829a4a4 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -2,6 +2,8 @@ namespace PrestaShop\Module\PsEventbus\Service; +use Behat\Behat\HelperContainer\Exception\ServiceNotFoundException; +use Exception; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Exception\FirebaseException; @@ -178,8 +180,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, CommonService::exitWithExceptionMessage($exception); } catch (\Exception $exception) { $this->errorHandler->handle($exception); - - CommonService::dieWithResponse(['message' => 'An error occured. Please check logs for more information'], 500); + CommonService::dieWithResponse(['message' => 'An error occured. Please check shop logs for more information'], 500); } } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index b0d7718b..e6285c33 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -94,7 +94,7 @@ public function sendFullSync( $module = \Module::getInstanceByName('ps_eventbus'); if (!$module->hasService($serviceId)) { - throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + throw new ServiceNotFoundException($serviceId); } /** @var ShopContentServiceInterface $shopContentApiService */ @@ -159,7 +159,7 @@ public function sendIncrementalSync( $module = \Module::getInstanceByName('ps_eventbus'); if (!$module->hasService($serviceId)) { - throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + throw new ServiceNotFoundException($serviceId); } /** @var ShopContentServiceInterface $shopContentApiService */ From b962dde0604da94066e2523aaf2cd336a38f8c58 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 26 Aug 2024 10:58:15 +0200 Subject: [PATCH 028/162] fix: common problems --- controllers/front/apiFront.php | 5 ++++- e2e/jest.config.json | 3 ++- e2e/src/helpers/shop-contents.ts | 6 +++--- src/Config/Config.php | 12 ++++++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 01c07340..969d8058 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -35,6 +35,9 @@ public function postProcess() /** @var FrontApiService $frontApiService */ $frontApiService = $module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); - $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); + // edit shopContent for matching Config.php const + $shopContentEdited = str_replace('-', '_', $shopContent); + + $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $isFull, $debug); } } diff --git a/e2e/jest.config.json b/e2e/jest.config.json index 5699c0ce..0effbacc 100644 --- a/e2e/jest.config.json +++ b/e2e/jest.config.json @@ -10,5 +10,6 @@ "testEnvironment": "node", "moduleNameMapper": { "^@/(.*)$": "/$1" - } + }, + "verbose": true } diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 37bbbd9b..abd72f5b 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -2,7 +2,7 @@ import R from "ramda"; export const shopContentMapping = { 'carriers': 'carriers', - 'carrier_details': 'carriers-details', + 'carrier_details': 'carrier-details', 'carts' : 'carts', 'cart_products': 'carts', 'cart_rules' : 'cart-rules', @@ -25,10 +25,10 @@ export const shopContentMapping = { 'wishlists': 'wishlists', 'wishlist_products': 'wishlist-products', 'stocks': 'stocks', - 'stock_movements': 'stock_movements', + 'stock_movements': 'stock-movements', 'manufacturers': 'manufacturers', 'suppliers': 'suppliers', - 'product_suppliers': 'product_suppliers', + 'product_suppliers': 'product-suppliers', 'languages': 'languages', 'employees': 'employees', 'translations': 'translations', diff --git a/src/Config/Config.php b/src/Config/Config.php index 15848fd8..41a8744b 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -32,8 +32,8 @@ class Config self::PS_ACCOUNTS_NOT_INSTALLED => 'PsAccounts not installed', ]; - const COLLECTION_BUNDLES = 'bundles'; const COLLECTION_CARRIERS = 'carriers'; + const COLLECTION_CARRIER_DETAILS = 'carrier_details'; const COLLECTION_CARTS = 'carts'; const COLLECTION_CART_PRODUCTS = 'cart_products'; const COLLECTION_CART_RULES = 'cart_rules'; @@ -46,15 +46,17 @@ class Config const COLLECTION_HEALTHCHECK = 'healthcheck'; const COLLECTION_IMAGES = 'images'; const COLLECTION_IMAGE_TYPES = 'image_types'; + const COLLECTION_INFO = 'info'; const COLLECTION_LANGUAGES = 'languages'; const COLLECTION_MANUFACTURERS = 'manufacturers'; const COLLECTION_MODULES = 'modules'; const COLLECTION_ORDERS = 'orders'; const COLLECTION_ORDER_CART_RULES = 'order_cart_rules'; const COLLECTION_ORDER_DETAILS = 'order_details'; - const COLLECTION_ORDER_STATUS_HISTORY = 'order_status_history'; + const COLLECTION_ORDER_STATUS_HISTORIES = 'order_status_histories'; const COLLECTION_PRODUCTS = 'products'; const COLLECTION_PRODUCT_ATTRIBUTES = 'attributes'; + const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; const COLLECTION_SHOPS = 'shops'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; @@ -69,8 +71,8 @@ class Config const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; const SHOP_CONTENTS = [ - self::COLLECTION_BUNDLES, self::COLLECTION_CARRIERS, + self::COLLECTION_CARRIER_DETAILS, self::COLLECTION_CARTS, self::COLLECTION_CART_PRODUCTS, self::COLLECTION_CART_RULES, @@ -82,15 +84,17 @@ class Config self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, + self::COLLECTION_INFO, self::COLLECTION_LANGUAGES, self::COLLECTION_MANUFACTURERS, self::COLLECTION_MODULES, self::COLLECTION_ORDERS, self::COLLECTION_ORDER_CART_RULES, self::COLLECTION_ORDER_DETAILS, - self::COLLECTION_ORDER_STATUS_HISTORY, + self::COLLECTION_ORDER_STATUS_HISTORIES, self::COLLECTION_PRODUCTS, self::COLLECTION_PRODUCT_ATTRIBUTES, + self::COLLECTION_PRODUCT_BUNDLES, self::COLLECTION_PRODUCT_SUPPLIERS, self::COLLECTION_SHOPS, self::COLLECTION_SPECIFIC_PRICES, From 5d0580a09d4f50a14caeb35923557a9266294e39 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 26 Jul 2024 15:48:57 +0200 Subject: [PATCH 029/162] refactor: rework hooks with traits --- ps_eventbus.php | 1535 +-------------------------------------- src/Traits/UseHooks.php | 1533 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1539 insertions(+), 1529 deletions(-) create mode 100644 src/Traits/UseHooks.php diff --git a/ps_eventbus.php b/ps_eventbus.php index bdedd343..35a7ef09 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -24,10 +24,9 @@ * International Registered Trademark & Property of PrestaShop SA */ -use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; -use PrestaShop\Module\PsEventbus\Service\SynchronizationService; +use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; if (!defined('_PS_VERSION_')) { exit; @@ -35,6 +34,9 @@ class Ps_eventbus extends Module { + // All hooks is here + use PrestaShop\Module\PsEventbus\UseHooks; + /** * @var array */ @@ -63,103 +65,7 @@ class Ps_eventbus extends Module public $version; /** - * List of hook to install at the installation of the module - * - * @var array - */ - private $hookToInstall = [ - 'actionObjectCarrierAddAfter', - 'actionObjectCarrierDeleteAfter', - 'actionObjectCarrierUpdateAfter', - - 'actionObjectCartAddAfter', - 'actionObjectCartUpdateAfter', - - 'actionObjectCartRuleAddAfter', - 'actionObjectCartRuleDeleteAfter', - 'actionObjectCartRuleUpdateAfter', - - 'actionObjectCategoryAddAfter', - 'actionObjectCategoryDeleteAfter', - 'actionObjectCategoryUpdateAfter', - - 'actionObjectCombinationDeleteAfter', - - 'actionObjectCountryAddAfter', - 'actionObjectCountryDeleteAfter', - 'actionObjectCountryUpdateAfter', - - 'actionObjectCurrencyAddAfter', - 'actionObjectCurrencyUpdateAfter', - - 'actionObjectCustomerAddAfter', - 'actionObjectCustomerDeleteAfter', - 'actionObjectCustomerUpdateAfter', - - 'actionObjectImageAddAfter', - 'actionObjectImageDeleteAfter', - 'actionObjectImageUpdateAfter', - - 'actionObjectLanguageAddAfter', - 'actionObjectLanguageDeleteAfter', - 'actionObjectLanguageUpdateAfter', - - 'actionObjectManufacturerAddAfter', - 'actionObjectManufacturerDeleteAfter', - 'actionObjectManufacturerUpdateAfter', - - 'actionObjectOrderAddAfter', - 'actionObjectOrderUpdateAfter', - - 'actionObjectProductAddAfter', - 'actionObjectProductDeleteAfter', - 'actionObjectProductUpdateAfter', - - 'actionObjectSpecificPriceAddAfter', - 'actionObjectSpecificPriceDeleteAfter', - 'actionObjectSpecificPriceUpdateAfter', - - 'actionObjectStateAddAfter', - 'actionObjectStateDeleteAfter', - 'actionObjectStateUpdateAfter', - - 'actionObjectStockAddAfter', - 'actionObjectStockUpdateAfter', - - 'actionObjectStoreAddAfter', - 'actionObjectStoreDeleteAfter', - 'actionObjectStoreUpdateAfter', - - 'actionObjectSupplierAddAfter', - 'actionObjectSupplierDeleteAfter', - 'actionObjectSupplierUpdateAfter', - - 'actionObjectTaxAddAfter', - 'actionObjectTaxDeleteAfter', - 'actionObjectTaxRulesGroupAddAfter', - 'actionObjectTaxRulesGroupDeleteAfter', - 'actionObjectTaxRulesGroupUpdateAfter', - 'actionObjectTaxUpdateAfter', - - 'actionObjectWishlistAddAfter', - 'actionObjectWishlistDeleteAfter', - 'actionObjectWishlistUpdateAfter', - - 'actionObjectZoneAddAfter', - 'actionObjectZoneDeleteAfter', - 'actionObjectZoneUpdateAfter', - - 'actionShippingPreferencesPageSave', - - 'actionObjectEmployeeAddAfter', - 'actionObjectEmployeeDeleteAfter', - 'actionObjectEmployeeUpdateAfter', - - 'actionDispatcherBefore', - ]; - - /** - * @var PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer + * @var ServiceContainer */ private $serviceContainer; @@ -258,7 +164,7 @@ public function install() return $installer->installDatabaseTables() && parent::install() - && $this->registerHook($this->hookToInstall); + && $this->registerHook($this->getHooks()); } /** @@ -323,1435 +229,6 @@ public function getService($serviceName) return $this->getServiceContainer()->getService($serviceName); } - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectImageDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $image = $parameters['object']; - - if (isset($image->id_product)) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectImageAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $image = $parameters['object']; - if (isset($image->id_product)) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectImageUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $image = $parameters['object']; - if (isset($image->id_product)) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectLanguageDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $language = $parameters['object']; - if (isset($language->id)) { - $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); - $synchronizationService->insertDeletedObject( - $language->id, - Config::COLLECTION_LANGUAGES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectLanguageAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectLanguageUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectManufacturerDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $manufacturer = $parameters['object']; - if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectManufacturerAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $manufacturer = $parameters['object']; - if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectManufacturerUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $manufacturer = $parameters['object']; - if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSupplierDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $supplier = $parameters['object']; - if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); - $synchronizationService->insertDeletedObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSupplierAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $supplier = $parameters['object']; - if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSupplierUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $supplier = $parameters['object']; - if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectProductDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectProductAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectProductUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Product $product */ - $product = $parameters['object']; - - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectWishlistDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $wishlist = $parameters['object']; - if (isset($wishlist->id)) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); - $synchronizationService->insertDeletedObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectWishlistAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $wishlist = $parameters['object']; - if (isset($wishlist->id)) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectWishlistUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $wishlist = $parameters['object']; - if (isset($wishlist->id)) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStockAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $stock = $parameters['object']; - if (isset($stock->id)) { - $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStockUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $stock = $parameters['object']; - if (isset($stock->id)) { - $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStoreDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_STORES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStoreAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_STORES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectStoreUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $store = $parameters['object']; - if (isset($store->id)) { - $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $store->id, - Config::COLLECTION_STORES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCombinationDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Combination $combination */ - $combination = $parameters['object']; - - if (isset($combination->id)) { - $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); - $synchronizationService->insertDeletedObject( - $combination->id, - Config::COLLECTION_PRODUCT_ATTRIBUTES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCategoryAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $category = $parameters['object']; - - if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCategoryUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $category = $parameters['object']; - - if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCategoryDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $category = $parameters['object']; - - if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); - $synchronizationService->insertDeletedObject( - $category->id, - Config::COLLECTION_CATEGORIES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCustomerAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $customer = $parameters['object']; - - if (isset($customer->id)) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCustomerUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $customer = $parameters['object']; - - if (isset($customer->id)) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCustomerDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $customer = $parameters['object']; - - if (isset($customer->id)) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCurrencyAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $currency = $parameters['object']; - - if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCurrencyUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $currency = $parameters['object']; - - if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, - date(DATE_ATOM), - $this->shopId, - true - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCurrencyDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $currency = $parameters['object']; - - if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); - $synchronizationService->insertDeletedObject( - $currency->id, - Config::COLLECTION_CURRENCIES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cart = $parameters['object']; - - if (isset($cart->id)) { - $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cart = $parameters['object']; - - if (isset($cart->id)) { - $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartRuleAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cartRule = $parameters['object']; - - if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartRuleDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cartRule = $parameters['object']; - - if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCartRuleUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $cartRule = $parameters['object']; - - if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectOrderAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $order = $parameters['object']; - - if (isset($order->id)) { - $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectOrderUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $order = $parameters['object']; - - if (isset($order->id)) { - $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCarrierAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ - $carrier = $parameters['object']; - - if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCarrierUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ - $carrier = $parameters['object']; - - if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectCarrierDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ - $carrier = $parameters['object']; - - if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - } - - /** - * @return void - */ - public function hookActionObjectCountryAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectCountryUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectCountryDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectStateAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectStateUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectStateDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectZoneAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectZoneUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectZoneDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxRulesGroupAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxRulesGroupUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectTaxRulesGroupDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionShippingPreferencesPageSave() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectEmployeeAddAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectEmployeeDeleteAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertDeletedObject( - 0, - Config::COLLECTION_EMPLOYEES, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * @return void - */ - public function hookActionObjectEmployeeUpdateAfter() - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, - date(DATE_ATOM), - $this->shopId - ); - } - - /** - * This is global hook. This hook is called at the beginning of the dispatch method of the Dispatcher - * It's possible to use this hook all time when we don't have specific hook. - * Available since: 1.7.1 - * - * Unable to use hookActionDispatcherAfter. Seem to be have a strange effect. When i use - * this hook and try to dump() the content, no dump appears in the symfony debugger, and no more hooks appear. - * For security reasons, I like to use the before hook, and put it in a try/catch - * - * @param array $parameters - * - * @return void - */ - public function hookActionDispatcherBefore($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - try { - /* - * Class "ActionDispatcherLegacyHooksSubscriber" as implement in 1.7.3.0: - * https://github.com/PrestaShop/PrestaShop/commit/a4ae4544cc62c818aba8b3d9254308f538b7acdc - */ - if ($parameters['controller_type'] != 2) { - return; - } - - if (array_key_exists('route', $parameters)) { - $route = $parameters['route']; - - // when translation is edited or reset, add to incremental sync - if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_TRANSLATIONS, - date(DATE_ATOM), - $this->shopId - ); - } - } - } catch (Exception $e) { - return; - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSpecificPriceAddAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var SpecificPrice $specificPrice */ - $specificPrice = $parameters['object']; - - if ($specificPrice instanceof SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, - date(DATE_ATOM), - $this->shopId - ); - } - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSpecificPriceUpdateAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var SpecificPrice $specificPrice */ - $specificPrice = $parameters['object']; - - if ($specificPrice instanceof SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, - date(DATE_ATOM), - $this->shopId - ); - } - } - } - - /** - * @param array $parameters - * - * @return void - */ - public function hookActionObjectSpecificPriceDeleteAfter($parameters) - { - /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var SpecificPrice $specificPrice */ - $specificPrice = $parameters['object']; - - if ($specificPrice instanceof SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); - $synchronizationService->insertDeletedObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, - date(DATE_ATOM), - $this->shopId - ); - } - } - } - /** * Set PHP compatibility to 7.1 * diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php new file mode 100644 index 00000000..99fd9fcb --- /dev/null +++ b/src/Traits/UseHooks.php @@ -0,0 +1,1533 @@ + $parameters + * + * @return void + */ + public function hookActionObjectImageDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $image = $parameters['object']; + + if (isset($image->id_product)) { + $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); + $synchronizationService->insertIncrementalSyncObject( + $image->id_product, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectImageAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $image = $parameters['object']; + if (isset($image->id_product)) { + $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $image->id_product, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectImageUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $image = $parameters['object']; + if (isset($image->id_product)) { + $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $image->id_product, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectLanguageDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $language = $parameters['object']; + if (isset($language->id)) { + $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); + $synchronizationService->insertDeletedObject( + $language->id, + Config::COLLECTION_LANGUAGES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectLanguageAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $language = $parameters['object']; + if (isset($language->id) && isset($language->id_product)) { + $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $language->id, + Config::COLLECTION_LANGUAGES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectLanguageUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $language = $parameters['object']; + if (isset($language->id) && isset($language->id_product)) { + $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $language->id, + Config::COLLECTION_LANGUAGES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectManufacturerDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { + $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); + $synchronizationService->insertDeletedObject( + $manufacturer->id, + Config::COLLECTION_MANUFACTURERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectManufacturerAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { + $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $manufacturer->id, + Config::COLLECTION_MANUFACTURERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectManufacturerUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { + $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $manufacturer->id, + Config::COLLECTION_MANUFACTURERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSupplierDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $supplier = $parameters['object']; + if (isset($supplier->id)) { + $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); + $synchronizationService->insertDeletedObject( + $supplier->id, + Config::COLLECTION_SUPPLIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSupplierAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $supplier = $parameters['object']; + if (isset($supplier->id)) { + $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $supplier->id, + Config::COLLECTION_SUPPLIERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSupplierUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $supplier = $parameters['object']; + if (isset($supplier->id)) { + $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $supplier->id, + Config::COLLECTION_SUPPLIERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectProductDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + + if (isset($product->id)) { + $synchronizationService->sendLiveSync('products', $product->id, 'delete'); + $synchronizationService->insertDeletedObject( + $product->id, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectProductAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + if (isset($product->id)) { + $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + + $synchronizationService->insertIncrementalSyncObject( + $product->id, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectProductUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Product $product */ + $product = $parameters['object']; + + if (isset($product->id)) { + $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + + $synchronizationService->insertIncrementalSyncObject( + $product->id, + Config::COLLECTION_PRODUCTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectWishlistDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $wishlist = $parameters['object']; + if (isset($wishlist->id)) { + $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); + $synchronizationService->insertDeletedObject( + $wishlist->id, + Config::COLLECTION_WISHLISTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectWishlistAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $wishlist = $parameters['object']; + if (isset($wishlist->id)) { + $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $wishlist->id, + Config::COLLECTION_WISHLISTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectWishlistUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $wishlist = $parameters['object']; + if (isset($wishlist->id)) { + $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $wishlist->id, + Config::COLLECTION_WISHLISTS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStockAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $stock = $parameters['object']; + if (isset($stock->id)) { + $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $stock->id, + Config::COLLECTION_STOCKS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStockUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $stock = $parameters['object']; + if (isset($stock->id)) { + $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $stock->id, + Config::COLLECTION_STOCKS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStoreDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + if (isset($product->id)) { + $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); + $synchronizationService->insertDeletedObject( + $product->id, + Config::COLLECTION_STORES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStoreAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $product = $parameters['object']; + if (isset($product->id)) { + $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $product->id, + Config::COLLECTION_STORES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectStoreUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $store = $parameters['object']; + if (isset($store->id)) { + $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $store->id, + Config::COLLECTION_STORES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCombinationDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Combination $combination */ + $combination = $parameters['object']; + + if (isset($combination->id)) { + $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); + $synchronizationService->insertDeletedObject( + $combination->id, + Config::COLLECTION_PRODUCT_ATTRIBUTES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCategoryAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $category = $parameters['object']; + + if (isset($category->id)) { + $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $category->id, + Config::COLLECTION_CATEGORIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCategoryUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $category = $parameters['object']; + + if (isset($category->id)) { + $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $category->id, + Config::COLLECTION_CATEGORIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCategoryDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $category = $parameters['object']; + + if (isset($category->id)) { + $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); + $synchronizationService->insertDeletedObject( + $category->id, + Config::COLLECTION_CATEGORIES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCustomerAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $customer = $parameters['object']; + + if (isset($customer->id)) { + $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $customer->id, + Config::COLLECTION_CUSTOMERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCustomerUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $customer = $parameters['object']; + + if (isset($customer->id)) { + $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $customer->id, + Config::COLLECTION_CUSTOMERS, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCustomerDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $customer = $parameters['object']; + + if (isset($customer->id)) { + $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); + $synchronizationService->insertDeletedObject( + $customer->id, + Config::COLLECTION_CUSTOMERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCurrencyAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $currency = $parameters['object']; + + if (isset($currency->id)) { + $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $currency->id, + Config::COLLECTION_CURRENCIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCurrencyUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $currency = $parameters['object']; + + if (isset($currency->id)) { + $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $currency->id, + Config::COLLECTION_CURRENCIES, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCurrencyDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $currency = $parameters['object']; + + if (isset($currency->id)) { + $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); + $synchronizationService->insertDeletedObject( + $currency->id, + Config::COLLECTION_CURRENCIES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cart = $parameters['object']; + + if (isset($cart->id)) { + $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cart->id, + Config::COLLECTION_CARTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cart = $parameters['object']; + + if (isset($cart->id)) { + $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cart->id, + Config::COLLECTION_CARTS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartRuleAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cartRule = $parameters['object']; + + if (isset($cartRule->id)) { + $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cartRule->id, + Config::COLLECTION_CART_RULES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartRuleDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cartRule = $parameters['object']; + + if (isset($cartRule->id)) { + $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'delete'); + $synchronizationService->insertIncrementalSyncObject( + $cartRule->id, + Config::COLLECTION_CART_RULES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCartRuleUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $cartRule = $parameters['object']; + + if (isset($cartRule->id)) { + $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $cartRule->id, + Config::COLLECTION_CART_RULES, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectOrderAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $order = $parameters['object']; + + if (isset($order->id)) { + $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $order->id, + Config::COLLECTION_ORDERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectOrderUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $order = $parameters['object']; + + if (isset($order->id)) { + $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $order->id, + Config::COLLECTION_ORDERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCarrierAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Carrier $carrier */ + $carrier = $parameters['object']; + + if (isset($carrier->id)) { + $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $carrier->id, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCarrierUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Carrier $carrier */ + $carrier = $parameters['object']; + + if (isset($carrier->id)) { + $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $carrier->id, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectCarrierDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var Carrier $carrier */ + $carrier = $parameters['object']; + + if (isset($carrier->id)) { + $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); + $synchronizationService->insertIncrementalSyncObject( + $carrier->id, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + } + + /** + * @return void + */ + public function hookActionObjectCountryAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectCountryUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectCountryDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectStateAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectStateUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectStateDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectZoneAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectZoneUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectZoneDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxRulesGroupAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxRulesGroupUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectTaxRulesGroupDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionShippingPreferencesPageSave() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_CARRIERS, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectEmployeeAddAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_EMPLOYEES, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectEmployeeDeleteAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService->insertDeletedObject( + 0, + Config::COLLECTION_EMPLOYEES, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * @return void + */ + public function hookActionObjectEmployeeUpdateAfter() + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_EMPLOYEES, + date(DATE_ATOM), + $this->shopId + ); + } + + /** + * This is global hook. This hook is called at the beginning of the dispatch method of the Dispatcher + * It's possible to use this hook all time when we don't have specific hook. + * Available since: 1.7.1 + * + * Unable to use hookActionDispatcherAfter. Seem to be have a strange effect. When i use + * this hook and try to dump() the content, no dump appears in the symfony debugger, and no more hooks appear. + * For security reasons, I like to use the before hook, and put it in a try/catch + * + * @param array $parameters + * + * @return void + */ + public function hookActionDispatcherBefore($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + try { + /* + * Class "ActionDispatcherLegacyHooksSubscriber" as implement in 1.7.3.0: + * https://github.com/PrestaShop/PrestaShop/commit/a4ae4544cc62c818aba8b3d9254308f538b7acdc + */ + if ($parameters['controller_type'] != 2) { + return; + } + + if (array_key_exists('route', $parameters)) { + $route = $parameters['route']; + + // when translation is edited or reset, add to incremental sync + if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { + $synchronizationService->insertIncrementalSyncObject( + 0, + Config::COLLECTION_TRANSLATIONS, + date(DATE_ATOM), + $this->shopId + ); + } + } + } catch (Exception $e) { + return; + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSpecificPriceAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var SpecificPrice $specificPrice */ + $specificPrice = $parameters['object']; + + if ($specificPrice instanceof SpecificPrice) { + if (isset($specificPrice->id)) { + $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $specificPrice->id, + Config::COLLECTION_SPECIFIC_PRICES, + date(DATE_ATOM), + $this->shopId + ); + } + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSpecificPriceUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var SpecificPrice $specificPrice */ + $specificPrice = $parameters['object']; + + if ($specificPrice instanceof SpecificPrice) { + if (isset($specificPrice->id)) { + $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); + $synchronizationService->insertIncrementalSyncObject( + $specificPrice->id, + Config::COLLECTION_SPECIFIC_PRICES, + date(DATE_ATOM), + $this->shopId + ); + } + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectSpecificPriceDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + + /** @var SpecificPrice $specificPrice */ + $specificPrice = $parameters['object']; + + if ($specificPrice instanceof SpecificPrice) { + if (isset($specificPrice->id)) { + $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); + $synchronizationService->insertDeletedObject( + $specificPrice->id, + Config::COLLECTION_SPECIFIC_PRICES, + date(DATE_ATOM), + $this->shopId + ); + } + } + } +} From 4095f730be37ff1153f1741234b74f61f1f6cc61 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 26 Jul 2024 17:18:05 +0200 Subject: [PATCH 030/162] refactor: synchronization service and connected services --- src/Config/Config.php | 9 + src/Controller/AbstractApiController.php | 4 +- .../ShopContentServiceInterface.php | 10 + src/Service/SynchronizationService.php | 229 +++++++++--------- 4 files changed, 136 insertions(+), 116 deletions(-) create mode 100644 src/Interfaces/ShopContentServiceInterface.php diff --git a/src/Config/Config.php b/src/Config/Config.php index bcf698ef..3116edc9 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 e5b34bf8..a708d3c3 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 00000000..b52c7760 --- /dev/null +++ b/src/Interfaces/ShopContentServiceInterface.php @@ -0,0 +1,10 @@ +module = $module; $this->eventbusSyncRepository = $eventbusSyncRepository; $this->incrementalSyncRepository = $incrementalSyncRepository; $this->liveSyncRepository = $liveSyncRepository; $this->deletedObjectsRepository = $deletedObjectsRepository; $this->languageRepository = $languageRepository; + $this->proxyService = $proxyService; $this->payloadDecorator = $payloadDecorator; } /** - * @param PaginatedApiDataProviderInterface $dataProvider - * @param string $type + * @param string $shopContent * @param string $jobId * @param string $langIso * @param int $offset * @param int $limit + * @param int $startTime * @param string $dateNow - * @param int $scriptStartTime - * @param bool $isFull + * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException|ApiException */ - public function handleFullSync( - PaginatedApiDataProviderInterface $dataProvider, - $type, - $jobId, - $langIso, - $offset, - $limit, - $dateNow, - $scriptStartTime, - $isFull + public function sendFullSync( + string $shopContent, + string $jobId, + string $langIso, + int $offset, + int $limit, + int $startTime, + string $dateNow, + bool $debug ) { $response = []; - $data = $dataProvider->getFormattedData($offset, $limit, $langIso); + $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceId = 'PrestaShop\Module\PsEventbusV4\Services\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent + + /** @var Ps_eventbus */ + $module = \Module::getInstanceByName('ps_eventbus'); + + if (!$module->hasService($serviceId)) { + throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + } + + /** @var ShopContentServiceInterface $shopContentApiService */ + $shopContentApiService = $this->module->getService($serviceId); + + /** @var ConfigurationRepository $configurationRepository */ + $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + + $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); + $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); + + $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $debug); $this->payloadDecorator->convertDateFormat($data); if (!empty($data)) { - /** @var ProxyService */ - $proxyService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\ProxyService'); - - $response = $proxyService->upload($jobId, $data, $scriptStartTime, $isFull); + $response = $this->proxyService->upload($jobId, $data, $startTime, true); if ($response['httpCode'] == 201) { $offset += $limit; } } - $remainingObjects = (int) $dataProvider->getRemainingObjectsCount($offset, $langIso); + $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $langIso); if ($remainingObjects <= 0) { $remainingObjects = 0; $offset = 0; } - $this->eventbusSyncRepository->updateTypeSync($type, $offset, $dateNow, $remainingObjects === 0, $langIso); + $this->eventbusSyncRepository->updateTypeSync($shopContent, $offset, $dateNow, $remainingObjects === 0, $langIso); return $this->returnSyncResponse($data, $response, $remainingObjects); } /** - * @param PaginatedApiDataProviderInterface $dataProvider * @param string $type * @param string $jobId - * @param int $limit * @param string $langIso - * @param int $scriptStartTime - * @param bool $isFull + * @param int $limit + * @param int $startTime + * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException */ - public function handleIncrementalSync( - PaginatedApiDataProviderInterface $dataProvider, - $type, - $jobId, - $limit, - $langIso, - $scriptStartTime, - $isFull + public function sendIncrementalSync( + string $shopContent, + string $jobId, + string $langIso, + int $limit, + int $startTime, + bool $debug ) { $response = []; - $objectIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($type, $langIso, $limit); + $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + + /** @var ShopContentServiceInterface $shopContentApiService */ + $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Services\\' . $serviceName . 'Service'); + + $contentIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($shopContent, $langIso, $limit); - if (empty($objectIds)) { + if (empty($contentIds)) { return [ 'total_objects' => 0, 'has_remaining_objects' => false, @@ -164,24 +179,21 @@ public function handleIncrementalSync( ]; } - $data = $dataProvider->getFormattedDataIncremental($limit, $langIso, $objectIds); + $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso, $debug); $this->payloadDecorator->convertDateFormat($data); if (!empty($data)) { - /** @var ProxyService */ - $proxyService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\ProxyService'); - - $response = $proxyService->upload($jobId, $data, $scriptStartTime, $isFull); + $response = $this->proxyService->upload($jobId, $data, $startTime, false); if ($response['httpCode'] == 201) { - $this->incrementalSyncRepository->removeIncrementalSyncObjects($type, $objectIds, $langIso); + $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, $contentIds, $langIso); } } else { - $this->incrementalSyncRepository->removeIncrementalSyncObjects($type, $objectIds, $langIso); + $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, $contentIds, $langIso); } - $remainingObjects = $this->incrementalSyncRepository->getRemainingIncrementalObjects($type, $langIso); + $remainingObjects = $this->incrementalSyncRepository->getRemainingIncrementalObjects($shopContent, $langIso); return $this->returnSyncResponse($data, $response, $remainingObjects); } @@ -203,17 +215,17 @@ public function sendLiveSync($shopContent, $shopContentId, $action) } /** - * @param int $objectId - * @param string $type + * @param array> $contentTypesWithIds + * @param string actionType * @param string $createdAt * @param int $shopId * @param bool $hasMultiLang * * @return void */ - public function insertIncrementalSyncObject($objectId, $type, $createdAt, $shopId, $hasMultiLang = null) + public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $createdAt, $shopId, $hasMultiLang = null) { - if ((int) $objectId === 0) { + if (count($contentTypesWithIds) == 0) { return; } @@ -222,80 +234,71 @@ public function insertIncrementalSyncObject($objectId, $type, $createdAt, $shopI * When random number == 10, we count number of entry exist in database for this specific shop content * If count > 100 000, we removed all entry corresponding to this shop content, and we enable full sync for this */ - if (mt_rand() % $this::RANDOM_SYNC_CHECK_MAX == 0) { - $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($type); - if ($count > $this::INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT) { - $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($type); - - if ($hasDeleted) { - $this->eventbusSyncRepository->updateTypeSync( - $type, - 0, - $createdAt, - false, - $this->languageRepository->getDefaultLanguageIsoCode() - ); + if (mt_rand() % Config::RANDOM_SYNC_CHECK_MAX == 0) { + foreach($contentTypesWithIds as $contentType => $contentIds) { + $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($contentType); + + if ($count > Config::INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT) { + $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); + + if ($hasDeleted) { + $this->eventbusSyncRepository->updateTypeSync( + $contentType, + 0, + $createdAt, + false, + $this->languageRepository->getDefaultLanguageIsoCode() + ); + } } - } - return; + return; + } } - $objectsData = []; + $contentToInsert = []; if ($hasMultiLang) { $allIsoCodes = $this->languageRepository->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { - if ($this->isFullSyncDone($type, $langIso)) { - array_push($objectsData, + foreach($contentTypesWithIds as $contentType => $contentIds) { + if ($this->isFullSyncDone($contentType, $langIso)) { + array_push($contentToInsert, + [ + 'type' => $contentType, + 'id_object' => $contentIds, + 'id_shop' => $shopId, + 'lang_iso' => $langIso, + 'action' => $actionType, + 'created_at' => $createdAt, + ] + ); + } + } + } + } else { + $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + + foreach($contentTypesWithIds as $contentType => $contentIds) { + if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { + array_push($contentToInsert, [ - 'type' => $type, - 'id_object' => $objectId, + 'type' => $contentType, + 'id_object' => $contentIds, 'id_shop' => $shopId, - 'lang_iso' => $langIso, + 'lang_iso' => $defaultIsoCode, + 'action' => $actionType, 'created_at' => $createdAt, ] ); } } - } else { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - - if ($this->isFullSyncDone($type, $defaultIsoCode)) { - array_push($objectsData, - [ - 'type' => $type, - 'id_object' => $objectId, - 'id_shop' => $shopId, - 'lang_iso' => $defaultIsoCode, - 'created_at' => $createdAt, - ] - ); - } - } - - if (empty($objectsData) == false) { - $this->incrementalSyncRepository->insertIncrementalObject($objectsData); } - } - /** - * @param int $objectId - * @param string $type - * @param string $date - * @param int $shopId - * - * @return void - */ - public function insertDeletedObject($objectId, $type, $date, $shopId) - { - if ((int) $objectId === 0) { - return; + if (empty($contentToInsert) == false) { + $this->incrementalSyncRepository->insertIncrementalObject($contentToInsert); } - - $this->deletedObjectsRepository->insertDeletedObject($objectId, $type, $date, $shopId); - $this->incrementalSyncRepository->removeIncrementalSyncObject($type, $objectId); } /** From 9cf2a6890484522b86257ea87600d8c6843ecea7 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 10:44:27 +0200 Subject: [PATCH 031/162] feature: add upgrade script --- upgrade/Upgrade-4.0.0.php | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 upgrade/Upgrade-4.0.0.php diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php new file mode 100644 index 00000000..20cfed1c --- /dev/null +++ b/upgrade/Upgrade-4.0.0.php @@ -0,0 +1,66 @@ +query($editIncrementalTable); + + // If ALTER is failed, stop update process + if (!$editIncrementalTableResult) { + return false; + } + + // Backup data from eventbus_deleted_objects + $backupDeletedTable = 'SELECT * FROM `' . _DB_PREFIX_ . 'eventbus_deleted_objects`'; + $backupDeletedTableResult = $db->executeS($backupDeletedTable); + + $elementsCount = count($backupDeletedTableResult); + $index = 0; + + // Insert data from backup into incremental table + $updateIncrementalTable = 'INSERT INTO `' . _DB_PREFIX_ . 'eventbus_incremental_sync` (type, id_object, id_shop, lang_iso, created_at, action) VALUES '; + + foreach ($backupDeletedTableResult as $deletedContent) { + $updateIncrementalTable .= "( + '{$db->escape($deletedContent['type'])}', + {$db->escape($deletedContent['id_object'])}, + {$db->escape($deletedContent['id_shop'])}, + {$db->escape($deletedContent['created_at'])}', + deleted' + )"; + + if (++$index < $elementsCount) { + $updateIncrementalTable .= ','; + } + } + + $updateIncrementalTable .= ' + ON DUPLICATE KEY UPDATE + type = VALUES(type), + id_object = VALUES(id_object), + id_shop = VALUES(id_shop), + created_at = VALUES(created_at) + action = deleted + '; + + $updateIncrementalTableResult = (bool) $db->query($updateIncrementalTable); + + // If insert backup is failed, stop update process + if (!$updateIncrementalTableResult) { + return false; + } + + // Drop eventbus_deleted_objects table + $dropDeletedTable = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'eventbus_deleted_objects`'; + $dropDeletedTableResult = (bool) $db->query($dropDeletedTable); + + return $dropDeletedTableResult; +} From 009fa4d9bb9c458ef447ce7a40aabf9dbd1dd0eb Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 10:45:01 +0200 Subject: [PATCH 032/162] fix: update service.yml --- config/front/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/front/services.yml b/config/front/services.yml index a68ff670..b36538f0 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -59,6 +59,7 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - '@PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator' PrestaShop\Module\PsEventbus\Service\SpecificPriceService: From b2da0886b85d6f51a3a1674d1fbb7fb30e72ca3e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 16:11:34 +0200 Subject: [PATCH 033/162] feat: add front service --- controllers/front/apiFront.php | 38 +++++ src/Config/Config.php | 49 +++++-- src/Service/FrontApiService.php | 248 ++++++++++++++++++++++++++++++++ 3 files changed, 327 insertions(+), 8 deletions(-) create mode 100644 controllers/front/apiFront.php create mode 100644 src/Service/FrontApiService.php diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php new file mode 100644 index 00000000..02204b09 --- /dev/null +++ b/controllers/front/apiFront.php @@ -0,0 +1,38 @@ +module->getService('PrestaShop\Module\PsEventbusV4\Services\ApiService'); + + $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); + } +} + diff --git a/src/Config/Config.php b/src/Config/Config.php index 3116edc9..5b8be4ad 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -4,6 +4,11 @@ class Config { + 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 SYNC_API_MAX_TIMEOUT = 5; const COLLECTOR_MAX_TIMEOUT = 30; const COLLECTOR_MULTIPART_BOUNDARY = 'ps_eventbus_boundary'; @@ -62,14 +67,42 @@ 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'; + public const SHOP_CONTENTS = [ + self::COLLECTION_BUNDLES, + self::COLLECTION_CARRIERS, + self::COLLECTION_CARTS, + self::COLLECTION_CART_PRODUCTS, + self::COLLECTION_CART_RULES, + self::COLLECTION_CATEGORIES, + self::COLLECTION_CURRENCIES, + self::COLLECTION_CUSTOM_PRODUCT_CARRIERS, + self::COLLECTION_CUSTOMERS, + self::COLLECTION_DELETED, + self::COLLECTION_EMPLOYEES, + self::COLLECTION_IMAGES, + self::COLLECTION_IMAGE_TYPES, + self::COLLECTION_LANGUAGES, + self::COLLECTION_MANUFACTURERS, + self::COLLECTION_MODULES, + self::COLLECTION_ORDERS, + self::COLLECTION_ORDER_CART_RULES, + self::COLLECTION_ORDER_DETAILS, + self::COLLECTION_ORDER_STATUS_HISTORY, + self::COLLECTION_PRODUCTS, + self::COLLECTION_PRODUCT_ATTRIBUTES, + self::COLLECTION_PRODUCT_SUPPLIERS, + self::COLLECTION_SHOPS, + self::COLLECTION_SPECIFIC_PRICES, + self::COLLECTION_STOCKS, + self::COLLECTION_STOCK_MVTS, + self::COLLECTION_STORES, + self::COLLECTION_SUPPLIERS, + self::COLLECTION_TAXONOMIES, + self::COLLECTION_THEMES, + self::COLLECTION_TRANSLATIONS, + self::COLLECTION_WISHLISTS, + self::COLLECTION_WISHLIST_PRODUCTS, + ]; /** * @param mixed $message diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php new file mode 100644 index 00000000..d514481d --- /dev/null +++ b/src/Service/FrontApiService.php @@ -0,0 +1,248 @@ +errorHandler = $this->module->getService(ErrorHandler::class); + + try { + $this->startTime = time(); + + $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); + $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); + $this->synchronizationService = $this->module->getService(SynchronizationService::class); + + $this->authorize(); + } catch (\Exception $exception) { + // For ApiHealthCheck, handle the error, and throw UnauthorizedException directly, to catch-up at top level. + if (strpos(get_class($this), 'apiHealthCheckController') !== false) { + $this->errorHandler->handle($exception); + throw new UnauthorizedException('You are not allowed to access to this resource'); + } + + if ($exception instanceof \PrestaShopDatabaseException) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } elseif ($exception instanceof EnvVarException) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } elseif ($exception instanceof FirebaseException) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } + } + } + + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) + { + try { + if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { + $this->exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); + } + + if ($limit < 0) { + $this->exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); + } + + /** @var ConfigurationRepository $configurationRepository */ + $configurationRepository = $this->module->getService('\PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + + $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); + $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); + + $offset = 0; + $incrementalSync = false; + $response = []; + + $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); + + if ($typeSync == false) { + $this->eventbusSyncRepository->insertTypeSync($shopContent, $offset, $dateNow, $langIso); + } + + if ($isFull) { + $response = $this->synchronizationService->sendFullSync( + $shopContent, + $jobId, + $langIso, + $offset, + $limit, + $this->startTime, + $dateNow, + $debug + ); + } else { + $response = $this->synchronizationService->sendIncrementalSync( + $shopContent, + $jobId, + $langIso, + $limit, + $this->startTime, + $debug + ); + } + + $this->exitWithResponse( + [ + 'job_id' => $jobId, + 'object_type' => $shopContent, + 'syncType' => $incrementalSync ? 'incremental' : 'full', + ], + $response + ); + } catch (\PrestaShopDatabaseException $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } catch (EnvVarException $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } catch (FirebaseException $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } catch (\Exception $exception) { + $this->errorHandler->handle($exception); + $this->exitWithExceptionMessage($exception); + } + } + + /** + * @return void + * + * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException + */ + private function authorize() + { + /** @var string $jobId */ + $jobId = \Tools::getValue('job_id', 'empty_job_id'); + + $authorizationResponse = $this->authorizationService->authorizeCall($jobId); + + if (is_array($authorizationResponse)) { + $this->exitWithResponse($authorizationResponse); + } elseif (!$authorizationResponse) { + throw new \PrestaShopDatabaseException('Failed saving job id to database'); + } + + try { + $token = $this->psAccountsAdapterService->getOrRefreshToken(); + } catch (\Exception $exception) { + throw new FirebaseException($exception->getMessage()); + } + + if (!$token) { + throw new FirebaseException('Invalid token'); + } + } + + /** + * @param array $response + * + * @return void + */ + private function exitWithResponse(array $response) + { + $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; + + $this->dieWithResponse($response, $httpCode); + } + + /** + * @param \Exception $exception + * + * @return void + */ + private function exitWithExceptionMessage(\Exception $exception) + { + $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); + + if ($exception instanceof \PrestaShopDatabaseException) { + $code = Config::DATABASE_QUERY_ERROR_CODE; + } elseif ($exception instanceof EnvVarException) { + $code = Config::ENV_MISCONFIGURED_ERROR_CODE; + } elseif ($exception instanceof FirebaseException) { + $code = Config::REFRESH_TOKEN_ERROR_CODE; + } elseif ($exception instanceof QueryParamsException) { + $code = Config::INVALID_URL_QUERY; + } + + $response = [ + 'object_type' => \Tools::getValue('shopContent'), + 'status' => false, + 'httpCode' => $code, + 'message' => $exception->getMessage(), + ]; + + $this->dieWithResponse($response, (int) $code); + } + + /** + * @param array $response + * @param int $code + * + * @return void + */ + private function dieWithResponse(array $response, $code) + { + $httpStatusText = "HTTP/1.1 $code"; + + if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { + $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; + } elseif (isset($response['body']['statusText'])) { + $httpStatusText .= ' ' . $response['body']['statusText']; + } + + $response['httpCode'] = (int) $code; + + header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); + header('Content-Type: application/json;charset=utf-8'); + header($httpStatusText); + + echo json_encode($response, JSON_UNESCAPED_SLASHES); + + exit; + } +} From 72d3cd0f77014ae039d235d5c03447030d371b58 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 16:11:56 +0200 Subject: [PATCH 034/162] refactor: remove all old front controllers --- controllers/front/apiCarriers.php | 25 -- controllers/front/apiCartRules.php | 25 -- controllers/front/apiCarts.php | 25 -- controllers/front/apiCategories.php | 25 -- controllers/front/apiCurrencies.php | 25 -- .../front/apiCustomProductCarriers.php | 25 -- controllers/front/apiCustomers.php | 25 -- controllers/front/apiDeletedObjects.php | 34 -- controllers/front/apiEmployees.php | 25 -- controllers/front/apiGoogleTaxonomies.php | 29 -- controllers/front/apiHealthCheck.php | 46 --- controllers/front/apiImageTypes.php | 25 -- controllers/front/apiImages.php | 25 -- controllers/front/apiInfo.php | 51 --- controllers/front/apiLanguages.php | 25 -- controllers/front/apiManufacturers.php | 25 -- controllers/front/apiModules.php | 25 -- controllers/front/apiOrders.php | 25 -- controllers/front/apiProducts.php | 25 -- controllers/front/apiSpecificPrices.php | 25 -- controllers/front/apiStocks.php | 25 -- controllers/front/apiStores.php | 25 -- controllers/front/apiSuppliers.php | 25 -- controllers/front/apiThemes.php | 51 --- controllers/front/apiTranslations.php | 25 -- controllers/front/apiWishlists.php | 25 -- src/Controller/AbstractApiController.php | 358 ------------------ tests/phpstan/phpstan.neon | 1 - 28 files changed, 1095 deletions(-) delete mode 100644 controllers/front/apiCarriers.php delete mode 100644 controllers/front/apiCartRules.php delete mode 100644 controllers/front/apiCarts.php delete mode 100644 controllers/front/apiCategories.php delete mode 100644 controllers/front/apiCurrencies.php delete mode 100644 controllers/front/apiCustomProductCarriers.php delete mode 100644 controllers/front/apiCustomers.php delete mode 100644 controllers/front/apiDeletedObjects.php delete mode 100644 controllers/front/apiEmployees.php delete mode 100644 controllers/front/apiGoogleTaxonomies.php delete mode 100644 controllers/front/apiHealthCheck.php delete mode 100644 controllers/front/apiImageTypes.php delete mode 100644 controllers/front/apiImages.php delete mode 100644 controllers/front/apiInfo.php delete mode 100644 controllers/front/apiLanguages.php delete mode 100644 controllers/front/apiManufacturers.php delete mode 100644 controllers/front/apiModules.php delete mode 100644 controllers/front/apiOrders.php delete mode 100644 controllers/front/apiProducts.php delete mode 100644 controllers/front/apiSpecificPrices.php delete mode 100644 controllers/front/apiStocks.php delete mode 100644 controllers/front/apiStores.php delete mode 100644 controllers/front/apiSuppliers.php delete mode 100644 controllers/front/apiThemes.php delete mode 100644 controllers/front/apiTranslations.php delete mode 100644 controllers/front/apiWishlists.php delete mode 100644 src/Controller/AbstractApiController.php diff --git a/controllers/front/apiCarriers.php b/controllers/front/apiCarriers.php deleted file mode 100644 index 2322915c..00000000 --- a/controllers/front/apiCarriers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CarrierDataProvider::class); - - $response = $this->handleDataSync($carrierDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCartRules.php b/controllers/front/apiCartRules.php deleted file mode 100644 index 9756bbfa..00000000 --- a/controllers/front/apiCartRules.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CartRuleDataProvider::class); - - $response = $this->handleDataSync($cartRuleDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCarts.php b/controllers/front/apiCarts.php deleted file mode 100644 index 5389995b..00000000 --- a/controllers/front/apiCarts.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CartDataProvider::class); - - $response = $this->handleDataSync($cartDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCategories.php b/controllers/front/apiCategories.php deleted file mode 100644 index 32de69d1..00000000 --- a/controllers/front/apiCategories.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CategoryDataProvider::class); - - $response = $this->handleDataSync($categoryDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCurrencies.php b/controllers/front/apiCurrencies.php deleted file mode 100644 index 9e39daa3..00000000 --- a/controllers/front/apiCurrencies.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CurrencyDataProvider::class); - - $response = $this->handleDataSync($currencyDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCustomProductCarriers.php b/controllers/front/apiCustomProductCarriers.php deleted file mode 100644 index 925ed474..00000000 --- a/controllers/front/apiCustomProductCarriers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CustomProductCarrierDataProvider::class); - - $response = $this->handleDataSync($categoryDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiCustomers.php b/controllers/front/apiCustomers.php deleted file mode 100644 index bb334118..00000000 --- a/controllers/front/apiCustomers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CustomerDataProvider::class); - - $response = $this->handleDataSync($customerDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiDeletedObjects.php b/controllers/front/apiDeletedObjects.php deleted file mode 100644 index 0a589df7..00000000 --- a/controllers/front/apiDeletedObjects.php +++ /dev/null @@ -1,34 +0,0 @@ -module->getService(DeletedObjectsService::class); - - try { - $response = $deletedObjectsService->handleDeletedObjectsSync($jobId, $this->startTime); - $this->exitWithResponse($response); - } catch (PrestaShopDatabaseException $exception) { - $this->exitWithExceptionMessage($exception); - } catch (EnvVarException $exception) { - $this->exitWithExceptionMessage($exception); - } - } -} diff --git a/controllers/front/apiEmployees.php b/controllers/front/apiEmployees.php deleted file mode 100644 index 0060c415..00000000 --- a/controllers/front/apiEmployees.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(EmployeeDataProvider::class); - - $response = $this->handleDataSync($employeeDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiGoogleTaxonomies.php b/controllers/front/apiGoogleTaxonomies.php deleted file mode 100644 index 01fc2316..00000000 --- a/controllers/front/apiGoogleTaxonomies.php +++ /dev/null @@ -1,29 +0,0 @@ -exitWithExceptionMessage(new Exception('Facebook module is not installed', Config::PS_FACEBOOK_NOT_INSTALLED)); - } - - /** @var GoogleTaxonomyDataProvider $categoryDataProvider */ - $categoryDataProvider = $this->module->getService(GoogleTaxonomyDataProvider::class); - - $response = $this->handleDataSync($categoryDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiHealthCheck.php b/controllers/front/apiHealthCheck.php deleted file mode 100644 index f1c32b69..00000000 --- a/controllers/front/apiHealthCheck.php +++ /dev/null @@ -1,46 +0,0 @@ -isAuthentifiedCall = false; - } - */ - } - - /** - * @return void - * - * @throws PrestaShopException - */ - public function postProcess() - { - /** @var ServerInformationRepository $serverInformationRepository */ - $serverInformationRepository = $this->module->getService(ServerInformationRepository::class); - - $status = $serverInformationRepository->getHealthCheckData($this->isAuthentifiedCall); - - $this->exitWithResponse($status); - } -} diff --git a/controllers/front/apiImageTypes.php b/controllers/front/apiImageTypes.php deleted file mode 100644 index 1c1f1803..00000000 --- a/controllers/front/apiImageTypes.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ImageTypeDataProvider::class); - - $response = $this->handleDataSync($imageTypeDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiImages.php b/controllers/front/apiImages.php deleted file mode 100644 index 87eea66f..00000000 --- a/controllers/front/apiImages.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ImageDataProvider::class); - - $response = $this->handleDataSync($imageDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiInfo.php b/controllers/front/apiInfo.php deleted file mode 100644 index 7115ed53..00000000 --- a/controllers/front/apiInfo.php +++ /dev/null @@ -1,51 +0,0 @@ -module->getService(ServerInformationRepository::class); - - /** @var string $langIso */ - $langIso = Tools::getValue('lang_iso', ''); - $serverInfo = $serverInformationRepository->getServerInformation($langIso); - - /** @var bool $initFullSync */ - $initFullSync = Tools::getValue('full', 0) == 1; - - try { - $response = $this->proxyService->upload($jobId, $serverInfo, $this->startTime, $initFullSync); - } catch (Exception $exception) { - $this->exitWithExceptionMessage($exception); - } - - $this->exitWithResponse( - array_merge( - [ - 'remaining_objects' => 0, - 'total_objects' => 1, - 'job_id' => $jobId, - 'object_type' => $this->type, - 'syncType' => 'full', - ], - $response - ) - ); - } -} diff --git a/controllers/front/apiLanguages.php b/controllers/front/apiLanguages.php deleted file mode 100644 index 9873ef46..00000000 --- a/controllers/front/apiLanguages.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(LanguageDataProvider::class); - - $response = $this->handleDataSync($languageDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiManufacturers.php b/controllers/front/apiManufacturers.php deleted file mode 100644 index e4ffe227..00000000 --- a/controllers/front/apiManufacturers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ManufacturerDataProvider::class); - - $response = $this->handleDataSync($manufacturerDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiModules.php b/controllers/front/apiModules.php deleted file mode 100644 index f409309a..00000000 --- a/controllers/front/apiModules.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ModuleDataProvider::class); - - $response = $this->handleDataSync($moduleDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiOrders.php b/controllers/front/apiOrders.php deleted file mode 100644 index deb0dd91..00000000 --- a/controllers/front/apiOrders.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(OrderDataProvider::class); - - $response = $this->handleDataSync($orderDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiProducts.php b/controllers/front/apiProducts.php deleted file mode 100644 index a8c835be..00000000 --- a/controllers/front/apiProducts.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(ProductDataProvider::class); - - $response = $this->handleDataSync($productDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiSpecificPrices.php b/controllers/front/apiSpecificPrices.php deleted file mode 100644 index ead620c5..00000000 --- a/controllers/front/apiSpecificPrices.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(CustomPriceDataProvider::class); - - $response = $this->handleDataSync($productDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiStocks.php b/controllers/front/apiStocks.php deleted file mode 100644 index 99cb7359..00000000 --- a/controllers/front/apiStocks.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(StockDataProvider::class); - - $response = $this->handleDataSync($stockDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiStores.php b/controllers/front/apiStores.php deleted file mode 100644 index 2de5cc70..00000000 --- a/controllers/front/apiStores.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(StoreDataProvider::class); - - $response = $this->handleDataSync($storeDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiSuppliers.php b/controllers/front/apiSuppliers.php deleted file mode 100644 index 46101b2a..00000000 --- a/controllers/front/apiSuppliers.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(SupplierDataProvider::class); - - $response = $this->handleDataSync($supplierDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiThemes.php b/controllers/front/apiThemes.php deleted file mode 100644 index dc0e2e5d..00000000 --- a/controllers/front/apiThemes.php +++ /dev/null @@ -1,51 +0,0 @@ -module->getService(ThemeRepository::class); - - /** @var array $themeInfo */ - $themeInfo = $themeRepository->getThemes(); - - /** @var bool $initFullSync */ - $initFullSync = Tools::getValue('full', 0) == 1; - - try { - $response = $this->proxyService->upload($jobId, $themeInfo, $this->startTime, $initFullSync); - } catch (Exception $exception) { - $this->exitWithExceptionMessage($exception); - } - - $this->exitWithResponse( - array_merge( - [ - 'remaining_objects' => 0, - 'total_objects' => count($themeInfo), - 'job_id' => $jobId, - 'object_type' => $this->type, - 'syncType' => 'full', - ], - $response - ) - ); - } -} diff --git a/controllers/front/apiTranslations.php b/controllers/front/apiTranslations.php deleted file mode 100644 index 50e8dd5c..00000000 --- a/controllers/front/apiTranslations.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(TranslationDataProvider::class); - - $response = $this->handleDataSync($translationDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/controllers/front/apiWishlists.php b/controllers/front/apiWishlists.php deleted file mode 100644 index 42292c1a..00000000 --- a/controllers/front/apiWishlists.php +++ /dev/null @@ -1,25 +0,0 @@ -module->getService(WishlistDataProvider::class); - - $response = $this->handleDataSync($wishlistDataProvider); - - $this->exitWithResponse($response); - } -} diff --git a/src/Controller/AbstractApiController.php b/src/Controller/AbstractApiController.php deleted file mode 100644 index a708d3c3..00000000 --- a/src/Controller/AbstractApiController.php +++ /dev/null @@ -1,358 +0,0 @@ -ajax = true; - $this->content_only = true; - $this->controller_type = 'module'; - - $this->errorHandler = $this->module->getService(ErrorHandler::class); - try { - $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); - $this->proxyService = $this->module->getService(ProxyService::class); - $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); - $this->synchronizationService = $this->module->getService(SynchronizationService::class); - } catch (\Exception $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } - - $this->eventbusSyncRepository = $this->module->getService(EventbusSyncRepository::class); - $this->languageRepository = $this->module->getService(LanguageRepository::class); - $this->incrementalSyncRepository = $this->module->getService(IncrementalSyncRepository::class); - } - - /** - * @return bool|void - * - * @throws UnauthorizedException - */ - public function init() - { - $this->startTime = time(); - - try { - $this->authorize(); - } catch (\Exception $exception) { - // For ApiHealthCheck, handle the error, and throw UnauthorizedException directly, to catch-up at top level. - if (strpos($this->page_name, 'apiHealthCheck') !== false) { - $this->errorHandler->handle($exception); - throw new UnauthorizedException('You are not allowed to access to this resource'); - } - - if ($exception instanceof \PrestaShopDatabaseException) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } elseif ($exception instanceof EnvVarException) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } elseif ($exception instanceof FirebaseException) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } - } - } - - /** - * @return void - * - * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException - */ - private function authorize() - { - /** @var string $jobId */ - $jobId = \Tools::getValue('job_id', 'empty_job_id'); - - $authorizationResponse = $this->authorizationService->authorizeCall($jobId); - - if (is_array($authorizationResponse)) { - $this->exitWithResponse($authorizationResponse); - } elseif (!$authorizationResponse) { - throw new \PrestaShopDatabaseException('Failed saving job id to database'); - } - - try { - $token = $this->psAccountsAdapterService->getOrRefreshToken(); - } catch (\Exception $exception) { - throw new FirebaseException($exception->getMessage()); - } - - if (!$token) { - throw new FirebaseException('Invalid token'); - } - } - - /** - * @param PaginatedApiDataProviderInterface $dataProvider - * - * @return array - */ - protected function handleDataSync(PaginatedApiDataProviderInterface $dataProvider) - { - /** @var bool $debug */ - $debug = \Tools::getValue('debug') == 1; - - /** @var string $jobId */ - $jobId = \Tools::getValue('job_id'); - /** @var string $langIso */ - $langIso = \Tools::getValue('lang_iso', $this->languageRepository->getDefaultLanguageIsoCode()); - /** @var int $limit */ - $limit = \Tools::getValue('limit', 50); - - if ($limit < 0) { - $this->exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); - } - - /** @var bool $initFullSync */ - $initFullSync = \Tools::getValue('full', 0) == 1; - - /** @var \PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService(\PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository::class); - $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); - - $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); - $offset = 0; - $incrementalSync = false; - $response = []; - - try { - $typeSync = $this->eventbusSyncRepository->findTypeSync($this->type, $langIso); - - if ($debug) { - $response = $dataProvider->getQueryForDebug($offset, $limit, $langIso); - - return array_merge( - [ - 'object_type' => $this->type, - ], - $response - ); - } - - if ($typeSync !== false && is_array($typeSync)) { - $offset = (int) $typeSync['offset']; - - if ((int) $typeSync['full_sync_finished'] === 1 && !$initFullSync) { - $incrementalSync = true; - } elseif ($initFullSync) { - $offset = 0; - $this->eventbusSyncRepository->updateTypeSync( - $this->type, - $offset, - $dateNow, - false, - $langIso - ); - - $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($this->type); - } - } else { - $this->eventbusSyncRepository->insertTypeSync($this->type, $offset, $dateNow, $langIso); - } - - if ($incrementalSync) { - $response = $this->synchronizationService->handleIncrementalSync( - $dataProvider, - $this->type, - $jobId, - $limit, - $langIso, - $this->startTime, - $initFullSync - ); - } else { - $response = $this->synchronizationService->handleFullSync( - $dataProvider, - $this->type, - $jobId, - $langIso, - $offset, - $limit, - $dateNow, - $this->startTime, - $initFullSync - ); - } - - return array_merge( - [ - 'job_id' => $jobId, - 'object_type' => $this->type, - 'syncType' => $incrementalSync ? 'incremental' : 'full', - ], - $response - ); - } catch (\PrestaShopDatabaseException $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } catch (EnvVarException $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } catch (FirebaseException $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } catch (\Exception $exception) { - $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); - } - - return $response; - } - - /** - * @param array|null $value - * @param string|null $controller - * @param string|null $method - * - * @return void - * - * @throws \PrestaShopException - */ - public function ajaxDie($value = null, $controller = null, $method = null) - { - parent::ajaxDie(json_encode($value) ?: null, $controller, $method); - } - - /** - * @param array $response - * - * @return void - */ - protected function exitWithResponse($response) - { - $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; - - $this->dieWithResponse($response, $httpCode); - } - - /** - * @param \Exception $exception - * - * @return void - */ - protected function exitWithExceptionMessage(\Exception $exception) - { - $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); - - if ($exception instanceof \PrestaShopDatabaseException) { - $code = Config::DATABASE_QUERY_ERROR_CODE; - } elseif ($exception instanceof EnvVarException) { - $code = Config::ENV_MISCONFIGURED_ERROR_CODE; - } elseif ($exception instanceof FirebaseException) { - $code = Config::REFRESH_TOKEN_ERROR_CODE; - } elseif ($exception instanceof QueryParamsException) { - $code = Config::INVALID_URL_QUERY; - } - - $response = [ - 'object_type' => $this->type, - 'status' => false, - 'httpCode' => $code, - 'message' => $exception->getMessage(), - ]; - - $this->dieWithResponse($response, (int) $code); - } - - /** - * @param array $response - * @param int $code - * - * @return void - */ - private function dieWithResponse($response, $code) - { - $httpStatusText = "HTTP/1.1 $code"; - - if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { - $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; - } elseif (isset($response['body']['statusText'])) { - $httpStatusText .= ' ' . $response['body']['statusText']; - } - - $response['httpCode'] = (int) $code; - - header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); - header('Content-Type: application/json;charset=utf-8'); - header($httpStatusText); - - echo json_encode($response, JSON_UNESCAPED_SLASHES); - - exit; - } -} diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index 5114a8eb..c6958554 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -17,7 +17,6 @@ parameters: - '#Cannot call method getOrRefreshToken\(\) on mixed.#' - '#Cannot call method getMetadata\(\) on mixed.#' - '#Method PrestaShop\\Module\\PsEventbus\\Api\\Post\\PostFileApi::getContent\(\) should return Psr\\Http\\Message\\StreamInterface but returns mixed.#' - - '#Property PrestaShop\\Module\\PsEventbus\\Controller\\AbstractApiController::[a-zA-Z0-9\\_\$\(\) ]+ does not accept mixed.#' - '#Cannot call method getShopUuid\(\) on mixed.#' - '#Cannot call method getPsAccountsService\(\) on mixed.#' - '#Cannot call method handle\(\) on mixed.#' From 934fd04dfc136e1f31e409acce268ef245d4a7a8 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 16:32:29 +0200 Subject: [PATCH 035/162] feat: rework orders for testing --- src/Repository/AbstractRepository.php | 55 ++++++++ src/Repository/OrderRepository.php | 155 ---------------------- src/Repository/OrdersRepository.php | 93 +++++++++++++ src/Service/ShopContent/OrdersService.php | 35 +++++ 4 files changed, 183 insertions(+), 155 deletions(-) create mode 100644 src/Repository/AbstractRepository.php delete mode 100644 src/Repository/OrderRepository.php create mode 100644 src/Repository/OrdersRepository.php create mode 100644 src/Service/ShopContent/OrdersService.php diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php new file mode 100644 index 00000000..3c178b32 --- /dev/null +++ b/src/Repository/AbstractRepository.php @@ -0,0 +1,55 @@ +context = $context; + $this->db = Db::getInstance(); + } + + public function getShopId() + { + if ($this->context->shop === null) { + throw new \PrestaShopException('No shop context'); + } + + return (int) $this->context->shop->id; + } + + protected function debugQuery() + { + $queryStringified = preg_replace('/\s+/', ' ', $this->query->build()); + + return array_merge( + (array) $this->query, + ['queryStringified' => $queryStringified] + ); + } + + protected function executeQuery() + { + return $this->db->executeS($this->query); + } +} diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php deleted file mode 100644 index a9d6a22b..00000000 --- a/src/Repository/OrderRepository.php +++ /dev/null @@ -1,155 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @param int $shopId - * - * @return \DbQuery - */ - public function getBaseQuery($shopId) - { - $query = new \DbQuery(); - $query->from(self::ORDERS_TABLE, 'o') - ->leftJoin('currency', 'c', 'o.id_currency = c.id_currency') - ->leftJoin('order_slip', 'os', 'o.id_order = os.id_order') - ->leftJoin('address', 'ad', 'ad.id_address = o.id_address_delivery') - ->leftJoin('address', 'ai', 'ai.id_address = o.id_address_invoice') - ->leftJoin('country', 'cntd', 'cntd.id_country = ad.id_country') - ->leftJoin('country', 'cnti', 'cnti.id_country = ai.id_country') - ->leftJoin('order_state_lang', 'osl', 'o.current_state = osl.id_order_state') - ->leftJoin('order_state', 'ost', 'o.current_state = ost.id_order_state') - ->where('o.id_shop = ' . (int) $shopId) - ->groupBy('o.id_order'); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * @param int $shopId - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getOrders($offset, $limit, $shopId) - { - $query = $this->getBaseQuery($shopId); - - $this->addSelectParameters($query); - - $query->limit((int) $limit, (int) $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $shopId - * - * @return int - */ - public function getRemainingOrderCount($offset, $shopId) - { - $orders = $this->getOrders($offset, 1, $shopId); - - if (!is_array($orders) || empty($orders)) { - return 0; - } - - return count($orders); - } - - /** - * @param int $limit - * @param int $shopId - * @param array $orderIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getOrdersIncremental($limit, $shopId, $orderIds) - { - $query = $this->getBaseQuery($shopId); - - $this->addSelectParameters($query); - - $query->where('o.id_order IN(' . implode(',', array_map('intval', $orderIds)) . ')') - ->limit($limit); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * @param int $limit - * @param int $shopId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $shopId) - { - $query = $this->getBaseQuery($shopId); - - $this->addSelectParameters($query); - - $query->limit((int) $limit, (int) $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('o.id_order, o.reference, o.id_customer, o.id_cart, o.current_state'); - $query->select('o.conversion_rate, o.total_paid_tax_excl, o.total_paid_tax_incl'); - $query->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer'); - $query->select('c.iso_code as currency, SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund'); - $query->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl, o.module as payment_module'); - $query->select('o.payment as payment_mode, o.total_paid_real, o.total_shipping as shipping_cost, o.date_add as created_at'); - $query->select('o.date_upd as updated_at, o.id_carrier'); - $query->select('o.payment as payment_name'); - $query->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso'); - $query->select('o.valid as is_validated'); - $query->select('ost.paid as is_paid'); - $query->select('ost.shipped as is_shipped'); - $query->select('osl.name as status_label'); - $query->select('o.module as payment_name'); - - $query->select('o.id_shop_group, o.id_shop, o.id_lang, o.id_currency, o.recyclable, o.gift'); - $query->select('o.total_discounts, o.total_discounts_tax_incl, o.total_discounts_tax_excl'); - $query->select('o.total_products, o.total_products_wt, o.total_shipping_tax_incl, o.total_shipping_tax_excl'); - $query->select('o.carrier_tax_rate, o.total_wrapping, o.total_wrapping_tax_incl, o.total_wrapping_tax_excl'); - $query->select('o.round_mode, o.round_type, o.invoice_number, o.delivery_number, o.invoice_date, o.delivery_date, o.valid'); - } -} diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php new file mode 100644 index 00000000..76dabd57 --- /dev/null +++ b/src/Repository/OrdersRepository.php @@ -0,0 +1,93 @@ +query = new \DbQuery(); + + $this->query->from(self::ORDERS_TABLE, 'o') + ->leftJoin('currency', 'c', 'o.id_currency = c.id_currency') + ->leftJoin('order_slip', 'os', 'o.id_order = os.id_order') + ->leftJoin('address', 'ad', 'ad.id_address = o.id_address_delivery') + ->leftJoin('address', 'ai', 'ai.id_address = o.id_address_invoice') + ->leftJoin('country', 'cntd', 'cntd.id_country = ad.id_country') + ->leftJoin('country', 'cnti', 'cnti.id_country = ai.id_country') + ->leftJoin('order_state_lang', 'osl', 'o.current_state = osl.id_order_state') + ->leftJoin('order_state', 'ost', 'o.current_state = ost.id_order_state') + ->where('o.id_shop = ' . (int) parent::getShopId()) + ->groupBy('o.id_order'); + + $this->query->select('o.id_order, o.reference, o.id_customer, o.id_cart, o.current_state'); + $this->query->select('o.conversion_rate, o.total_paid_tax_excl, o.total_paid_tax_incl'); + $this->query->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer'); + $this->query->select('c.iso_code as currency, SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund'); + $this->query->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl, o.module as payment_module'); + $this->query->select('o.payment as payment_mode, o.total_paid_real, o.total_shipping as shipping_cost, o.date_add as created_at'); + $this->query->select('o.date_upd as updated_at, o.id_carrier'); + $this->query->select('o.payment as payment_name'); + $this->query->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso'); + $this->query->select('o.valid as is_validated'); + $this->query->select('ost.paid as is_paid'); + $this->query->select('ost.shipped as is_shipped'); + $this->query->select('osl.name as status_label'); + $this->query->select('o.module as payment_name'); + + $this->query->select('o.id_shop_group, o.id_shop, o.id_lang, o.id_currency, o.recyclable, o.gift'); + $this->query->select('o.total_discounts, o.total_discounts_tax_incl, o.total_discounts_tax_excl'); + $this->query->select('o.total_products, o.total_products_wt, o.total_shipping_tax_incl, o.total_shipping_tax_excl'); + $this->query->select('o.carrier_tax_rate, o.total_wrapping, o.total_wrapping_tax_incl, o.total_wrapping_tax_excl'); + $this->query->select('o.round_mode, o.round_type, o.invoice_number, o.delivery_number, o.invoice_date, o.delivery_date, o.valid'); + } + + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + { + $this->generateBaseQuery(); + + $this->query->limit((int) $limit, (int) $offset); + + if ($debug) { + return $this->debugQuery(); + } else { + return $this->executeQuery(); + } + + } + + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + { + $this->generateBaseQuery(); + + $this->query->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit); + + if ($debug) { + return $this->debugQuery(); + } else { + return $this->executeQuery(); + } + } + + public function countFullSyncContentLeft($offset, $langIso = null, $debug = false) + { + $orders = $this->getContentsForFull($offset, 1, parent::getShopId()); + + if (!is_array($orders) || empty($orders)) { + return 0; + } + + return count($orders); + } +} diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php new file mode 100644 index 00000000..af345685 --- /dev/null +++ b/src/Service/ShopContent/OrdersService.php @@ -0,0 +1,35 @@ +ordersRepository = $ordersRepository; + } + + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { + $result = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + return $result; + } + + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { + $result = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); + + return $result; + } + + public function countFullSyncContentLeft($offset, $langIso = null) { + $result = $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + + return $result; + } +} From 48c41ec01fbe16cc4259b5524a984e5ac9667e65 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 17:26:40 +0200 Subject: [PATCH 036/162] fix: all hooks --- ps_eventbus.php | 2 +- src/Config/Config.php | 4 + src/Service/SynchronizationService.php | 45 +-- src/Traits/UseHooks.php | 393 +++++++++++++------------ 4 files changed, 227 insertions(+), 217 deletions(-) diff --git a/ps_eventbus.php b/ps_eventbus.php index 35a7ef09..ee053629 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -35,7 +35,7 @@ class Ps_eventbus extends Module { // All hooks is here - use PrestaShop\Module\PsEventbus\UseHooks; + use PrestaShop\Module\PsEventbus\Traits\UseHooks; /** * @var array diff --git a/src/Config/Config.php b/src/Config/Config.php index 5b8be4ad..b68438e7 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -104,6 +104,10 @@ class Config self::COLLECTION_WISHLIST_PRODUCTS, ]; + const INCREMENTAL_TYPE_ADD = 'add'; + const INCREMENTAL_TYPE_UPDATE = 'update'; + const INCREMENTAL_TYPE_DELETE = 'delete'; + /** * @param mixed $message * diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index d7f632f8..3a05f604 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -263,13 +263,35 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, foreach ($allIsoCodes as $langIso) { foreach($contentTypesWithIds as $contentType => $contentIds) { - if ($this->isFullSyncDone($contentType, $langIso)) { + foreach ($contentIds as $contentId) { + if ($this->isFullSyncDone($contentType, $langIso)) { + array_push($contentToInsert, + [ + 'type' => $contentType, + 'id_object' => $contentId, + 'id_shop' => $shopId, + 'lang_iso' => $langIso, + 'action' => $actionType, + 'created_at' => $createdAt, + ] + ); + } + } + + } + } + } else { + $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + + foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentIds as $contentId) { + if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { array_push($contentToInsert, [ 'type' => $contentType, - 'id_object' => $contentIds, + 'id_object' => $contentId, 'id_shop' => $shopId, - 'lang_iso' => $langIso, + 'lang_iso' => $defaultIsoCode, 'action' => $actionType, 'created_at' => $createdAt, ] @@ -277,23 +299,6 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } } } - } else { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - - foreach($contentTypesWithIds as $contentType => $contentIds) { - if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { - array_push($contentToInsert, - [ - 'type' => $contentType, - 'id_object' => $contentIds, - 'id_shop' => $shopId, - 'lang_iso' => $defaultIsoCode, - 'action' => $actionType, - 'created_at' => $createdAt, - ] - ); - } - } } if (empty($contentToInsert) == false) { diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 99fd9fcb..11a9f02a 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -116,9 +116,9 @@ public function hookActionObjectImageDeleteAfter($parameters) if (isset($image->id_product)) { $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $image->id_product], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId, true @@ -139,9 +139,9 @@ public function hookActionObjectImageAddAfter($parameters) $image = $parameters['object']; if (isset($image->id_product)) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $image->id_product], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -162,9 +162,9 @@ public function hookActionObjectImageUpdateAfter($parameters) $image = $parameters['object']; if (isset($image->id_product)) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $image->id_product, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $image->id_product], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -185,9 +185,9 @@ public function hookActionObjectLanguageDeleteAfter($parameters) $language = $parameters['object']; if (isset($language->id)) { $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); - $synchronizationService->insertDeletedObject( - $language->id, - Config::COLLECTION_LANGUAGES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_LANGUAGES => $language->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -207,9 +207,9 @@ public function hookActionObjectLanguageAddAfter($parameters) $language = $parameters['object']; if (isset($language->id) && isset($language->id_product)) { $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_LANGUAGES => $language->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -230,9 +230,9 @@ public function hookActionObjectLanguageUpdateAfter($parameters) $language = $parameters['object']; if (isset($language->id) && isset($language->id_product)) { $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $language->id, - Config::COLLECTION_LANGUAGES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_LANGUAGES => $language->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -253,9 +253,9 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_MANUFACTURERS, $manufacturer->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -275,9 +275,9 @@ public function hookActionObjectManufacturerAddAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -298,9 +298,9 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $manufacturer->id, - Config::COLLECTION_MANUFACTURERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -321,9 +321,9 @@ public function hookActionObjectSupplierDeleteAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); - $synchronizationService->insertDeletedObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SUPPLIERS, $supplier->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -343,9 +343,9 @@ public function hookActionObjectSupplierAddAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SUPPLIERS => $supplier->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -366,9 +366,9 @@ public function hookActionObjectSupplierUpdateAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $supplier->id, - Config::COLLECTION_SUPPLIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SUPPLIERS => $supplier->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -390,9 +390,9 @@ public function hookActionObjectProductDeleteAfter($parameters) if (isset($product->id)) { $synchronizationService->sendLiveSync('products', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS, $product->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -415,9 +415,9 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $product->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -443,9 +443,9 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_PRODUCTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCTS => $product->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -466,9 +466,9 @@ public function hookActionObjectWishlistDeleteAfter($parameters) $wishlist = $parameters['object']; if (isset($wishlist->id)) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); - $synchronizationService->insertDeletedObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_WISHLISTS, $wishlist->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -488,9 +488,9 @@ public function hookActionObjectWishlistAddAfter($parameters) $wishlist = $parameters['object']; if (isset($wishlist->id)) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_WISHLISTS => $wishlist->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -511,9 +511,9 @@ public function hookActionObjectWishlistUpdateAfter($parameters) $wishlist = $parameters['object']; if (isset($wishlist->id)) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $wishlist->id, - Config::COLLECTION_WISHLISTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_WISHLISTS => $wishlist->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -534,9 +534,9 @@ public function hookActionObjectStockAddAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STOCKS => $stock->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -557,9 +557,9 @@ public function hookActionObjectStockUpdateAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $stock->id, - Config::COLLECTION_STOCKS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STOCKS => $stock->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -580,9 +580,9 @@ public function hookActionObjectStoreDeleteAfter($parameters) $product = $parameters['object']; if (isset($product->id)) { $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); - $synchronizationService->insertDeletedObject( - $product->id, - Config::COLLECTION_STORES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STORES, $product->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -602,9 +602,9 @@ public function hookActionObjectStoreAddAfter($parameters) $product = $parameters['object']; if (isset($product->id)) { $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $product->id, - Config::COLLECTION_STORES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STORES => $product->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -625,9 +625,9 @@ public function hookActionObjectStoreUpdateAfter($parameters) $store = $parameters['object']; if (isset($store->id)) { $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $store->id, - Config::COLLECTION_STORES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_STORES => $store->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -650,9 +650,9 @@ public function hookActionObjectCombinationDeleteAfter($parameters) if (isset($combination->id)) { $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); - $synchronizationService->insertDeletedObject( - $combination->id, - Config::COLLECTION_PRODUCT_ATTRIBUTES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_PRODUCT_ATTRIBUTES, $combination->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -673,9 +673,9 @@ public function hookActionObjectCategoryAddAfter($parameters) if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CATEGORIES => $category->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -697,9 +697,9 @@ public function hookActionObjectCategoryUpdateAfter($parameters) if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $category->id, - Config::COLLECTION_CATEGORIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CATEGORIES => $category->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -721,9 +721,9 @@ public function hookActionObjectCategoryDeleteAfter($parameters) if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); - $synchronizationService->insertDeletedObject( - $category->id, - Config::COLLECTION_CATEGORIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CATEGORIES, $category->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -744,9 +744,9 @@ public function hookActionObjectCustomerAddAfter($parameters) if (isset($customer->id)) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CUSTOMERS => $customer->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -768,9 +768,9 @@ public function hookActionObjectCustomerUpdateAfter($parameters) if (isset($customer->id)) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CUSTOMERS => $customer->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -792,9 +792,9 @@ public function hookActionObjectCustomerDeleteAfter($parameters) if (isset($customer->id)) { $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); - $synchronizationService->insertDeletedObject( - $customer->id, - Config::COLLECTION_CUSTOMERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CUSTOMERS, $customer->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -815,9 +815,9 @@ public function hookActionObjectCurrencyAddAfter($parameters) if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CURRENCIES => $currency->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, true @@ -839,9 +839,9 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $currency->id, - Config::COLLECTION_CURRENCIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CURRENCIES => $currency->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, true @@ -863,9 +863,9 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); - $synchronizationService->insertDeletedObject( - $currency->id, - Config::COLLECTION_CURRENCIES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CURRENCIES, $currency->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -886,9 +886,9 @@ public function hookActionObjectCartAddAfter($parameters) if (isset($cart->id)) { $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARTS => $cart->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -909,9 +909,9 @@ public function hookActionObjectCartUpdateAfter($parameters) if (isset($cart->id)) { $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cart->id, - Config::COLLECTION_CARTS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARTS => $cart->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -932,9 +932,9 @@ public function hookActionObjectCartRuleAddAfter($parameters) if (isset($cartRule->id)) { $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CART_RULES => $cartRule->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -955,9 +955,9 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) if (isset($cartRule->id)) { $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CART_RULES => $cartRule->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -978,9 +978,9 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) if (isset($cartRule->id)) { $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $cartRule->id, - Config::COLLECTION_CART_RULES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CART_RULES => $cartRule->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1001,9 +1001,9 @@ public function hookActionObjectOrderAddAfter($parameters) if (isset($order->id)) { $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_ORDERS => $order->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1024,9 +1024,9 @@ public function hookActionObjectOrderUpdateAfter($parameters) if (isset($order->id)) { $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $order->id, - Config::COLLECTION_ORDERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_ORDERS => $order->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1048,9 +1048,9 @@ public function hookActionObjectCarrierAddAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => $carrier->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1072,9 +1072,9 @@ public function hookActionObjectCarrierUpdateAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => $carrier->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1096,9 +1096,9 @@ public function hookActionObjectCarrierDeleteAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); - $synchronizationService->insertIncrementalSyncObject( - $carrier->id, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => $carrier->id], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1113,9 +1113,9 @@ public function hookActionObjectCountryAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1129,9 +1129,9 @@ public function hookActionObjectCountryUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1145,9 +1145,9 @@ public function hookActionObjectCountryDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1161,9 +1161,9 @@ public function hookActionObjectStateAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1177,9 +1177,9 @@ public function hookActionObjectStateUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1193,9 +1193,9 @@ public function hookActionObjectStateDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1209,9 +1209,9 @@ public function hookActionObjectZoneAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1225,9 +1225,9 @@ public function hookActionObjectZoneUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1241,9 +1241,9 @@ public function hookActionObjectZoneDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1257,9 +1257,9 @@ public function hookActionObjectTaxAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1273,9 +1273,9 @@ public function hookActionObjectTaxUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1289,9 +1289,9 @@ public function hookActionObjectTaxDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1305,9 +1305,9 @@ public function hookActionObjectTaxRulesGroupAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1321,9 +1321,9 @@ public function hookActionObjectTaxRulesGroupUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1337,9 +1337,9 @@ public function hookActionObjectTaxRulesGroupDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1353,9 +1353,9 @@ public function hookActionShippingPreferencesPageSave() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_CARRIERS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_CARRIERS => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1369,9 +1369,9 @@ public function hookActionObjectEmployeeAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_EMPLOYEES => 0], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1384,9 +1384,9 @@ public function hookActionObjectEmployeeDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertDeletedObject( - 0, - Config::COLLECTION_EMPLOYEES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_EMPLOYEES => 0], + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); @@ -1400,9 +1400,9 @@ public function hookActionObjectEmployeeUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_EMPLOYEES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_EMPLOYEES => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1440,9 +1440,9 @@ public function hookActionDispatcherBefore($parameters) // when translation is edited or reset, add to incremental sync if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { - $synchronizationService->insertIncrementalSyncObject( - 0, - Config::COLLECTION_TRANSLATIONS, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_TRANSLATIONS => 0], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1469,9 +1469,9 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) if ($specificPrice instanceof SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], + Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId ); @@ -1495,9 +1495,9 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) if ($specificPrice instanceof SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); - $synchronizationService->insertIncrementalSyncObject( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], + Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); @@ -1521,9 +1521,10 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) if ($specificPrice instanceof SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); - $synchronizationService->insertDeletedObject( + $synchronizationService->insertContentIntoIncremental( $specificPrice->id, Config::COLLECTION_SPECIFIC_PRICES, + Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId ); From 8c837c85fb64a2c7af75f90b67265e770837c9aa Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 29 Jul 2024 18:22:49 +0200 Subject: [PATCH 037/162] fix: common problems --- config/front/services.yml | 7 ++++++- controllers/front/apiFront.php | 6 +++--- src/Interfaces/RepositoryInterface.php | 16 ++++++++++++++++ src/Repository/AbstractRepository.php | 2 +- src/Repository/OrdersRepository.php | 4 ++-- src/Service/FrontApiService.php | 14 +++++++++----- src/Service/ShopContent/OrdersService.php | 4 ++-- src/Service/SynchronizationService.php | 6 +++--- 8 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 src/Interfaces/RepositoryInterface.php diff --git a/config/front/services.yml b/config/front/services.yml index b36538f0..0799a2b1 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -53,7 +53,6 @@ services: class: PrestaShop\Module\PsEventbus\Service\SynchronizationService public: true arguments: - - '@ps_eventbus' - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' @@ -71,3 +70,9 @@ services: PrestaShop\Module\PsEventbus\Service\PresenterService: class: PrestaShop\Module\PsEventbus\Service\PresenterService public: true + + PrestaShop\Module\PsEventbus\Service\FrontApiService: + class: PrestaShop\Module\PsEventbus\Service\FrontApiService + public: true + arguments: + - '@ps_eventbus' diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 02204b09..a29e93b9 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -1,6 +1,6 @@ module->getService('PrestaShop\Module\PsEventbusV4\Services\ApiService'); + $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); } diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php new file mode 100644 index 00000000..833be27a --- /dev/null +++ b/src/Interfaces/RepositoryInterface.php @@ -0,0 +1,16 @@ +module = $module; + $this->errorHandler = $this->module->getService(ErrorHandler::class); try { @@ -55,6 +58,7 @@ public function __construct() $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); $this->synchronizationService = $this->module->getService(SynchronizationService::class); + $this->eventbusSyncRepository = $this->module->getService(EventbusSyncRepository::class); $this->authorize(); } catch (\Exception $exception) { @@ -89,7 +93,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService('\PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index af345685..9bc5b491 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -1,8 +1,8 @@ module->getService($serviceId); /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbusV4\Repository\ConfigurationRepository'); + $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); @@ -167,7 +167,7 @@ public function sendIncrementalSync( $serviceName = str_replace('-', '', ucwords($shopContent, "-")); /** @var ShopContentServiceInterface $shopContentApiService */ - $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Services\\' . $serviceName . 'Service'); + $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Service\\' . $serviceName . 'Service'); $contentIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($shopContent, $langIso, $limit); From 79102f71c4343a9657753eb9ccb1bf00a0fef4f8 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 31 Jul 2024 14:48:04 +0200 Subject: [PATCH 038/162] fix: common problems --- config/common.yml | 25 +++ config/front/provider.yml | 2 +- config/front/repository.yml | 4 +- config/front/services.yml | 44 ++--- ps_eventbus.php | 12 +- src/DependencyInjection/ServiceContainer.php | 12 ++ src/Interfaces/RepositoryInterface.php | 6 +- src/Provider/OrderDataProvider.php | 18 +-- src/Repository/AbstractRepository.php | 6 +- src/Repository/OrdersRepository.php | 7 +- src/Service/DeletedObjectsService.php | 93 ----------- src/Service/ShopContent/OrdersService.php | 161 ++++++++++++++++++- src/Service/SynchronizationService.php | 27 ++-- 13 files changed, 244 insertions(+), 173 deletions(-) delete mode 100644 src/Service/DeletedObjectsService.php diff --git a/config/common.yml b/config/common.yml index bfabce66..0f4f6771 100644 --- a/config/common.yml +++ b/config/common.yml @@ -25,4 +25,29 @@ services: arguments: - '@ps_eventbus.helper.module' + PrestaShop\Module\PsEventbus\Formatter\JsonFormatter: + class: PrestaShop\Module\PsEventbus\Formatter\JsonFormatter + public: true + + PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter: + class: PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter + public: true + + PrestaShop\Module\PsEventbus\Service\CacheService: + class: PrestaShop\Module\PsEventbus\Service\CacheService + public: true + + PrestaShop\Module\PsEventbus\Service\CompressionService: + class: PrestaShop\Module\PsEventbus\Service\CompressionService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' + + PrestaShop\Module\PsEventbus\Service\ProxyService: + class: PrestaShop\Module\PsEventbus\Service\ProxyService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Api\CollectorApiClient' + - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' diff --git a/config/front/provider.yml b/config/front/provider.yml index f531a0eb..bc6d0faf 100644 --- a/config/front/provider.yml +++ b/config/front/provider.yml @@ -48,7 +48,7 @@ services: public: true arguments: - "@ps_eventbus.context" - - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' diff --git a/config/front/repository.yml b/config/front/repository.yml index a26fee3e..04522bb3 100644 --- a/config/front/repository.yml +++ b/config/front/repository.yml @@ -68,8 +68,8 @@ services: arguments: - '@ps_eventbus.context' - PrestaShop\Module\PsEventbus\Repository\OrderRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderRepository + PrestaShop\Module\PsEventbus\Repository\OrdersRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrdersRepository public: true PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository: diff --git a/config/front/services.yml b/config/front/services.yml index 0799a2b1..2b5e2ecc 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -8,32 +8,6 @@ imports: - { resource: context.yml } services: - PrestaShop\Module\PsEventbus\Formatter\JsonFormatter: - class: PrestaShop\Module\PsEventbus\Formatter\JsonFormatter - public: true - - PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter: - class: PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter - public: true - - PrestaShop\Module\PsEventbus\Service\CacheService: - class: PrestaShop\Module\PsEventbus\Service\CacheService - public: true - - PrestaShop\Module\PsEventbus\Service\CompressionService: - class: PrestaShop\Module\PsEventbus\Service\CompressionService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - - PrestaShop\Module\PsEventbus\Service\ProxyService: - class: PrestaShop\Module\PsEventbus\Service\ProxyService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Api\CollectorApiClient' - - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' - PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: class: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService public: true @@ -41,14 +15,6 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Api\SyncApiClient' - PrestaShop\Module\PsEventbus\Service\DeletedObjectsService: - class: PrestaShop\Module\PsEventbus\Service\DeletedObjectsService - public: true - arguments: - - "@ps_eventbus.context" - - '@PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository' - - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - PrestaShop\Module\PsEventbus\Service\SynchronizationService: class: PrestaShop\Module\PsEventbus\Service\SynchronizationService public: true @@ -56,7 +22,6 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - - '@PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - '@PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator' @@ -76,3 +41,12 @@ services: public: true arguments: - '@ps_eventbus' + + # SHOP CONTENT SERVICES + PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' diff --git a/ps_eventbus.php b/ps_eventbus.php index ee053629..76649a56 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -225,10 +225,20 @@ public function getServiceContainer() * @return mixed */ public function getService($serviceName) - { + { return $this->getServiceContainer()->getService($serviceName); } + /** + * @param string $serviceName + * + * @return mixed + */ + public function hasService($serviceName) + { + return $this->getServiceContainer()->hasService($serviceName); + } + /** * Set PHP compatibility to 7.1 * diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php index 231e917d..40fffb94 100644 --- a/src/DependencyInjection/ServiceContainer.php +++ b/src/DependencyInjection/ServiceContainer.php @@ -73,6 +73,18 @@ public function getService($serviceName) return $this->getContainer()->get($serviceName); } + /** + * @param string $serviceName + * + * @return bool + * + * @throws \Exception + */ + public function hasService($serviceName) + { + return $this->getContainer()->has($serviceName); + } + /** * @return ContainerInterface * diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php index 833be27a..7c350f33 100644 --- a/src/Interfaces/RepositoryInterface.php +++ b/src/Interfaces/RepositoryInterface.php @@ -4,11 +4,11 @@ use DbQuery; +/** + * @property DbQuery $query + */ interface RepositoryInterface { - /** @var DbQuery */ - public $query; - public function generateBaseQuery(); public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); diff --git a/src/Provider/OrderDataProvider.php b/src/Provider/OrderDataProvider.php index 1cdef93b..4dc4a478 100644 --- a/src/Provider/OrderDataProvider.php +++ b/src/Provider/OrderDataProvider.php @@ -7,14 +7,14 @@ use PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository; use PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository; use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; -use PrestaShop\Module\PsEventbus\Repository\OrderRepository; +use PrestaShop\Module\PsEventbus\Repository\OrdersRepository; class OrderDataProvider implements PaginatedApiDataProviderInterface { /** - * @var OrderRepository + * @var OrdersRepository */ - private $orderRepository; + private $ordersRepository; /** * @var \Context */ @@ -43,13 +43,13 @@ class OrderDataProvider implements PaginatedApiDataProviderInterface public function __construct( \Context $context, - OrderRepository $orderRepository, + OrdersRepository $ordersRepository, OrderDetailsRepository $orderDetailsRepository, ArrayFormatter $arrayFormatter, OrderHistoryRepository $orderHistoryRepository, OrderCartRuleRepository $orderCartRuleRepository ) { - $this->orderRepository = $orderRepository; + $this->ordersRepository = $ordersRepository; $this->context = $context; $this->arrayFormatter = $arrayFormatter; $this->orderDetailsRepository = $orderDetailsRepository; @@ -74,7 +74,7 @@ public function __construct( */ public function getFormattedData($offset, $limit, $langIso) { - $orders = $this->orderRepository->getOrders($offset, $limit, $this->shopId); + $orders = $this->ordersRepository->getOrders($offset, $limit, $this->shopId); if (empty($orders)) { return []; @@ -106,7 +106,7 @@ public function getFormattedData($offset, $limit, $langIso) */ public function getRemainingObjectsCount($offset, $langIso) { - return (int) $this->orderRepository->getRemainingOrderCount($offset, $this->shopId); + return (int) $this->ordersRepository->getRemainingOrderCount($offset, $this->shopId); } /** @@ -120,7 +120,7 @@ public function getRemainingObjectsCount($offset, $langIso) public function getFormattedDataIncremental($limit, $langIso, $objectIds) { $langId = (int) \Language::getIdByIso($langIso); - $orders = $this->orderRepository->getOrdersIncremental($limit, $this->shopId, $objectIds); + $orders = $this->ordersRepository->getOrdersIncremental($limit, $this->shopId, $objectIds); if (!is_array($orders) || empty($orders)) { return []; @@ -154,7 +154,7 @@ public function getFormattedDataIncremental($limit, $langIso, $objectIds) */ public function getQueryForDebug($offset, $limit, $langIso) { - return $this->orderRepository->getQueryForDebug($offset, $limit, $this->shopId); + return $this->ordersRepository->getQueryForDebug($offset, $limit, $this->shopId); } /** diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index d0cb2c81..124f75e3 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -21,11 +21,11 @@ abstract class AbstractRepository /** * @var DbQuery */ - private $query; + protected $query; - public function __construct(Context $context) + public function __construct() { - $this->context = $context; + $this->context = Context::getContext(); $this->db = Db::getInstance(); } diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index 7af8f689..e4b8509e 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -9,11 +9,6 @@ class OrdersRepository extends AbstractRepository implements RepositoryInterface { public const ORDERS_TABLE = 'orders'; - public function __construct(\Context $context) - { - parent::__construct($context); - } - public function generateBaseQuery() { $this->query = new \DbQuery(); @@ -61,6 +56,8 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa if ($debug) { return $this->debugQuery(); } else { + dump("test"); + die; return $this->executeQuery(); } diff --git a/src/Service/DeletedObjectsService.php b/src/Service/DeletedObjectsService.php deleted file mode 100644 index ad772ed2..00000000 --- a/src/Service/DeletedObjectsService.php +++ /dev/null @@ -1,93 +0,0 @@ -context = $context; - $this->deletedObjectsRepository = $deletedObjectsRepository; - $this->proxyService = $proxyService; - } - - /** - * @param string $jobId - * @param int $scriptStartTime - * - * @return array - * - * @@throws \PrestaShopDatabaseException|EnvVarException - */ - public function handleDeletedObjectsSync($jobId, $scriptStartTime) - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $deletedObjects = $this->deletedObjectsRepository->getDeletedObjectsGrouped($shopId); - - if (empty($deletedObjects)) { - return [ - 'job_id' => $jobId, - 'total_objects' => 0, - 'syncType' => 'full', - ]; - } - - $data = $this->formatData($deletedObjects); - - $response = $this->proxyService->delete($jobId, $data, $scriptStartTime); - - if ($response['httpCode'] == 200) { - foreach ($data as $dataItem) { - $this->deletedObjectsRepository->removeDeletedObjects( - $dataItem['collection'], - $dataItem['deleteIds'], - $shopId - ); - } - } - - return array_merge( - [ - 'job_id' => $jobId, - 'total_objects' => count($data), - 'syncType' => 'full', - ], - $response - ); - } - - /** - * @param array $data - * - * @return array - */ - private function formatData($data) - { - return array_map(function ($dataItem) { - return [ - 'collection' => $dataItem['type'], - 'deleteIds' => explode(';', $dataItem['ids']), - ]; - }, $data); - } -} diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 9bc5b491..13dc7727 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -1,8 +1,11 @@ ordersRepository = $ordersRepository; + $this->orderHistoryRepository = $orderHistoryRepository; + $this->arrayFormatter = $arrayFormatter; } public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { $result = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); - return $result; + if (empty($result)) { + return []; + } + + $this->castOrders($orders, $langIso); + + return array_map(function ($order) { + return [ + 'id' => $order['id_order'], + 'collection' => Config::COLLECTION_ORDERS, + 'properties' => $order, + ]; + }, $orders); } public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { $result = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); - return $result; + if (empty($result)) { + return []; + } + + $this->castOrders($orders, $langIso); + + return array_map(function ($order) { + return [ + 'id' => $order['id_order'], + 'collection' => Config::COLLECTION_ORDERS, + 'properties' => $order, + ]; + }, $orders); } public function countFullSyncContentLeft($offset, $langIso = null) { - $result = $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + } + + public function castOrders(&$orders, $langIso) + { + $langId = (int) \Language::getIdByIso($langIso); + + foreach ($orders as &$order) { + $order['id_order'] = (int) $order['id_order']; + $order['id_customer'] = (int) $order['id_customer']; + $order['current_state'] = (int) $order['current_state']; + $order['conversion_rate'] = (float) $order['conversion_rate']; + $order['total_paid_tax_incl'] = (float) $order['total_paid_tax_incl']; + $order['total_paid_tax_excl'] = (float) $order['total_paid_tax_excl']; + $order['refund'] = (float) $order['refund']; + $order['refund_tax_excl'] = (float) $order['refund_tax_excl']; + $order['new_customer'] = $order['new_customer'] == 1; + $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langId); + $order['shipping_cost'] = (float) $order['shipping_cost']; + $order['total_paid_tax'] = $order['total_paid_tax_incl'] - $order['total_paid_tax_excl']; + $order['id_carrier'] = (int) $order['id_carrier']; + + $order['id_shop_group'] = (int) $order['id_shop_group']; + $order['id_shop'] = (int) $order['id_shop']; + $order['id_lang'] = (int) $order['id_lang']; + $order['id_currency'] = (int) $order['id_currency']; + $order['recyclable'] = (bool) $order['recyclable']; + $order['gift'] = (bool) $order['gift']; + + $order['total_discounts'] = (int) $order['total_discounts']; + $order['total_discounts_tax_incl'] = (int) $order['total_discounts_tax_incl']; + $order['total_discounts_tax_excl'] = (int) $order['total_discounts_tax_excl']; + $order['total_products'] = (int) $order['total_products']; + $order['total_products_wt'] = (int) $order['total_products_wt']; + $order['total_shipping_tax_incl'] = (int) $order['total_shipping_tax_incl']; + $order['total_shipping_tax_excl'] = (int) $order['total_shipping_tax_excl']; + + $order['carrier_tax_rate'] = (int) $order['carrier_tax_rate']; + $order['total_wrapping'] = (int) $order['total_wrapping']; + $order['total_wrapping_tax_incl'] = (int) $order['total_wrapping_tax_incl']; + $order['total_wrapping_tax_excl'] = (int) $order['total_wrapping_tax_excl']; + $order['round_mode'] = (int) $order['round_mode']; + $order['round_type'] = (int) $order['round_type']; + $order['invoice_number'] = (int) $order['invoice_number']; + $order['delivery_number'] = (int) $order['delivery_number']; + $order['valid'] = (bool) $order['valid']; - return $result; + $this->castAddressIsoCodes($order); + unset($order['address_iso']); + } } + + /** + * @param array $orders + * @param array $order + * @param int $langId + * + * @return bool + * + * @@throws \PrestaShopDatabaseException + */ + private function castIsPaidValue($orders, $order, $langId) + { + $isPaid = $dateAdd = 0; + $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); + /** @var array $orderHistoryStatuses */ + $orderHistoryStatuses = $this->orderHistoryRepository->getOrderHistoryStatuses($orderIds, $langId); + + foreach ($orderHistoryStatuses as &$orderHistoryStatus) { + if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { + $isPaid = (bool) $orderHistoryStatus['paid']; + $dateAdd = $orderHistoryStatus['date_add']; + } + } + + return (bool) $isPaid; + } + + /** + * @param array $orderDetail + * + * @return void + */ + private function castAddressIsoCodes(&$orderDetail) + { + if (!$orderDetail['address_iso']) { + $orderDetail['invoice_country_code'] = null; + $orderDetail['delivery_country_code'] = null; + + return; + } + + $addressAndIsoCodes = explode(',', $orderDetail['address_iso']); + if (count($addressAndIsoCodes) === 1) { + $addressAndIsoCode = explode(':', $addressAndIsoCodes[0]); + $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; + $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; + + return; + } + + foreach ($addressAndIsoCodes as $addressAndIsoCodeString) { + $addressAndIsoCode = explode(':', $addressAndIsoCodeString); + if ($addressAndIsoCode[0] === 'delivery') { + $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; + } elseif ($addressAndIsoCode[0] === 'invoice') { + $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; + } + } + } + } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 3bd6de01..a3e6f74a 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -6,7 +6,6 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; -use PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; @@ -34,11 +33,6 @@ class SynchronizationService */ private $liveSyncRepository; - /** - * @var DeletedObjectsRepository - */ - private $deletedObjectsRepository; - /** * @var LanguageRepository */ @@ -59,7 +53,6 @@ public function __construct( EventbusSyncRepository $eventbusSyncRepository, IncrementalSyncRepository $incrementalSyncRepository, LiveSyncRepository $liveSyncRepository, - DeletedObjectsRepository $deletedObjectsRepository, LanguageRepository $languageRepository, ProxyServiceInterface $proxyService, PayloadDecorator $payloadDecorator @@ -67,7 +60,6 @@ public function __construct( $this->eventbusSyncRepository = $eventbusSyncRepository; $this->incrementalSyncRepository = $incrementalSyncRepository; $this->liveSyncRepository = $liveSyncRepository; - $this->deletedObjectsRepository = $deletedObjectsRepository; $this->languageRepository = $languageRepository; $this->proxyService = $proxyService; $this->payloadDecorator = $payloadDecorator; @@ -100,9 +92,9 @@ public function sendFullSync( $response = []; $serviceName = str_replace('-', '', ucwords($shopContent, "-")); - $serviceId = 'PrestaShop\Module\PsEventbus\Service\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent + $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent - /** @var Ps_eventbus */ + /** @var \Ps_eventbus */ $module = \Module::getInstanceByName('ps_eventbus'); if (!$module->hasService($serviceId)) { @@ -110,10 +102,10 @@ public function sendFullSync( } /** @var ShopContentServiceInterface $shopContentApiService */ - $shopContentApiService = $this->module->getService($serviceId); + $shopContentApiService = $module->getService($serviceId); /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); + $configurationRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); @@ -165,9 +157,18 @@ public function sendIncrementalSync( $response = []; $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; + + + /** @var \Ps_eventbus */ + $module = \Module::getInstanceByName('ps_eventbus'); + + if (!$module->hasService($serviceId)) { + throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + } /** @var ShopContentServiceInterface $shopContentApiService */ - $shopContentApiService = $this->module->getService('PrestaShop\\Module\\PsEventbus\\Service\\' . $serviceName . 'Service'); + $shopContentApiService = $module->getService($serviceId); $contentIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($shopContent, $langIso, $limit); From b4d496e84c6dc4d5f594f2f014d83db343fc9f6e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 31 Jul 2024 18:04:12 +0200 Subject: [PATCH 039/162] fix: debug mode --- config/common.yml | 10 -- config/front/services.yml | 1 - controllers/front/apiFront.php | 2 +- .../ProxyServiceInterface.php | 2 +- src/Repository/AbstractRepository.php | 19 ++- src/Repository/OrdersRepository.php | 19 +-- src/Service/CacheService.php | 35 ----- src/Service/CommonService.php | 78 ++++++++++ src/Service/CompressionService.php | 42 ------ src/Service/FrontApiService.php | 133 ++++++------------ src/Service/ProxyService.php | 1 + src/Service/ShopContent/OrdersService.php | 4 +- src/Service/SynchronizationService.php | 6 +- 13 files changed, 146 insertions(+), 206 deletions(-) rename src/{Service => Interfaces}/ProxyServiceInterface.php (90%) delete mode 100644 src/Service/CacheService.php create mode 100644 src/Service/CommonService.php delete mode 100644 src/Service/CompressionService.php diff --git a/config/common.yml b/config/common.yml index 0f4f6771..f81002e9 100644 --- a/config/common.yml +++ b/config/common.yml @@ -33,16 +33,6 @@ services: class: PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter public: true - PrestaShop\Module\PsEventbus\Service\CacheService: - class: PrestaShop\Module\PsEventbus\Service\CacheService - public: true - - PrestaShop\Module\PsEventbus\Service\CompressionService: - class: PrestaShop\Module\PsEventbus\Service\CompressionService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - PrestaShop\Module\PsEventbus\Service\ProxyService: class: PrestaShop\Module\PsEventbus\Service\ProxyService public: true diff --git a/config/front/services.yml b/config/front/services.yml index 2b5e2ecc..e47174b5 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -5,7 +5,6 @@ imports: - { resource: provider.yml } - { resource: repository.yml } - { resource: builder.yml } - - { resource: context.yml } services: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index a29e93b9..2c9e06fe 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -18,7 +18,7 @@ public function postProcess() $jobId = \Tools::getValue('job_id'); /** @var string $langIso */ - $langIso = \Tools::getValue('lang_iso'); + $langIso = \Tools::getValue('lang_iso'); /** @var int $limit */ $limit = \Tools::getValue('limit', 50); diff --git a/src/Service/ProxyServiceInterface.php b/src/Interfaces/ProxyServiceInterface.php similarity index 90% rename from src/Service/ProxyServiceInterface.php rename to src/Interfaces/ProxyServiceInterface.php index 4ea84e07..10c319bc 100644 --- a/src/Service/ProxyServiceInterface.php +++ b/src/Interfaces/ProxyServiceInterface.php @@ -1,6 +1,6 @@ context->shop->id; } - protected function debugQuery() + protected function runQuery($debug) + { + if ($debug) { + $this->debugQuery(); + } + + return $this->db->executeS($this->query); + } + + private function debugQuery() { $queryStringified = preg_replace('/\s+/', ' ', $this->query->build()); - return array_merge( + $response = array_merge( (array) $this->query, ['queryStringified' => $queryStringified] ); - } - protected function executeQuery() - { - return $this->db->executeS($this->query); + CommonService::exitWithResponse($response); } } diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index e4b8509e..76aa1fed 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -53,14 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa $this->query->limit((int) $limit, (int) $offset); - if ($debug) { - return $this->debugQuery(); - } else { - dump("test"); - die; - return $this->executeQuery(); - } - + return $this->runQuery($debug); } public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) @@ -69,17 +62,13 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, $this->query->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - - if ($debug) { - return $this->debugQuery(); - } else { - return $this->executeQuery(); - } + + return $this->runQuery($debug); } public function countFullSyncContentLeft($offset, $langIso = null, $debug = false) { - $orders = $this->getContentsForFull($offset, 1, parent::getShopId()); + $orders = $this->getContentsForFull($offset, 1, parent::getShopId(), $debug); if (!is_array($orders) || empty($orders)) { return 0; diff --git a/src/Service/CacheService.php b/src/Service/CacheService.php deleted file mode 100644 index 858354a3..00000000 --- a/src/Service/CacheService.php +++ /dev/null @@ -1,35 +0,0 @@ -getItem($key); - $cacheItem->set($value); - $cache->save($cacheItem); - } - - /** - * @param string $key - * - * @return mixed - */ - public function getCacheProperty($key) - { - $cache = new FilesystemAdapter(); - $cacheItem = $cache->getItem($key); - - return $cacheItem->get(); - } -} diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php new file mode 100644 index 00000000..9e72ec79 --- /dev/null +++ b/src/Service/CommonService.php @@ -0,0 +1,78 @@ +getCode() == 0 ? 500 : $exception->getCode(); + + if ($exception instanceof \PrestaShopDatabaseException) { + $code = Config::DATABASE_QUERY_ERROR_CODE; + } elseif ($exception instanceof EnvVarException) { + $code = Config::ENV_MISCONFIGURED_ERROR_CODE; + } elseif ($exception instanceof FirebaseException) { + $code = Config::REFRESH_TOKEN_ERROR_CODE; + } elseif ($exception instanceof QueryParamsException) { + $code = Config::INVALID_URL_QUERY; + } + + $response = [ + 'object_type' => \Tools::getValue('shopContent'), + 'status' => false, + 'httpCode' => $code, + 'message' => $exception->getMessage(), + ]; + + self::dieWithResponse($response, (int) $code); + } + + /** + * @param array $response + * @param int $code + * + * @return void + */ + public static function dieWithResponse(array $response, $code) + { + $httpStatusText = "HTTP/1.1 $code"; + + if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { + $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; + } elseif (isset($response['body']['statusText'])) { + $httpStatusText .= ' ' . $response['body']['statusText']; + } + + $response['httpCode'] = (int) $code; + + header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); + header('Content-Type: application/json;charset=utf-8'); + header($httpStatusText); + + echo json_encode($response, JSON_UNESCAPED_SLASHES); + + exit; + } +} diff --git a/src/Service/CompressionService.php b/src/Service/CompressionService.php deleted file mode 100644 index c4763a13..00000000 --- a/src/Service/CompressionService.php +++ /dev/null @@ -1,42 +0,0 @@ -jsonFormatter = $jsonFormatter; - } - - /** - * Compresses data with gzip - * - * @param array $data - * - * @return string - * - * @@throws \Exception - */ - public function gzipCompressData($data) - { - if (!extension_loaded('zlib')) { - throw new \Exception('Zlib extension for PHP is not enabled'); - } - - $dataJson = $this->jsonFormatter->formatNewlineJsonString($data); - - if (!$encodedData = gzencode($dataJson)) { - throw new \Exception('Failed encoding data to GZIP'); - } - - return $encodedData; - } -} diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 02c6817c..b168c391 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -8,6 +8,8 @@ use PrestaShop\Module\PsEventbus\Exception\UnauthorizedException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; +use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; +use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; use PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService; @@ -70,13 +72,13 @@ public function __construct(\Ps_eventbus $module) if ($exception instanceof \PrestaShopDatabaseException) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } elseif ($exception instanceof EnvVarException) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } elseif ($exception instanceof FirebaseException) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } } } @@ -85,27 +87,48 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, { try { if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { - $this->exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); + CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } if ($limit < 0) { - $this->exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); + CommonService::exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); } /** @var ConfigurationRepository $configurationRepository */ $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); + /** @var LanguageRepository $languageRepository */ + $languageRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\LanguageRepository'); + /** @var IncrementalSyncRepository $incrementalSyncRepository */ + $incrementalSyncRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); + $langIso = $langIso ? $langIso : $languageRepository->getDefaultLanguageIsoCode(); + $offset = 0; - $incrementalSync = false; $response = []; $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); - if ($typeSync == false) { + if (is_array($typeSync)) { + if (!$isFull) { + $offset = (int) $typeSync['offset']; + } else { + $this->eventbusSyncRepository->updateTypeSync( + $shopContent, + $offset, + $dateNow, + false, + $langIso + ); + + $incrementalSyncRepository->removeIncrementaSyncObjectByType($shopContent); + } + } else { $this->eventbusSyncRepository->insertTypeSync($shopContent, $offset, $dateNow, $langIso); + + $isFull = true; } if ($isFull) { @@ -129,27 +152,29 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug ); } - - $this->exitWithResponse( - [ - 'job_id' => $jobId, - 'object_type' => $shopContent, - 'syncType' => $incrementalSync ? 'incremental' : 'full', - ], - $response + + CommonService::exitWithResponse( + array_merge( + [ + 'job_id' => $jobId, + 'object_type' => $shopContent, + 'syncType' => $isFull ? 'full' : 'incremental', + ], + $response + ) ); } catch (\PrestaShopDatabaseException $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } catch (EnvVarException $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } catch (FirebaseException $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } catch (\Exception $exception) { $this->errorHandler->handle($exception); - $this->exitWithExceptionMessage($exception); + CommonService::exitWithExceptionMessage($exception); } } @@ -166,7 +191,7 @@ private function authorize() $authorizationResponse = $this->authorizationService->authorizeCall($jobId); if (is_array($authorizationResponse)) { - $this->exitWithResponse($authorizationResponse); + CommonService::exitWithResponse($authorizationResponse); } elseif (!$authorizationResponse) { throw new \PrestaShopDatabaseException('Failed saving job id to database'); } @@ -181,72 +206,4 @@ private function authorize() throw new FirebaseException('Invalid token'); } } - - /** - * @param array $response - * - * @return void - */ - private function exitWithResponse(array $response) - { - $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; - - $this->dieWithResponse($response, $httpCode); - } - - /** - * @param \Exception $exception - * - * @return void - */ - private function exitWithExceptionMessage(\Exception $exception) - { - $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); - - if ($exception instanceof \PrestaShopDatabaseException) { - $code = Config::DATABASE_QUERY_ERROR_CODE; - } elseif ($exception instanceof EnvVarException) { - $code = Config::ENV_MISCONFIGURED_ERROR_CODE; - } elseif ($exception instanceof FirebaseException) { - $code = Config::REFRESH_TOKEN_ERROR_CODE; - } elseif ($exception instanceof QueryParamsException) { - $code = Config::INVALID_URL_QUERY; - } - - $response = [ - 'object_type' => \Tools::getValue('shopContent'), - 'status' => false, - 'httpCode' => $code, - 'message' => $exception->getMessage(), - ]; - - $this->dieWithResponse($response, (int) $code); - } - - /** - * @param array $response - * @param int $code - * - * @return void - */ - private function dieWithResponse(array $response, $code) - { - $httpStatusText = "HTTP/1.1 $code"; - - if (array_key_exists((int) $code, Config::HTTP_STATUS_MESSAGES)) { - $httpStatusText .= ' ' . Config::HTTP_STATUS_MESSAGES[(int) $code]; - } elseif (isset($response['body']['statusText'])) { - $httpStatusText .= ' ' . $response['body']['statusText']; - } - - $response['httpCode'] = (int) $code; - - header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); - header('Content-Type: application/json;charset=utf-8'); - header($httpStatusText); - - echo json_encode($response, JSON_UNESCAPED_SLASHES); - - exit; - } } diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index adf65316..a0905857 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -8,6 +8,7 @@ use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Formatter\JsonFormatter; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +use PrestaShop\Module\PsEventbus\Interfaces\ProxyServiceInterface; class ProxyService implements ProxyServiceInterface { diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 13dc7727..ccdfdbcf 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -30,7 +30,7 @@ public function __construct( } public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { - $result = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $orders = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -48,7 +48,7 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa } public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { - $result = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); + $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); if (empty($result)) { return []; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index a3e6f74a..36185ceb 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -5,6 +5,7 @@ use Behat\Behat\HelperContainer\Exception\ServiceNotFoundException; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; +use PrestaShop\Module\PsEventbus\Interfaces\ProxyServiceInterface; use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; @@ -13,11 +14,6 @@ class SynchronizationService { - /** - * @var \Ps_eventbus - */ - private $module; - /** * @var EventbusSyncRepository */ From 6d1f3c01d2b3681a4d383ae9646810f349be2ba2 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 15:06:33 +0200 Subject: [PATCH 040/162] fix: update services and error handler --- config/admin/services.yml | 6 +-- config/{front => common}/builder.yml | 0 config/{ => common}/common.yml | 18 ++++++++- config/{front => common}/decorator.yml | 4 +- config/common/handler.yml | 11 ------ config/{front => common}/provider.yml | 5 +-- config/{front => common}/repository.yml | 46 +++++++++++------------ config/front/context.yml | 40 -------------------- config/front/services.yml | 10 ++--- ps_eventbus.php | 7 +++- src/Handler/ErrorHandler/ErrorHandler.php | 16 +++++++- src/Service/FrontApiService.php | 5 ++- 12 files changed, 75 insertions(+), 93 deletions(-) rename config/{front => common}/builder.yml (100%) rename config/{ => common}/common.yml (64%) rename config/{front => common}/decorator.yml (95%) delete mode 100644 config/common/handler.yml rename config/{front => common}/provider.yml (98%) rename config/{front => common}/repository.yml (82%) delete mode 100644 config/front/context.yml diff --git a/config/admin/services.yml b/config/admin/services.yml index 64714c35..94c72e8f 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1,7 +1,7 @@ imports: - - { resource: ../common.yml } - - { resource: ../front/repository.yml } - - { resource: ../front/services.yml } + - { resource: ../common/common.yml } + - { resource: ../common/repository.yml } + - { resource: ../common/services.yml } services: ps_eventbus.service.presenter: diff --git a/config/front/builder.yml b/config/common/builder.yml similarity index 100% rename from config/front/builder.yml rename to config/common/builder.yml diff --git a/config/common.yml b/config/common/common.yml similarity index 64% rename from config/common.yml rename to config/common/common.yml index f81002e9..3d024759 100644 --- a/config/common.yml +++ b/config/common/common.yml @@ -1,6 +1,5 @@ imports: - - { resource: parameters.yml } - - { resource: common/handler.yml } + - { resource: ../parameters.yml } services: ps_eventbus.db: @@ -15,6 +14,11 @@ services: arguments: - 'ps_eventbus' + ps_eventbus.context: + class: 'Context' + public: true + factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getContext'] + ps_eventbus.helper.module: class: 'PrestaShop\Module\PsEventbus\Helper\ModuleHelper' public: true @@ -41,3 +45,13 @@ services: - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' + PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface: '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' + + PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler: + class: PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler + public: true + arguments: + - '@ps_eventbus' + - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' + - '%ps_eventbus.sentry_dsn%' + - '%ps_eventbus.sentry_env%' diff --git a/config/front/decorator.yml b/config/common/decorator.yml similarity index 95% rename from config/front/decorator.yml rename to config/common/decorator.yml index 24bde51d..690012ea 100644 --- a/config/front/decorator.yml +++ b/config/common/decorator.yml @@ -3,7 +3,7 @@ services: class: PrestaShop\Module\PsEventbus\Decorator\ProductDecorator public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' @@ -32,7 +32,7 @@ services: class: PrestaShop\Module\PsEventbus\Decorator\CustomPriceDecorator public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Service\SpecificPriceService' PrestaShop\Module\PsEventbus\Decorator\WishlistDecorator: diff --git a/config/common/handler.yml b/config/common/handler.yml deleted file mode 100644 index 7dd3eea9..00000000 --- a/config/common/handler.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface: '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - - PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler: - class: PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler - public: true - arguments: - - '@ps_eventbus' - - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - - '%ps_eventbus.sentry_dsn%' - - '%ps_eventbus.sentry_env%' diff --git a/config/front/provider.yml b/config/common/provider.yml similarity index 98% rename from config/front/provider.yml rename to config/common/provider.yml index bc6d0faf..1e1a6628 100644 --- a/config/front/provider.yml +++ b/config/common/provider.yml @@ -47,7 +47,7 @@ services: class: PrestaShop\Module\PsEventbus\Provider\OrderDataProvider public: true arguments: - - "@ps_eventbus.context" + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' @@ -72,7 +72,7 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository' - - "@ps_eventbus.context" + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Provider\CarrierDataProvider: class: PrestaShop\Module\PsEventbus\Provider\CarrierDataProvider @@ -149,7 +149,6 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Decorator\LanguageDecorator' - PrestaShop\Module\PsEventbus\Provider\ImageDataProvider: class: PrestaShop\Module\PsEventbus\Provider\ImageDataProvider public: true diff --git a/config/front/repository.yml b/config/common/repository.yml similarity index 82% rename from config/front/repository.yml rename to config/common/repository.yml index 04522bb3..29b84a81 100644 --- a/config/front/repository.yml +++ b/config/common/repository.yml @@ -3,7 +3,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\LanguageRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository: class: PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository @@ -13,19 +13,19 @@ services: class: PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CategoryRepository: class: PrestaShop\Module\PsEventbus\Repository\CategoryRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CustomerRepository: class: PrestaShop\Module\PsEventbus\Repository\CustomerRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CurrencyRepository: class: PrestaShop\Module\PsEventbus\Repository\CurrencyRepository @@ -39,19 +39,19 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ProductRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository: class: PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - '@PrestaShop\Module\PsEventbus\Repository\CurrencyRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' @@ -66,7 +66,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ThemeRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\OrdersRepository: class: PrestaShop\Module\PsEventbus\Repository\OrdersRepository @@ -76,7 +76,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository: class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository @@ -90,13 +90,13 @@ services: class: PrestaShop\Module\PsEventbus\Repository\CartRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CartProductRepository: class: PrestaShop\Module\PsEventbus\Repository\CartProductRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CartRuleRepository: class: PrestaShop\Module\PsEventbus\Repository\CartRuleRepository @@ -116,7 +116,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' PrestaShop\Module\PsEventbus\Repository\ShopRepository: @@ -127,7 +127,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\CountryRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\StateRepository: class: PrestaShop\Module\PsEventbus\Repository\StateRepository @@ -137,19 +137,19 @@ services: class: PrestaShop\Module\PsEventbus\Repository\TaxRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\CarrierRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository: class: PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\BundleRepository: class: PrestaShop\Module\PsEventbus\Repository\BundleRepository @@ -159,7 +159,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\WishlistRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository: class: PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository @@ -173,13 +173,13 @@ services: class: PrestaShop\Module\PsEventbus\Repository\StoreRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\StockRepository: class: PrestaShop\Module\PsEventbus\Repository\StockRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\StockMvtRepository: class: PrestaShop\Module\PsEventbus\Repository\StockMvtRepository @@ -189,13 +189,13 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\SupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\SupplierRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository @@ -205,7 +205,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\EmployeeRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ImageRepository: class: PrestaShop\Module\PsEventbus\Repository\ImageRepository @@ -219,7 +219,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\TranslationRepository public: true arguments: - - '@ps_eventbus.context' + - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository diff --git a/config/front/context.yml b/config/front/context.yml deleted file mode 100644 index 85b9c6ea..00000000 --- a/config/front/context.yml +++ /dev/null @@ -1,40 +0,0 @@ -services: - ps_eventbus.context: - class: 'Context' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getContext'] - - ps_eventbus.controller: - class: 'Controller' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getController'] - - ps_eventbus.cookie: - class: 'Cookie' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getCookie'] - - ps_eventbus.language: - class: 'Language' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getLanguage'] - - ps_eventbus.currency: - class: 'Currency' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getCurrency'] - - ps_eventbus.smarty: - class: 'Smarty' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getSmarty'] - - ps_eventbus.shop: - class: 'Shop' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getShop'] - - ps_eventbus.link: - class: 'Link' - public: true - factory: ['PrestaShop\Module\PsEventbus\Factory\ContextFactory', 'getLink'] diff --git a/config/front/services.yml b/config/front/services.yml index e47174b5..c4482c20 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -1,10 +1,10 @@ imports: - - { resource: ../common.yml } - { resource: api.yml } - - { resource: decorator.yml } - - { resource: provider.yml } - - { resource: repository.yml } - - { resource: builder.yml } + - { resource: ../common/common.yml } + - { resource: ../common/decorator.yml } + - { resource: ../common/provider.yml } + - { resource: ../common/repository.yml } + - { resource: ../common/builder.yml } services: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: diff --git a/ps_eventbus.php b/ps_eventbus.php index 76649a56..56299e17 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -27,6 +27,7 @@ use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; if (!defined('_PS_VERSION_')) { exit; @@ -226,7 +227,11 @@ public function getServiceContainer() */ public function getService($serviceName) { - return $this->getServiceContainer()->getService($serviceName); + try { + return $this->getServiceContainer()->getService($serviceName); + } catch (ServiceNotFoundException $exception) { + return $this->get($serviceName); + } } /** diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 506af5a6..c4a1ebae 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -21,7 +21,10 @@ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; +use Exception; +use Module; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; +use PrestaShopLogger; /** * Handle Error. @@ -68,7 +71,7 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc } /** - * @param \Exception $error + * @param Exception $error * @param mixed $code * @param bool|null $throw * @param array|null $data @@ -86,7 +89,18 @@ public function handle($error, $code = null, $throw = null, $data = null) if (!$this->client) { return; } + $this->client->captureException($error, $data); + + PrestaShopLogger::addLog( + $error->getMessage() . ' : ' . $error->getFile() . ':' . $error->getLine() . ' | ' . $error->getTraceAsString(), + 3, + $error->getCode(), + 'Module', + Module::getModuleIdByName('ps_eventbus'), + true + ); + if (is_int($code) && true === $throw) { http_response_code($code); throw $error; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index b168c391..3a0b1c6f 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -152,7 +152,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug ); } - + CommonService::exitWithResponse( array_merge( [ @@ -174,7 +174,8 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, CommonService::exitWithExceptionMessage($exception); } catch (\Exception $exception) { $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + + CommonService::dieWithResponse(["message" => "An error occured. Please check logs for more information"], 500); } } From ca572c8b48a21f4f670d10a48b8dbb2acb9c6742 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 15:06:57 +0200 Subject: [PATCH 041/162] fix: service --- config/admin/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/admin/services.yml b/config/admin/services.yml index 94c72e8f..521fb78a 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1,7 +1,7 @@ imports: - { resource: ../common/common.yml } - { resource: ../common/repository.yml } - - { resource: ../common/services.yml } + - { resource: ../front/services.yml } services: ps_eventbus.service.presenter: From 2bbdc94b4fa2cb563716d624d13a79a8ddd3fe60 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 16:16:01 +0200 Subject: [PATCH 042/162] feat: add healthcheck mecanic --- config/front/services.yml | 11 +++ controllers/front/apiFront.php | 12 +-- src/Service/FrontApiService.php | 114 ++++++++++++++++------------- src/Service/HealthCheckService.php | 38 ++++++++++ 4 files changed, 118 insertions(+), 57 deletions(-) create mode 100644 src/Service/HealthCheckService.php diff --git a/config/front/services.yml b/config/front/services.yml index c4482c20..fdc84893 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -40,6 +40,17 @@ services: public: true arguments: - '@ps_eventbus' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' + - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' + - '@PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService' + - '@PrestaShop\Module\PsEventbus\Service\SynchronizationService' + - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' + + PrestaShop\Module\PsEventbus\Service\HealthCheckService: + class: PrestaShop\Module\PsEventbus\Service\HealthCheckService + public: true + arguments: + - '@ps_eventbus' # SHOP CONTENT SERVICES PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 2c9e06fe..fd6ade0f 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -12,22 +12,22 @@ class ps_EventbusApiFrontModuleFrontController extends ModuleFrontController public function postProcess() { /** @var string $shopContent */ - $shopContent = \Tools::getValue('shop_content'); + $shopContent = Tools::getValue('shop_content'); /** @var string $jobId */ - $jobId = \Tools::getValue('job_id'); + $jobId = Tools::getValue('job_id'); /** @var string $langIso */ - $langIso = \Tools::getValue('lang_iso'); + $langIso = Tools::getValue('lang_iso'); /** @var int $limit */ - $limit = \Tools::getValue('limit', 50); + $limit = Tools::getValue('limit', 50); /** @var bool $initFullSync */ - $isFull = \Tools::getValue('full', 0) == 1; + $isFull = Tools::getValue('full', 0) == 1; /** @var bool $debug */ - $debug = \Tools::getValue('debug') == 1; + $debug = Tools::getValue('debug') == 1; /** @var FrontApiService $frontApiService */ $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 3a0b1c6f..55e7ba47 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -1,6 +1,7 @@ module = $module; - - $this->errorHandler = $this->module->getService(ErrorHandler::class); - - try { - $this->startTime = time(); - - $this->psAccountsAdapterService = $this->module->getService(PsAccountsAdapterService::class); - $this->authorizationService = $this->module->getService(ApiAuthorizationService::class); - $this->synchronizationService = $this->module->getService(SynchronizationService::class); - $this->eventbusSyncRepository = $this->module->getService(EventbusSyncRepository::class); + public function __construct( + Ps_eventbus $module, + ErrorHandler $errorHandler, + PsAccountsAdapterService $psAccountsAdapterService, + ApiAuthorizationService $apiAuthorizationService, + SynchronizationService $synchronizationService, + EventbusSyncRepository $eventbusSyncRepository + ) { + $this->startTime = time(); - $this->authorize(); - } catch (\Exception $exception) { - // For ApiHealthCheck, handle the error, and throw UnauthorizedException directly, to catch-up at top level. - if (strpos(get_class($this), 'apiHealthCheckController') !== false) { - $this->errorHandler->handle($exception); - throw new UnauthorizedException('You are not allowed to access to this resource'); - } - - if ($exception instanceof \PrestaShopDatabaseException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); - } elseif ($exception instanceof EnvVarException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); - } elseif ($exception instanceof FirebaseException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); - } - } + $this->module = $module; + $this->errorHandler = $errorHandler; + $this->psAccountsAdapterService = $psAccountsAdapterService; + $this->apiAuthorizationService = $apiAuthorizationService; + $this->synchronizationService = $synchronizationService; + $this->eventbusSyncRepository = $eventbusSyncRepository; } public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) - { + { + $isAuthentified = $this->authorize($jobId, $shopContent == 'HealthCheck'); + + if ($shopContent == 'HealthCheck') { + /** @var HealthCheckService $healthCheckService */ + $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); + return $healthCheckService->getHealthCheck($isAuthentified); + } + try { if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); @@ -163,7 +158,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $response ) ); - } catch (\PrestaShopDatabaseException $exception) { + } catch (PrestaShopDatabaseException $exception) { $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } catch (EnvVarException $exception) { @@ -180,31 +175,48 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } /** - * @return void + * @return bool|void * * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException */ - private function authorize() + private function authorize($jobId, $isHealthCheck = null) { - /** @var string $jobId */ - $jobId = \Tools::getValue('job_id', 'empty_job_id'); + try { + $authorizationResponse = $this->apiAuthorizationService->authorizeCall($jobId); - $authorizationResponse = $this->authorizationService->authorizeCall($jobId); + if (is_array($authorizationResponse)) { + CommonService::exitWithResponse($authorizationResponse); + } elseif (!$authorizationResponse) { + throw new PrestaShopDatabaseException('Failed saving job id to database'); + } - if (is_array($authorizationResponse)) { - CommonService::exitWithResponse($authorizationResponse); - } elseif (!$authorizationResponse) { - throw new \PrestaShopDatabaseException('Failed saving job id to database'); - } + try { + $token = $this->psAccountsAdapterService->getOrRefreshToken(); + } catch (Exception $exception) { + throw new FirebaseException($exception->getMessage()); + } - try { - $token = $this->psAccountsAdapterService->getOrRefreshToken(); + if (!$token) { + throw new FirebaseException('Invalid token'); + } + + return true; } catch (\Exception $exception) { - throw new FirebaseException($exception->getMessage()); - } + // For ApiHealthCheck, handle the error, and return false + if ($isHealthCheck) { + return false; + } - if (!$token) { - throw new FirebaseException('Invalid token'); + if ($exception instanceof PrestaShopDatabaseException) { + $this->errorHandler->handle($exception); + CommonService::exitWithExceptionMessage($exception); + } elseif ($exception instanceof EnvVarException) { + $this->errorHandler->handle($exception); + CommonService::exitWithExceptionMessage($exception); + } elseif ($exception instanceof FirebaseException) { + $this->errorHandler->handle($exception); + CommonService::exitWithExceptionMessage($exception); + } } } } diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php new file mode 100644 index 00000000..595a58b6 --- /dev/null +++ b/src/Service/HealthCheckService.php @@ -0,0 +1,38 @@ +module = $module; + } + + /** + * @return void + * + * @throws PrestaShopException + */ + public function getHealthCheck($isAuthentified = null) + { + if ($isAuthentified == null) { + $isAuthentified = false; + } + + /** @var ServerInformationRepository $serverInformationRepository */ + $serverInformationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository'); + + $status = $serverInformationRepository->getHealthCheckData($isAuthentified); + + CommonService::exitWithResponse($status); + } + +} From 511c54fb43a1f1d410fc548e1acdf72c0f71474c Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 16:20:08 +0200 Subject: [PATCH 043/162] chore: set healhcheck to shopcontent --- src/Config/Config.php | 2 ++ src/Service/FrontApiService.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index b68438e7..8c60a6cd 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -43,6 +43,7 @@ class Config const COLLECTION_CUSTOMERS = 'customers'; const COLLECTION_DELETED = 'deleted'; const COLLECTION_EMPLOYEES = 'employees'; + const COLLECTION_HEALTHCHECK = 'healthcheck'; const COLLECTION_IMAGES = 'images'; const COLLECTION_IMAGE_TYPES = 'image_types'; const COLLECTION_LANGUAGES = 'languages'; @@ -81,6 +82,7 @@ class Config self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, + self::COLLECTION_HEALTHCHECK, self::COLLECTION_LANGUAGES, self::COLLECTION_MANUFACTURERS, self::COLLECTION_MODULES, diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 55e7ba47..a071b545 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -72,19 +72,21 @@ public function __construct( public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) { - $isAuthentified = $this->authorize($jobId, $shopContent == 'HealthCheck'); - - if ($shopContent == 'HealthCheck') { - /** @var HealthCheckService $healthCheckService */ - $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); - return $healthCheckService->getHealthCheck($isAuthentified); - } - try { if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } + $isHealthCheck = $shopContent == Config::COLLECTION_HEALTHCHECK; + + $isAuthentified = $this->authorize($jobId, $isHealthCheck); + + if ($isHealthCheck) { + /** @var HealthCheckService $healthCheckService */ + $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); + return $healthCheckService->getHealthCheck($isAuthentified); + } + if ($limit < 0) { CommonService::exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); } From 25c1e5f80e1563aba8980f4972d4a387f4fa0041 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 1 Aug 2024 16:29:49 +0200 Subject: [PATCH 044/162] fix: problem with service declaration --- src/Service/FrontApiService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index a071b545..bf326437 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -14,7 +14,7 @@ use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; use PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService; -use PrestaShop\Module\PsEventbus\Service\ShopContent\HealthCheckService; +use PrestaShop\Module\PsEventbus\Service\HealthCheckService; use PrestaShopDatabaseException; use Ps_eventbus; From a5addbdbfd58a0d2bd240854cea5e41a42a315a0 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 2 Aug 2024 15:52:52 +0200 Subject: [PATCH 045/162] fix: config --- src/Config/Config.php | 1 - src/Service/FrontApiService.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 8c60a6cd..d5bd74af 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -82,7 +82,6 @@ class Config self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, - self::COLLECTION_HEALTHCHECK, self::COLLECTION_LANGUAGES, self::COLLECTION_MANUFACTURERS, self::COLLECTION_MODULES, diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index bf326437..748bdd61 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -6,7 +6,6 @@ use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; -use PrestaShop\Module\PsEventbus\Exception\UnauthorizedException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; @@ -73,7 +72,7 @@ public function __construct( public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) { try { - if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { + if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [CONFIG::COLLECTION_HEALTHCHECK]), true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } From 3a77e4096f0c6b877c9f460a2cf64f199b89cf36 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 2 Aug 2024 16:49:17 +0200 Subject: [PATCH 046/162] e2e: change all endpoint and rename controller into shoContent --- e2e/README.md | 10 ++--- e2e/src/full-sync.spec.ts | 60 +++++++++++++-------------- e2e/src/helpers/controllers.ts | 47 --------------------- e2e/src/helpers/data-helper.ts | 16 +++---- e2e/src/helpers/log-helper.ts | 1 + e2e/src/helpers/mock-probe.ts | 6 +-- e2e/src/helpers/shop-contents.ts | 47 +++++++++++++++++++++ e2e/src/reject-invalid-job-id.spec.ts | 8 ++-- 8 files changed, 98 insertions(+), 97 deletions(-) delete mode 100644 e2e/src/helpers/controllers.ts create mode 100644 e2e/src/helpers/shop-contents.ts diff --git a/e2e/README.md b/e2e/README.md index 7d90455f..1ae8fee1 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -17,13 +17,13 @@ import { MockProbe } from './helpers/mock-probe'; import testConfig from './helpers/test.config'; import request from 'supertest'; -const controller = 'apiCategories'; -const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5`; +const controller = 'categories'; +const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5`; -describe('CategoriesController', () => { - it(`${controller} should upload to collector`, async () => { +describe('CategoriesShopContent', () => { + it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; // jobId starting with "valid-job-" will be considered valid by the mock sync-api and will always return 201; // other values will be rejected by the mock const jobId = 'valid-job-1' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index de6db3d0..77faa06e 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -10,19 +10,19 @@ import { omitProperties, sortUploadData, } from "./helpers/data-helper"; -import { Controller, controllerList } from "./helpers/controllers"; +import { ShopContent, shopContentList } from "./helpers/shop-contents"; expect.extend(matchers); -// these controllers will be excluded from the following test suite -const EXCLUDED_API: Controller[] = ["apiGoogleTaxonomies"]; +// these ShopContent will be excluded from the following test suite +const EXCLUDED_API: ShopContent[] = ["google-taxonomies"]; // FIXME : these api can't send anything to the mock api because the database is empty from the factory -const MISSING_TEST_DATA: Controller[] = [ - "apiCartRules", - "apiCustomProductCarriers", - "apiTranslations", - "apiWishlists", +const MISSING_TEST_DATA: ShopContent[] = [ + "cart-rules", + "custom-product-carriers", + "translations", + "wishlists", ]; // these fields change from test run to test run, so we replace them with a matcher to only ensure the type and format are correct @@ -53,7 +53,7 @@ describe('Full Sync', () => { let testIndex = 0; // gérer les cas ou un shopContent n'existe pas (pas de fixture du coup) - const controllers: Controller[] = controllerList.filter( + const shopContents: ShopContent[] = shopContentList.filter( (it) => !EXCLUDED_API.includes(it) ); @@ -64,17 +64,17 @@ describe('Full Sync', () => { }); // TODO : some versions of prestashop include ps_facebook out of the box, this test can't reliably be run for all versions - describe.skip("apiGoogleTaxonomies", () => { - const controller = "apiGoogleTaxonomies"; + describe.skip("google-taxonomies", () => { + const shoContent = "google-taxonomies"; // TODO : apiGoogleTaxonomies requires an additional module to be present : devise a specific test setup for this endpoint - it.skip(`${controller} should accept full sync`, async () => {}); + it.skip(`${shoContent} should accept full sync`, async () => {}); - it.skip(`${controller} should upload to collector`, async () => {}); + it.skip(`${shoContent} should upload to collector`, async () => {}); - it(`${controller} should reject full sync when ps_facebook is not installed`, async () => { + it(`${shoContent} should reject full sync when ps_facebook is not installed`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -98,10 +98,10 @@ describe('Full Sync', () => { }); }); - describe.each(controllers)("%s", (controller) => { - it(`${controller} should accept full sync`, async () => { + describe.each(shopContents)("%s", (shopContent) => { + it(`${shopContent} should accept full sync`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -128,12 +128,12 @@ describe('Full Sync', () => { }); }); - if (MISSING_TEST_DATA.includes(controller)) { - it.skip(`${controller} should upload to collector`, () => {}); + if (MISSING_TEST_DATA.includes(shopContent)) { + it.skip(`${shopContent} should upload to collector`, () => {}); } else { - it(`${controller} should upload to collector`, async () => { + it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const message$ = probe({ url: `/upload/${jobId}` }); const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -168,13 +168,13 @@ describe('Full Sync', () => { } - if (MISSING_TEST_DATA.includes(controller)) { - it.skip(`${controller} should upload complete dataset to collector`, () => {}); + if (MISSING_TEST_DATA.includes(shopContent)) { + it.skip(`${shopContent} should upload complete dataset to collector`, () => {}); } else { - it(`${controller} should upload complete dataset collector`, async () => { + it(`${shopContent} should upload complete dataset collector`, async () => { // arrange - const fullSync$ = doFullSync(jobId, controller, { timeout: 4000 }); + const fullSync$ = doFullSync(jobId, shopContent, { timeout: 4000 }); const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); // act @@ -187,18 +187,18 @@ describe('Full Sync', () => { toArray() ) ); - + console.log('test', testConfig.dumpFullSyncData); // dump data for easier debugging or updating fixtures if (testConfig.dumpFullSyncData) { - await dumpUploadData(syncedData, controller); + await dumpUploadData(syncedData, shopContent); } - const fixture = await loadFixture(controller); + const fixture = await loadFixture(shopContent); // we need to process fixtures and data returned from ps_eventbus to make them easier to compare let processedData = syncedData; let processedFixture = fixture; - if (controller === "apiModules") { + if (shopContent === "modules") { processedData = generatePredictableModuleId(processedData); processedFixture = generatePredictableModuleId(processedFixture); } diff --git a/e2e/src/helpers/controllers.ts b/e2e/src/helpers/controllers.ts deleted file mode 100644 index 73103286..00000000 --- a/e2e/src/helpers/controllers.ts +++ /dev/null @@ -1,47 +0,0 @@ -import R from "ramda"; - -export const contentControllerMapping = { - 'carriers': 'apiCarriers', - 'carrier_details': 'apiCarriers', - 'carts' : 'apiCarts', - 'cart_products': 'apiCarts', - 'cart_rules' : 'apiCartRules', - 'categories' : 'apiCategories', - 'currencies' : 'apiCurrencies', - 'specific_prices': 'apiSpecificPrices', - 'custom_product_carriers' : 'apiCustomProductCarriers', - 'customers': 'apiCustomers', - 'taxonomies': 'apiGoogleTaxonomies', - 'modules': 'apiModules', - 'orders': 'apiOrders', - 'order_details': 'apiOrders', - 'order_status_history': 'apiOrders', - 'order_cart_rules': 'apiOrders', - 'products': 'apiProducts', - 'shops': 'apiInfo', - 'stores': 'apiStores', - 'themes': 'apiThemes', - 'bundles': 'apiProducts', - 'wishlists': 'apiWishlists', - 'wishlist_products': 'apiWishlists', - 'stocks': 'apiStocks', - 'stock_movements': 'apiStocks', - 'manufacturers': 'apiManufacturers', - 'suppliers': 'apiSuppliers', - 'product_suppliers': 'apiProducts', - 'languages': 'apiLanguages', - 'employees': 'apiEmployees', - 'translations': 'apiTranslations', - 'images': 'apiImages', - 'image_types': 'apiImageTypes' -} as const; - -type ContentControllerMapping = typeof contentControllerMapping; - -export type Content = keyof ContentControllerMapping; -export const contentList = Object.keys(contentControllerMapping) as Content[]; - -export type Controller = ContentControllerMapping[Content]; -export const controllerList = R.uniq(Object.values(contentControllerMapping)) as Controller[]; - - diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 3e08261c..94fa82ff 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -1,7 +1,7 @@ import R from "ramda"; import { PsEventbusSyncUpload } from "./mock-probe"; import fs from "fs"; -import { Content, contentControllerMapping, Controller } from "./controllers"; +import { Content, shopContentMapping, ShopContent } from "./shop-contents"; import axios from "axios"; import testConfig from "./test.config"; import { HealthCheck } from "../type/health-check"; @@ -39,9 +39,9 @@ export function omitProperties( })); } -export function getControllerContent(controller: Controller): Content[] { - return Object.entries(contentControllerMapping) - .filter((it) => it[1] === controller) +export function getControllerContent(shopContent: ShopContent): Content[] { + return Object.entries(shopContentMapping) + .filter((it) => it[1] === shopContent) .map((it) => it[0]) as Content[]; } @@ -56,7 +56,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-healthcheck` + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=helathcheck&job_id=valid-job-healthcheck` ); healthCheck = res.data; cachedHealthCheck = healthCheck; @@ -67,9 +67,9 @@ export async function getShopHealthCheck(options?: { const FIXTURE_DIR = "./src/fixtures"; export async function loadFixture( - controller: Controller + shopContent: ShopContent ): Promise { - const contents = getControllerContent(controller); + const contents = getControllerContent(shopContent); const shopVersion = (await getShopHealthCheck()).prestashop_version; const shopSemver = semver.coerce(shopVersion); const fixture = []; @@ -95,7 +95,7 @@ export async function loadFixture( const files = contents.map((content) => fs.promises.readFile( - `${FIXTURE_DIR}/${useFixture}/${controller}/${content}.json`, + `${FIXTURE_DIR}/${useFixture}/${shopContent}/${content}.json`, "utf-8" ) ); diff --git a/e2e/src/helpers/log-helper.ts b/e2e/src/helpers/log-helper.ts index f359289a..917216db 100644 --- a/e2e/src/helpers/log-helper.ts +++ b/e2e/src/helpers/log-helper.ts @@ -14,6 +14,7 @@ export function logAxiosError(err: Error) { export async function dumpUploadData(data: PsEventbusSyncUpload[], filename: string) { const shopVersion = (await getShopHealthCheck()).prestashop_version; const dir = `./dumps/${testConfig.testRunTime}/${shopVersion}/${filename}`; + await fs.promises.mkdir(dir, {recursive: true}); const groupedData = R.groupBy( el => el.collection, data ) const files = Object.keys(groupedData).map(collection => { diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index eb9d66c4..cae8710a 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -13,7 +13,7 @@ import { import R from 'ramda'; import testConfig from "./test.config"; import axios from "axios"; -import {Controller} from "./controllers"; +import {ShopContent} from "./shop-contents"; import {anyBoolean} from "jest-mock-extended"; const DEFAULT_OPTIONS = { @@ -77,13 +77,13 @@ export type PsEventbusSyncUpload = { collection: Collection, id: string, properties: any } -export function doFullSync(jobId: string, controller: Controller, options?: MockClientOptions): Observable { +export function doFullSync(jobId: string, shopContent: ShopContent, options?: MockClientOptions): Observable { options = R.mergeLeft(options, DEFAULT_OPTIONS); const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; const requestNext = (full: number) => axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&full=${full}&job_id=${jobId}`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, callId, { headers: { diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts new file mode 100644 index 00000000..37bbbd9b --- /dev/null +++ b/e2e/src/helpers/shop-contents.ts @@ -0,0 +1,47 @@ +import R from "ramda"; + +export const shopContentMapping = { + 'carriers': 'carriers', + 'carrier_details': 'carriers-details', + 'carts' : 'carts', + 'cart_products': 'carts', + 'cart_rules' : 'cart-rules', + 'categories' : 'categories', + 'currencies' : 'currencies', + 'specific_prices': 'specific-prices', + 'custom_product_carriers' : 'custom-product-carriers', + 'customers': 'customers', + 'taxonomies': 'google-taxonomies', + 'modules': 'modules', + 'orders': 'orders', + 'order_details': 'order-details', + 'order_status_histories': 'order-status-histories', + 'order_cart_rules': 'order-cart-rules', + 'products': 'products', + 'shops': 'info', + 'stores': 'stores', + 'themes': 'themes', + 'product_bundles': 'product-bundles', + 'wishlists': 'wishlists', + 'wishlist_products': 'wishlist-products', + 'stocks': 'stocks', + 'stock_movements': 'stock_movements', + 'manufacturers': 'manufacturers', + 'suppliers': 'suppliers', + 'product_suppliers': 'product_suppliers', + 'languages': 'languages', + 'employees': 'employees', + 'translations': 'translations', + 'images': 'images', + 'image_types': 'image-types' +} as const; + +type ShopContentMapping = typeof shopContentMapping; + +export type Content = keyof ShopContentMapping; +export const contentList = Object.keys(shopContentMapping) as Content[]; + +export type ShopContent = ShopContentMapping[Content]; +export const shopContentList = R.uniq(Object.values(shopContentMapping)) as ShopContent[]; + + diff --git a/e2e/src/reject-invalid-job-id.spec.ts b/e2e/src/reject-invalid-job-id.spec.ts index 9a15dc99..ecd7472e 100644 --- a/e2e/src/reject-invalid-job-id.spec.ts +++ b/e2e/src/reject-invalid-job-id.spec.ts @@ -3,12 +3,12 @@ import {beforeEach, describe, expect} from "@jest/globals"; import axios from "axios"; import {from, lastValueFrom, map, toArray, zip} from "rxjs"; import {probe} from "./helpers/mock-probe"; -import {Controller, controllerList} from "./helpers/controllers"; +import { ShopContent, shopContentList } from "./helpers/shop-contents"; describe('Reject invalid job-id', () => { let testIndex = 0; - const controllers: Controller[] = controllerList + const shopContents: ShopContent[] = shopContentList let jobId: string; @@ -16,10 +16,10 @@ describe('Reject invalid job-id', () => { jobId = `invalid-job-id-${testIndex++}` }); - it.each(controllers)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (controller) => { + it.each(shopContents)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=${controller}&limit=5&job_id=${jobId}` + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&job_id=${jobId}` const message$ = probe({params: {id: jobId}}); //act From d96a90e68dbf2ec3d4fee4538d657466f51bd2c3 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 6 Aug 2024 16:23:33 +0200 Subject: [PATCH 047/162] fix: healtcheck --- e2e/src/helpers/data-helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 94fa82ff..75cc60f8 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -56,7 +56,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=helathcheck&job_id=valid-job-healthcheck` + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-healthcheck` ); healthCheck = res.data; cachedHealthCheck = healthCheck; From 51177f1c5a0927c5b6e94f7a5d8f9c1727b36d1c Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 6 Aug 2024 16:29:27 +0200 Subject: [PATCH 048/162] fix: phpcs-fixer --- controllers/front/apiFront.php | 3 +- ps_eventbus.php | 8 +-- src/Handler/ErrorHandler/ErrorHandler.php | 8 +-- src/Interfaces/RepositoryInterface.php | 7 +- .../ShopContentServiceInterface.php | 2 + src/Repository/AbstractRepository.php | 13 ++-- src/Repository/OrdersRepository.php | 3 +- src/Service/CommonService.php | 1 + src/Service/FrontApiService.php | 29 ++++---- src/Service/HealthCheckService.php | 7 +- src/Service/ShopContent/OrdersService.php | 14 ++-- src/Service/SynchronizationService.php | 17 ++--- src/Traits/UseHooks.php | 70 +++++++++---------- upgrade/Upgrade-4.0.0.php | 6 +- 14 files changed, 87 insertions(+), 101 deletions(-) diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index fd6ade0f..2ea96b0c 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -30,9 +30,8 @@ public function postProcess() $debug = Tools::getValue('debug') == 1; /** @var FrontApiService $frontApiService */ - $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); + $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); } } - diff --git a/ps_eventbus.php b/ps_eventbus.php index 56299e17..8f43498d 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -24,9 +24,9 @@ * International Registered Trademark & Property of PrestaShop SA */ +use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; -use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; if (!defined('_PS_VERSION_')) { @@ -199,7 +199,7 @@ public function getModuleEnv($default = null) } /** - * @return PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer + * @return ServiceContainer * * @throws Exception */ @@ -207,7 +207,7 @@ public function getServiceContainer() { if (null === $this->serviceContainer) { // append version number to force cache generation (1.6 Core won't clear it) - $this->serviceContainer = new PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer( + $this->serviceContainer = new ServiceContainer( $this->name . str_replace(['.', '-', '+'], '', $this->version), $this->getLocalPath(), $this->getModuleEnv() @@ -226,7 +226,7 @@ public function getServiceContainer() * @return mixed */ public function getService($serviceName) - { + { try { return $this->getServiceContainer()->getService($serviceName); } catch (ServiceNotFoundException $exception) { diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index c4a1ebae..294d2a2e 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -22,9 +22,7 @@ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; use Exception; -use Module; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; -use PrestaShopLogger; /** * Handle Error. @@ -71,7 +69,7 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc } /** - * @param Exception $error + * @param \Exception $error * @param mixed $code * @param bool|null $throw * @param array|null $data @@ -92,12 +90,12 @@ public function handle($error, $code = null, $throw = null, $data = null) $this->client->captureException($error, $data); - PrestaShopLogger::addLog( + \PrestaShopLogger::addLog( $error->getMessage() . ' : ' . $error->getFile() . ':' . $error->getLine() . ' | ' . $error->getTraceAsString(), 3, $error->getCode(), 'Module', - Module::getModuleIdByName('ps_eventbus'), + \Module::getModuleIdByName('ps_eventbus'), true ); diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php index 7c350f33..7c696bd7 100644 --- a/src/Interfaces/RepositoryInterface.php +++ b/src/Interfaces/RepositoryInterface.php @@ -2,15 +2,16 @@ namespace PrestaShop\Module\PsEventbus\Interfaces; -use DbQuery; - /** - * @property DbQuery $query + * @property \DbQuery $query */ interface RepositoryInterface { public function generateBaseQuery(); + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + public function countFullSyncContentLeft($offset, $langIso = null); } diff --git a/src/Interfaces/ShopContentServiceInterface.php b/src/Interfaces/ShopContentServiceInterface.php index b52c7760..d2404dc5 100644 --- a/src/Interfaces/ShopContentServiceInterface.php +++ b/src/Interfaces/ShopContentServiceInterface.php @@ -5,6 +5,8 @@ interface ShopContentServiceInterface { public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + public function countFullSyncContentLeft($offset, $langIso = null); } diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 16e5fd29..0727c0ae 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -2,32 +2,29 @@ namespace PrestaShop\Module\PsEventbus\Repository; -use Context; -use Db; -use DbQuery; use PrestaShop\Module\PsEventbus\Service\CommonService; abstract class AbstractRepository { /** - * @var Context + * @var \Context */ private $context; /** - * @var Db + * @var \Db */ private $db; /** - * @var DbQuery + * @var \DbQuery */ protected $query; public function __construct() { - $this->context = Context::getContext(); - $this->db = Db::getInstance(); + $this->context = \Context::getContext(); + $this->db = \Db::getInstance(); } public function getShopId() diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index 76aa1fed..4c4b41e6 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -3,7 +3,6 @@ namespace PrestaShop\Module\PsEventbus\Repository; use PrestaShop\Module\PsEventbus\Interfaces\RepositoryInterface; -use PrestaShop\Module\PsEventbus\Repository\AbstractRepository; class OrdersRepository extends AbstractRepository implements RepositoryInterface { @@ -62,7 +61,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, $this->query->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - + return $this->runQuery($debug); } diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 9e72ec79..9666be7e 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -1,4 +1,5 @@ startTime = time(); $this->module = $module; @@ -70,9 +64,9 @@ public function __construct( } public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) - { + { try { - if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [CONFIG::COLLECTION_HEALTHCHECK]), true)) { + if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } @@ -83,6 +77,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, if ($isHealthCheck) { /** @var HealthCheckService $healthCheckService */ $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); + return $healthCheckService->getHealthCheck($isAuthentified); } @@ -99,7 +94,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); - + $langIso = $langIso ? $langIso : $languageRepository->getDefaultLanguageIsoCode(); $offset = 0; @@ -159,7 +154,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $response ) ); - } catch (PrestaShopDatabaseException $exception) { + } catch (\PrestaShopDatabaseException $exception) { $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } catch (EnvVarException $exception) { @@ -171,7 +166,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } catch (\Exception $exception) { $this->errorHandler->handle($exception); - CommonService::dieWithResponse(["message" => "An error occured. Please check logs for more information"], 500); + CommonService::dieWithResponse(['message' => 'An error occured. Please check logs for more information'], 500); } } @@ -188,12 +183,12 @@ private function authorize($jobId, $isHealthCheck = null) if (is_array($authorizationResponse)) { CommonService::exitWithResponse($authorizationResponse); } elseif (!$authorizationResponse) { - throw new PrestaShopDatabaseException('Failed saving job id to database'); + throw new \PrestaShopDatabaseException('Failed saving job id to database'); } try { $token = $this->psAccountsAdapterService->getOrRefreshToken(); - } catch (Exception $exception) { + } catch (\Exception $exception) { throw new FirebaseException($exception->getMessage()); } @@ -208,7 +203,7 @@ private function authorize($jobId, $isHealthCheck = null) return false; } - if ($exception instanceof PrestaShopDatabaseException) { + if ($exception instanceof \PrestaShopDatabaseException) { $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } elseif ($exception instanceof EnvVarException) { diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 595a58b6..9737eca1 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -3,15 +3,13 @@ namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository; -use PrestaShop\Module\PsEventbus\Service\CommonService; -use Ps_eventbus; class HealthCheckService { - /** @var Ps_Eventbus $module */ + /** @var \Ps_eventbus */ private $module; - public function __construct(Ps_eventbus $module) + public function __construct(\Ps_eventbus $module) { $this->module = $module; } @@ -34,5 +32,4 @@ public function getHealthCheck($isAuthentified = null) CommonService::exitWithResponse($status); } - } diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index ccdfdbcf..2a66e13d 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -10,7 +10,7 @@ class OrdersService implements ShopContentServiceInterface { - /** @var OrdersRepository $ordersRepository */ + /** @var OrdersRepository */ private $ordersRepository; /** @var OrderHistoryRepository */ @@ -29,7 +29,8 @@ public function __construct( $this->arrayFormatter = $arrayFormatter; } - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) { + public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + { $orders = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { @@ -47,7 +48,8 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa }, $orders); } - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) { + public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + { $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); if (empty($result)) { @@ -65,14 +67,15 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, }, $orders); } - public function countFullSyncContentLeft($offset, $langIso = null) { + public function countFullSyncContentLeft($offset, $langIso = null) + { return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); } public function castOrders(&$orders, $langIso) { $langId = (int) \Language::getIdByIso($langIso); - + foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; $order['id_customer'] = (int) $order['id_customer']; @@ -176,5 +179,4 @@ private function castAddressIsoCodes(&$orderDetail) } } } - } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 36185ceb..315897e5 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -44,7 +44,6 @@ class SynchronizationService */ private $proxyService; - public function __construct( EventbusSyncRepository $eventbusSyncRepository, IncrementalSyncRepository $incrementalSyncRepository, @@ -87,9 +86,9 @@ public function sendFullSync( ) { $response = []; - $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceName = str_replace('-', '', ucwords($shopContent, '-')); $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; // faire un mapping entre le service et le nom du shopcontent - + /** @var \Ps_eventbus */ $module = \Module::getInstanceByName('ps_eventbus'); @@ -152,10 +151,9 @@ public function sendIncrementalSync( ) { $response = []; - $serviceName = str_replace('-', '', ucwords($shopContent, "-")); + $serviceName = str_replace('-', '', ucwords($shopContent, '-')); $serviceId = 'PrestaShop\Module\PsEventbus\Service\ShopContent\\' . $serviceName . 'Service'; - /** @var \Ps_eventbus */ $module = \Module::getInstanceByName('ps_eventbus'); @@ -232,9 +230,9 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, * If count > 100 000, we removed all entry corresponding to this shop content, and we enable full sync for this */ if (mt_rand() % Config::RANDOM_SYNC_CHECK_MAX == 0) { - foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($contentType); - + if ($count > Config::INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT) { $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); @@ -259,7 +257,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $allIsoCodes = $this->languageRepository->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { - foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { foreach ($contentIds as $contentId) { if ($this->isFullSyncDone($contentType, $langIso)) { array_push($contentToInsert, @@ -274,13 +272,12 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, ); } } - } } } else { $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - foreach($contentTypesWithIds as $contentType => $contentIds) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { foreach ($contentIds as $contentId) { if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { array_push($contentToInsert, diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 11a9f02a..54005323 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -2,102 +2,102 @@ namespace PrestaShop\Module\PsEventbus\Traits; -use Exception; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; -use SpecificPrice; -trait UseHooks { - public function getHooks() { +trait UseHooks +{ + public function getHooks() + { // Retourne la liste des hooks a register return [ 'actionObjectCarrierAddAfter', 'actionObjectCarrierDeleteAfter', 'actionObjectCarrierUpdateAfter', - + 'actionObjectCartAddAfter', 'actionObjectCartUpdateAfter', - + 'actionObjectCartRuleAddAfter', 'actionObjectCartRuleDeleteAfter', 'actionObjectCartRuleUpdateAfter', - + 'actionObjectCategoryAddAfter', 'actionObjectCategoryDeleteAfter', 'actionObjectCategoryUpdateAfter', - + 'actionObjectCombinationDeleteAfter', - + 'actionObjectCountryAddAfter', 'actionObjectCountryDeleteAfter', 'actionObjectCountryUpdateAfter', - + 'actionObjectCurrencyAddAfter', 'actionObjectCurrencyUpdateAfter', - + 'actionObjectCustomerAddAfter', 'actionObjectCustomerDeleteAfter', 'actionObjectCustomerUpdateAfter', - + 'actionObjectImageAddAfter', 'actionObjectImageDeleteAfter', 'actionObjectImageUpdateAfter', - + 'actionObjectLanguageAddAfter', 'actionObjectLanguageDeleteAfter', 'actionObjectLanguageUpdateAfter', - + 'actionObjectManufacturerAddAfter', 'actionObjectManufacturerDeleteAfter', 'actionObjectManufacturerUpdateAfter', - + 'actionObjectOrderAddAfter', 'actionObjectOrderUpdateAfter', - + 'actionObjectProductAddAfter', 'actionObjectProductDeleteAfter', 'actionObjectProductUpdateAfter', - + 'actionObjectSpecificPriceAddAfter', 'actionObjectSpecificPriceDeleteAfter', 'actionObjectSpecificPriceUpdateAfter', - + 'actionObjectStateAddAfter', 'actionObjectStateDeleteAfter', 'actionObjectStateUpdateAfter', - + 'actionObjectStockAddAfter', 'actionObjectStockUpdateAfter', - + 'actionObjectStoreAddAfter', 'actionObjectStoreDeleteAfter', 'actionObjectStoreUpdateAfter', - + 'actionObjectSupplierAddAfter', 'actionObjectSupplierDeleteAfter', 'actionObjectSupplierUpdateAfter', - + 'actionObjectTaxAddAfter', 'actionObjectTaxDeleteAfter', 'actionObjectTaxRulesGroupAddAfter', 'actionObjectTaxRulesGroupDeleteAfter', 'actionObjectTaxRulesGroupUpdateAfter', 'actionObjectTaxUpdateAfter', - + 'actionObjectWishlistAddAfter', 'actionObjectWishlistDeleteAfter', 'actionObjectWishlistUpdateAfter', - + 'actionObjectZoneAddAfter', 'actionObjectZoneDeleteAfter', 'actionObjectZoneUpdateAfter', - + 'actionShippingPreferencesPageSave', - + 'actionObjectEmployeeAddAfter', 'actionObjectEmployeeDeleteAfter', 'actionObjectEmployeeUpdateAfter', - + 'actionDispatcherBefore', ]; } @@ -1441,14 +1441,14 @@ public function hookActionDispatcherBefore($parameters) // when translation is edited or reset, add to incremental sync if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_TRANSLATIONS => 0], + [Config::COLLECTION_TRANSLATIONS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId ); } } - } catch (Exception $e) { + } catch (\Exception $e) { return; } } @@ -1463,10 +1463,10 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var SpecificPrice $specificPrice */ + /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof SpecificPrice) { + if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -1489,10 +1489,10 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var SpecificPrice $specificPrice */ + /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof SpecificPrice) { + if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -1515,10 +1515,10 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var SpecificPrice $specificPrice */ + /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof SpecificPrice) { + if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); $synchronizationService->insertContentIntoIncremental( diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index 20cfed1c..8ee106b3 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -1,18 +1,16 @@ query($editIncrementalTable); - + // If ALTER is failed, stop update process if (!$editIncrementalTableResult) { return false; From f5c182ab598a60f931bde1cd2020dc8e3e572a55 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 7 Aug 2024 17:17:32 +0200 Subject: [PATCH 049/162] fix: phpcs-fixer and phpstan --- controllers/front/apiFront.php | 7 +- src/Builder/CarrierBuilder.php | 6 +- src/Interfaces/ProxyServiceInterface.php | 2 +- src/Interfaces/RepositoryInterface.php | 32 +- .../ShopContentServiceInterface.php | 29 +- src/Provider/OrderDataProvider.php | 429 ------------------ src/Repository/AbstractRepository.php | 32 +- src/Repository/CountryRepository.php | 6 +- src/Repository/OrderHistoryRepository.php | 2 +- src/Repository/OrdersRepository.php | 45 +- src/Repository/StateRepository.php | 6 +- src/Repository/TaxRepository.php | 6 +- src/Service/CommonService.php | 8 +- src/Service/FrontApiService.php | 26 +- src/Service/HealthCheckService.php | 10 +- src/Service/ProxyService.php | 2 +- src/Service/ShopContent/OrdersService.php | 47 +- src/Service/SynchronizationService.php | 67 ++- src/Traits/UseHooks.php | 264 +++++++---- 19 files changed, 421 insertions(+), 605 deletions(-) delete mode 100644 src/Provider/OrderDataProvider.php diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 2ea96b0c..01c07340 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -23,14 +23,17 @@ public function postProcess() /** @var int $limit */ $limit = Tools::getValue('limit', 50); - /** @var bool $initFullSync */ + /** @var bool $isFull */ $isFull = Tools::getValue('full', 0) == 1; /** @var bool $debug */ $debug = Tools::getValue('debug') == 1; + /** @var Ps_eventbus $module */ + $module = Module::getInstanceByName('ps_eventbus'); + /** @var FrontApiService $frontApiService */ - $frontApiService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); + $frontApiService = $module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); } diff --git a/src/Builder/CarrierBuilder.php b/src/Builder/CarrierBuilder.php index 9139eca2..aeb65fed 100644 --- a/src/Builder/CarrierBuilder.php +++ b/src/Builder/CarrierBuilder.php @@ -186,14 +186,14 @@ private function buildCarrierDetails(\Carrier $carrier, $range, $zone) $carrierDetail->setRangeId($rangeId); /** @var array $countryIsoCodes */ - $countryIsoCodes = $this->countryRepository->getCountyIsoCodesByZoneId($zone['id_zone']); + $countryIsoCodes = $this->countryRepository->getCountyIsoCodesByZoneId($zone['id_zone'], true); if (!$countryIsoCodes) { return false; } $carrierDetail->setCountryIsoCodes($countryIsoCodes); /** @var array $stateIsoCodes */ - $stateIsoCodes = $this->stateRepository->getStateIsoCodesByZoneId($zone['id_zone']); + $stateIsoCodes = $this->stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); $carrierDetail->setStateIsoCodes($stateIsoCodes); return $carrierDetail; @@ -212,7 +212,7 @@ private function buildCarrierTaxes(\Carrier $carrier, $zoneId, $rangeId) { $taxRulesGroupId = (int) $carrier->getIdTaxRulesGroup(); /** @var array $carrierTaxesByZone */ - $carrierTaxesByZone = $this->taxRepository->getCarrierTaxesByZone($zoneId, $taxRulesGroupId); + $carrierTaxesByZone = $this->taxRepository->getCarrierTaxesByZone($zoneId, $taxRulesGroupId, true); if (!$carrierTaxesByZone[0]['country_iso_code']) { return null; diff --git a/src/Interfaces/ProxyServiceInterface.php b/src/Interfaces/ProxyServiceInterface.php index 10c319bc..528ff932 100644 --- a/src/Interfaces/ProxyServiceInterface.php +++ b/src/Interfaces/ProxyServiceInterface.php @@ -12,7 +12,7 @@ interface ProxyServiceInterface * * @return array */ - public function upload($jobId, $data, $scriptStartTime, $isFull = null); + public function upload($jobId, $data, $scriptStartTime, $isFull); /** * @param string $jobId diff --git a/src/Interfaces/RepositoryInterface.php b/src/Interfaces/RepositoryInterface.php index 7c696bd7..9723ab2d 100644 --- a/src/Interfaces/RepositoryInterface.php +++ b/src/Interfaces/RepositoryInterface.php @@ -7,11 +7,37 @@ */ interface RepositoryInterface { + /** + * @return mixed + */ public function generateBaseQuery(); - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug); - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug); - public function countFullSyncContentLeft($offset, $langIso = null); + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug); } diff --git a/src/Interfaces/ShopContentServiceInterface.php b/src/Interfaces/ShopContentServiceInterface.php index d2404dc5..9223815c 100644 --- a/src/Interfaces/ShopContentServiceInterface.php +++ b/src/Interfaces/ShopContentServiceInterface.php @@ -4,9 +4,32 @@ interface ShopContentServiceInterface { - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false); + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug); - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false); + /** + * @param int $limit + * @param mixed $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug); - public function countFullSyncContentLeft($offset, $langIso = null); + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug); } diff --git a/src/Provider/OrderDataProvider.php b/src/Provider/OrderDataProvider.php deleted file mode 100644 index 4dc4a478..00000000 --- a/src/Provider/OrderDataProvider.php +++ /dev/null @@ -1,429 +0,0 @@ -ordersRepository = $ordersRepository; - $this->context = $context; - $this->arrayFormatter = $arrayFormatter; - $this->orderDetailsRepository = $orderDetailsRepository; - $this->orderHistoryRepository = $orderHistoryRepository; - $this->orderCartRuleRepository = $orderCartRuleRepository; - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $orders = $this->ordersRepository->getOrders($offset, $limit, $this->shopId); - - if (empty($orders)) { - return []; - } - - $langId = (int) \Language::getIdByIso($langIso); - $this->castOrderValues($orders, $langId); - - $orderDetails = $this->getOrderDetails($orders); - $orderStatuses = $this->getOrderStatuses($orders, $langId); - $orderCartRules = $this->getOrderCartRules($orders); - - $orders = array_map(function ($order) { - return [ - 'id' => $order['id_order'], - 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, - ]; - }, $orders); - - return array_merge($orders, $orderDetails, $orderStatuses, $orderCartRules); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->ordersRepository->getRemainingOrderCount($offset, $this->shopId); - } - - /** - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $langId = (int) \Language::getIdByIso($langIso); - $orders = $this->ordersRepository->getOrdersIncremental($limit, $this->shopId, $objectIds); - - if (!is_array($orders) || empty($orders)) { - return []; - } - - $orderDetails = $this->getOrderDetails($orders); - $orderStatuses = $this->getOrderStatuses($orders, $langId); - $orderCartRules = $this->getOrderCartRules($orders); - - $this->castOrderValues($orders, (int) \Language::getIdByIso($langIso)); - - $orders = array_map(function ($order) { - return [ - 'id' => $order['id_order'], - 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, - ]; - }, $orders); - - return array_merge($orders, $orderDetails, $orderStatuses, $orderCartRules); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->ordersRepository->getQueryForDebug($offset, $limit, $this->shopId); - } - - /** - * @param array $orders - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getOrderDetails($orders) - { - if (empty($orders)) { - return []; - } - - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - - $orderDetails = $this->orderDetailsRepository->getOrderDetails($orderIds, $this->shopId); - - if (!is_array($orderDetails) || empty($orderDetails)) { - return []; - } - - $this->castOrderDetailValues($orderDetails); - - $orderDetails = array_map(function ($orderDetail) { - return [ - 'id' => $orderDetail['id_order_detail'], - 'collection' => Config::COLLECTION_ORDER_DETAILS, - 'properties' => $orderDetail, - ]; - }, $orderDetails); - - return $orderDetails; - } - - /** - * @param array $orders - * @param int $langId - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getOrderStatuses($orders, $langId) - { - if (empty($orders)) { - return []; - } - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - $orderHistoryStatuses = $this->orderHistoryRepository->getOrderHistoryStatuses($orderIds, $langId); - $orderHistoryStatuses = $this->castOrderStatuses($orderHistoryStatuses); - - return array_map(function ($orderHistoryStatus) { - return [ - 'id' => $orderHistoryStatus['id_order_history'], - 'collection' => Config::COLLECTION_ORDER_STATUS_HISTORY, - 'properties' => $orderHistoryStatus, - ]; - }, $orderHistoryStatuses); - } - - /** - * @param array $orders - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getOrderCartRules($orders) - { - if (empty($orders)) { - return []; - } - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - $orderCartRules = $this->orderCartRuleRepository->getOrderCartRules($orderIds); - $this->castOrderCartRulesValues($orderCartRules); - - return array_map(function ($orderCartRule) { - return [ - 'id' => $orderCartRule['id_order_cart_rule'], - 'collection' => Config::COLLECTION_ORDER_CART_RULES, - 'properties' => $orderCartRule, - ]; - }, $orderCartRules); - } - - /** - * @param array $orders - * @param int $langId - * - * @return void - * - * @@throws \PrestaShopDatabaseException - */ - private function castOrderValues(&$orders, $langId) - { - foreach ($orders as &$order) { - $order['id_order'] = (int) $order['id_order']; - $order['id_customer'] = (int) $order['id_customer']; - $order['current_state'] = (int) $order['current_state']; - $order['conversion_rate'] = (float) $order['conversion_rate']; - $order['total_paid_tax_incl'] = (float) $order['total_paid_tax_incl']; - $order['total_paid_tax_excl'] = (float) $order['total_paid_tax_excl']; - $order['refund'] = (float) $order['refund']; - $order['refund_tax_excl'] = (float) $order['refund_tax_excl']; - $order['new_customer'] = $order['new_customer'] == 1; - $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langId); - $order['shipping_cost'] = (float) $order['shipping_cost']; - $order['total_paid_tax'] = $order['total_paid_tax_incl'] - $order['total_paid_tax_excl']; - $order['id_carrier'] = (int) $order['id_carrier']; - - $order['id_shop_group'] = (int) $order['id_shop_group']; - $order['id_shop'] = (int) $order['id_shop']; - $order['id_lang'] = (int) $order['id_lang']; - $order['id_currency'] = (int) $order['id_currency']; - $order['recyclable'] = (bool) $order['recyclable']; - $order['gift'] = (bool) $order['gift']; - - $order['total_discounts'] = (int) $order['total_discounts']; - $order['total_discounts_tax_incl'] = (int) $order['total_discounts_tax_incl']; - $order['total_discounts_tax_excl'] = (int) $order['total_discounts_tax_excl']; - $order['total_products'] = (int) $order['total_products']; - $order['total_products_wt'] = (int) $order['total_products_wt']; - $order['total_shipping_tax_incl'] = (int) $order['total_shipping_tax_incl']; - $order['total_shipping_tax_excl'] = (int) $order['total_shipping_tax_excl']; - - $order['carrier_tax_rate'] = (int) $order['carrier_tax_rate']; - $order['total_wrapping'] = (int) $order['total_wrapping']; - $order['total_wrapping_tax_incl'] = (int) $order['total_wrapping_tax_incl']; - $order['total_wrapping_tax_excl'] = (int) $order['total_wrapping_tax_excl']; - $order['round_mode'] = (int) $order['round_mode']; - $order['round_type'] = (int) $order['round_type']; - $order['invoice_number'] = (int) $order['invoice_number']; - $order['delivery_number'] = (int) $order['delivery_number']; - $order['valid'] = (bool) $order['valid']; - - $this->castAddressIsoCodes($order); - unset($order['address_iso']); - } - } - - /** - * @param array $orders - * @param array $order - * @param int $langId - * - * @return bool - * - * @@throws \PrestaShopDatabaseException - */ - private function castIsPaidValue($orders, $order, $langId) - { - $isPaid = $dateAdd = 0; - $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - /** @var array $orderHistoryStatuses */ - $orderHistoryStatuses = $this->orderHistoryRepository->getOrderHistoryStatuses($orderIds, $langId); - - foreach ($orderHistoryStatuses as &$orderHistoryStatus) { - if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { - $isPaid = (bool) $orderHistoryStatus['paid']; - $dateAdd = $orderHistoryStatus['date_add']; - } - } - - return (bool) $isPaid; - } - - /** - * @param array $orderDetails - * - * @return void - */ - private function castOrderDetailValues(&$orderDetails) - { - foreach ($orderDetails as &$orderDetail) { - $orderDetail['id_order_detail'] = (int) $orderDetail['id_order_detail']; - $orderDetail['id_order'] = (int) $orderDetail['id_order']; - $orderDetail['product_id'] = (int) $orderDetail['product_id']; - $orderDetail['product_attribute_id'] = (int) $orderDetail['product_attribute_id']; - $orderDetail['product_quantity'] = (int) $orderDetail['product_quantity']; - $orderDetail['unit_price_tax_incl'] = (float) $orderDetail['unit_price_tax_incl']; - $orderDetail['unit_price_tax_excl'] = (float) $orderDetail['unit_price_tax_excl']; - $orderDetail['refund'] = (float) $orderDetail['refund'] > 0 ? -1 * (float) $orderDetail['refund'] : 0; - $orderDetail['refund_tax_excl'] = (float) $orderDetail['refund_tax_excl'] > 0 ? -1 * (float) $orderDetail['refund_tax_excl'] : 0; - $orderDetail['category'] = (int) $orderDetail['category']; - $orderDetail['unique_product_id'] = "{$orderDetail['product_id']}-{$orderDetail['product_attribute_id']}-{$orderDetail['iso_code']}"; - $orderDetail['conversion_rate'] = (float) $orderDetail['conversion_rate']; - } - } - - /** - * @param array $orderStatuses - * - * @return array - */ - private function castOrderStatuses(&$orderStatuses) - { - $castedOrderStatuses = []; - foreach ($orderStatuses as $orderStatus) { - $castedOrderStatus = []; - $castedOrderStatus['id_order_state'] = (int) $orderStatus['id_order_state']; - $castedOrderStatus['id_order'] = (int) $orderStatus['id_order']; - $castedOrderStatus['id_order_history'] = (int) $orderStatus['id_order_history']; - $castedOrderStatus['name'] = (string) $orderStatus['name']; - $castedOrderStatus['template'] = (string) $orderStatus['template']; - $castedOrderStatus['date_add'] = $orderStatus['date_add']; - $castedOrderStatus['is_validated'] = (bool) $orderStatus['logable']; - $castedOrderStatus['is_delivered'] = (bool) $orderStatus['delivery']; - $castedOrderStatus['is_shipped'] = (bool) $orderStatus['shipped']; - $castedOrderStatus['is_paid'] = (bool) $orderStatus['paid']; - $castedOrderStatus['is_deleted'] = (bool) $orderStatus['deleted']; - $castedOrderStatus['created_at'] = $castedOrderStatus['date_add']; - $castedOrderStatus['updated_at'] = $castedOrderStatus['date_add']; - $castedOrderStatuses[] = $castedOrderStatus; - } - - return $castedOrderStatuses; - } - - /** - * @param array $orderDetail - * - * @return void - */ - private function castAddressIsoCodes(&$orderDetail) - { - if (!$orderDetail['address_iso']) { - $orderDetail['invoice_country_code'] = null; - $orderDetail['delivery_country_code'] = null; - - return; - } - - $addressAndIsoCodes = explode(',', $orderDetail['address_iso']); - if (count($addressAndIsoCodes) === 1) { - $addressAndIsoCode = explode(':', $addressAndIsoCodes[0]); - $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; - $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; - - return; - } - - foreach ($addressAndIsoCodes as $addressAndIsoCodeString) { - $addressAndIsoCode = explode(':', $addressAndIsoCodeString); - if ($addressAndIsoCode[0] === 'delivery') { - $orderDetail['delivery_country_code'] = $addressAndIsoCode[1]; - } elseif ($addressAndIsoCode[0] === 'invoice') { - $orderDetail['invoice_country_code'] = $addressAndIsoCode[1]; - } - } - } - - /** - * @param array $orderCartRules - * - * @return void - */ - private function castOrderCartRulesValues(&$orderCartRules) - { - foreach ($orderCartRules as &$orderCartRule) { - $orderCartRule['id_order_cart_rule'] = (int) $orderCartRule['id_order_cart_rule']; - $orderCartRule['id_order'] = (int) $orderCartRule['id_order']; - $orderCartRule['id_cart_rule'] = (int) $orderCartRule['id_cart_rule']; - $orderCartRule['id_order_invoice'] = (int) $orderCartRule['id_order_invoice']; - $orderCartRule['value'] = (float) $orderCartRule['value']; - $orderCartRule['value_tax_excl'] = (float) $orderCartRule['value_tax_excl']; - $orderCartRule['free_shipping'] = (bool) $orderCartRule['free_shipping']; - $orderCartRule['deleted'] = isset($orderCartRule['deleted']) ? (bool) $orderCartRule['deleted'] : false; - } - } -} diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 0727c0ae..364e2c87 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -23,10 +23,21 @@ abstract class AbstractRepository public function __construct() { - $this->context = \Context::getContext(); + $context = \Context::getContext(); + + if ($context == null) { + throw new \PrestaShopException('Context not found'); + } + + $this->context = $context; $this->db = \Db::getInstance(); } + /** + * @return int + * + * @throws \PrestaShopException + */ public function getShopId() { if ($this->context->shop === null) { @@ -36,15 +47,30 @@ public function getShopId() return (int) $this->context->shop->id; } + /** + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ protected function runQuery($debug) { - if ($debug) { + if ($debug != null && $debug === true) { $this->debugQuery(); } - return $this->db->executeS($this->query); + $result = $this->db->executeS($this->query); + + return is_array($result) ? $result : []; } + /** + * @return void + * + * @throws \PrestaShopException + */ private function debugQuery() { $queryStringified = preg_replace('/\s+/', ' ', $this->query->build()); diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index 43e637d8..1c34582d 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -57,12 +57,8 @@ private function getBaseQuery() * * @throws \PrestaShopDatabaseException */ - public function getCountyIsoCodesByZoneId($zoneId, $active = null) + public function getCountyIsoCodesByZoneId($zoneId, $active) { - if ($active == null) { - $active = true; - } - $cacheKey = $zoneId . '-' . (int) $active; if (!isset($this->countryIsoCodeCache[$cacheKey])) { diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php index 9cf0d31d..99385541 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -30,7 +30,7 @@ public function getBaseQuery() /** * @param array $orderIds - * @param int $langId + * @param int|null $langId * * @return array|bool|\mysqli_result|\PDOStatement|resource|null * diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index 4c4b41e6..a699cdf9 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -8,6 +8,11 @@ class OrdersRepository extends AbstractRepository implements RepositoryInterface { public const ORDERS_TABLE = 'orders'; + /** + * @return mixed + * + * @throws \PrestaShopException + */ public function generateBaseQuery() { $this->query = new \DbQuery(); @@ -46,7 +51,18 @@ public function generateBaseQuery() $this->query->select('o.round_mode, o.round_type, o.invoice_number, o.delivery_number, o.invoice_date, o.delivery_date, o.valid'); } - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) { $this->generateBaseQuery(); @@ -55,7 +71,18 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa return $this->runQuery($debug); } - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { $this->generateBaseQuery(); @@ -65,9 +92,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, return $this->runQuery($debug); } - public function countFullSyncContentLeft($offset, $langIso = null, $debug = false) + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) { - $orders = $this->getContentsForFull($offset, 1, parent::getShopId(), $debug); + $orders = $this->getContentsForFull($offset, 1, $langIso, $debug); if (!is_array($orders) || empty($orders)) { return 0; diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index c7e92b73..372cc239 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -39,12 +39,8 @@ private function getBaseQuery() * * @throws \PrestaShopDatabaseException */ - public function getStateIsoCodesByZoneId($zoneId, $active = null) + public function getStateIsoCodesByZoneId($zoneId, $active) { - if ($active == null) { - $active = true; - } - $cacheKey = $zoneId . '-' . (int) $active; if (!isset($this->stateIsoCodeCache[$cacheKey])) { diff --git a/src/Repository/TaxRepository.php b/src/Repository/TaxRepository.php index 0ccb78c3..a0fbd029 100644 --- a/src/Repository/TaxRepository.php +++ b/src/Repository/TaxRepository.php @@ -64,12 +64,8 @@ private function getBaseQuery() * * @throws \PrestaShopDatabaseException */ - public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active = null) + public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active) { - if ($active == null) { - $active = true; - } - $cacheKey = $zoneId . '-' . (int) $active; if (!isset($this->countryIsoCodeCache[$cacheKey])) { diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 9666be7e..35756687 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -10,11 +10,11 @@ class CommonService { /** - * @param array $response + * @param array $response * * @return void */ - public static function exitWithResponse(array $response) + public static function exitWithResponse($response) { $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; @@ -51,12 +51,12 @@ public static function exitWithExceptionMessage(\Exception $exception) } /** - * @param array $response + * @param array $response * @param int $code * * @return void */ - public static function dieWithResponse(array $response, $code) + public static function dieWithResponse($response, $code) { $httpStatusText = "HTTP/1.1 $code"; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index c2ae71aa..ddec1fa0 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -7,6 +7,7 @@ use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; +use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; @@ -63,7 +64,17 @@ public function __construct( $this->eventbusSyncRepository = $eventbusSyncRepository; } - public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug = false) + /** + * @param string $shopContent + * @param string $jobId + * @param string $langIso + * @param int $limit + * @param bool $isFull + * @param bool $debug + * + * @return void + */ + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug) { try { if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { @@ -78,7 +89,9 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, /** @var HealthCheckService $healthCheckService */ $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); - return $healthCheckService->getHealthCheck($isAuthentified); + $healthCheckService->getHealthCheck($isAuthentified); + + return; } if ($limit < 0) { @@ -171,11 +184,14 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } /** - * @return bool|void + * @param string $jobId + * @param bool $isHealthCheck + * + * @return bool * * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException */ - private function authorize($jobId, $isHealthCheck = null) + private function authorize($jobId, $isHealthCheck) { try { $authorizationResponse = $this->apiAuthorizationService->authorizeCall($jobId); @@ -213,6 +229,8 @@ private function authorize($jobId, $isHealthCheck = null) $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); } + + return false; } } } diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 9737eca1..19d0d8d9 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -15,16 +15,14 @@ public function __construct(\Ps_eventbus $module) } /** + * @param bool $isAuthentified + * * @return void * - * @throws PrestaShopException + * @throws \PrestaShopException */ - public function getHealthCheck($isAuthentified = null) + public function getHealthCheck($isAuthentified) { - if ($isAuthentified == null) { - $isAuthentified = false; - } - /** @var ServerInformationRepository $serverInformationRepository */ $serverInformationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository'); diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index a0905857..2f8e9091 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -42,7 +42,7 @@ public function __construct(CollectorApiClient $eventBusProxyClient, JsonFormatt * * @throws EnvVarException */ - public function upload($jobId, $data, $scriptStartTime, $isFull = null) + public function upload($jobId, $data, $scriptStartTime, $isFull) { $dataJson = $this->jsonFormatter->formatNewlineJsonString($data); diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 2a66e13d..a1680a5b 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -29,11 +29,19 @@ public function __construct( $this->arrayFormatter = $arrayFormatter; } - public function getContentsForFull($offset, $limit, $langIso = null, $debug = false) + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) { $orders = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); - if (empty($result)) { + if (empty($orders)) { return []; } @@ -48,11 +56,19 @@ public function getContentsForFull($offset, $limit, $langIso = null, $debug = fa }, $orders); } - public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false) + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso = null, $debug); + $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); - if (empty($result)) { + if (empty($orders)) { return []; } @@ -67,14 +83,27 @@ public function getContentsForIncremental($limit, $contentIds, $langIso = null, }, $orders); } - public function countFullSyncContentLeft($offset, $langIso = null) + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) { - return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso); + return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso, $debug); } + /** + * @param array $orders + * @param string $langIso + * + * @return void + */ public function castOrders(&$orders, $langIso) { - $langId = (int) \Language::getIdByIso($langIso); + $langId = \Language::getIdByIso($langIso); foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; @@ -124,7 +153,7 @@ public function castOrders(&$orders, $langIso) /** * @param array $orders * @param array $order - * @param int $langId + * @param int|null $langId * * @return bool * diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 315897e5..b0d7718b 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -2,15 +2,16 @@ namespace PrestaShop\Module\PsEventbus\Service; -use Behat\Behat\HelperContainer\Exception\ServiceNotFoundException; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; use PrestaShop\Module\PsEventbus\Interfaces\ProxyServiceInterface; use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; +use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; class SynchronizationService { @@ -70,7 +71,7 @@ public function __construct( * @param string $dateNow * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException|ApiException */ @@ -117,7 +118,7 @@ public function sendFullSync( } } - $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $langIso); + $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $langIso, $debug); if ($remainingObjects <= 0) { $remainingObjects = 0; @@ -130,14 +131,14 @@ public function sendFullSync( } /** - * @param string $type + * @param string $shopContent * @param string $jobId * @param string $langIso * @param int $limit * @param int $startTime * @param bool $debug * - * @return array + * @return array * * @@throws \PrestaShopDatabaseException|EnvVarException */ @@ -204,21 +205,21 @@ public function sendIncrementalSync( */ public function sendLiveSync($shopContent, $shopContentId, $action) { - if ($this->isFullSyncDone($shopContent)) { + if ($this->isFullSyncDone($shopContent, '')) { // $this->debounceLiveSync($shopContent); } } /** - * @param array> $contentTypesWithIds - * @param string actionType + * @param array $contentTypesWithIds + * @param string $actionType * @param string $createdAt * @param int $shopId * @param bool $hasMultiLang * * @return void */ - public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $createdAt, $shopId, $hasMultiLang = null) + public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $createdAt, $shopId, $hasMultiLang) { if (count($contentTypesWithIds) == 0) { return; @@ -257,35 +258,14 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $allIsoCodes = $this->languageRepository->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { - foreach ($contentTypesWithIds as $contentType => $contentIds) { - foreach ($contentIds as $contentId) { - if ($this->isFullSyncDone($contentType, $langIso)) { - array_push($contentToInsert, - [ - 'type' => $contentType, - 'id_object' => $contentId, - 'id_shop' => $shopId, - 'lang_iso' => $langIso, - 'action' => $actionType, - 'created_at' => $createdAt, - ] - ); - } - } - } - } - } else { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); - - foreach ($contentTypesWithIds as $contentType => $contentIds) { - foreach ($contentIds as $contentId) { - if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { + foreach ($contentTypesWithIds as $contentType => $contentId) { + if ($this->isFullSyncDone($contentType, $langIso)) { array_push($contentToInsert, [ 'type' => $contentType, 'id_object' => $contentId, 'id_shop' => $shopId, - 'lang_iso' => $defaultIsoCode, + 'lang_iso' => $langIso, 'action' => $actionType, 'created_at' => $createdAt, ] @@ -293,6 +273,23 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } } } + } else { + $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + + foreach ($contentTypesWithIds as $contentType => $contentId) { + if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { + array_push($contentToInsert, + [ + 'type' => $contentType, + 'id_object' => $contentId, + 'id_shop' => $shopId, + 'lang_iso' => $defaultIsoCode, + 'action' => $actionType, + 'created_at' => $createdAt, + ] + ); + } + } } if (empty($contentToInsert) == false) { @@ -329,11 +326,11 @@ private function debounceLiveSync($shopContentName) // @phpstan-ignore method.un * Return true if full sync is done for this shop content * * @param string $shopContent - * @param string|null $langIso + * @param string $langIso * * @return bool */ - private function isFullSyncDone($shopContent, $langIso = null) + private function isFullSyncDone($shopContent, $langIso) { return $this->eventbusSyncRepository->isFullSyncDoneForThisTypeSync($shopContent, $langIso); } diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 54005323..35ea2848 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -4,9 +4,13 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; +use Product; trait UseHooks { + /** + * @return array + */ public function getHooks() { // Retourne la liste des hooks a register @@ -112,9 +116,10 @@ public function hookActionObjectImageDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Image $image */ $image = $parameters['object']; - if (isset($image->id_product)) { + if ($image->id_product) { $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], @@ -136,8 +141,10 @@ public function hookActionObjectImageAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Image $image */ $image = $parameters['object']; - if (isset($image->id_product)) { + + if ($image->id_product) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], @@ -159,8 +166,10 @@ public function hookActionObjectImageUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Image $image */ $image = $parameters['object']; - if (isset($image->id_product)) { + + if ($image->id_product) { $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], @@ -182,14 +191,17 @@ public function hookActionObjectLanguageDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Language $language */ $language = $parameters['object']; - if (isset($language->id)) { + + if ($language->id) { $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -204,9 +216,11 @@ public function hookActionObjectLanguageAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Language $language */ $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + + if ($language->id) { + $synchronizationService->sendLiveSync('languages', $language->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_ADD, @@ -227,9 +241,11 @@ public function hookActionObjectLanguageUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Language $language */ $language = $parameters['object']; - if (isset($language->id) && isset($language->id_product)) { - $synchronizationService->sendLiveSync('languages', $language->id_product, 'upsert'); + + if ($language->id) { + $synchronizationService->sendLiveSync('languages', $language->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -250,14 +266,17 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_MANUFACTURERS, $manufacturer->id], + [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -272,7 +291,9 @@ public function hookActionObjectManufacturerAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -295,7 +316,9 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; + if (isset($manufacturer->id)) { $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -318,14 +341,17 @@ public function hookActionObjectSupplierDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Supplier $supplier */ $supplier = $parameters['object']; + if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_SUPPLIERS, $supplier->id], + [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -340,7 +366,9 @@ public function hookActionObjectSupplierAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Supplier $supplier */ $supplier = $parameters['object']; + if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -363,7 +391,9 @@ public function hookActionObjectSupplierUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Supplier $supplier */ $supplier = $parameters['object']; + if (isset($supplier->id)) { $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -386,15 +416,17 @@ public function hookActionObjectProductDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Product $product */ $product = $parameters['object']; if (isset($product->id)) { $synchronizationService->sendLiveSync('products', $product->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS, $product->id], + [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -409,12 +441,16 @@ public function hookActionObjectProductAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Product $product */ $product = $parameters['object']; + if (isset($product->id)) { $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + // TODO: Need to insertContentIntoIncremental custom-product-carriers and stocks + $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_ADD, @@ -435,7 +471,7 @@ public function hookActionObjectProductUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Product $product */ + /** @var \Product $product */ $product = $parameters['object']; if (isset($product->id)) { @@ -443,6 +479,8 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + // TODO: Need to insertContentIntoIncremental custom-product-carriers and stocks + $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -463,14 +501,17 @@ public function hookActionObjectWishlistDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \WishList $wishlist */ $wishlist = $parameters['object']; - if (isset($wishlist->id)) { + + if ($wishlist->id) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_WISHLISTS, $wishlist->id], + [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -485,8 +526,10 @@ public function hookActionObjectWishlistAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \WishList $wishlist */ $wishlist = $parameters['object']; - if (isset($wishlist->id)) { + + if ($wishlist->id) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], @@ -508,8 +551,10 @@ public function hookActionObjectWishlistUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \WishList $wishlist */ $wishlist = $parameters['object']; - if (isset($wishlist->id)) { + + if ($wishlist->id) { $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], @@ -531,7 +576,9 @@ public function hookActionObjectStockAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Stock $stock */ $stock = $parameters['object']; + if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -554,7 +601,9 @@ public function hookActionObjectStockUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Stock $stock */ $stock = $parameters['object']; + if (isset($stock->id)) { $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( @@ -577,14 +626,17 @@ public function hookActionObjectStoreDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'delete'); + /** @var \Store $store */ + $store = $parameters['object']; + + if ($store->id) { + $synchronizationService->sendLiveSync('stores', $store->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_STORES, $product->id], + [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -599,11 +651,13 @@ public function hookActionObjectStoreAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $product = $parameters['object']; - if (isset($product->id)) { - $synchronizationService->sendLiveSync('stores', $product->id, 'upsert'); + /** @var \Store $store */ + $store = $parameters['object']; + + if ($store->id) { + $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_STORES => $product->id], + [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, @@ -622,8 +676,10 @@ public function hookActionObjectStoreUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Store $store */ $store = $parameters['object']; - if (isset($store->id)) { + + if ($store->id) { $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], @@ -645,16 +701,17 @@ public function hookActionObjectCombinationDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Combination $combination */ + /** @var \Combination $combination */ $combination = $parameters['object']; if (isset($combination->id)) { $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCT_ATTRIBUTES, $combination->id], + [Config::COLLECTION_PRODUCT_ATTRIBUTES => $combination->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -669,6 +726,7 @@ public function hookActionObjectCategoryAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Category $category * */ $category = $parameters['object']; if (isset($category->id)) { @@ -693,6 +751,7 @@ public function hookActionObjectCategoryUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Category $category * */ $category = $parameters['object']; if (isset($category->id)) { @@ -717,15 +776,17 @@ public function hookActionObjectCategoryDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Category $category * */ $category = $parameters['object']; if (isset($category->id)) { $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CATEGORIES, $category->id], + [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -740,9 +801,10 @@ public function hookActionObjectCustomerAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Customer $customer * */ $customer = $parameters['object']; - if (isset($customer->id)) { + if ($customer->id) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], @@ -764,9 +826,10 @@ public function hookActionObjectCustomerUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Customer $customer * */ $customer = $parameters['object']; - if (isset($customer->id)) { + if ($customer->id) { $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], @@ -788,15 +851,17 @@ public function hookActionObjectCustomerDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Customer $customer * */ $customer = $parameters['object']; - if (isset($customer->id)) { + if ($customer->id) { $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CUSTOMERS, $customer->id], + [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -811,6 +876,7 @@ public function hookActionObjectCurrencyAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Currency $currency * */ $currency = $parameters['object']; if (isset($currency->id)) { @@ -835,6 +901,7 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Currency $currency * */ $currency = $parameters['object']; if (isset($currency->id)) { @@ -859,15 +926,17 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + /** @var \Currency $currency * */ $currency = $parameters['object']; if (isset($currency->id)) { $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CURRENCIES, $currency->id], + [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -890,7 +959,8 @@ public function hookActionObjectCartAddAfter($parameters) [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -913,7 +983,8 @@ public function hookActionObjectCartUpdateAfter($parameters) [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -936,7 +1007,8 @@ public function hookActionObjectCartRuleAddAfter($parameters) [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -959,7 +1031,8 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -982,7 +1055,8 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1005,7 +1079,8 @@ public function hookActionObjectOrderAddAfter($parameters) [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1028,7 +1103,8 @@ public function hookActionObjectOrderUpdateAfter($parameters) [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1043,7 +1119,7 @@ public function hookActionObjectCarrierAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Carrier $carrier */ + /** @var \Carrier $carrier */ $carrier = $parameters['object']; if (isset($carrier->id)) { @@ -1052,7 +1128,8 @@ public function hookActionObjectCarrierAddAfter($parameters) [Config::COLLECTION_CARRIERS => $carrier->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1067,7 +1144,7 @@ public function hookActionObjectCarrierUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var Carrier $carrier */ + /** @var \Carrier $carrier */ $carrier = $parameters['object']; if (isset($carrier->id)) { @@ -1076,7 +1153,8 @@ public function hookActionObjectCarrierUpdateAfter($parameters) [Config::COLLECTION_CARRIERS => $carrier->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1090,8 +1168,7 @@ public function hookActionObjectCarrierDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - - /** @var Carrier $carrier */ + /** @var \Carrier $carrier */ $carrier = $parameters['object']; if (isset($carrier->id)) { @@ -1100,7 +1177,8 @@ public function hookActionObjectCarrierDeleteAfter($parameters) [Config::COLLECTION_CARRIERS => $carrier->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1117,7 +1195,8 @@ public function hookActionObjectCountryAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1133,7 +1212,8 @@ public function hookActionObjectCountryUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1149,7 +1229,8 @@ public function hookActionObjectCountryDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1165,7 +1246,8 @@ public function hookActionObjectStateAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1181,7 +1263,8 @@ public function hookActionObjectStateUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1197,7 +1280,8 @@ public function hookActionObjectStateDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1213,7 +1297,8 @@ public function hookActionObjectZoneAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1229,7 +1314,8 @@ public function hookActionObjectZoneUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1245,7 +1331,8 @@ public function hookActionObjectZoneDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1261,7 +1348,8 @@ public function hookActionObjectTaxAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1277,7 +1365,8 @@ public function hookActionObjectTaxUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1293,7 +1382,8 @@ public function hookActionObjectTaxDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1309,7 +1399,8 @@ public function hookActionObjectTaxRulesGroupAddAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1325,7 +1416,8 @@ public function hookActionObjectTaxRulesGroupUpdateAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1341,7 +1433,8 @@ public function hookActionObjectTaxRulesGroupDeleteAfter() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1357,7 +1450,8 @@ public function hookActionShippingPreferencesPageSave() [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1373,7 +1467,8 @@ public function hookActionObjectEmployeeAddAfter() [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1388,7 +1483,8 @@ public function hookActionObjectEmployeeDeleteAfter() [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1404,7 +1500,8 @@ public function hookActionObjectEmployeeUpdateAfter() [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } @@ -1444,7 +1541,8 @@ public function hookActionDispatcherBefore($parameters) [Config::COLLECTION_TRANSLATIONS => 0], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1473,7 +1571,8 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1499,7 +1598,8 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } @@ -1522,11 +1622,11 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) if (isset($specificPrice->id)) { $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); $synchronizationService->insertContentIntoIncremental( - $specificPrice->id, - Config::COLLECTION_SPECIFIC_PRICES, + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), - $this->shopId + $this->shopId, + false ); } } From 8315918ef26fe413c6dc0a1c74873a9a0d6ee8a9 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 09:56:48 +0200 Subject: [PATCH 050/162] fix: compat 5.6 --- src/Config/Config.php | 2 +- src/Repository/OrdersRepository.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index d5bd74af..15848fd8 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -68,7 +68,7 @@ class Config const COLLECTION_WISHLISTS = 'wishlists'; const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; - public const SHOP_CONTENTS = [ + const SHOP_CONTENTS = [ self::COLLECTION_BUNDLES, self::COLLECTION_CARRIERS, self::COLLECTION_CARTS, diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrdersRepository.php index a699cdf9..8a2d391a 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrdersRepository.php @@ -6,7 +6,7 @@ class OrdersRepository extends AbstractRepository implements RepositoryInterface { - public const ORDERS_TABLE = 'orders'; + const ORDERS_TABLE = 'orders'; /** * @return mixed From 41e5a2ac9ecebb17427b081ede48db4608fc40a3 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 10:09:31 +0200 Subject: [PATCH 051/162] fix: compat ps 1.6.1.11 --- ps_eventbus.php | 6 +++++- src/Service/ShopContent/OrdersService.php | 2 +- src/Traits/UseHooks.php | 4 +--- tests/phpstan/phpstan-1-6.neon | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ps_eventbus.php b/ps_eventbus.php index 8f43498d..4d12eb6c 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -230,7 +230,11 @@ public function getService($serviceName) try { return $this->getServiceContainer()->getService($serviceName); } catch (ServiceNotFoundException $exception) { - return $this->get($serviceName); + if (method_exists($this, 'get')) { + return $this->get($serviceName); + } + + throw new ServiceNotFoundException('Service not found'); } } diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index a1680a5b..255298e3 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -103,7 +103,7 @@ public function countFullSyncContentLeft($offset, $langIso, $debug) */ public function castOrders(&$orders, $langIso) { - $langId = \Language::getIdByIso($langIso); + $langId = (int) \Language::getIdByIso($langIso); foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 35ea2848..97f62ea0 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -501,7 +501,7 @@ public function hookActionObjectWishlistDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \WishList $wishlist */ + $wishlist = $parameters['object']; if ($wishlist->id) { @@ -526,7 +526,6 @@ public function hookActionObjectWishlistAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \WishList $wishlist */ $wishlist = $parameters['object']; if ($wishlist->id) { @@ -551,7 +550,6 @@ public function hookActionObjectWishlistUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \WishList $wishlist */ $wishlist = $parameters['object']; if ($wishlist->id) { diff --git a/tests/phpstan/phpstan-1-6.neon b/tests/phpstan/phpstan-1-6.neon index be2d56ce..050c969a 100644 --- a/tests/phpstan/phpstan-1-6.neon +++ b/tests/phpstan/phpstan-1-6.neon @@ -1,6 +1,6 @@ parameters: ignoreErrors: - - '#Parameter \#1 \$hook_name of method ModuleCore::registerHook\(\) expects string, array given#' + - '#Parameter \#1 \$hook_name of method ModuleCore::registerHook\(\) expects string, array given#' - '#Access to undefined constant Module::MULTISTORE_COMPATIBILITY_YES#' - '#Property ObjectModelCore::\$id \(int\) in isset\(\) is not nullable#' - '#Call to method buildRepository\(\) on an unknown class PrestaShop\\PrestaShop\\Core\\Addon\\Theme\\ThemeManagerBuilder.#' From 532327f87064adf059d5f6bee3fb1db50e6f7d6e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 10:11:45 +0200 Subject: [PATCH 052/162] fix: php-cs-fixer --- src/Traits/UseHooks.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 97f62ea0..a465a352 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -501,7 +501,6 @@ public function hookActionObjectWishlistDeleteAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - $wishlist = $parameters['object']; if ($wishlist->id) { From 5ec0b2824073ff71f86e62fa812408a5b9b16641 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 11:28:49 +0200 Subject: [PATCH 053/162] fix: e2e env --- README.md | 4 ++-- e2e-env/docker-compose.yml | 2 +- e2e/src/fixtures/1.6/{apiProducts => }/bundles.json | 0 e2e/src/fixtures/1.6/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/1.6/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/1.6/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/1.6/{apiCarts => }/carts.json | 0 e2e/src/fixtures/1.6/{apiCategories => }/categories.json | 0 e2e/src/fixtures/1.6/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/1.6/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/1.6/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/1.6/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/1.6/{apiImages => }/images.json | 0 e2e/src/fixtures/1.6/{apiLanguages => }/languages.json | 0 .../fixtures/1.6/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/1.6/{apiModules => }/modules.json | 0 e2e/src/fixtures/1.6/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/1.6/{apiOrders => }/order_details.json | 0 .../fixtures/1.6/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/1.6/{apiOrders => }/orders.json | 0 e2e/src/fixtures/1.6/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/1.6/{apiProducts => }/products.json | 0 e2e/src/fixtures/1.6/{apiInfo => }/shops.json | 0 .../fixtures/1.6/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/1.6/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/1.6/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/1.6/{apiStores => }/stores.json | 0 e2e/src/fixtures/1.6/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/1.6/{apiThemes => }/themes.json | 0 e2e/src/fixtures/1.7/{apiProducts => }/bundles.json | 0 e2e/src/fixtures/1.7/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/1.7/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/1.7/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/1.7/{apiCarts => }/carts.json | 0 e2e/src/fixtures/1.7/{apiCategories => }/categories.json | 0 e2e/src/fixtures/1.7/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/1.7/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/1.7/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/1.7/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/1.7/{apiImages => }/images.json | 0 e2e/src/fixtures/1.7/{apiLanguages => }/languages.json | 0 .../fixtures/1.7/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/1.7/{apiModules => }/modules.json | 0 e2e/src/fixtures/1.7/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/1.7/{apiOrders => }/order_details.json | 0 .../fixtures/1.7/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/1.7/{apiOrders => }/orders.json | 0 e2e/src/fixtures/1.7/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/1.7/{apiProducts => }/products.json | 0 e2e/src/fixtures/1.7/{apiInfo => }/shops.json | 0 .../fixtures/1.7/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/1.7/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/1.7/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/1.7/{apiStores => }/stores.json | 0 e2e/src/fixtures/1.7/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/1.7/{apiThemes => }/themes.json | 0 e2e/src/fixtures/8/{apiProducts => }/bundles.json | 0 e2e/src/fixtures/8/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/8/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/8/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/8/{apiCarts => }/carts.json | 0 e2e/src/fixtures/8/{apiCategories => }/categories.json | 0 e2e/src/fixtures/8/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/8/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/8/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/8/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/8/{apiImages => }/images.json | 0 e2e/src/fixtures/8/{apiLanguages => }/languages.json | 0 e2e/src/fixtures/8/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/8/{apiModules => }/modules.json | 0 e2e/src/fixtures/8/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/8/{apiOrders => }/order_details.json | 0 e2e/src/fixtures/8/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/8/{apiOrders => }/orders.json | 0 e2e/src/fixtures/8/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/8/{apiProducts => }/products.json | 0 e2e/src/fixtures/8/{apiInfo => }/shops.json | 0 .../fixtures/8/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/8/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/8/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/8/{apiStores => }/stores.json | 0 e2e/src/fixtures/8/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/8/{apiThemes => }/themes.json | 0 e2e/src/fixtures/9/{apiCarriers => }/carrier_details.json | 0 e2e/src/fixtures/9/{apiCarriers => }/carriers.json | 0 e2e/src/fixtures/9/{apiCarts => }/cart_products.json | 0 e2e/src/fixtures/9/{apiCarts => }/carts.json | 0 e2e/src/fixtures/9/{apiCategories => }/categories.json | 0 e2e/src/fixtures/9/{apiCurrencies => }/currencies.json | 0 e2e/src/fixtures/9/{apiCustomers => }/customers.json | 0 e2e/src/fixtures/9/{apiEmployees => }/employees.json | 0 e2e/src/fixtures/9/{apiImageTypes => }/image_types.json | 0 e2e/src/fixtures/9/{apiImages => }/images.json | 0 e2e/src/fixtures/9/{apiLanguages => }/languages.json | 0 e2e/src/fixtures/9/{apiManufacturers => }/manufacturers.json | 0 e2e/src/fixtures/9/{apiModules => }/modules.json | 0 e2e/src/fixtures/9/{apiOrders => }/order_cart_rules.json | 0 e2e/src/fixtures/9/{apiOrders => }/order_details.json | 0 e2e/src/fixtures/9/{apiOrders => }/order_status_history.json | 0 e2e/src/fixtures/9/{apiOrders => }/orders.json | 0 .../9/{apiProducts/bundles.json => product_bundles.json} | 0 e2e/src/fixtures/9/{apiProducts => }/product_suppliers.json | 0 e2e/src/fixtures/9/{apiProducts => }/products.json | 0 e2e/src/fixtures/9/{apiInfo => }/shops.json | 0 .../fixtures/9/{apiSpecificPrices => }/specific_prices.json | 0 e2e/src/fixtures/9/{apiStocks => }/stock_movements.json | 0 e2e/src/fixtures/9/{apiStocks => }/stocks.json | 0 e2e/src/fixtures/9/{apiStores => }/stores.json | 0 e2e/src/fixtures/9/{apiSuppliers => }/suppliers.json | 0 e2e/src/fixtures/9/{apiThemes => }/themes.json | 0 e2e/src/helpers/data-helper.ts | 2 +- 111 files changed, 4 insertions(+), 4 deletions(-) rename e2e/src/fixtures/1.6/{apiProducts => }/bundles.json (100%) rename e2e/src/fixtures/1.6/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/1.6/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/1.6/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/1.6/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/1.6/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/1.6/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/1.6/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/1.6/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/1.6/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/1.6/{apiImages => }/images.json (100%) rename e2e/src/fixtures/1.6/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/1.6/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/1.6/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/1.6/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/1.6/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/1.6/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/1.6/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/1.6/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/1.6/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/1.6/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/1.6/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/1.6/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/1.6/{apiThemes => }/themes.json (100%) rename e2e/src/fixtures/1.7/{apiProducts => }/bundles.json (100%) rename e2e/src/fixtures/1.7/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/1.7/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/1.7/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/1.7/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/1.7/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/1.7/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/1.7/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/1.7/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/1.7/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/1.7/{apiImages => }/images.json (100%) rename e2e/src/fixtures/1.7/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/1.7/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/1.7/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/1.7/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/1.7/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/1.7/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/1.7/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/1.7/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/1.7/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/1.7/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/1.7/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/1.7/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/1.7/{apiThemes => }/themes.json (100%) rename e2e/src/fixtures/8/{apiProducts => }/bundles.json (100%) rename e2e/src/fixtures/8/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/8/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/8/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/8/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/8/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/8/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/8/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/8/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/8/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/8/{apiImages => }/images.json (100%) rename e2e/src/fixtures/8/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/8/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/8/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/8/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/8/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/8/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/8/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/8/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/8/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/8/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/8/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/8/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/8/{apiThemes => }/themes.json (100%) rename e2e/src/fixtures/9/{apiCarriers => }/carrier_details.json (100%) rename e2e/src/fixtures/9/{apiCarriers => }/carriers.json (100%) rename e2e/src/fixtures/9/{apiCarts => }/cart_products.json (100%) rename e2e/src/fixtures/9/{apiCarts => }/carts.json (100%) rename e2e/src/fixtures/9/{apiCategories => }/categories.json (100%) rename e2e/src/fixtures/9/{apiCurrencies => }/currencies.json (100%) rename e2e/src/fixtures/9/{apiCustomers => }/customers.json (100%) rename e2e/src/fixtures/9/{apiEmployees => }/employees.json (100%) rename e2e/src/fixtures/9/{apiImageTypes => }/image_types.json (100%) rename e2e/src/fixtures/9/{apiImages => }/images.json (100%) rename e2e/src/fixtures/9/{apiLanguages => }/languages.json (100%) rename e2e/src/fixtures/9/{apiManufacturers => }/manufacturers.json (100%) rename e2e/src/fixtures/9/{apiModules => }/modules.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/order_cart_rules.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/order_details.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/order_status_history.json (100%) rename e2e/src/fixtures/9/{apiOrders => }/orders.json (100%) rename e2e/src/fixtures/9/{apiProducts/bundles.json => product_bundles.json} (100%) rename e2e/src/fixtures/9/{apiProducts => }/product_suppliers.json (100%) rename e2e/src/fixtures/9/{apiProducts => }/products.json (100%) rename e2e/src/fixtures/9/{apiInfo => }/shops.json (100%) rename e2e/src/fixtures/9/{apiSpecificPrices => }/specific_prices.json (100%) rename e2e/src/fixtures/9/{apiStocks => }/stock_movements.json (100%) rename e2e/src/fixtures/9/{apiStocks => }/stocks.json (100%) rename e2e/src/fixtures/9/{apiStores => }/stores.json (100%) rename e2e/src/fixtures/9/{apiSuppliers => }/suppliers.json (100%) rename e2e/src/fixtures/9/{apiThemes => }/themes.json (100%) diff --git a/README.md b/README.md index a55ea0f4..ac254564 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ To check the module healthiness (authentified route): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-stuff" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-stuff" | jq . { "prestashop_version": "1.6.1.24", "ps_eventbus_version": "0.0.0", @@ -66,7 +66,7 @@ To check the fallback route (unauthentified): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck" | jq . { "ps_account": true, "is_valid_jwt": true, diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index 32721fdd..155c0af7 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -12,7 +12,7 @@ services: "-sI", "-H", "Host: localhost:8000", - "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck", + "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck", ] interval: 30s volumes: diff --git a/e2e/src/fixtures/1.6/apiProducts/bundles.json b/e2e/src/fixtures/1.6/bundles.json similarity index 100% rename from e2e/src/fixtures/1.6/apiProducts/bundles.json rename to e2e/src/fixtures/1.6/bundles.json diff --git a/e2e/src/fixtures/1.6/apiCarriers/carrier_details.json b/e2e/src/fixtures/1.6/carrier_details.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarriers/carrier_details.json rename to e2e/src/fixtures/1.6/carrier_details.json diff --git a/e2e/src/fixtures/1.6/apiCarriers/carriers.json b/e2e/src/fixtures/1.6/carriers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarriers/carriers.json rename to e2e/src/fixtures/1.6/carriers.json diff --git a/e2e/src/fixtures/1.6/apiCarts/cart_products.json b/e2e/src/fixtures/1.6/cart_products.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarts/cart_products.json rename to e2e/src/fixtures/1.6/cart_products.json diff --git a/e2e/src/fixtures/1.6/apiCarts/carts.json b/e2e/src/fixtures/1.6/carts.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCarts/carts.json rename to e2e/src/fixtures/1.6/carts.json diff --git a/e2e/src/fixtures/1.6/apiCategories/categories.json b/e2e/src/fixtures/1.6/categories.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCategories/categories.json rename to e2e/src/fixtures/1.6/categories.json diff --git a/e2e/src/fixtures/1.6/apiCurrencies/currencies.json b/e2e/src/fixtures/1.6/currencies.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCurrencies/currencies.json rename to e2e/src/fixtures/1.6/currencies.json diff --git a/e2e/src/fixtures/1.6/apiCustomers/customers.json b/e2e/src/fixtures/1.6/customers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiCustomers/customers.json rename to e2e/src/fixtures/1.6/customers.json diff --git a/e2e/src/fixtures/1.6/apiEmployees/employees.json b/e2e/src/fixtures/1.6/employees.json similarity index 100% rename from e2e/src/fixtures/1.6/apiEmployees/employees.json rename to e2e/src/fixtures/1.6/employees.json diff --git a/e2e/src/fixtures/1.6/apiImageTypes/image_types.json b/e2e/src/fixtures/1.6/image_types.json similarity index 100% rename from e2e/src/fixtures/1.6/apiImageTypes/image_types.json rename to e2e/src/fixtures/1.6/image_types.json diff --git a/e2e/src/fixtures/1.6/apiImages/images.json b/e2e/src/fixtures/1.6/images.json similarity index 100% rename from e2e/src/fixtures/1.6/apiImages/images.json rename to e2e/src/fixtures/1.6/images.json diff --git a/e2e/src/fixtures/1.6/apiLanguages/languages.json b/e2e/src/fixtures/1.6/languages.json similarity index 100% rename from e2e/src/fixtures/1.6/apiLanguages/languages.json rename to e2e/src/fixtures/1.6/languages.json diff --git a/e2e/src/fixtures/1.6/apiManufacturers/manufacturers.json b/e2e/src/fixtures/1.6/manufacturers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/1.6/manufacturers.json diff --git a/e2e/src/fixtures/1.6/apiModules/modules.json b/e2e/src/fixtures/1.6/modules.json similarity index 100% rename from e2e/src/fixtures/1.6/apiModules/modules.json rename to e2e/src/fixtures/1.6/modules.json diff --git a/e2e/src/fixtures/1.6/apiOrders/order_cart_rules.json b/e2e/src/fixtures/1.6/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/1.6/order_cart_rules.json diff --git a/e2e/src/fixtures/1.6/apiOrders/order_details.json b/e2e/src/fixtures/1.6/order_details.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/order_details.json rename to e2e/src/fixtures/1.6/order_details.json diff --git a/e2e/src/fixtures/1.6/apiOrders/order_status_history.json b/e2e/src/fixtures/1.6/order_status_history.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/order_status_history.json rename to e2e/src/fixtures/1.6/order_status_history.json diff --git a/e2e/src/fixtures/1.6/apiOrders/orders.json b/e2e/src/fixtures/1.6/orders.json similarity index 100% rename from e2e/src/fixtures/1.6/apiOrders/orders.json rename to e2e/src/fixtures/1.6/orders.json diff --git a/e2e/src/fixtures/1.6/apiProducts/product_suppliers.json b/e2e/src/fixtures/1.6/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiProducts/product_suppliers.json rename to e2e/src/fixtures/1.6/product_suppliers.json diff --git a/e2e/src/fixtures/1.6/apiProducts/products.json b/e2e/src/fixtures/1.6/products.json similarity index 100% rename from e2e/src/fixtures/1.6/apiProducts/products.json rename to e2e/src/fixtures/1.6/products.json diff --git a/e2e/src/fixtures/1.6/apiInfo/shops.json b/e2e/src/fixtures/1.6/shops.json similarity index 100% rename from e2e/src/fixtures/1.6/apiInfo/shops.json rename to e2e/src/fixtures/1.6/shops.json diff --git a/e2e/src/fixtures/1.6/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/1.6/specific_prices.json similarity index 100% rename from e2e/src/fixtures/1.6/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/1.6/specific_prices.json diff --git a/e2e/src/fixtures/1.6/apiStocks/stock_movements.json b/e2e/src/fixtures/1.6/stock_movements.json similarity index 100% rename from e2e/src/fixtures/1.6/apiStocks/stock_movements.json rename to e2e/src/fixtures/1.6/stock_movements.json diff --git a/e2e/src/fixtures/1.6/apiStocks/stocks.json b/e2e/src/fixtures/1.6/stocks.json similarity index 100% rename from e2e/src/fixtures/1.6/apiStocks/stocks.json rename to e2e/src/fixtures/1.6/stocks.json diff --git a/e2e/src/fixtures/1.6/apiStores/stores.json b/e2e/src/fixtures/1.6/stores.json similarity index 100% rename from e2e/src/fixtures/1.6/apiStores/stores.json rename to e2e/src/fixtures/1.6/stores.json diff --git a/e2e/src/fixtures/1.6/apiSuppliers/suppliers.json b/e2e/src/fixtures/1.6/suppliers.json similarity index 100% rename from e2e/src/fixtures/1.6/apiSuppliers/suppliers.json rename to e2e/src/fixtures/1.6/suppliers.json diff --git a/e2e/src/fixtures/1.6/apiThemes/themes.json b/e2e/src/fixtures/1.6/themes.json similarity index 100% rename from e2e/src/fixtures/1.6/apiThemes/themes.json rename to e2e/src/fixtures/1.6/themes.json diff --git a/e2e/src/fixtures/1.7/apiProducts/bundles.json b/e2e/src/fixtures/1.7/bundles.json similarity index 100% rename from e2e/src/fixtures/1.7/apiProducts/bundles.json rename to e2e/src/fixtures/1.7/bundles.json diff --git a/e2e/src/fixtures/1.7/apiCarriers/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarriers/carrier_details.json rename to e2e/src/fixtures/1.7/carrier_details.json diff --git a/e2e/src/fixtures/1.7/apiCarriers/carriers.json b/e2e/src/fixtures/1.7/carriers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarriers/carriers.json rename to e2e/src/fixtures/1.7/carriers.json diff --git a/e2e/src/fixtures/1.7/apiCarts/cart_products.json b/e2e/src/fixtures/1.7/cart_products.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarts/cart_products.json rename to e2e/src/fixtures/1.7/cart_products.json diff --git a/e2e/src/fixtures/1.7/apiCarts/carts.json b/e2e/src/fixtures/1.7/carts.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCarts/carts.json rename to e2e/src/fixtures/1.7/carts.json diff --git a/e2e/src/fixtures/1.7/apiCategories/categories.json b/e2e/src/fixtures/1.7/categories.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCategories/categories.json rename to e2e/src/fixtures/1.7/categories.json diff --git a/e2e/src/fixtures/1.7/apiCurrencies/currencies.json b/e2e/src/fixtures/1.7/currencies.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCurrencies/currencies.json rename to e2e/src/fixtures/1.7/currencies.json diff --git a/e2e/src/fixtures/1.7/apiCustomers/customers.json b/e2e/src/fixtures/1.7/customers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiCustomers/customers.json rename to e2e/src/fixtures/1.7/customers.json diff --git a/e2e/src/fixtures/1.7/apiEmployees/employees.json b/e2e/src/fixtures/1.7/employees.json similarity index 100% rename from e2e/src/fixtures/1.7/apiEmployees/employees.json rename to e2e/src/fixtures/1.7/employees.json diff --git a/e2e/src/fixtures/1.7/apiImageTypes/image_types.json b/e2e/src/fixtures/1.7/image_types.json similarity index 100% rename from e2e/src/fixtures/1.7/apiImageTypes/image_types.json rename to e2e/src/fixtures/1.7/image_types.json diff --git a/e2e/src/fixtures/1.7/apiImages/images.json b/e2e/src/fixtures/1.7/images.json similarity index 100% rename from e2e/src/fixtures/1.7/apiImages/images.json rename to e2e/src/fixtures/1.7/images.json diff --git a/e2e/src/fixtures/1.7/apiLanguages/languages.json b/e2e/src/fixtures/1.7/languages.json similarity index 100% rename from e2e/src/fixtures/1.7/apiLanguages/languages.json rename to e2e/src/fixtures/1.7/languages.json diff --git a/e2e/src/fixtures/1.7/apiManufacturers/manufacturers.json b/e2e/src/fixtures/1.7/manufacturers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/1.7/manufacturers.json diff --git a/e2e/src/fixtures/1.7/apiModules/modules.json b/e2e/src/fixtures/1.7/modules.json similarity index 100% rename from e2e/src/fixtures/1.7/apiModules/modules.json rename to e2e/src/fixtures/1.7/modules.json diff --git a/e2e/src/fixtures/1.7/apiOrders/order_cart_rules.json b/e2e/src/fixtures/1.7/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/1.7/order_cart_rules.json diff --git a/e2e/src/fixtures/1.7/apiOrders/order_details.json b/e2e/src/fixtures/1.7/order_details.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/order_details.json rename to e2e/src/fixtures/1.7/order_details.json diff --git a/e2e/src/fixtures/1.7/apiOrders/order_status_history.json b/e2e/src/fixtures/1.7/order_status_history.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/order_status_history.json rename to e2e/src/fixtures/1.7/order_status_history.json diff --git a/e2e/src/fixtures/1.7/apiOrders/orders.json b/e2e/src/fixtures/1.7/orders.json similarity index 100% rename from e2e/src/fixtures/1.7/apiOrders/orders.json rename to e2e/src/fixtures/1.7/orders.json diff --git a/e2e/src/fixtures/1.7/apiProducts/product_suppliers.json b/e2e/src/fixtures/1.7/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiProducts/product_suppliers.json rename to e2e/src/fixtures/1.7/product_suppliers.json diff --git a/e2e/src/fixtures/1.7/apiProducts/products.json b/e2e/src/fixtures/1.7/products.json similarity index 100% rename from e2e/src/fixtures/1.7/apiProducts/products.json rename to e2e/src/fixtures/1.7/products.json diff --git a/e2e/src/fixtures/1.7/apiInfo/shops.json b/e2e/src/fixtures/1.7/shops.json similarity index 100% rename from e2e/src/fixtures/1.7/apiInfo/shops.json rename to e2e/src/fixtures/1.7/shops.json diff --git a/e2e/src/fixtures/1.7/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/1.7/specific_prices.json similarity index 100% rename from e2e/src/fixtures/1.7/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/1.7/specific_prices.json diff --git a/e2e/src/fixtures/1.7/apiStocks/stock_movements.json b/e2e/src/fixtures/1.7/stock_movements.json similarity index 100% rename from e2e/src/fixtures/1.7/apiStocks/stock_movements.json rename to e2e/src/fixtures/1.7/stock_movements.json diff --git a/e2e/src/fixtures/1.7/apiStocks/stocks.json b/e2e/src/fixtures/1.7/stocks.json similarity index 100% rename from e2e/src/fixtures/1.7/apiStocks/stocks.json rename to e2e/src/fixtures/1.7/stocks.json diff --git a/e2e/src/fixtures/1.7/apiStores/stores.json b/e2e/src/fixtures/1.7/stores.json similarity index 100% rename from e2e/src/fixtures/1.7/apiStores/stores.json rename to e2e/src/fixtures/1.7/stores.json diff --git a/e2e/src/fixtures/1.7/apiSuppliers/suppliers.json b/e2e/src/fixtures/1.7/suppliers.json similarity index 100% rename from e2e/src/fixtures/1.7/apiSuppliers/suppliers.json rename to e2e/src/fixtures/1.7/suppliers.json diff --git a/e2e/src/fixtures/1.7/apiThemes/themes.json b/e2e/src/fixtures/1.7/themes.json similarity index 100% rename from e2e/src/fixtures/1.7/apiThemes/themes.json rename to e2e/src/fixtures/1.7/themes.json diff --git a/e2e/src/fixtures/8/apiProducts/bundles.json b/e2e/src/fixtures/8/bundles.json similarity index 100% rename from e2e/src/fixtures/8/apiProducts/bundles.json rename to e2e/src/fixtures/8/bundles.json diff --git a/e2e/src/fixtures/8/apiCarriers/carrier_details.json b/e2e/src/fixtures/8/carrier_details.json similarity index 100% rename from e2e/src/fixtures/8/apiCarriers/carrier_details.json rename to e2e/src/fixtures/8/carrier_details.json diff --git a/e2e/src/fixtures/8/apiCarriers/carriers.json b/e2e/src/fixtures/8/carriers.json similarity index 100% rename from e2e/src/fixtures/8/apiCarriers/carriers.json rename to e2e/src/fixtures/8/carriers.json diff --git a/e2e/src/fixtures/8/apiCarts/cart_products.json b/e2e/src/fixtures/8/cart_products.json similarity index 100% rename from e2e/src/fixtures/8/apiCarts/cart_products.json rename to e2e/src/fixtures/8/cart_products.json diff --git a/e2e/src/fixtures/8/apiCarts/carts.json b/e2e/src/fixtures/8/carts.json similarity index 100% rename from e2e/src/fixtures/8/apiCarts/carts.json rename to e2e/src/fixtures/8/carts.json diff --git a/e2e/src/fixtures/8/apiCategories/categories.json b/e2e/src/fixtures/8/categories.json similarity index 100% rename from e2e/src/fixtures/8/apiCategories/categories.json rename to e2e/src/fixtures/8/categories.json diff --git a/e2e/src/fixtures/8/apiCurrencies/currencies.json b/e2e/src/fixtures/8/currencies.json similarity index 100% rename from e2e/src/fixtures/8/apiCurrencies/currencies.json rename to e2e/src/fixtures/8/currencies.json diff --git a/e2e/src/fixtures/8/apiCustomers/customers.json b/e2e/src/fixtures/8/customers.json similarity index 100% rename from e2e/src/fixtures/8/apiCustomers/customers.json rename to e2e/src/fixtures/8/customers.json diff --git a/e2e/src/fixtures/8/apiEmployees/employees.json b/e2e/src/fixtures/8/employees.json similarity index 100% rename from e2e/src/fixtures/8/apiEmployees/employees.json rename to e2e/src/fixtures/8/employees.json diff --git a/e2e/src/fixtures/8/apiImageTypes/image_types.json b/e2e/src/fixtures/8/image_types.json similarity index 100% rename from e2e/src/fixtures/8/apiImageTypes/image_types.json rename to e2e/src/fixtures/8/image_types.json diff --git a/e2e/src/fixtures/8/apiImages/images.json b/e2e/src/fixtures/8/images.json similarity index 100% rename from e2e/src/fixtures/8/apiImages/images.json rename to e2e/src/fixtures/8/images.json diff --git a/e2e/src/fixtures/8/apiLanguages/languages.json b/e2e/src/fixtures/8/languages.json similarity index 100% rename from e2e/src/fixtures/8/apiLanguages/languages.json rename to e2e/src/fixtures/8/languages.json diff --git a/e2e/src/fixtures/8/apiManufacturers/manufacturers.json b/e2e/src/fixtures/8/manufacturers.json similarity index 100% rename from e2e/src/fixtures/8/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/8/manufacturers.json diff --git a/e2e/src/fixtures/8/apiModules/modules.json b/e2e/src/fixtures/8/modules.json similarity index 100% rename from e2e/src/fixtures/8/apiModules/modules.json rename to e2e/src/fixtures/8/modules.json diff --git a/e2e/src/fixtures/8/apiOrders/order_cart_rules.json b/e2e/src/fixtures/8/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/8/order_cart_rules.json diff --git a/e2e/src/fixtures/8/apiOrders/order_details.json b/e2e/src/fixtures/8/order_details.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/order_details.json rename to e2e/src/fixtures/8/order_details.json diff --git a/e2e/src/fixtures/8/apiOrders/order_status_history.json b/e2e/src/fixtures/8/order_status_history.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/order_status_history.json rename to e2e/src/fixtures/8/order_status_history.json diff --git a/e2e/src/fixtures/8/apiOrders/orders.json b/e2e/src/fixtures/8/orders.json similarity index 100% rename from e2e/src/fixtures/8/apiOrders/orders.json rename to e2e/src/fixtures/8/orders.json diff --git a/e2e/src/fixtures/8/apiProducts/product_suppliers.json b/e2e/src/fixtures/8/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/8/apiProducts/product_suppliers.json rename to e2e/src/fixtures/8/product_suppliers.json diff --git a/e2e/src/fixtures/8/apiProducts/products.json b/e2e/src/fixtures/8/products.json similarity index 100% rename from e2e/src/fixtures/8/apiProducts/products.json rename to e2e/src/fixtures/8/products.json diff --git a/e2e/src/fixtures/8/apiInfo/shops.json b/e2e/src/fixtures/8/shops.json similarity index 100% rename from e2e/src/fixtures/8/apiInfo/shops.json rename to e2e/src/fixtures/8/shops.json diff --git a/e2e/src/fixtures/8/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/8/specific_prices.json similarity index 100% rename from e2e/src/fixtures/8/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/8/specific_prices.json diff --git a/e2e/src/fixtures/8/apiStocks/stock_movements.json b/e2e/src/fixtures/8/stock_movements.json similarity index 100% rename from e2e/src/fixtures/8/apiStocks/stock_movements.json rename to e2e/src/fixtures/8/stock_movements.json diff --git a/e2e/src/fixtures/8/apiStocks/stocks.json b/e2e/src/fixtures/8/stocks.json similarity index 100% rename from e2e/src/fixtures/8/apiStocks/stocks.json rename to e2e/src/fixtures/8/stocks.json diff --git a/e2e/src/fixtures/8/apiStores/stores.json b/e2e/src/fixtures/8/stores.json similarity index 100% rename from e2e/src/fixtures/8/apiStores/stores.json rename to e2e/src/fixtures/8/stores.json diff --git a/e2e/src/fixtures/8/apiSuppliers/suppliers.json b/e2e/src/fixtures/8/suppliers.json similarity index 100% rename from e2e/src/fixtures/8/apiSuppliers/suppliers.json rename to e2e/src/fixtures/8/suppliers.json diff --git a/e2e/src/fixtures/8/apiThemes/themes.json b/e2e/src/fixtures/8/themes.json similarity index 100% rename from e2e/src/fixtures/8/apiThemes/themes.json rename to e2e/src/fixtures/8/themes.json diff --git a/e2e/src/fixtures/9/apiCarriers/carrier_details.json b/e2e/src/fixtures/9/carrier_details.json similarity index 100% rename from e2e/src/fixtures/9/apiCarriers/carrier_details.json rename to e2e/src/fixtures/9/carrier_details.json diff --git a/e2e/src/fixtures/9/apiCarriers/carriers.json b/e2e/src/fixtures/9/carriers.json similarity index 100% rename from e2e/src/fixtures/9/apiCarriers/carriers.json rename to e2e/src/fixtures/9/carriers.json diff --git a/e2e/src/fixtures/9/apiCarts/cart_products.json b/e2e/src/fixtures/9/cart_products.json similarity index 100% rename from e2e/src/fixtures/9/apiCarts/cart_products.json rename to e2e/src/fixtures/9/cart_products.json diff --git a/e2e/src/fixtures/9/apiCarts/carts.json b/e2e/src/fixtures/9/carts.json similarity index 100% rename from e2e/src/fixtures/9/apiCarts/carts.json rename to e2e/src/fixtures/9/carts.json diff --git a/e2e/src/fixtures/9/apiCategories/categories.json b/e2e/src/fixtures/9/categories.json similarity index 100% rename from e2e/src/fixtures/9/apiCategories/categories.json rename to e2e/src/fixtures/9/categories.json diff --git a/e2e/src/fixtures/9/apiCurrencies/currencies.json b/e2e/src/fixtures/9/currencies.json similarity index 100% rename from e2e/src/fixtures/9/apiCurrencies/currencies.json rename to e2e/src/fixtures/9/currencies.json diff --git a/e2e/src/fixtures/9/apiCustomers/customers.json b/e2e/src/fixtures/9/customers.json similarity index 100% rename from e2e/src/fixtures/9/apiCustomers/customers.json rename to e2e/src/fixtures/9/customers.json diff --git a/e2e/src/fixtures/9/apiEmployees/employees.json b/e2e/src/fixtures/9/employees.json similarity index 100% rename from e2e/src/fixtures/9/apiEmployees/employees.json rename to e2e/src/fixtures/9/employees.json diff --git a/e2e/src/fixtures/9/apiImageTypes/image_types.json b/e2e/src/fixtures/9/image_types.json similarity index 100% rename from e2e/src/fixtures/9/apiImageTypes/image_types.json rename to e2e/src/fixtures/9/image_types.json diff --git a/e2e/src/fixtures/9/apiImages/images.json b/e2e/src/fixtures/9/images.json similarity index 100% rename from e2e/src/fixtures/9/apiImages/images.json rename to e2e/src/fixtures/9/images.json diff --git a/e2e/src/fixtures/9/apiLanguages/languages.json b/e2e/src/fixtures/9/languages.json similarity index 100% rename from e2e/src/fixtures/9/apiLanguages/languages.json rename to e2e/src/fixtures/9/languages.json diff --git a/e2e/src/fixtures/9/apiManufacturers/manufacturers.json b/e2e/src/fixtures/9/manufacturers.json similarity index 100% rename from e2e/src/fixtures/9/apiManufacturers/manufacturers.json rename to e2e/src/fixtures/9/manufacturers.json diff --git a/e2e/src/fixtures/9/apiModules/modules.json b/e2e/src/fixtures/9/modules.json similarity index 100% rename from e2e/src/fixtures/9/apiModules/modules.json rename to e2e/src/fixtures/9/modules.json diff --git a/e2e/src/fixtures/9/apiOrders/order_cart_rules.json b/e2e/src/fixtures/9/order_cart_rules.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/order_cart_rules.json rename to e2e/src/fixtures/9/order_cart_rules.json diff --git a/e2e/src/fixtures/9/apiOrders/order_details.json b/e2e/src/fixtures/9/order_details.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/order_details.json rename to e2e/src/fixtures/9/order_details.json diff --git a/e2e/src/fixtures/9/apiOrders/order_status_history.json b/e2e/src/fixtures/9/order_status_history.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/order_status_history.json rename to e2e/src/fixtures/9/order_status_history.json diff --git a/e2e/src/fixtures/9/apiOrders/orders.json b/e2e/src/fixtures/9/orders.json similarity index 100% rename from e2e/src/fixtures/9/apiOrders/orders.json rename to e2e/src/fixtures/9/orders.json diff --git a/e2e/src/fixtures/9/apiProducts/bundles.json b/e2e/src/fixtures/9/product_bundles.json similarity index 100% rename from e2e/src/fixtures/9/apiProducts/bundles.json rename to e2e/src/fixtures/9/product_bundles.json diff --git a/e2e/src/fixtures/9/apiProducts/product_suppliers.json b/e2e/src/fixtures/9/product_suppliers.json similarity index 100% rename from e2e/src/fixtures/9/apiProducts/product_suppliers.json rename to e2e/src/fixtures/9/product_suppliers.json diff --git a/e2e/src/fixtures/9/apiProducts/products.json b/e2e/src/fixtures/9/products.json similarity index 100% rename from e2e/src/fixtures/9/apiProducts/products.json rename to e2e/src/fixtures/9/products.json diff --git a/e2e/src/fixtures/9/apiInfo/shops.json b/e2e/src/fixtures/9/shops.json similarity index 100% rename from e2e/src/fixtures/9/apiInfo/shops.json rename to e2e/src/fixtures/9/shops.json diff --git a/e2e/src/fixtures/9/apiSpecificPrices/specific_prices.json b/e2e/src/fixtures/9/specific_prices.json similarity index 100% rename from e2e/src/fixtures/9/apiSpecificPrices/specific_prices.json rename to e2e/src/fixtures/9/specific_prices.json diff --git a/e2e/src/fixtures/9/apiStocks/stock_movements.json b/e2e/src/fixtures/9/stock_movements.json similarity index 100% rename from e2e/src/fixtures/9/apiStocks/stock_movements.json rename to e2e/src/fixtures/9/stock_movements.json diff --git a/e2e/src/fixtures/9/apiStocks/stocks.json b/e2e/src/fixtures/9/stocks.json similarity index 100% rename from e2e/src/fixtures/9/apiStocks/stocks.json rename to e2e/src/fixtures/9/stocks.json diff --git a/e2e/src/fixtures/9/apiStores/stores.json b/e2e/src/fixtures/9/stores.json similarity index 100% rename from e2e/src/fixtures/9/apiStores/stores.json rename to e2e/src/fixtures/9/stores.json diff --git a/e2e/src/fixtures/9/apiSuppliers/suppliers.json b/e2e/src/fixtures/9/suppliers.json similarity index 100% rename from e2e/src/fixtures/9/apiSuppliers/suppliers.json rename to e2e/src/fixtures/9/suppliers.json diff --git a/e2e/src/fixtures/9/apiThemes/themes.json b/e2e/src/fixtures/9/themes.json similarity index 100% rename from e2e/src/fixtures/9/apiThemes/themes.json rename to e2e/src/fixtures/9/themes.json diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 75cc60f8..04cae9fc 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -95,7 +95,7 @@ export async function loadFixture( const files = contents.map((content) => fs.promises.readFile( - `${FIXTURE_DIR}/${useFixture}/${shopContent}/${content}.json`, + `${FIXTURE_DIR}/${useFixture}/${content}.json`, "utf-8" ) ); From 44066b0b3e5d30b0616d49f7a2f1ebcd1800072e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 14:14:58 +0200 Subject: [PATCH 054/162] fix: rename json dump --- e2e/src/fixtures/1.6/{bundles.json => product_bundles.json} | 0 e2e/src/fixtures/1.7/{bundles.json => product_bundles.json} | 0 e2e/src/fixtures/8/{bundles.json => product_bundles.json} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename e2e/src/fixtures/1.6/{bundles.json => product_bundles.json} (100%) rename e2e/src/fixtures/1.7/{bundles.json => product_bundles.json} (100%) rename e2e/src/fixtures/8/{bundles.json => product_bundles.json} (100%) diff --git a/e2e/src/fixtures/1.6/bundles.json b/e2e/src/fixtures/1.6/product_bundles.json similarity index 100% rename from e2e/src/fixtures/1.6/bundles.json rename to e2e/src/fixtures/1.6/product_bundles.json diff --git a/e2e/src/fixtures/1.7/bundles.json b/e2e/src/fixtures/1.7/product_bundles.json similarity index 100% rename from e2e/src/fixtures/1.7/bundles.json rename to e2e/src/fixtures/1.7/product_bundles.json diff --git a/e2e/src/fixtures/8/bundles.json b/e2e/src/fixtures/8/product_bundles.json similarity index 100% rename from e2e/src/fixtures/8/bundles.json rename to e2e/src/fixtures/8/product_bundles.json From 245916885e29075cda6dd0bf0f6466f79085f9b6 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 8 Aug 2024 15:30:02 +0200 Subject: [PATCH 055/162] fix: bug e2e --- e2e/src/full-sync.spec.ts | 2 +- e2e/src/helpers/log-helper.ts | 8 +++++++- src/Service/FrontApiService.php | 5 +++-- src/Service/SynchronizationService.php | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 77faa06e..737ecd94 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -187,7 +187,7 @@ describe('Full Sync', () => { toArray() ) ); - console.log('test', testConfig.dumpFullSyncData); + // dump data for easier debugging or updating fixtures if (testConfig.dumpFullSyncData) { await dumpUploadData(syncedData, shopContent); diff --git a/e2e/src/helpers/log-helper.ts b/e2e/src/helpers/log-helper.ts index 917216db..dd88a31b 100644 --- a/e2e/src/helpers/log-helper.ts +++ b/e2e/src/helpers/log-helper.ts @@ -7,7 +7,13 @@ import {getShopHealthCheck} from "./data-helper"; export function logAxiosError(err: Error) { if(err instanceof AxiosError) { - console.log(R.pick(['status', 'statusText' ,'data',], err.response)) + const data = { + + ...R.pick(['url'], err.response.config), + ...R.pick(['status', 'statusText' ,'data'], err.response) + } + + console.log(data) } } diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index ddec1fa0..5829a4a4 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -2,6 +2,8 @@ namespace PrestaShop\Module\PsEventbus\Service; +use Behat\Behat\HelperContainer\Exception\ServiceNotFoundException; +use Exception; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Exception\FirebaseException; @@ -178,8 +180,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, CommonService::exitWithExceptionMessage($exception); } catch (\Exception $exception) { $this->errorHandler->handle($exception); - - CommonService::dieWithResponse(['message' => 'An error occured. Please check logs for more information'], 500); + CommonService::dieWithResponse(['message' => 'An error occured. Please check shop logs for more information'], 500); } } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index b0d7718b..e6285c33 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -94,7 +94,7 @@ public function sendFullSync( $module = \Module::getInstanceByName('ps_eventbus'); if (!$module->hasService($serviceId)) { - throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + throw new ServiceNotFoundException($serviceId); } /** @var ShopContentServiceInterface $shopContentApiService */ @@ -159,7 +159,7 @@ public function sendIncrementalSync( $module = \Module::getInstanceByName('ps_eventbus'); if (!$module->hasService($serviceId)) { - throw new ServiceNotFoundException('Service ' . $serviceName . 'doesn\'t exist !', $serviceId); + throw new ServiceNotFoundException($serviceId); } /** @var ShopContentServiceInterface $shopContentApiService */ From 25aeca4d9f36281e4522f5f8060a5978f2098930 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 26 Aug 2024 10:58:15 +0200 Subject: [PATCH 056/162] fix: common problems --- controllers/front/apiFront.php | 5 ++++- e2e/jest.config.json | 3 ++- e2e/src/helpers/shop-contents.ts | 6 +++--- src/Config/Config.php | 12 ++++++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 01c07340..969d8058 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -35,6 +35,9 @@ public function postProcess() /** @var FrontApiService $frontApiService */ $frontApiService = $module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); - $frontApiService->handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug); + // edit shopContent for matching Config.php const + $shopContentEdited = str_replace('-', '_', $shopContent); + + $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $isFull, $debug); } } diff --git a/e2e/jest.config.json b/e2e/jest.config.json index 5699c0ce..0effbacc 100644 --- a/e2e/jest.config.json +++ b/e2e/jest.config.json @@ -10,5 +10,6 @@ "testEnvironment": "node", "moduleNameMapper": { "^@/(.*)$": "/$1" - } + }, + "verbose": true } diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 37bbbd9b..abd72f5b 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -2,7 +2,7 @@ import R from "ramda"; export const shopContentMapping = { 'carriers': 'carriers', - 'carrier_details': 'carriers-details', + 'carrier_details': 'carrier-details', 'carts' : 'carts', 'cart_products': 'carts', 'cart_rules' : 'cart-rules', @@ -25,10 +25,10 @@ export const shopContentMapping = { 'wishlists': 'wishlists', 'wishlist_products': 'wishlist-products', 'stocks': 'stocks', - 'stock_movements': 'stock_movements', + 'stock_movements': 'stock-movements', 'manufacturers': 'manufacturers', 'suppliers': 'suppliers', - 'product_suppliers': 'product_suppliers', + 'product_suppliers': 'product-suppliers', 'languages': 'languages', 'employees': 'employees', 'translations': 'translations', diff --git a/src/Config/Config.php b/src/Config/Config.php index 15848fd8..41a8744b 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -32,8 +32,8 @@ class Config self::PS_ACCOUNTS_NOT_INSTALLED => 'PsAccounts not installed', ]; - const COLLECTION_BUNDLES = 'bundles'; const COLLECTION_CARRIERS = 'carriers'; + const COLLECTION_CARRIER_DETAILS = 'carrier_details'; const COLLECTION_CARTS = 'carts'; const COLLECTION_CART_PRODUCTS = 'cart_products'; const COLLECTION_CART_RULES = 'cart_rules'; @@ -46,15 +46,17 @@ class Config const COLLECTION_HEALTHCHECK = 'healthcheck'; const COLLECTION_IMAGES = 'images'; const COLLECTION_IMAGE_TYPES = 'image_types'; + const COLLECTION_INFO = 'info'; const COLLECTION_LANGUAGES = 'languages'; const COLLECTION_MANUFACTURERS = 'manufacturers'; const COLLECTION_MODULES = 'modules'; const COLLECTION_ORDERS = 'orders'; const COLLECTION_ORDER_CART_RULES = 'order_cart_rules'; const COLLECTION_ORDER_DETAILS = 'order_details'; - const COLLECTION_ORDER_STATUS_HISTORY = 'order_status_history'; + const COLLECTION_ORDER_STATUS_HISTORIES = 'order_status_histories'; const COLLECTION_PRODUCTS = 'products'; const COLLECTION_PRODUCT_ATTRIBUTES = 'attributes'; + const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; const COLLECTION_SHOPS = 'shops'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; @@ -69,8 +71,8 @@ class Config const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; const SHOP_CONTENTS = [ - self::COLLECTION_BUNDLES, self::COLLECTION_CARRIERS, + self::COLLECTION_CARRIER_DETAILS, self::COLLECTION_CARTS, self::COLLECTION_CART_PRODUCTS, self::COLLECTION_CART_RULES, @@ -82,15 +84,17 @@ class Config self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, + self::COLLECTION_INFO, self::COLLECTION_LANGUAGES, self::COLLECTION_MANUFACTURERS, self::COLLECTION_MODULES, self::COLLECTION_ORDERS, self::COLLECTION_ORDER_CART_RULES, self::COLLECTION_ORDER_DETAILS, - self::COLLECTION_ORDER_STATUS_HISTORY, + self::COLLECTION_ORDER_STATUS_HISTORIES, self::COLLECTION_PRODUCTS, self::COLLECTION_PRODUCT_ATTRIBUTES, + self::COLLECTION_PRODUCT_BUNDLES, self::COLLECTION_PRODUCT_SUPPLIERS, self::COLLECTION_SHOPS, self::COLLECTION_SPECIFIC_PRICES, From 5117b4b58aee4005784c90b59153b6ab82c81e08 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 27 Aug 2024 10:07:42 +0200 Subject: [PATCH 057/162] fix: phpcs-fixer and phpstan --- src/Decorator/ProductDecorator.php | 2 +- src/Service/FrontApiService.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Decorator/ProductDecorator.php b/src/Decorator/ProductDecorator.php index d63fbd90..89a33761 100644 --- a/src/Decorator/ProductDecorator.php +++ b/src/Decorator/ProductDecorator.php @@ -165,7 +165,7 @@ private function getBundleCollection($product) return array_map(function ($bundleProduct) use ($uniqueProductId) { return [ 'id' => $bundleProduct['id_bundle'], - 'collection' => Config::COLLECTION_BUNDLES, + 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, 'properties' => [ 'id_bundle' => $bundleProduct['id_bundle'], 'id_product' => $bundleProduct['id_product'], diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 5829a4a4..1f240050 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -2,8 +2,6 @@ namespace PrestaShop\Module\PsEventbus\Service; -use Behat\Behat\HelperContainer\Exception\ServiceNotFoundException; -use Exception; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Exception\FirebaseException; From 01fed977741a8920569e5e4827cd1785682499c6 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 27 Aug 2024 15:19:29 +0200 Subject: [PATCH 058/162] fix: autoload --- ps_eventbus.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ps_eventbus.php b/ps_eventbus.php index 4d12eb6c..d2a42027 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -33,6 +33,8 @@ exit; } +require_once __DIR__ . '/vendor/autoload.php'; + class Ps_eventbus extends Module { // All hooks is here @@ -123,8 +125,6 @@ public function __construct() return; } - require_once __DIR__ . '/vendor/autoload.php'; - if ($this->context->shop === null) { throw new PrestaShopException('No shop context'); } From 5366fcd6e485c67dcd3951b866f87f8df4dda70e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 27 Aug 2024 15:57:17 +0200 Subject: [PATCH 059/162] fix: rename ordersRepository to orderRepository --- config/common/provider.yml | 2 +- config/common/repository.yml | 4 ++-- config/front/services.yml | 2 +- ...{OrdersRepository.php => OrderRepository.php} | 2 +- src/Service/ShopContent/OrdersService.php | 16 ++++++++-------- 5 files changed, 13 insertions(+), 13 deletions(-) rename src/Repository/{OrdersRepository.php => OrderRepository.php} (98%) diff --git a/config/common/provider.yml b/config/common/provider.yml index 1e1a6628..ff0694e7 100644 --- a/config/common/provider.yml +++ b/config/common/provider.yml @@ -48,7 +48,7 @@ services: public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' diff --git a/config/common/repository.yml b/config/common/repository.yml index 29b84a81..52eab365 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -68,8 +68,8 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\OrdersRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrdersRepository + PrestaShop\Module\PsEventbus\Repository\OrderRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderRepository public: true PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository: diff --git a/config/front/services.yml b/config/front/services.yml index fdc84893..94792527 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -57,6 +57,6 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\OrdersRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' diff --git a/src/Repository/OrdersRepository.php b/src/Repository/OrderRepository.php similarity index 98% rename from src/Repository/OrdersRepository.php rename to src/Repository/OrderRepository.php index 8a2d391a..3b39d645 100644 --- a/src/Repository/OrdersRepository.php +++ b/src/Repository/OrderRepository.php @@ -4,7 +4,7 @@ use PrestaShop\Module\PsEventbus\Interfaces\RepositoryInterface; -class OrdersRepository extends AbstractRepository implements RepositoryInterface +class OrderRepository extends AbstractRepository implements RepositoryInterface { const ORDERS_TABLE = 'orders'; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 255298e3..6855eb6d 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -6,12 +6,12 @@ use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; -use PrestaShop\Module\PsEventbus\Repository\OrdersRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderRepository; class OrdersService implements ShopContentServiceInterface { - /** @var OrdersRepository */ - private $ordersRepository; + /** @var OrderRepository */ + private $orderRepository; /** @var OrderHistoryRepository */ private $orderHistoryRepository; @@ -20,11 +20,11 @@ class OrdersService implements ShopContentServiceInterface private $arrayFormatter; public function __construct( - OrdersRepository $ordersRepository, + OrderRepository $orderRepository, OrderHistoryRepository $orderHistoryRepository, ArrayFormatter $arrayFormatter ) { - $this->ordersRepository = $ordersRepository; + $this->orderRepository = $orderRepository; $this->orderHistoryRepository = $orderHistoryRepository; $this->arrayFormatter = $arrayFormatter; } @@ -39,7 +39,7 @@ public function __construct( */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $orders = $this->ordersRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $orders = $this->orderRepository->getContentsForFull($offset, $limit, $langIso, $debug); if (empty($orders)) { return []; @@ -66,7 +66,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $orders = $this->ordersRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $orders = $this->orderRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($orders)) { return []; @@ -92,7 +92,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) */ public function countFullSyncContentLeft($offset, $langIso, $debug) { - return (int) $this->ordersRepository->countFullSyncContentLeft($offset, $langIso, $debug); + return (int) $this->orderRepository->countFullSyncContentLeft($offset, $langIso, $debug); } /** From cd741119a6af54618d85f0b6c018a5c6df6439fa Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 29 Aug 2024 09:57:51 +0200 Subject: [PATCH 060/162] chore: move old file for clearly visualisation of code --- {src => OLD}/Provider/CarrierDataProvider.php | 0 {src => OLD}/Provider/CartDataProvider.php | 0 .../Provider/CartRuleDataProvider.php | 0 .../Provider/CategoryDataProvider.php | 0 .../Provider/CurrencyDataProvider.php | 0 .../Provider/CustomPriceDataProvider.php | 0 .../CustomProductCarrierDataProvider.php | 0 .../Provider/CustomerDataProvider.php | 0 .../Provider/EmployeeDataProvider.php | 0 .../Provider/GoogleTaxonomyDataProvider.php | 0 {src => OLD}/Provider/ImageDataProvider.php | 0 .../Provider/ImageTypeDataProvider.php | 0 .../Provider/LanguageDataProvider.php | 0 .../Provider/ManufacturerDataProvider.php | 0 {src => OLD}/Provider/ModuleDataProvider.php | 0 .../PaginatedApiDataProviderInterface.php | 0 {src => OLD}/Provider/ProductDataProvider.php | 0 .../Provider/ProductSupplierDataProvider.php | 0 {src => OLD}/Provider/StockDataProvider.php | 0 {src => OLD}/Provider/StoreDataProvider.php | 0 .../Provider/SupplierDataProvider.php | 0 .../Provider/TranslationDataProvider.php | 0 .../Provider/WishlistDataProvider.php | 0 {src => OLD}/Repository/BundleRepository.php | 0 {src => OLD}/Repository/CarrierRepository.php | 0 .../Repository/CartProductRepository.php | 0 {src => OLD}/Repository/CartRepository.php | 0 .../Repository/CartRuleRepository.php | 0 .../Repository/CategoryRepository.php | 0 .../Repository/ConfigurationRepository.php | 0 {src => OLD}/Repository/CountryRepository.php | 0 .../Repository/CurrencyRepository.php | 0 .../Repository/CustomPriceRepository.php | 0 .../Repository/CustomerRepository.php | 0 .../Repository/DeletedObjectsRepository.php | 0 .../Repository/EmployeeRepository.php | 0 .../Repository/EventbusSyncRepository.php | 0 .../Repository/GoogleTaxonomyRepository.php | 0 {src => OLD}/Repository/ImageRepository.php | 0 .../Repository/ImageTypeRepository.php | 0 .../Repository/IncrementalSyncRepository.php | 0 .../Repository/LanguageRepository.php | 0 .../Repository/LiveSyncRepository.php | 0 .../Repository/ManufacturerRepository.php | 0 {src => OLD}/Repository/ModuleRepository.php | 0 .../Repository/OrderCartRuleRepository.php | 0 .../Repository/OrderDetailsRepository.php | 0 .../Repository/OrderHistoryRepository.php | 0 .../Repository/ProductCarrierRepository.php | 0 {src => OLD}/Repository/ProductRepository.php | 0 .../Repository/ProductSupplierRepository.php | 0 .../ServerInformationRepository.php | 0 {src => OLD}/Repository/ShopRepository.php | 0 .../Repository/SpecificPriceRepository.php | 0 {src => OLD}/Repository/StateRepository.php | 0 .../Repository/StockMvtRepository.php | 0 {src => OLD}/Repository/StockRepository.php | 0 {src => OLD}/Repository/StoreRepository.php | 0 .../Repository/SupplierRepository.php | 0 {src => OLD}/Repository/TaxRepository.php | 0 {src => OLD}/Repository/ThemeRepository.php | 0 .../Repository/TranslationRepository.php | 0 .../Repository/WishlistProductRepository.php | 0 .../Repository/WishlistRepository.php | 0 config/common/provider.yml | 172 ------------------ config/front/services.yml | 1 - 66 files changed, 173 deletions(-) rename {src => OLD}/Provider/CarrierDataProvider.php (100%) rename {src => OLD}/Provider/CartDataProvider.php (100%) rename {src => OLD}/Provider/CartRuleDataProvider.php (100%) rename {src => OLD}/Provider/CategoryDataProvider.php (100%) rename {src => OLD}/Provider/CurrencyDataProvider.php (100%) rename {src => OLD}/Provider/CustomPriceDataProvider.php (100%) rename {src => OLD}/Provider/CustomProductCarrierDataProvider.php (100%) rename {src => OLD}/Provider/CustomerDataProvider.php (100%) rename {src => OLD}/Provider/EmployeeDataProvider.php (100%) rename {src => OLD}/Provider/GoogleTaxonomyDataProvider.php (100%) rename {src => OLD}/Provider/ImageDataProvider.php (100%) rename {src => OLD}/Provider/ImageTypeDataProvider.php (100%) rename {src => OLD}/Provider/LanguageDataProvider.php (100%) rename {src => OLD}/Provider/ManufacturerDataProvider.php (100%) rename {src => OLD}/Provider/ModuleDataProvider.php (100%) rename {src => OLD}/Provider/PaginatedApiDataProviderInterface.php (100%) rename {src => OLD}/Provider/ProductDataProvider.php (100%) rename {src => OLD}/Provider/ProductSupplierDataProvider.php (100%) rename {src => OLD}/Provider/StockDataProvider.php (100%) rename {src => OLD}/Provider/StoreDataProvider.php (100%) rename {src => OLD}/Provider/SupplierDataProvider.php (100%) rename {src => OLD}/Provider/TranslationDataProvider.php (100%) rename {src => OLD}/Provider/WishlistDataProvider.php (100%) rename {src => OLD}/Repository/BundleRepository.php (100%) rename {src => OLD}/Repository/CarrierRepository.php (100%) rename {src => OLD}/Repository/CartProductRepository.php (100%) rename {src => OLD}/Repository/CartRepository.php (100%) rename {src => OLD}/Repository/CartRuleRepository.php (100%) rename {src => OLD}/Repository/CategoryRepository.php (100%) rename {src => OLD}/Repository/ConfigurationRepository.php (100%) rename {src => OLD}/Repository/CountryRepository.php (100%) rename {src => OLD}/Repository/CurrencyRepository.php (100%) rename {src => OLD}/Repository/CustomPriceRepository.php (100%) rename {src => OLD}/Repository/CustomerRepository.php (100%) rename {src => OLD}/Repository/DeletedObjectsRepository.php (100%) rename {src => OLD}/Repository/EmployeeRepository.php (100%) rename {src => OLD}/Repository/EventbusSyncRepository.php (100%) rename {src => OLD}/Repository/GoogleTaxonomyRepository.php (100%) rename {src => OLD}/Repository/ImageRepository.php (100%) rename {src => OLD}/Repository/ImageTypeRepository.php (100%) rename {src => OLD}/Repository/IncrementalSyncRepository.php (100%) rename {src => OLD}/Repository/LanguageRepository.php (100%) rename {src => OLD}/Repository/LiveSyncRepository.php (100%) rename {src => OLD}/Repository/ManufacturerRepository.php (100%) rename {src => OLD}/Repository/ModuleRepository.php (100%) rename {src => OLD}/Repository/OrderCartRuleRepository.php (100%) rename {src => OLD}/Repository/OrderDetailsRepository.php (100%) rename {src => OLD}/Repository/OrderHistoryRepository.php (100%) rename {src => OLD}/Repository/ProductCarrierRepository.php (100%) rename {src => OLD}/Repository/ProductRepository.php (100%) rename {src => OLD}/Repository/ProductSupplierRepository.php (100%) rename {src => OLD}/Repository/ServerInformationRepository.php (100%) rename {src => OLD}/Repository/ShopRepository.php (100%) rename {src => OLD}/Repository/SpecificPriceRepository.php (100%) rename {src => OLD}/Repository/StateRepository.php (100%) rename {src => OLD}/Repository/StockMvtRepository.php (100%) rename {src => OLD}/Repository/StockRepository.php (100%) rename {src => OLD}/Repository/StoreRepository.php (100%) rename {src => OLD}/Repository/SupplierRepository.php (100%) rename {src => OLD}/Repository/TaxRepository.php (100%) rename {src => OLD}/Repository/ThemeRepository.php (100%) rename {src => OLD}/Repository/TranslationRepository.php (100%) rename {src => OLD}/Repository/WishlistProductRepository.php (100%) rename {src => OLD}/Repository/WishlistRepository.php (100%) delete mode 100644 config/common/provider.yml diff --git a/src/Provider/CarrierDataProvider.php b/OLD/Provider/CarrierDataProvider.php similarity index 100% rename from src/Provider/CarrierDataProvider.php rename to OLD/Provider/CarrierDataProvider.php diff --git a/src/Provider/CartDataProvider.php b/OLD/Provider/CartDataProvider.php similarity index 100% rename from src/Provider/CartDataProvider.php rename to OLD/Provider/CartDataProvider.php diff --git a/src/Provider/CartRuleDataProvider.php b/OLD/Provider/CartRuleDataProvider.php similarity index 100% rename from src/Provider/CartRuleDataProvider.php rename to OLD/Provider/CartRuleDataProvider.php diff --git a/src/Provider/CategoryDataProvider.php b/OLD/Provider/CategoryDataProvider.php similarity index 100% rename from src/Provider/CategoryDataProvider.php rename to OLD/Provider/CategoryDataProvider.php diff --git a/src/Provider/CurrencyDataProvider.php b/OLD/Provider/CurrencyDataProvider.php similarity index 100% rename from src/Provider/CurrencyDataProvider.php rename to OLD/Provider/CurrencyDataProvider.php diff --git a/src/Provider/CustomPriceDataProvider.php b/OLD/Provider/CustomPriceDataProvider.php similarity index 100% rename from src/Provider/CustomPriceDataProvider.php rename to OLD/Provider/CustomPriceDataProvider.php diff --git a/src/Provider/CustomProductCarrierDataProvider.php b/OLD/Provider/CustomProductCarrierDataProvider.php similarity index 100% rename from src/Provider/CustomProductCarrierDataProvider.php rename to OLD/Provider/CustomProductCarrierDataProvider.php diff --git a/src/Provider/CustomerDataProvider.php b/OLD/Provider/CustomerDataProvider.php similarity index 100% rename from src/Provider/CustomerDataProvider.php rename to OLD/Provider/CustomerDataProvider.php diff --git a/src/Provider/EmployeeDataProvider.php b/OLD/Provider/EmployeeDataProvider.php similarity index 100% rename from src/Provider/EmployeeDataProvider.php rename to OLD/Provider/EmployeeDataProvider.php diff --git a/src/Provider/GoogleTaxonomyDataProvider.php b/OLD/Provider/GoogleTaxonomyDataProvider.php similarity index 100% rename from src/Provider/GoogleTaxonomyDataProvider.php rename to OLD/Provider/GoogleTaxonomyDataProvider.php diff --git a/src/Provider/ImageDataProvider.php b/OLD/Provider/ImageDataProvider.php similarity index 100% rename from src/Provider/ImageDataProvider.php rename to OLD/Provider/ImageDataProvider.php diff --git a/src/Provider/ImageTypeDataProvider.php b/OLD/Provider/ImageTypeDataProvider.php similarity index 100% rename from src/Provider/ImageTypeDataProvider.php rename to OLD/Provider/ImageTypeDataProvider.php diff --git a/src/Provider/LanguageDataProvider.php b/OLD/Provider/LanguageDataProvider.php similarity index 100% rename from src/Provider/LanguageDataProvider.php rename to OLD/Provider/LanguageDataProvider.php diff --git a/src/Provider/ManufacturerDataProvider.php b/OLD/Provider/ManufacturerDataProvider.php similarity index 100% rename from src/Provider/ManufacturerDataProvider.php rename to OLD/Provider/ManufacturerDataProvider.php diff --git a/src/Provider/ModuleDataProvider.php b/OLD/Provider/ModuleDataProvider.php similarity index 100% rename from src/Provider/ModuleDataProvider.php rename to OLD/Provider/ModuleDataProvider.php diff --git a/src/Provider/PaginatedApiDataProviderInterface.php b/OLD/Provider/PaginatedApiDataProviderInterface.php similarity index 100% rename from src/Provider/PaginatedApiDataProviderInterface.php rename to OLD/Provider/PaginatedApiDataProviderInterface.php diff --git a/src/Provider/ProductDataProvider.php b/OLD/Provider/ProductDataProvider.php similarity index 100% rename from src/Provider/ProductDataProvider.php rename to OLD/Provider/ProductDataProvider.php diff --git a/src/Provider/ProductSupplierDataProvider.php b/OLD/Provider/ProductSupplierDataProvider.php similarity index 100% rename from src/Provider/ProductSupplierDataProvider.php rename to OLD/Provider/ProductSupplierDataProvider.php diff --git a/src/Provider/StockDataProvider.php b/OLD/Provider/StockDataProvider.php similarity index 100% rename from src/Provider/StockDataProvider.php rename to OLD/Provider/StockDataProvider.php diff --git a/src/Provider/StoreDataProvider.php b/OLD/Provider/StoreDataProvider.php similarity index 100% rename from src/Provider/StoreDataProvider.php rename to OLD/Provider/StoreDataProvider.php diff --git a/src/Provider/SupplierDataProvider.php b/OLD/Provider/SupplierDataProvider.php similarity index 100% rename from src/Provider/SupplierDataProvider.php rename to OLD/Provider/SupplierDataProvider.php diff --git a/src/Provider/TranslationDataProvider.php b/OLD/Provider/TranslationDataProvider.php similarity index 100% rename from src/Provider/TranslationDataProvider.php rename to OLD/Provider/TranslationDataProvider.php diff --git a/src/Provider/WishlistDataProvider.php b/OLD/Provider/WishlistDataProvider.php similarity index 100% rename from src/Provider/WishlistDataProvider.php rename to OLD/Provider/WishlistDataProvider.php diff --git a/src/Repository/BundleRepository.php b/OLD/Repository/BundleRepository.php similarity index 100% rename from src/Repository/BundleRepository.php rename to OLD/Repository/BundleRepository.php diff --git a/src/Repository/CarrierRepository.php b/OLD/Repository/CarrierRepository.php similarity index 100% rename from src/Repository/CarrierRepository.php rename to OLD/Repository/CarrierRepository.php diff --git a/src/Repository/CartProductRepository.php b/OLD/Repository/CartProductRepository.php similarity index 100% rename from src/Repository/CartProductRepository.php rename to OLD/Repository/CartProductRepository.php diff --git a/src/Repository/CartRepository.php b/OLD/Repository/CartRepository.php similarity index 100% rename from src/Repository/CartRepository.php rename to OLD/Repository/CartRepository.php diff --git a/src/Repository/CartRuleRepository.php b/OLD/Repository/CartRuleRepository.php similarity index 100% rename from src/Repository/CartRuleRepository.php rename to OLD/Repository/CartRuleRepository.php diff --git a/src/Repository/CategoryRepository.php b/OLD/Repository/CategoryRepository.php similarity index 100% rename from src/Repository/CategoryRepository.php rename to OLD/Repository/CategoryRepository.php diff --git a/src/Repository/ConfigurationRepository.php b/OLD/Repository/ConfigurationRepository.php similarity index 100% rename from src/Repository/ConfigurationRepository.php rename to OLD/Repository/ConfigurationRepository.php diff --git a/src/Repository/CountryRepository.php b/OLD/Repository/CountryRepository.php similarity index 100% rename from src/Repository/CountryRepository.php rename to OLD/Repository/CountryRepository.php diff --git a/src/Repository/CurrencyRepository.php b/OLD/Repository/CurrencyRepository.php similarity index 100% rename from src/Repository/CurrencyRepository.php rename to OLD/Repository/CurrencyRepository.php diff --git a/src/Repository/CustomPriceRepository.php b/OLD/Repository/CustomPriceRepository.php similarity index 100% rename from src/Repository/CustomPriceRepository.php rename to OLD/Repository/CustomPriceRepository.php diff --git a/src/Repository/CustomerRepository.php b/OLD/Repository/CustomerRepository.php similarity index 100% rename from src/Repository/CustomerRepository.php rename to OLD/Repository/CustomerRepository.php diff --git a/src/Repository/DeletedObjectsRepository.php b/OLD/Repository/DeletedObjectsRepository.php similarity index 100% rename from src/Repository/DeletedObjectsRepository.php rename to OLD/Repository/DeletedObjectsRepository.php diff --git a/src/Repository/EmployeeRepository.php b/OLD/Repository/EmployeeRepository.php similarity index 100% rename from src/Repository/EmployeeRepository.php rename to OLD/Repository/EmployeeRepository.php diff --git a/src/Repository/EventbusSyncRepository.php b/OLD/Repository/EventbusSyncRepository.php similarity index 100% rename from src/Repository/EventbusSyncRepository.php rename to OLD/Repository/EventbusSyncRepository.php diff --git a/src/Repository/GoogleTaxonomyRepository.php b/OLD/Repository/GoogleTaxonomyRepository.php similarity index 100% rename from src/Repository/GoogleTaxonomyRepository.php rename to OLD/Repository/GoogleTaxonomyRepository.php diff --git a/src/Repository/ImageRepository.php b/OLD/Repository/ImageRepository.php similarity index 100% rename from src/Repository/ImageRepository.php rename to OLD/Repository/ImageRepository.php diff --git a/src/Repository/ImageTypeRepository.php b/OLD/Repository/ImageTypeRepository.php similarity index 100% rename from src/Repository/ImageTypeRepository.php rename to OLD/Repository/ImageTypeRepository.php diff --git a/src/Repository/IncrementalSyncRepository.php b/OLD/Repository/IncrementalSyncRepository.php similarity index 100% rename from src/Repository/IncrementalSyncRepository.php rename to OLD/Repository/IncrementalSyncRepository.php diff --git a/src/Repository/LanguageRepository.php b/OLD/Repository/LanguageRepository.php similarity index 100% rename from src/Repository/LanguageRepository.php rename to OLD/Repository/LanguageRepository.php diff --git a/src/Repository/LiveSyncRepository.php b/OLD/Repository/LiveSyncRepository.php similarity index 100% rename from src/Repository/LiveSyncRepository.php rename to OLD/Repository/LiveSyncRepository.php diff --git a/src/Repository/ManufacturerRepository.php b/OLD/Repository/ManufacturerRepository.php similarity index 100% rename from src/Repository/ManufacturerRepository.php rename to OLD/Repository/ManufacturerRepository.php diff --git a/src/Repository/ModuleRepository.php b/OLD/Repository/ModuleRepository.php similarity index 100% rename from src/Repository/ModuleRepository.php rename to OLD/Repository/ModuleRepository.php diff --git a/src/Repository/OrderCartRuleRepository.php b/OLD/Repository/OrderCartRuleRepository.php similarity index 100% rename from src/Repository/OrderCartRuleRepository.php rename to OLD/Repository/OrderCartRuleRepository.php diff --git a/src/Repository/OrderDetailsRepository.php b/OLD/Repository/OrderDetailsRepository.php similarity index 100% rename from src/Repository/OrderDetailsRepository.php rename to OLD/Repository/OrderDetailsRepository.php diff --git a/src/Repository/OrderHistoryRepository.php b/OLD/Repository/OrderHistoryRepository.php similarity index 100% rename from src/Repository/OrderHistoryRepository.php rename to OLD/Repository/OrderHistoryRepository.php diff --git a/src/Repository/ProductCarrierRepository.php b/OLD/Repository/ProductCarrierRepository.php similarity index 100% rename from src/Repository/ProductCarrierRepository.php rename to OLD/Repository/ProductCarrierRepository.php diff --git a/src/Repository/ProductRepository.php b/OLD/Repository/ProductRepository.php similarity index 100% rename from src/Repository/ProductRepository.php rename to OLD/Repository/ProductRepository.php diff --git a/src/Repository/ProductSupplierRepository.php b/OLD/Repository/ProductSupplierRepository.php similarity index 100% rename from src/Repository/ProductSupplierRepository.php rename to OLD/Repository/ProductSupplierRepository.php diff --git a/src/Repository/ServerInformationRepository.php b/OLD/Repository/ServerInformationRepository.php similarity index 100% rename from src/Repository/ServerInformationRepository.php rename to OLD/Repository/ServerInformationRepository.php diff --git a/src/Repository/ShopRepository.php b/OLD/Repository/ShopRepository.php similarity index 100% rename from src/Repository/ShopRepository.php rename to OLD/Repository/ShopRepository.php diff --git a/src/Repository/SpecificPriceRepository.php b/OLD/Repository/SpecificPriceRepository.php similarity index 100% rename from src/Repository/SpecificPriceRepository.php rename to OLD/Repository/SpecificPriceRepository.php diff --git a/src/Repository/StateRepository.php b/OLD/Repository/StateRepository.php similarity index 100% rename from src/Repository/StateRepository.php rename to OLD/Repository/StateRepository.php diff --git a/src/Repository/StockMvtRepository.php b/OLD/Repository/StockMvtRepository.php similarity index 100% rename from src/Repository/StockMvtRepository.php rename to OLD/Repository/StockMvtRepository.php diff --git a/src/Repository/StockRepository.php b/OLD/Repository/StockRepository.php similarity index 100% rename from src/Repository/StockRepository.php rename to OLD/Repository/StockRepository.php diff --git a/src/Repository/StoreRepository.php b/OLD/Repository/StoreRepository.php similarity index 100% rename from src/Repository/StoreRepository.php rename to OLD/Repository/StoreRepository.php diff --git a/src/Repository/SupplierRepository.php b/OLD/Repository/SupplierRepository.php similarity index 100% rename from src/Repository/SupplierRepository.php rename to OLD/Repository/SupplierRepository.php diff --git a/src/Repository/TaxRepository.php b/OLD/Repository/TaxRepository.php similarity index 100% rename from src/Repository/TaxRepository.php rename to OLD/Repository/TaxRepository.php diff --git a/src/Repository/ThemeRepository.php b/OLD/Repository/ThemeRepository.php similarity index 100% rename from src/Repository/ThemeRepository.php rename to OLD/Repository/ThemeRepository.php diff --git a/src/Repository/TranslationRepository.php b/OLD/Repository/TranslationRepository.php similarity index 100% rename from src/Repository/TranslationRepository.php rename to OLD/Repository/TranslationRepository.php diff --git a/src/Repository/WishlistProductRepository.php b/OLD/Repository/WishlistProductRepository.php similarity index 100% rename from src/Repository/WishlistProductRepository.php rename to OLD/Repository/WishlistProductRepository.php diff --git a/src/Repository/WishlistRepository.php b/OLD/Repository/WishlistRepository.php similarity index 100% rename from src/Repository/WishlistRepository.php rename to OLD/Repository/WishlistRepository.php diff --git a/config/common/provider.yml b/config/common/provider.yml deleted file mode 100644 index ff0694e7..00000000 --- a/config/common/provider.yml +++ /dev/null @@ -1,172 +0,0 @@ -services: - PrestaShop\Module\PsEventbus\Provider\ModuleDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\ModuleDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ModuleRepository' - - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' - - PrestaShop\Module\PsEventbus\Provider\ProductSupplierDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\ProductSupplierDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\ProductSupplierDecorator' - - PrestaShop\Module\PsEventbus\Provider\ProductDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\ProductDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\ProductDecorator' - - '@PrestaShop\Module\PsEventbus\Provider\ProductSupplierDataProvider' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - - PrestaShop\Module\PsEventbus\Provider\CategoryDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CategoryDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\CategoryDecorator' - - PrestaShop\Module\PsEventbus\Provider\CurrencyDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CurrencyDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CurrencyRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\CurrencyDecorator' - - PrestaShop\Module\PsEventbus\Provider\CustomerDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CustomerDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CustomerRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\CustomerDecorator' - - PrestaShop\Module\PsEventbus\Provider\OrderDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\OrderDataProvider - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' - - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository' - - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - - '@PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository' - - PrestaShop\Module\PsEventbus\Provider\CartDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CartDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CartRepository' - - '@PrestaShop\Module\PsEventbus\Repository\CartProductRepository' - - PrestaShop\Module\PsEventbus\Provider\CartRuleDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CartRuleDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CartRuleRepository' - - PrestaShop\Module\PsEventbus\Provider\GoogleTaxonomyDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\GoogleTaxonomyDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository' - - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Provider\CarrierDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CarrierDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsEventbus\Builder\CarrierBuilder' - - '@PrestaShop\Module\PsEventbus\Repository\CarrierRepository' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - - PrestaShop\Module\PsEventbus\Provider\CustomPriceDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CustomPriceDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\CustomPriceDecorator' - - PrestaShop\Module\PsEventbus\Provider\CustomProductCarrierDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\CustomProductCarrierDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository' - - PrestaShop\Module\PsEventbus\Provider\WishlistDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\WishlistDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\WishlistRepository' - - '@PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\WishlistDecorator' - - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - - PrestaShop\Module\PsEventbus\Provider\StoreDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\StoreDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\StoreRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\StoreDecorator' - - PrestaShop\Module\PsEventbus\Provider\StockDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\StockDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\StockRepository' - - '@PrestaShop\Module\PsEventbus\Repository\StockMvtRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\StockDecorator' - - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - - PrestaShop\Module\PsEventbus\Provider\ManufacturerDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\ManufacturerDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\ManufacturerDecorator' - - PrestaShop\Module\PsEventbus\Provider\SupplierDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\SupplierDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\SupplierRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator' - - PrestaShop\Module\PsEventbus\Provider\EmployeeDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\EmployeeDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\EmployeeRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\EmployeeDecorator' - - PrestaShop\Module\PsEventbus\Provider\LanguageDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\LanguageDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\LanguageDecorator' - - PrestaShop\Module\PsEventbus\Provider\ImageDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\ImageDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ImageRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\ImageDecorator' - - PrestaShop\Module\PsEventbus\Provider\ImageTypeDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\ImageTypeDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\ImageTypeDecorator' - - PrestaShop\Module\PsEventbus\Provider\TranslationDataProvider: - class: PrestaShop\Module\PsEventbus\Provider\TranslationDataProvider - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\TranslationRepository' - - '@PrestaShop\Module\PsEventbus\Decorator\TranslationDecorator' - diff --git a/config/front/services.yml b/config/front/services.yml index 94792527..4762076b 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -2,7 +2,6 @@ imports: - { resource: api.yml } - { resource: ../common/common.yml } - { resource: ../common/decorator.yml } - - { resource: ../common/provider.yml } - { resource: ../common/repository.yml } - { resource: ../common/builder.yml } From 973b503cf076768d37e2a8c3fc5f3d9d429cabaf Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 29 Aug 2024 10:05:18 +0200 Subject: [PATCH 061/162] chore: change method for clearly view of code --- config/common/repository.yml | 4 ++-- config/front/services.yml | 2 +- {OLD => src}/Repository/BundleRepository.php | 0 {OLD => src}/Repository/CarrierRepository.php | 0 {OLD => src}/Repository/CartProductRepository.php | 0 {OLD => src}/Repository/CartRepository.php | 0 {OLD => src}/Repository/CartRuleRepository.php | 0 {OLD => src}/Repository/CategoryRepository.php | 0 {OLD => src}/Repository/ConfigurationRepository.php | 0 {OLD => src}/Repository/CountryRepository.php | 0 {OLD => src}/Repository/CurrencyRepository.php | 0 {OLD => src}/Repository/CustomPriceRepository.php | 0 {OLD => src}/Repository/CustomerRepository.php | 0 {OLD => src}/Repository/DeletedObjectsRepository.php | 0 {OLD => src}/Repository/EmployeeRepository.php | 0 {OLD => src}/Repository/EventbusSyncRepository.php | 0 {OLD => src}/Repository/GoogleTaxonomyRepository.php | 0 {OLD => src}/Repository/ImageRepository.php | 0 {OLD => src}/Repository/ImageTypeRepository.php | 0 {OLD => src}/Repository/IncrementalSyncRepository.php | 0 {OLD => src}/Repository/LanguageRepository.php | 0 {OLD => src}/Repository/LiveSyncRepository.php | 0 {OLD => src}/Repository/ManufacturerRepository.php | 0 {OLD => src}/Repository/ModuleRepository.php | 0 src/Repository/{ => NewRepositoryTemp}/AbstractRepository.php | 2 +- src/Repository/{ => NewRepositoryTemp}/OrderRepository.php | 3 ++- {OLD => src}/Repository/OrderCartRuleRepository.php | 0 {OLD => src}/Repository/OrderDetailsRepository.php | 0 {OLD => src}/Repository/OrderHistoryRepository.php | 0 {OLD => src}/Repository/ProductCarrierRepository.php | 0 {OLD => src}/Repository/ProductRepository.php | 0 {OLD => src}/Repository/ProductSupplierRepository.php | 0 {OLD => src}/Repository/ServerInformationRepository.php | 0 {OLD => src}/Repository/ShopRepository.php | 0 {OLD => src}/Repository/SpecificPriceRepository.php | 0 {OLD => src}/Repository/StateRepository.php | 0 {OLD => src}/Repository/StockMvtRepository.php | 0 {OLD => src}/Repository/StockRepository.php | 0 {OLD => src}/Repository/StoreRepository.php | 0 {OLD => src}/Repository/SupplierRepository.php | 0 {OLD => src}/Repository/TaxRepository.php | 0 {OLD => src}/Repository/ThemeRepository.php | 0 {OLD => src}/Repository/TranslationRepository.php | 0 {OLD => src}/Repository/WishlistProductRepository.php | 0 {OLD => src}/Repository/WishlistRepository.php | 0 src/Service/ShopContent/OrdersService.php | 2 +- 46 files changed, 7 insertions(+), 6 deletions(-) rename {OLD => src}/Repository/BundleRepository.php (100%) rename {OLD => src}/Repository/CarrierRepository.php (100%) rename {OLD => src}/Repository/CartProductRepository.php (100%) rename {OLD => src}/Repository/CartRepository.php (100%) rename {OLD => src}/Repository/CartRuleRepository.php (100%) rename {OLD => src}/Repository/CategoryRepository.php (100%) rename {OLD => src}/Repository/ConfigurationRepository.php (100%) rename {OLD => src}/Repository/CountryRepository.php (100%) rename {OLD => src}/Repository/CurrencyRepository.php (100%) rename {OLD => src}/Repository/CustomPriceRepository.php (100%) rename {OLD => src}/Repository/CustomerRepository.php (100%) rename {OLD => src}/Repository/DeletedObjectsRepository.php (100%) rename {OLD => src}/Repository/EmployeeRepository.php (100%) rename {OLD => src}/Repository/EventbusSyncRepository.php (100%) rename {OLD => src}/Repository/GoogleTaxonomyRepository.php (100%) rename {OLD => src}/Repository/ImageRepository.php (100%) rename {OLD => src}/Repository/ImageTypeRepository.php (100%) rename {OLD => src}/Repository/IncrementalSyncRepository.php (100%) rename {OLD => src}/Repository/LanguageRepository.php (100%) rename {OLD => src}/Repository/LiveSyncRepository.php (100%) rename {OLD => src}/Repository/ManufacturerRepository.php (100%) rename {OLD => src}/Repository/ModuleRepository.php (100%) rename src/Repository/{ => NewRepositoryTemp}/AbstractRepository.php (95%) rename src/Repository/{ => NewRepositoryTemp}/OrderRepository.php (96%) rename {OLD => src}/Repository/OrderCartRuleRepository.php (100%) rename {OLD => src}/Repository/OrderDetailsRepository.php (100%) rename {OLD => src}/Repository/OrderHistoryRepository.php (100%) rename {OLD => src}/Repository/ProductCarrierRepository.php (100%) rename {OLD => src}/Repository/ProductRepository.php (100%) rename {OLD => src}/Repository/ProductSupplierRepository.php (100%) rename {OLD => src}/Repository/ServerInformationRepository.php (100%) rename {OLD => src}/Repository/ShopRepository.php (100%) rename {OLD => src}/Repository/SpecificPriceRepository.php (100%) rename {OLD => src}/Repository/StateRepository.php (100%) rename {OLD => src}/Repository/StockMvtRepository.php (100%) rename {OLD => src}/Repository/StockRepository.php (100%) rename {OLD => src}/Repository/StoreRepository.php (100%) rename {OLD => src}/Repository/SupplierRepository.php (100%) rename {OLD => src}/Repository/TaxRepository.php (100%) rename {OLD => src}/Repository/ThemeRepository.php (100%) rename {OLD => src}/Repository/TranslationRepository.php (100%) rename {OLD => src}/Repository/WishlistProductRepository.php (100%) rename {OLD => src}/Repository/WishlistRepository.php (100%) diff --git a/config/common/repository.yml b/config/common/repository.yml index 52eab365..e51f00e3 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -68,8 +68,8 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\OrderRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderRepository + PrestaShop\Module\PsEventbus\Repository\NewRepositoryTemp\OrderRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepositoryTemp\OrderRepository public: true PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository: diff --git a/config/front/services.yml b/config/front/services.yml index 4762076b..cf0bbc98 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -56,6 +56,6 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' + - '@PrestaShop\Module\PsEventbus\Repository\NewRepositoryTemp\OrderRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' diff --git a/OLD/Repository/BundleRepository.php b/src/Repository/BundleRepository.php similarity index 100% rename from OLD/Repository/BundleRepository.php rename to src/Repository/BundleRepository.php diff --git a/OLD/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php similarity index 100% rename from OLD/Repository/CarrierRepository.php rename to src/Repository/CarrierRepository.php diff --git a/OLD/Repository/CartProductRepository.php b/src/Repository/CartProductRepository.php similarity index 100% rename from OLD/Repository/CartProductRepository.php rename to src/Repository/CartProductRepository.php diff --git a/OLD/Repository/CartRepository.php b/src/Repository/CartRepository.php similarity index 100% rename from OLD/Repository/CartRepository.php rename to src/Repository/CartRepository.php diff --git a/OLD/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php similarity index 100% rename from OLD/Repository/CartRuleRepository.php rename to src/Repository/CartRuleRepository.php diff --git a/OLD/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php similarity index 100% rename from OLD/Repository/CategoryRepository.php rename to src/Repository/CategoryRepository.php diff --git a/OLD/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php similarity index 100% rename from OLD/Repository/ConfigurationRepository.php rename to src/Repository/ConfigurationRepository.php diff --git a/OLD/Repository/CountryRepository.php b/src/Repository/CountryRepository.php similarity index 100% rename from OLD/Repository/CountryRepository.php rename to src/Repository/CountryRepository.php diff --git a/OLD/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php similarity index 100% rename from OLD/Repository/CurrencyRepository.php rename to src/Repository/CurrencyRepository.php diff --git a/OLD/Repository/CustomPriceRepository.php b/src/Repository/CustomPriceRepository.php similarity index 100% rename from OLD/Repository/CustomPriceRepository.php rename to src/Repository/CustomPriceRepository.php diff --git a/OLD/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php similarity index 100% rename from OLD/Repository/CustomerRepository.php rename to src/Repository/CustomerRepository.php diff --git a/OLD/Repository/DeletedObjectsRepository.php b/src/Repository/DeletedObjectsRepository.php similarity index 100% rename from OLD/Repository/DeletedObjectsRepository.php rename to src/Repository/DeletedObjectsRepository.php diff --git a/OLD/Repository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php similarity index 100% rename from OLD/Repository/EmployeeRepository.php rename to src/Repository/EmployeeRepository.php diff --git a/OLD/Repository/EventbusSyncRepository.php b/src/Repository/EventbusSyncRepository.php similarity index 100% rename from OLD/Repository/EventbusSyncRepository.php rename to src/Repository/EventbusSyncRepository.php diff --git a/OLD/Repository/GoogleTaxonomyRepository.php b/src/Repository/GoogleTaxonomyRepository.php similarity index 100% rename from OLD/Repository/GoogleTaxonomyRepository.php rename to src/Repository/GoogleTaxonomyRepository.php diff --git a/OLD/Repository/ImageRepository.php b/src/Repository/ImageRepository.php similarity index 100% rename from OLD/Repository/ImageRepository.php rename to src/Repository/ImageRepository.php diff --git a/OLD/Repository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php similarity index 100% rename from OLD/Repository/ImageTypeRepository.php rename to src/Repository/ImageTypeRepository.php diff --git a/OLD/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php similarity index 100% rename from OLD/Repository/IncrementalSyncRepository.php rename to src/Repository/IncrementalSyncRepository.php diff --git a/OLD/Repository/LanguageRepository.php b/src/Repository/LanguageRepository.php similarity index 100% rename from OLD/Repository/LanguageRepository.php rename to src/Repository/LanguageRepository.php diff --git a/OLD/Repository/LiveSyncRepository.php b/src/Repository/LiveSyncRepository.php similarity index 100% rename from OLD/Repository/LiveSyncRepository.php rename to src/Repository/LiveSyncRepository.php diff --git a/OLD/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php similarity index 100% rename from OLD/Repository/ManufacturerRepository.php rename to src/Repository/ManufacturerRepository.php diff --git a/OLD/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php similarity index 100% rename from OLD/Repository/ModuleRepository.php rename to src/Repository/ModuleRepository.php diff --git a/src/Repository/AbstractRepository.php b/src/Repository/NewRepositoryTemp/AbstractRepository.php similarity index 95% rename from src/Repository/AbstractRepository.php rename to src/Repository/NewRepositoryTemp/AbstractRepository.php index 364e2c87..0770ab93 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/NewRepositoryTemp/AbstractRepository.php @@ -1,6 +1,6 @@ Date: Thu, 29 Aug 2024 14:47:42 +0200 Subject: [PATCH 062/162] feat: pseventbus v4 order cart rules (#347) --- README.md | 4 +- composer.lock | 2 +- config/admin/services.yml | 1 + config/common/new-repository.yml | 8 ++ config/common/repository.yml | 8 -- config/front/services.yml | 9 +- controllers/front/apiFront.php | 5 +- e2e-env/docker-compose.yml | 2 +- e2e/README.md | 4 +- e2e/src/full-sync.spec.ts | 12 +- e2e/src/helpers/data-helper.ts | 2 +- e2e/src/helpers/mock-probe.ts | 2 +- e2e/src/helpers/shop-contents.ts | 2 +- e2e/src/reject-invalid-job-id.spec.ts | 2 +- .../AbstractRepository.php | 2 +- .../NewRepository/OrderCartRuleRepository.php | 95 ++++++++++++++ .../OrderRepository.php | 71 +++++++--- .../NewRepository}/RepositoryInterface.php | 2 +- src/Repository/OrderCartRuleRepository.php | 78 ----------- src/Service/FrontApiService.php | 29 ++++- src/Service/ProxyService.php | 1 - .../ProxyServiceInterface.php | 2 +- .../ShopContent/OrderCartRulesService.php | 123 ++++++++++++++++++ src/Service/ShopContent/OrdersService.php | 3 +- .../ShopContentServiceInterface.php | 2 +- src/Service/SynchronizationService.php | 7 +- 26 files changed, 339 insertions(+), 139 deletions(-) create mode 100644 config/common/new-repository.yml rename src/Repository/{NewRepositoryTemp => NewRepository}/AbstractRepository.php (95%) create mode 100644 src/Repository/NewRepository/OrderCartRuleRepository.php rename src/Repository/{NewRepositoryTemp => NewRepository}/OrderRepository.php (56%) rename src/{Interfaces => Repository/NewRepository}/RepositoryInterface.php (92%) delete mode 100644 src/Repository/OrderCartRuleRepository.php rename src/{Interfaces => Service}/ProxyServiceInterface.php (90%) create mode 100644 src/Service/ShopContent/OrderCartRulesService.php rename src/{Interfaces => Service/ShopContent}/ShopContentServiceInterface.php (92%) diff --git a/README.md b/README.md index ac254564..66b7c371 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ To check the module healthiness (authentified route): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-stuff" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck&job_id=valid-job-stuff" | jq . { "prestashop_version": "1.6.1.24", "ps_eventbus_version": "0.0.0", @@ -66,7 +66,7 @@ To check the fallback route (unauthentified): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck" | jq . { "ps_account": true, "is_valid_jwt": true, diff --git a/composer.lock b/composer.lock index cba5142c..d7659e4b 100644 --- a/composer.lock +++ b/composer.lock @@ -1504,5 +1504,5 @@ "platform-overrides": { "php": "5.6" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/config/admin/services.yml b/config/admin/services.yml index 521fb78a..0489a1c6 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1,6 +1,7 @@ imports: - { resource: ../common/common.yml } - { resource: ../common/repository.yml } + - { resource: ../common/new-repository.yml } - { resource: ../front/services.yml } services: diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml new file mode 100644 index 00000000..9a91b7d0 --- /dev/null +++ b/config/common/new-repository.yml @@ -0,0 +1,8 @@ +services: + PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index e51f00e3..d2b8412f 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -68,10 +68,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\NewRepositoryTemp\OrderRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepositoryTemp\OrderRepository - public: true - PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository: class: PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository public: true @@ -82,10 +78,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository public: true - PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository - public: true - PrestaShop\Module\PsEventbus\Repository\CartRepository: class: PrestaShop\Module\PsEventbus\Repository\CartRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index cf0bbc98..ae6dfbb7 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -3,6 +3,7 @@ imports: - { resource: ../common/common.yml } - { resource: ../common/decorator.yml } - { resource: ../common/repository.yml } + - { resource: ../common/new-repository.yml } - { resource: ../common/builder.yml } services: @@ -56,6 +57,12 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepositoryTemp\OrderRepository' + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository' - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' + + PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository' diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 969d8058..e2344373 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -29,6 +29,9 @@ public function postProcess() /** @var bool $debug */ $debug = Tools::getValue('debug') == 1; + /** @var bool $ise2e */ + $ise2e = Tools::getValue('is_e2e') == 1; + /** @var Ps_eventbus $module */ $module = Module::getInstanceByName('ps_eventbus'); @@ -38,6 +41,6 @@ public function postProcess() // edit shopContent for matching Config.php const $shopContentEdited = str_replace('-', '_', $shopContent); - $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $isFull, $debug); + $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $isFull, $debug, $ise2e); } } diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index 155c0af7..add5990e 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -12,7 +12,7 @@ services: "-sI", "-H", "Host: localhost:8000", - "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck", + "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck", ] interval: 30s volumes: diff --git a/e2e/README.md b/e2e/README.md index 1ae8fee1..08bfa19d 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -18,12 +18,12 @@ import testConfig from './helpers/test.config'; import request from 'supertest'; const controller = 'categories'; -const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5`; +const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5`; describe('CategoriesShopContent', () => { it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; // jobId starting with "valid-job-" will be considered valid by the mock sync-api and will always return 201; // other values will be rejected by the mock const jobId = 'valid-job-1' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 737ecd94..78041e9e 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -15,7 +15,7 @@ import { ShopContent, shopContentList } from "./helpers/shop-contents"; expect.extend(matchers); // these ShopContent will be excluded from the following test suite -const EXCLUDED_API: ShopContent[] = ["google-taxonomies"]; +const EXCLUDED_API: ShopContent[] = ["taxonomies"]; // FIXME : these api can't send anything to the mock api because the database is empty from the factory const MISSING_TEST_DATA: ShopContent[] = [ @@ -64,8 +64,8 @@ describe('Full Sync', () => { }); // TODO : some versions of prestashop include ps_facebook out of the box, this test can't reliably be run for all versions - describe.skip("google-taxonomies", () => { - const shoContent = "google-taxonomies"; + describe.skip("taxonomies", () => { + const shoContent = "taxonomies"; // TODO : apiGoogleTaxonomies requires an additional module to be present : devise a specific test setup for this endpoint it.skip(`${shoContent} should accept full sync`, async () => {}); @@ -74,7 +74,7 @@ describe('Full Sync', () => { it(`${shoContent} should reject full sync when ps_facebook is not installed`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -101,7 +101,7 @@ describe('Full Sync', () => { describe.each(shopContents)("%s", (shopContent) => { it(`${shopContent} should accept full sync`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; @@ -133,7 +133,7 @@ describe('Full Sync', () => { } else { it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const message$ = probe({ url: `/upload/${jobId}` }); const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 04cae9fc..fb05825c 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -56,7 +56,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-healthcheck` + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck&job_id=valid-job-healthcheck` ); healthCheck = res.data; cachedHealthCheck = healthCheck; diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index cae8710a..645c2ff4 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -83,7 +83,7 @@ export function doFullSync(jobId: string, shopContent: ShopContent, options?: Mo const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; const requestNext = (full: number) => axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, callId, { headers: { diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index abd72f5b..d73d13ee 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -11,7 +11,7 @@ export const shopContentMapping = { 'specific_prices': 'specific-prices', 'custom_product_carriers' : 'custom-product-carriers', 'customers': 'customers', - 'taxonomies': 'google-taxonomies', + 'taxonomies': 'taxonomies', 'modules': 'modules', 'orders': 'orders', 'order_details': 'order-details', diff --git a/e2e/src/reject-invalid-job-id.spec.ts b/e2e/src/reject-invalid-job-id.spec.ts index ecd7472e..807e133f 100644 --- a/e2e/src/reject-invalid-job-id.spec.ts +++ b/e2e/src/reject-invalid-job-id.spec.ts @@ -19,7 +19,7 @@ describe('Reject invalid job-id', () => { it.each(shopContents)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=${shopContent}&limit=5&job_id=${jobId}` + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&job_id=${jobId}` const message$ = probe({params: {id: jobId}}); //act diff --git a/src/Repository/NewRepositoryTemp/AbstractRepository.php b/src/Repository/NewRepository/AbstractRepository.php similarity index 95% rename from src/Repository/NewRepositoryTemp/AbstractRepository.php rename to src/Repository/NewRepository/AbstractRepository.php index 0770ab93..a54de804 100644 --- a/src/Repository/NewRepositoryTemp/AbstractRepository.php +++ b/src/Repository/NewRepository/AbstractRepository.php @@ -1,6 +1,6 @@ query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'ocr'); + + $this->query->select('ocr.id_order_cart_rule'); + $this->query->select('ocr.id_order'); + $this->query->select('ocr.id_cart_rule'); + $this->query->select('ocr.id_order_invoice'); + $this->query->select('ocr.name'); + $this->query->select('ocr.value'); + $this->query->select('ocr.value_tax_excl'); + $this->query->select('ocr.free_shipping'); + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.7.0', '>=')) { + $this->query->select('ocr.deleted'); + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateBaseQuery(); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateBaseQuery(); + + $this->query->where('ocr.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit); + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + + if (!is_array($result) || empty($result)) { + return 0; + } + + return count($result); + } +} diff --git a/src/Repository/NewRepositoryTemp/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php similarity index 56% rename from src/Repository/NewRepositoryTemp/OrderRepository.php rename to src/Repository/NewRepository/OrderRepository.php index f757c3c2..d8cf2242 100644 --- a/src/Repository/NewRepositoryTemp/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -1,9 +1,6 @@ where('o.id_shop = ' . (int) parent::getShopId()) ->groupBy('o.id_order'); - $this->query->select('o.id_order, o.reference, o.id_customer, o.id_cart, o.current_state'); - $this->query->select('o.conversion_rate, o.total_paid_tax_excl, o.total_paid_tax_incl'); - $this->query->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer'); - $this->query->select('c.iso_code as currency, SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund'); - $this->query->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl, o.module as payment_module'); - $this->query->select('o.payment as payment_mode, o.total_paid_real, o.total_shipping as shipping_cost, o.date_add as created_at'); - $this->query->select('o.date_upd as updated_at, o.id_carrier'); + $this->query->select('o.id_order'); + $this->query->select('o.reference'); + $this->query->select('o.id_customer'); + $this->query->select('o.id_cart'); + $this->query->select('o.current_state'); + $this->query->select('o.conversion_rate'); + $this->query->select('o.total_paid_tax_excl'); + $this->query->select('o.total_paid_tax_incl'); + + $this->query->select('c.iso_code as currency'); + $this->query->select('o.module as payment_module'); + $this->query->select('o.payment as payment_mode'); + $this->query->select('o.total_paid_real'); + $this->query->select('o.total_shipping as shipping_cost'); + $this->query->select('o.date_add as created_at'); + $this->query->select('o.date_upd as updated_at'); + $this->query->select('o.id_carrier'); $this->query->select('o.payment as payment_name'); - $this->query->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso'); $this->query->select('o.valid as is_validated'); $this->query->select('ost.paid as is_paid'); $this->query->select('ost.shipped as is_shipped'); $this->query->select('osl.name as status_label'); $this->query->select('o.module as payment_name'); - - $this->query->select('o.id_shop_group, o.id_shop, o.id_lang, o.id_currency, o.recyclable, o.gift'); - $this->query->select('o.total_discounts, o.total_discounts_tax_incl, o.total_discounts_tax_excl'); - $this->query->select('o.total_products, o.total_products_wt, o.total_shipping_tax_incl, o.total_shipping_tax_excl'); - $this->query->select('o.carrier_tax_rate, o.total_wrapping, o.total_wrapping_tax_incl, o.total_wrapping_tax_excl'); - $this->query->select('o.round_mode, o.round_type, o.invoice_number, o.delivery_number, o.invoice_date, o.delivery_date, o.valid'); + $this->query->select('o.id_shop_group'); + $this->query->select('o.id_shop'); + $this->query->select('o.id_lang'); + $this->query->select('o.id_currency'); + $this->query->select('o.recyclable'); + $this->query->select('o.gift'); + $this->query->select('o.total_discounts'); + $this->query->select('o.total_discounts_tax_incl'); + $this->query->select('o.total_discounts_tax_excl'); + $this->query->select('o.total_products'); + $this->query->select('o.total_products_wt'); + $this->query->select('o.total_shipping_tax_incl'); + $this->query->select('o.total_shipping_tax_excl'); + $this->query->select('o.carrier_tax_rate'); + $this->query->select('o.total_wrapping'); + $this->query->select('o.total_wrapping_tax_incl'); + $this->query->select('o.total_wrapping_tax_excl'); + $this->query->select('o.round_mode'); + $this->query->select('o.round_type'); + $this->query->select('o.invoice_number'); + $this->query->select('o.delivery_number'); + $this->query->select('o.invoice_date'); + $this->query->select('o.delivery_date'); + $this->query->select('o.valid'); + + $this->query->select('SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund'); + $this->query->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl'); + $this->query->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso'); + $this->query->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer'); } /** @@ -105,12 +134,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) */ public function countFullSyncContentLeft($offset, $langIso, $debug) { - $orders = $this->getContentsForFull($offset, 1, $langIso, $debug); + $result = $this->getContentsForFull($offset, 1, $langIso, $debug); - if (!is_array($orders) || empty($orders)) { + if (!is_array($result) || empty($result)) { return 0; } - return count($orders); + return count($result); } } diff --git a/src/Interfaces/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php similarity index 92% rename from src/Interfaces/RepositoryInterface.php rename to src/Repository/NewRepository/RepositoryInterface.php index 9723ab2d..2d484318 100644 --- a/src/Interfaces/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -1,6 +1,6 @@ db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - $query = new \DbQuery(); - - $query->from(self::TABLE_NAME, 'ocr'); - - return $query; - } - - /** - * @param array $orderIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getOrderCartRules($orderIds) - { - if (!$orderIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('ocr.id_order_cart_rule,ocr.id_order,ocr.id_cart_rule,ocr.id_order_invoice,ocr.name,ocr.value,ocr.value_tax_excl, ocr.free_shipping'); - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.7.0', '>=')) { - $query->select('ocr.deleted'); - } - $query->where('ocr.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')'); - - return $this->db->executeS($query); - } - - /** - * @param array $orderIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getOrderCartRuleIdsByOrderIds($orderIds) - { - if (!$orderIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('ocr.id_order_cart_rule as id'); - $query->where('ocr.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')'); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } -} diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 1f240050..cf9f7ea7 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -11,6 +11,7 @@ use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; class FrontApiService { @@ -71,10 +72,11 @@ public function __construct( * @param int $limit * @param bool $isFull * @param bool $debug + * @param bool $ise2e * * @return void */ - public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug) + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug, $ise2e) { try { if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { @@ -176,10 +178,31 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } catch (FirebaseException $exception) { $this->errorHandler->handle($exception); CommonService::exitWithExceptionMessage($exception); + } catch (ServiceNotFoundException $exception) { + $this->catchGenericException($exception, $ise2e); } catch (\Exception $exception) { - $this->errorHandler->handle($exception); - CommonService::dieWithResponse(['message' => 'An error occured. Please check shop logs for more information'], 500); + $this->catchGenericException($exception, $ise2e); + } + } + + /** + * @param mixed $exception + * @param mixed $ise2e + * + * @return void + * + * @throws \Exception + */ + private function catchGenericException($exception, $ise2e) + { + $this->errorHandler->handle($exception); + + // if debug mode enabled, print error + if (_PS_MODE_DEV_ == true && $ise2e == false) { + throw $exception; } + + CommonService::dieWithResponse(['message' => 'An error occured. Please check shop logs for more information'], 500); } /** diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index 2f8e9091..e804aa50 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -8,7 +8,6 @@ use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Formatter\JsonFormatter; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; -use PrestaShop\Module\PsEventbus\Interfaces\ProxyServiceInterface; class ProxyService implements ProxyServiceInterface { diff --git a/src/Interfaces/ProxyServiceInterface.php b/src/Service/ProxyServiceInterface.php similarity index 90% rename from src/Interfaces/ProxyServiceInterface.php rename to src/Service/ProxyServiceInterface.php index 528ff932..bcf1bc95 100644 --- a/src/Interfaces/ProxyServiceInterface.php +++ b/src/Service/ProxyServiceInterface.php @@ -1,6 +1,6 @@ orderCartRuleRepository = $orderCartRuleRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $orders = $this->orderCartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($orders)) { + return []; + } + + $this->castOrderCartRules($orders, $langIso); + + return array_map(function ($order) { + return [ + 'id' => $order['id_order'], + 'collection' => Config::COLLECTION_ORDERS, + 'properties' => $order, + ]; + }, $orders); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $orders = $this->orderCartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($orders)) { + return []; + } + + $this->castOrderCartRules($orders, $langIso); + + return array_map(function ($order) { + return [ + 'id' => $order['id_order'], + 'collection' => Config::COLLECTION_ORDERS, + 'properties' => $order, + ]; + }, $orders); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + return (int) $this->orderCartRuleRepository->countFullSyncContentLeft($offset, $langIso, $debug); + } + + /** + * @param array $cartRules + * @param string $langIso + * + * @return void + */ + public function castOrderCartRules(&$cartRules, $langIso) + { + foreach ($cartRules as &$cartRule) { + $cartRule['id_cart_rule'] = (int) $cartRule['id_cart_rule']; + $cartRule['id_customer'] = (int) $cartRule['id_customer']; + $cartRule['quantity'] = (int) $cartRule['quantity']; + $cartRule['quantity_per_user'] = (int) $cartRule['quantity_per_user']; + $cartRule['priority'] = (int) $cartRule['priority']; + $cartRule['partial_use'] = (bool) $cartRule['partial_use']; + $cartRule['minimum_amount'] = (float) $cartRule['minimum_amount']; + $cartRule['minimum_amount_tax'] = (bool) $cartRule['minimum_amount_tax']; + $cartRule['minimum_amount_currency'] = (int) $cartRule['minimum_amount_currency']; + $cartRule['minimum_amount_shipping'] = (bool) $cartRule['minimum_amount_shipping']; + $cartRule['country_restriction'] = (bool) $cartRule['country_restriction']; + $cartRule['carrier_restriction'] = (bool) $cartRule['carrier_restriction']; + $cartRule['group_restriction'] = (bool) $cartRule['group_restriction']; + $cartRule['cart_rule_restriction'] = (bool) $cartRule['cart_rule_restriction']; + $cartRule['product_restriction'] = (bool) $cartRule['product_restriction']; + $cartRule['shop_restriction'] = (bool) $cartRule['shop_restriction']; + $cartRule['free_shipping'] = (bool) $cartRule['free_shipping']; + $cartRule['reduction_percent'] = (float) $cartRule['reduction_percent']; + $cartRule['reduction_amount'] = (float) $cartRule['reduction_amount']; + $cartRule['reduction_tax'] = (bool) $cartRule['reduction_tax']; + $cartRule['reduction_currency'] = (int) $cartRule['reduction_currency']; + $cartRule['reduction_product'] = (int) $cartRule['reduction_product']; + $cartRule['reduction_exclude_special'] = (bool) $cartRule['reduction_exclude_special']; + $cartRule['gift_product'] = (int) $cartRule['gift_product']; + $cartRule['gift_product_attribute'] = (int) $cartRule['gift_product_attribute']; + $cartRule['highlight'] = (bool) $cartRule['highlight']; + $cartRule['active'] = (bool) $cartRule['active']; + } + } +} diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index f9a1b24f..b54178a2 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -4,9 +4,8 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Interfaces\ShopContentServiceInterface; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository; use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; -use PrestaShop\Module\PsEventbus\Repository\NewRepositoryTemp\OrderRepository; class OrdersService implements ShopContentServiceInterface { diff --git a/src/Interfaces/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php similarity index 92% rename from src/Interfaces/ShopContentServiceInterface.php rename to src/Service/ShopContent/ShopContentServiceInterface.php index 9223815c..718e7fa3 100644 --- a/src/Interfaces/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -1,6 +1,6 @@ Date: Fri, 30 Aug 2024 17:29:46 +0200 Subject: [PATCH 063/162] feat: pseventbus v4 order statuse histories (#349) --- config/common/new-repository.yml | 4 + config/common/repository.yml | 4 - config/front/services.yml | 8 +- ...status_history.json => order_history.json} | 14 +- ...atus_history.json => order_histories.json} | 14 +- e2e/src/fixtures/1.7/product_bundles.json | 4 +- ...atus_history.json => order_histories.json} | 14 +- e2e/src/fixtures/8/product_bundles.json | 4 +- ...atus_history.json => order_histories.json} | 14 +- e2e/src/fixtures/9/product_bundles.json | 4 +- e2e/src/full-sync.spec.ts | 12 +- e2e/src/helpers/shop-contents.ts | 12 +- e2e/src/type/bundles.ts | 2 +- e2e/src/type/carrier-details.ts | 2 +- e2e/src/type/carriers.ts | 2 +- e2e/src/type/cart-products.ts | 2 +- e2e/src/type/carts.ts | 2 +- e2e/src/type/categories.ts | 2 +- e2e/src/type/currency.ts | 2 +- e2e/src/type/customers.ts | 2 +- e2e/src/type/employees.ts | 2 +- e2e/src/type/image-type.ts | 2 +- e2e/src/type/images.ts | 2 +- e2e/src/type/languages.ts | 2 +- e2e/src/type/manufacturers.ts | 2 +- e2e/src/type/modules.ts | 2 +- e2e/src/type/order-details.ts | 2 +- e2e/src/type/order-status-history.ts | 6 +- e2e/src/type/orders.ts | 2 +- e2e/src/type/product-supplier.ts | 2 +- e2e/src/type/products.ts | 2 +- e2e/src/type/shops.ts | 2 +- e2e/src/type/specific-prices.ts | 2 +- e2e/src/type/stocks.ts | 2 +- e2e/src/type/stores.ts | 2 +- e2e/src/type/suppliers.ts | 2 +- ps_eventbus.php | 2 +- src/Config/Config.php | 4 +- src/Handler/ErrorHandler/ErrorHandler.php | 2 +- .../NewRepository/OrderCartRuleRepository.php | 31 +++-- .../NewRepository/OrderHistoryRepository.php | 128 ++++++++++++++++++ .../NewRepository/OrderRepository.php | 128 +++++++++--------- .../NewRepository/RepositoryInterface.php | 4 +- src/Repository/OrderHistoryRepository.php | 80 ----------- .../ShopContent/OrderCartRulesService.php | 93 +++++++------ .../ShopContent/OrderHistoriesService.php | 107 +++++++++++++++ src/Service/ShopContent/OrdersService.php | 24 ++-- 47 files changed, 472 insertions(+), 291 deletions(-) rename e2e/src/fixtures/1.6/{order_status_history.json => order_history.json} (91%) rename e2e/src/fixtures/1.7/{order_status_history.json => order_histories.json} (91%) rename e2e/src/fixtures/8/{order_status_history.json => order_histories.json} (91%) rename e2e/src/fixtures/9/{order_status_history.json => order_histories.json} (91%) create mode 100644 src/Repository/NewRepository/OrderHistoryRepository.php delete mode 100644 src/Repository/OrderHistoryRepository.php create mode 100644 src/Service/ShopContent/OrderHistoriesService.php diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 9a91b7d0..a61bdcdf 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -6,3 +6,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index d2b8412f..bd2c8946 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -74,10 +74,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository - public: true - PrestaShop\Module\PsEventbus\Repository\CartRepository: class: PrestaShop\Module\PsEventbus\Repository\CartRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index ae6dfbb7..2ea84edd 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -58,7 +58,7 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository' - - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService: @@ -66,3 +66,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository' diff --git a/e2e/src/fixtures/1.6/order_status_history.json b/e2e/src/fixtures/1.6/order_history.json similarity index 91% rename from e2e/src/fixtures/1.6/order_status_history.json rename to e2e/src/fixtures/1.6/order_history.json index e39bdde7..962c6777 100644 --- a/e2e/src/fixtures/1.6/order_status_history.json +++ b/e2e/src/fixtures/1.6/order_history.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/fixtures/1.7/order_status_history.json b/e2e/src/fixtures/1.7/order_histories.json similarity index 91% rename from e2e/src/fixtures/1.7/order_status_history.json rename to e2e/src/fixtures/1.7/order_histories.json index 80aa3b22..310f587e 100644 --- a/e2e/src/fixtures/1.7/order_status_history.json +++ b/e2e/src/fixtures/1.7/order_histories.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/fixtures/1.7/product_bundles.json b/e2e/src/fixtures/1.7/product_bundles.json index 7fced11c..563190cc 100644 --- a/e2e/src/fixtures/1.7/product_bundles.json +++ b/e2e/src/fixtures/1.7/product_bundles.json @@ -1,7 +1,7 @@ [ { "id": "15", - "collection": "bundles", + "collection": "product_bundles", "properties": { "id_bundle": "15", "id_product": "5", @@ -12,7 +12,7 @@ }, { "id": "15", - "collection": "bundles", + "collection": "product_bundles", "properties": { "id_bundle": "15", "id_product": "7", diff --git a/e2e/src/fixtures/8/order_status_history.json b/e2e/src/fixtures/8/order_histories.json similarity index 91% rename from e2e/src/fixtures/8/order_status_history.json rename to e2e/src/fixtures/8/order_histories.json index f5d6eac5..49223656 100644 --- a/e2e/src/fixtures/8/order_status_history.json +++ b/e2e/src/fixtures/8/order_histories.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/fixtures/8/product_bundles.json b/e2e/src/fixtures/8/product_bundles.json index 7438d673..bca28be0 100644 --- a/e2e/src/fixtures/8/product_bundles.json +++ b/e2e/src/fixtures/8/product_bundles.json @@ -1,7 +1,7 @@ [ { "id": 15, - "collection": "bundles", + "collection": "product_bundles", "properties": { "id_bundle": 15, "id_product": 5, @@ -12,7 +12,7 @@ }, { "id": 15, - "collection": "bundles", + "collection": "product_bundles", "properties": { "id_bundle": 15, "id_product": 7, diff --git a/e2e/src/fixtures/9/order_status_history.json b/e2e/src/fixtures/9/order_histories.json similarity index 91% rename from e2e/src/fixtures/9/order_status_history.json rename to e2e/src/fixtures/9/order_histories.json index 05868d4b..b33a067c 100644 --- a/e2e/src/fixtures/9/order_status_history.json +++ b/e2e/src/fixtures/9/order_histories.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_status_history", + "collection": "order_histories", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/fixtures/9/product_bundles.json b/e2e/src/fixtures/9/product_bundles.json index 7438d673..bca28be0 100644 --- a/e2e/src/fixtures/9/product_bundles.json +++ b/e2e/src/fixtures/9/product_bundles.json @@ -1,7 +1,7 @@ [ { "id": 15, - "collection": "bundles", + "collection": "product_bundles", "properties": { "id_bundle": 15, "id_product": 5, @@ -12,7 +12,7 @@ }, { "id": 15, - "collection": "bundles", + "collection": "product_bundles", "properties": { "id_bundle": 15, "id_product": 7, diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 78041e9e..4dde48ed 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -15,14 +15,14 @@ import { ShopContent, shopContentList } from "./helpers/shop-contents"; expect.extend(matchers); // these ShopContent will be excluded from the following test suite -const EXCLUDED_API: ShopContent[] = ["taxonomies"]; +const EXCLUDED_API: ShopContent[] = ["taxonomies" as ShopContent]; // FIXME : these api can't send anything to the mock api because the database is empty from the factory const MISSING_TEST_DATA: ShopContent[] = [ - "cart-rules", - "custom-product-carriers", - "translations", - "wishlists", + "cart-rules" as ShopContent, + "custom-product-carriers" as ShopContent, + "translations" as ShopContent, + "wishlists" as ShopContent, ]; // these fields change from test run to test run, so we replace them with a matcher to only ensure the type and format are correct @@ -198,7 +198,7 @@ describe('Full Sync', () => { // we need to process fixtures and data returned from ps_eventbus to make them easier to compare let processedData = syncedData; let processedFixture = fixture; - if (shopContent === "modules") { + if (shopContent === "modules" as ShopContent) { processedData = generatePredictableModuleId(processedData); processedFixture = generatePredictableModuleId(processedFixture); } diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index d73d13ee..5dc033e6 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -1,6 +1,8 @@ import R from "ramda"; -export const shopContentMapping = { +// TEMPORARY DISABLED, WAIT ADD ALL SHOP CONTENT +// AFTER UNCOMMENT THIS, CHANGE ALL "as ShopContent"CAST IN FULLSYNC TEST +/* export const shopContentMapping = { 'carriers': 'carriers', 'carrier_details': 'carrier-details', 'carts' : 'carts', @@ -15,7 +17,7 @@ export const shopContentMapping = { 'modules': 'modules', 'orders': 'orders', 'order_details': 'order-details', - 'order_status_histories': 'order-status-histories', + 'order_histories': 'order-histories', 'order_cart_rules': 'order-cart-rules', 'products': 'products', 'shops': 'info', @@ -34,6 +36,12 @@ export const shopContentMapping = { 'translations': 'translations', 'images': 'images', 'image_types': 'image-types' +} as const; */ + +export const shopContentMapping = { + 'orders': 'orders', + 'order_histories': 'order-histories', + 'order_cart_rules': 'order-cart-rules', } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/e2e/src/type/bundles.ts b/e2e/src/type/bundles.ts index dbadecaa..02fa58ab 100644 --- a/e2e/src/type/bundles.ts +++ b/e2e/src/type/bundles.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiProducts/bundles.json"; +import fixture from "../fixtures/latest/product_bundles.json"; // test type const t: Bundles[] = fixture; diff --git a/e2e/src/type/carrier-details.ts b/e2e/src/type/carrier-details.ts index f6f6d4d8..df48bd86 100644 --- a/e2e/src/type/carrier-details.ts +++ b/e2e/src/type/carrier-details.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiCarriers/carrier_details.json" +import fixture from "../fixtures/latest/carrier_details.json" // test type const t: CarrierDetails[] = fixture; diff --git a/e2e/src/type/carriers.ts b/e2e/src/type/carriers.ts index 141ac727..bd9cd5f2 100644 --- a/e2e/src/type/carriers.ts +++ b/e2e/src/type/carriers.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiCarriers/carriers.json"; +import fixture from "../fixtures/latest/carriers.json"; // test type const t: Carriers[] = fixture; diff --git a/e2e/src/type/cart-products.ts b/e2e/src/type/cart-products.ts index 47458904..fe41f286 100644 --- a/e2e/src/type/cart-products.ts +++ b/e2e/src/type/cart-products.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiCarts/cart_products.json" +import fixture from "../fixtures/latest/cart_products.json" // test type const t: CartProducts[] = fixture; diff --git a/e2e/src/type/carts.ts b/e2e/src/type/carts.ts index f93d9f8a..335add7f 100644 --- a/e2e/src/type/carts.ts +++ b/e2e/src/type/carts.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiCarts/carts.json" +import fixture from "../fixtures/latest/carts.json" // test type const t: Carts[] = fixture; diff --git a/e2e/src/type/categories.ts b/e2e/src/type/categories.ts index 3ff7d3c1..d8abd1d3 100644 --- a/e2e/src/type/categories.ts +++ b/e2e/src/type/categories.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiCategories/categories.json" +import fixture from "../fixtures/latest/categories.json" // test type const t: Categories[] = fixture; diff --git a/e2e/src/type/currency.ts b/e2e/src/type/currency.ts index 1dc2dd85..c040cf9e 100644 --- a/e2e/src/type/currency.ts +++ b/e2e/src/type/currency.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiCurrencies/currencies.json" +import fixture from "../fixtures/latest/currencies.json" // test type const t: Currencies[] = fixture; diff --git a/e2e/src/type/customers.ts b/e2e/src/type/customers.ts index 534c3b9e..e6c38c01 100644 --- a/e2e/src/type/customers.ts +++ b/e2e/src/type/customers.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/apiCustomers/customers.json" +import fixture from "../fixtures/latest/customers.json" // test type const t: Customers[] = fixture; diff --git a/e2e/src/type/employees.ts b/e2e/src/type/employees.ts index a37bc1ca..7ed1de17 100644 --- a/e2e/src/type/employees.ts +++ b/e2e/src/type/employees.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiEmployees/employees.json' +import fixture from '../fixtures/latest/employees.json' // test type const t: Employees[] = fixture; diff --git a/e2e/src/type/image-type.ts b/e2e/src/type/image-type.ts index 4fab6030..82f7a3ef 100644 --- a/e2e/src/type/image-type.ts +++ b/e2e/src/type/image-type.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiImageTypes/image_types.json' +import fixture from '../fixtures/latest/image_types.json' // test type const t: ImageType[] = fixture; diff --git a/e2e/src/type/images.ts b/e2e/src/type/images.ts index fa8d0d00..ecef929e 100644 --- a/e2e/src/type/images.ts +++ b/e2e/src/type/images.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiImages/images.json' +import fixture from '../fixtures/latest/images.json' // test type const t: Images[] = fixture; diff --git a/e2e/src/type/languages.ts b/e2e/src/type/languages.ts index 660ba9e4..6a08f6d3 100644 --- a/e2e/src/type/languages.ts +++ b/e2e/src/type/languages.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiLanguages/languages.json' +import fixture from '../fixtures/latest/languages.json' // test type const t: Languages[] = fixture; diff --git a/e2e/src/type/manufacturers.ts b/e2e/src/type/manufacturers.ts index 4f1fafaa..9d1a9008 100644 --- a/e2e/src/type/manufacturers.ts +++ b/e2e/src/type/manufacturers.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiManufacturers/manufacturers.json' +import fixture from '../fixtures/latest/manufacturers.json' // test type const t: Manufacturers[] = fixture; diff --git a/e2e/src/type/modules.ts b/e2e/src/type/modules.ts index a96a2e03..9cc70020 100644 --- a/e2e/src/type/modules.ts +++ b/e2e/src/type/modules.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiModules/modules.json' +import fixture from '../fixtures/latest/modules.json' // test type const t: Modules[] = fixture; diff --git a/e2e/src/type/order-details.ts b/e2e/src/type/order-details.ts index 25fc421d..24f9ed75 100644 --- a/e2e/src/type/order-details.ts +++ b/e2e/src/type/order-details.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiOrders/order_details.json' +import fixture from '../fixtures/latest/order_details.json' // test type const t: OrderDetails[] = fixture; diff --git a/e2e/src/type/order-status-history.ts b/e2e/src/type/order-status-history.ts index b2524234..e09e4f39 100644 --- a/e2e/src/type/order-status-history.ts +++ b/e2e/src/type/order-status-history.ts @@ -1,9 +1,9 @@ -import fixture from '../fixtures/latest/apiOrders/order_status_history.json' +import fixture from '../fixtures/latest/order_histories.json' // test type -const t: OrderStatusHistory[] = fixture; +const t: OrderHistory[] = fixture; -export type OrderStatusHistory = { +export type OrderHistory = { id: number, collection: string, properties: { diff --git a/e2e/src/type/orders.ts b/e2e/src/type/orders.ts index ea320ac6..f741bbb3 100644 --- a/e2e/src/type/orders.ts +++ b/e2e/src/type/orders.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiOrders/orders.json' +import fixture from '../fixtures/latest/orders.json' // test type const t: Orders[] = fixture; diff --git a/e2e/src/type/product-supplier.ts b/e2e/src/type/product-supplier.ts index a2f8b6f0..10489847 100644 --- a/e2e/src/type/product-supplier.ts +++ b/e2e/src/type/product-supplier.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiProducts/product_suppliers.json'; +import fixture from '../fixtures/latest/product_suppliers.json'; // test type const t: ProductSuppliers[] = fixture; diff --git a/e2e/src/type/products.ts b/e2e/src/type/products.ts index 4629eeb1..81f9323e 100644 --- a/e2e/src/type/products.ts +++ b/e2e/src/type/products.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiProducts/products.json' +import fixture from '../fixtures/latest/products.json' // test type const t: Products[] = fixture; diff --git a/e2e/src/type/shops.ts b/e2e/src/type/shops.ts index f9e9be2b..89358ca1 100644 --- a/e2e/src/type/shops.ts +++ b/e2e/src/type/shops.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiInfo/shops.json' +import fixture from '../fixtures/latest/shops.json' // test type const t: Shops[] = fixture; diff --git a/e2e/src/type/specific-prices.ts b/e2e/src/type/specific-prices.ts index 05d3b829..f35268f2 100644 --- a/e2e/src/type/specific-prices.ts +++ b/e2e/src/type/specific-prices.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiSpecificPrices/specific_prices.json' +import fixture from '../fixtures/latest/specific_prices.json' // test type const t: SpecificPrices[] = fixture; diff --git a/e2e/src/type/stocks.ts b/e2e/src/type/stocks.ts index b3df988d..78a71e46 100644 --- a/e2e/src/type/stocks.ts +++ b/e2e/src/type/stocks.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiStocks/stocks.json' +import fixture from '../fixtures/latest/stocks.json' // test type const t: Stocks[] = fixture; diff --git a/e2e/src/type/stores.ts b/e2e/src/type/stores.ts index bf2ef217..32bbd8b6 100644 --- a/e2e/src/type/stores.ts +++ b/e2e/src/type/stores.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiStores/stores.json' +import fixture from '../fixtures/latest/stores.json' // test type const t: Stores[] = fixture; diff --git a/e2e/src/type/suppliers.ts b/e2e/src/type/suppliers.ts index 38833290..4a308570 100644 --- a/e2e/src/type/suppliers.ts +++ b/e2e/src/type/suppliers.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/apiSuppliers/suppliers.json' +import fixture from '../fixtures/latest/suppliers.json' // test type const t: Suppliers[] = fixture; diff --git a/ps_eventbus.php b/ps_eventbus.php index d2a42027..73801480 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -234,7 +234,7 @@ public function getService($serviceName) return $this->get($serviceName); } - throw new ServiceNotFoundException('Service not found'); + throw new ServiceNotFoundException($serviceName); } } diff --git a/src/Config/Config.php b/src/Config/Config.php index 41a8744b..39ad3e95 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -53,7 +53,7 @@ class Config const COLLECTION_ORDERS = 'orders'; const COLLECTION_ORDER_CART_RULES = 'order_cart_rules'; const COLLECTION_ORDER_DETAILS = 'order_details'; - const COLLECTION_ORDER_STATUS_HISTORIES = 'order_status_histories'; + const COLLECTION_ORDER_HISTORIES = 'order_histories'; const COLLECTION_PRODUCTS = 'products'; const COLLECTION_PRODUCT_ATTRIBUTES = 'attributes'; const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; @@ -91,7 +91,7 @@ class Config self::COLLECTION_ORDERS, self::COLLECTION_ORDER_CART_RULES, self::COLLECTION_ORDER_DETAILS, - self::COLLECTION_ORDER_STATUS_HISTORIES, + self::COLLECTION_ORDER_HISTORIES, self::COLLECTION_PRODUCTS, self::COLLECTION_PRODUCT_ATTRIBUTES, self::COLLECTION_PRODUCT_BUNDLES, diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 294d2a2e..f6d83e7e 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -93,7 +93,7 @@ public function handle($error, $code = null, $throw = null, $data = null) \PrestaShopLogger::addLog( $error->getMessage() . ' : ' . $error->getFile() . ':' . $error->getLine() . ' | ' . $error->getTraceAsString(), 3, - $error->getCode(), + $error->getCode() > 0 ? $error->getCode() : 500, 'Module', \Module::getModuleIdByName('ps_eventbus'), true diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/NewRepository/OrderCartRuleRepository.php index 009cdf51..b7cfe543 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/NewRepository/OrderCartRuleRepository.php @@ -7,24 +7,28 @@ class OrderCartRuleRepository extends AbstractRepository implements RepositoryIn const TABLE_NAME = 'order_cart_rule'; /** + * @param string $langIso + * * @return mixed * * @throws \PrestaShopException */ - public function generateBaseQuery() + public function generateBaseQuery($langIso) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'ocr'); + $this->query + ->from(self::TABLE_NAME, 'ocr'); - $this->query->select('ocr.id_order_cart_rule'); - $this->query->select('ocr.id_order'); - $this->query->select('ocr.id_cart_rule'); - $this->query->select('ocr.id_order_invoice'); - $this->query->select('ocr.name'); - $this->query->select('ocr.value'); - $this->query->select('ocr.value_tax_excl'); - $this->query->select('ocr.free_shipping'); + $this->query + ->select('ocr.id_order_cart_rule') + ->select('ocr.id_order') + ->select('ocr.id_cart_rule') + ->select('ocr.id_order_invoice') + ->select('ocr.name') + ->select('ocr.value') + ->select('ocr.value_tax_excl') + ->select('ocr.free_shipping'); if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.7.0', '>=')) { $this->query->select('ocr.deleted'); @@ -44,7 +48,7 @@ public function generateBaseQuery() */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateBaseQuery(); + $this->generateBaseQuery($langIso); $this->query->limit((int) $limit, (int) $offset); @@ -64,9 +68,10 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateBaseQuery(); + $this->generateBaseQuery($langIso); - $this->query->where('ocr.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + $this->query + ->where('ocr.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); return $this->runQuery($debug); diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php new file mode 100644 index 00000000..854847a2 --- /dev/null +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -0,0 +1,128 @@ +query = new \DbQuery(); + + $this->query + ->from(self::TABLE_NAME, 'oh') + ->innerJoin('order_state', 'os', 'os.id_order_state = oh.id_order_State') + ->innerJoin('order_state_lang', 'osl', 'osl.id_order_state = os.id_order_State AND osl.id_lang = ' . (int) $langId) + ; + + $this->query + ->select('oh.id_order_state') + ->select('osl.name') + ->select('osl.template') + ->select('oh.date_add') + ->select('oh.id_order') + ->select('oh.id_order_history') + ->select('os.logable') + ->select('os.delivery') + ->select('os.shipped') + ->select('os.paid') + ->select('os.deleted') + ; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateBaseQuery($langIso); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateBaseQuery($langIso); + + $this->query + ->where('oh.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + + if (!is_array($result) || empty($result)) { + return 0; + } + + return count($result); + } + + /** + * @param array $orderIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopDatabaseException + */ + public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $debug) + { + if (!$orderIds) { + return []; + } + + $this->generateBaseQuery($langIso); + + $this->query->where('oh.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')'); + + return $this->runQuery($debug); + } +} diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php index d8cf2242..29053013 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -4,18 +4,21 @@ class OrderRepository extends AbstractRepository implements RepositoryInterface { - const ORDERS_TABLE = 'orders'; + const TABLE_NAME = 'orders'; /** + * @param string $langIso + * * @return mixed * * @throws \PrestaShopException */ - public function generateBaseQuery() + public function generateBaseQuery($langIso) { $this->query = new \DbQuery(); - $this->query->from(self::ORDERS_TABLE, 'o') + $this->query + ->from(self::TABLE_NAME, 'o') ->leftJoin('currency', 'c', 'o.id_currency = c.id_currency') ->leftJoin('order_slip', 'os', 'o.id_order = os.id_order') ->leftJoin('address', 'ad', 'ad.id_address = o.id_address_delivery') @@ -25,60 +28,61 @@ public function generateBaseQuery() ->leftJoin('order_state_lang', 'osl', 'o.current_state = osl.id_order_state') ->leftJoin('order_state', 'ost', 'o.current_state = ost.id_order_state') ->where('o.id_shop = ' . (int) parent::getShopId()) - ->groupBy('o.id_order'); - - $this->query->select('o.id_order'); - $this->query->select('o.reference'); - $this->query->select('o.id_customer'); - $this->query->select('o.id_cart'); - $this->query->select('o.current_state'); - $this->query->select('o.conversion_rate'); - $this->query->select('o.total_paid_tax_excl'); - $this->query->select('o.total_paid_tax_incl'); - - $this->query->select('c.iso_code as currency'); - $this->query->select('o.module as payment_module'); - $this->query->select('o.payment as payment_mode'); - $this->query->select('o.total_paid_real'); - $this->query->select('o.total_shipping as shipping_cost'); - $this->query->select('o.date_add as created_at'); - $this->query->select('o.date_upd as updated_at'); - $this->query->select('o.id_carrier'); - $this->query->select('o.payment as payment_name'); - $this->query->select('o.valid as is_validated'); - $this->query->select('ost.paid as is_paid'); - $this->query->select('ost.shipped as is_shipped'); - $this->query->select('osl.name as status_label'); - $this->query->select('o.module as payment_name'); - $this->query->select('o.id_shop_group'); - $this->query->select('o.id_shop'); - $this->query->select('o.id_lang'); - $this->query->select('o.id_currency'); - $this->query->select('o.recyclable'); - $this->query->select('o.gift'); - $this->query->select('o.total_discounts'); - $this->query->select('o.total_discounts_tax_incl'); - $this->query->select('o.total_discounts_tax_excl'); - $this->query->select('o.total_products'); - $this->query->select('o.total_products_wt'); - $this->query->select('o.total_shipping_tax_incl'); - $this->query->select('o.total_shipping_tax_excl'); - $this->query->select('o.carrier_tax_rate'); - $this->query->select('o.total_wrapping'); - $this->query->select('o.total_wrapping_tax_incl'); - $this->query->select('o.total_wrapping_tax_excl'); - $this->query->select('o.round_mode'); - $this->query->select('o.round_type'); - $this->query->select('o.invoice_number'); - $this->query->select('o.delivery_number'); - $this->query->select('o.invoice_date'); - $this->query->select('o.delivery_date'); - $this->query->select('o.valid'); - - $this->query->select('SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund'); - $this->query->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl'); - $this->query->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso'); - $this->query->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer'); + ->groupBy('o.id_order') + ; + + $this->query + ->select('o.id_order') + ->select('o.reference') + ->select('o.id_customer') + ->select('o.id_cart') + ->select('o.current_state') + ->select('o.conversion_rate') + ->select('o.total_paid_tax_excl') + ->select('o.total_paid_tax_incl') + ->select('c.iso_code as currency') + ->select('o.module as payment_module') + ->select('o.payment as payment_mode') + ->select('o.total_paid_real') + ->select('o.total_shipping as shipping_cost') + ->select('o.date_add as created_at') + ->select('o.date_upd as updated_at') + ->select('o.id_carrier') + ->select('o.payment as payment_name') + ->select('o.valid as is_validated') + ->select('ost.paid as is_paid') + ->select('ost.shipped as is_shipped') + ->select('osl.name as status_label') + ->select('o.module as payment_name') + ->select('o.id_shop_group') + ->select('o.id_shop') + ->select('o.id_lang') + ->select('o.id_currency') + ->select('o.recyclable') + ->select('o.gift') + ->select('o.total_discounts') + ->select('o.total_discounts_tax_incl') + ->select('o.total_discounts_tax_excl') + ->select('o.total_products') + ->select('o.total_products_wt') + ->select('o.total_shipping_tax_incl') + ->select('o.total_shipping_tax_excl') + ->select('o.carrier_tax_rate') + ->select('o.total_wrapping') + ->select('o.total_wrapping_tax_incl') + ->select('o.total_wrapping_tax_excl') + ->select('o.round_mode') + ->select('o.round_type') + ->select('o.invoice_number') + ->select('o.delivery_number') + ->select('o.invoice_date') + ->select('o.delivery_date') + ->select('o.valid') + ->select('SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund') + ->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl') + ->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso') + ->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer') + ; } /** @@ -94,7 +98,7 @@ public function generateBaseQuery() */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateBaseQuery(); + $this->generateBaseQuery($langIso); $this->query->limit((int) $limit, (int) $offset); @@ -114,10 +118,12 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateBaseQuery(); + $this->generateBaseQuery($langIso); - $this->query->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') - ->limit($limit); + $this->query + ->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; return $this->runQuery($debug); } diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php index 2d484318..d6ec5a21 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -8,9 +8,11 @@ interface RepositoryInterface { /** + * @param string $langIso + * * @return mixed */ - public function generateBaseQuery(); + public function generateBaseQuery($langIso); /** * @param int $offset diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php deleted file mode 100644 index 99385541..00000000 --- a/src/Repository/OrderHistoryRepository.php +++ /dev/null @@ -1,80 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - $query = new \DbQuery(); - - $query->from(self::TABLE_NAME, 'oh'); - - return $query; - } - - /** - * @param array $orderIds - * @param int|null $langId - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getOrderHistoryStatuses($orderIds, $langId) - { - if (!$orderIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('oh.id_order_state, osl.name, osl.template, oh.date_add, oh.id_order, oh.id_order_history') - ->select('os.logable, os.delivery, os.shipped, os.paid, os.deleted') - ->innerJoin('order_state', 'os', 'os.id_order_state = oh.id_order_State') - ->innerJoin('order_state_lang', 'osl', 'osl.id_order_state = os.id_order_State AND osl.id_lang = ' . (int) $langId) - ->where('oh.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')') - ; - - return $this->db->executeS($query); - } - - /** - * @param array $orderIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getOrderHistoryStatuseIdsByOrderIds($orderIds) - { - if (!$orderIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('oh.id_order_state as id') - ->where('oh.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')') - ; - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } -} diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index 59581db3..9b2c9153 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -26,21 +26,21 @@ public function __construct( */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $orders = $this->orderCartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $orderCartRules = $this->orderCartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); - if (empty($orders)) { + if (empty($orderCartRules)) { return []; } - $this->castOrderCartRules($orders, $langIso); + $this->castOrderCartRules($orderCartRules); - return array_map(function ($order) { + return array_map(function ($orderCartRule) { return [ - 'id' => $order['id_order'], - 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, + 'id' => $orderCartRule['id_order_cart_rule'], + 'collection' => Config::COLLECTION_ORDER_CART_RULES, + 'properties' => $orderCartRule, ]; - }, $orders); + }, $orderCartRules); } /** @@ -53,21 +53,21 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $orders = $this->orderCartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $orderCartRules = $this->orderCartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); - if (empty($orders)) { + if (empty($orderCartRules)) { return []; } - $this->castOrderCartRules($orders, $langIso); + $this->castOrderCartRules($orderCartRules); - return array_map(function ($order) { + return array_map(function ($orderCartRule) { return [ - 'id' => $order['id_order'], - 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, + 'id' => $orderCartRule['id_order_cart_rule'], + 'collection' => Config::COLLECTION_ORDER_CART_RULES, + 'properties' => $orderCartRule, ]; - }, $orders); + }, $orderCartRules); } /** @@ -83,41 +83,40 @@ public function countFullSyncContentLeft($offset, $langIso, $debug) } /** - * @param array $cartRules - * @param string $langIso + * @param array $orderCartRules * * @return void */ - public function castOrderCartRules(&$cartRules, $langIso) + public function castOrderCartRules(&$orderCartRules) { - foreach ($cartRules as &$cartRule) { - $cartRule['id_cart_rule'] = (int) $cartRule['id_cart_rule']; - $cartRule['id_customer'] = (int) $cartRule['id_customer']; - $cartRule['quantity'] = (int) $cartRule['quantity']; - $cartRule['quantity_per_user'] = (int) $cartRule['quantity_per_user']; - $cartRule['priority'] = (int) $cartRule['priority']; - $cartRule['partial_use'] = (bool) $cartRule['partial_use']; - $cartRule['minimum_amount'] = (float) $cartRule['minimum_amount']; - $cartRule['minimum_amount_tax'] = (bool) $cartRule['minimum_amount_tax']; - $cartRule['minimum_amount_currency'] = (int) $cartRule['minimum_amount_currency']; - $cartRule['minimum_amount_shipping'] = (bool) $cartRule['minimum_amount_shipping']; - $cartRule['country_restriction'] = (bool) $cartRule['country_restriction']; - $cartRule['carrier_restriction'] = (bool) $cartRule['carrier_restriction']; - $cartRule['group_restriction'] = (bool) $cartRule['group_restriction']; - $cartRule['cart_rule_restriction'] = (bool) $cartRule['cart_rule_restriction']; - $cartRule['product_restriction'] = (bool) $cartRule['product_restriction']; - $cartRule['shop_restriction'] = (bool) $cartRule['shop_restriction']; - $cartRule['free_shipping'] = (bool) $cartRule['free_shipping']; - $cartRule['reduction_percent'] = (float) $cartRule['reduction_percent']; - $cartRule['reduction_amount'] = (float) $cartRule['reduction_amount']; - $cartRule['reduction_tax'] = (bool) $cartRule['reduction_tax']; - $cartRule['reduction_currency'] = (int) $cartRule['reduction_currency']; - $cartRule['reduction_product'] = (int) $cartRule['reduction_product']; - $cartRule['reduction_exclude_special'] = (bool) $cartRule['reduction_exclude_special']; - $cartRule['gift_product'] = (int) $cartRule['gift_product']; - $cartRule['gift_product_attribute'] = (int) $cartRule['gift_product_attribute']; - $cartRule['highlight'] = (bool) $cartRule['highlight']; - $cartRule['active'] = (bool) $cartRule['active']; + foreach ($orderCartRules as &$orderCartRule) { + $orderCartRule['id_cart_rule'] = (int) $orderCartRule['id_cart_rule']; + $orderCartRule['id_customer'] = (int) $orderCartRule['id_customer']; + $orderCartRule['quantity'] = (int) $orderCartRule['quantity']; + $orderCartRule['quantity_per_user'] = (int) $orderCartRule['quantity_per_user']; + $orderCartRule['priority'] = (int) $orderCartRule['priority']; + $orderCartRule['partial_use'] = (bool) $orderCartRule['partial_use']; + $orderCartRule['minimum_amount'] = (float) $orderCartRule['minimum_amount']; + $orderCartRule['minimum_amount_tax'] = (bool) $orderCartRule['minimum_amount_tax']; + $orderCartRule['minimum_amount_currency'] = (int) $orderCartRule['minimum_amount_currency']; + $orderCartRule['minimum_amount_shipping'] = (bool) $orderCartRule['minimum_amount_shipping']; + $orderCartRule['country_restriction'] = (bool) $orderCartRule['country_restriction']; + $orderCartRule['carrier_restriction'] = (bool) $orderCartRule['carrier_restriction']; + $orderCartRule['group_restriction'] = (bool) $orderCartRule['group_restriction']; + $orderCartRule['cart_rule_restriction'] = (bool) $orderCartRule['cart_rule_restriction']; + $orderCartRule['product_restriction'] = (bool) $orderCartRule['product_restriction']; + $orderCartRule['shop_restriction'] = (bool) $orderCartRule['shop_restriction']; + $orderCartRule['free_shipping'] = (bool) $orderCartRule['free_shipping']; + $orderCartRule['reduction_percent'] = (float) $orderCartRule['reduction_percent']; + $orderCartRule['reduction_amount'] = (float) $orderCartRule['reduction_amount']; + $orderCartRule['reduction_tax'] = (bool) $orderCartRule['reduction_tax']; + $orderCartRule['reduction_currency'] = (int) $orderCartRule['reduction_currency']; + $orderCartRule['reduction_product'] = (int) $orderCartRule['reduction_product']; + $orderCartRule['reduction_exclude_special'] = (bool) $orderCartRule['reduction_exclude_special']; + $orderCartRule['gift_product'] = (int) $orderCartRule['gift_product']; + $orderCartRule['gift_product_attribute'] = (int) $orderCartRule['gift_product_attribute']; + $orderCartRule['highlight'] = (bool) $orderCartRule['highlight']; + $orderCartRule['active'] = (bool) $orderCartRule['active']; } } } diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php new file mode 100644 index 00000000..c32f13e4 --- /dev/null +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -0,0 +1,107 @@ +orderHistoryRepository = $orderHistoryRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $orderHistories = $this->orderHistoryRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($orderHistories)) { + return []; + } + + $this->castOrderHistories($orderHistories); + + return array_map(function ($orderHistory) { + return [ + 'id' => $orderHistory['id_order_history'], + 'collection' => Config::COLLECTION_ORDER_HISTORIES, + 'properties' => $orderHistory, + ]; + }, $orderHistories); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $orderHistories = $this->orderHistoryRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($orderHistories)) { + return []; + } + + $this->castOrderHistories($orderHistories); + + return array_map(function ($orderHistory) { + return [ + 'id' => $orderHistory['id_order_history'], + 'collection' => Config::COLLECTION_ORDER_HISTORIES, + 'properties' => $orderHistory, + ]; + }, $orderHistories); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + return (int) $this->orderHistoryRepository->countFullSyncContentLeft($offset, $langIso, $debug); + } + + /** + * @param array $orderHistories + * + * @return void + */ + public function castOrderHistories(&$orderHistories) + { + foreach ($orderHistories as &$orderHistory) { + $orderHistory['id_order_state'] = (int) $orderHistory['id_order_state']; + $orderHistory['id_order'] = (int) $orderHistory['id_order']; + $orderHistory['id_order_history'] = (int) $orderHistory['id_order_history']; + $orderHistory['name'] = (string) $orderHistory['name']; + $orderHistory['template'] = (string) $orderHistory['template']; + $orderHistory['date_add'] = $orderHistory['date_add']; + $orderHistory['is_validated'] = (bool) $orderHistory['logable']; + $orderHistory['is_delivered'] = (bool) $orderHistory['delivery']; + $orderHistory['is_shipped'] = (bool) $orderHistory['shipped']; + $orderHistory['is_paid'] = (bool) $orderHistory['paid']; + $orderHistory['is_deleted'] = (bool) $orderHistory['deleted']; + $orderHistory['created_at'] = $orderHistory['date_add']; + $orderHistory['updated_at'] = $orderHistory['date_add']; + } + } +} diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index b54178a2..5af0e9f6 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -4,8 +4,8 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository; use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository; -use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; class OrdersService implements ShopContentServiceInterface { @@ -44,7 +44,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castOrders($orders, $langIso); + $this->castOrders($orders, $langIso, $debug); return array_map(function ($order) { return [ @@ -71,7 +71,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castOrders($orders, $langIso); + $this->castOrders($orders, $langIso, $debug); return array_map(function ($order) { return [ @@ -97,13 +97,12 @@ public function countFullSyncContentLeft($offset, $langIso, $debug) /** * @param array $orders * @param string $langIso + * @param bool $debug * * @return void */ - public function castOrders(&$orders, $langIso) + public function castOrders(&$orders, $langIso, $debug) { - $langId = (int) \Language::getIdByIso($langIso); - foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; $order['id_customer'] = (int) $order['id_customer']; @@ -114,7 +113,7 @@ public function castOrders(&$orders, $langIso) $order['refund'] = (float) $order['refund']; $order['refund_tax_excl'] = (float) $order['refund_tax_excl']; $order['new_customer'] = $order['new_customer'] == 1; - $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langId); + $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langIso, $debug); $order['shipping_cost'] = (float) $order['shipping_cost']; $order['total_paid_tax'] = $order['total_paid_tax_incl'] - $order['total_paid_tax_excl']; $order['id_carrier'] = (int) $order['id_carrier']; @@ -152,20 +151,21 @@ public function castOrders(&$orders, $langIso) /** * @param array $orders * @param array $order - * @param int|null $langId + * @param string $langIso + * @param bool $debug * * @return bool * * @@throws \PrestaShopDatabaseException */ - private function castIsPaidValue($orders, $order, $langId) + private function castIsPaidValue($orders, $order, $langIso, $debug) { $isPaid = $dateAdd = 0; $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - /** @var array $orderHistoryStatuses */ - $orderHistoryStatuses = $this->orderHistoryRepository->getOrderHistoryStatuses($orderIds, $langId); + /** @var array $orderHistoryStatuss */ + $orderHistoryStatuss = $this->orderHistoryRepository->getOrderHistoryIdsByOrderIds($orderIds, $langIso, $debug); - foreach ($orderHistoryStatuses as &$orderHistoryStatus) { + foreach ($orderHistoryStatuss as &$orderHistoryStatus) { if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { $isPaid = (bool) $orderHistoryStatus['paid']; $dateAdd = $orderHistoryStatus['date_add']; From 50260050dcbce9f3259070f6dd1d40161a13b80d Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:21:46 +0200 Subject: [PATCH 064/162] feat: pseventbus v4 order details (#350) --- config/common/new-repository.yml | 4 + config/common/repository.yml | 4 +- config/front/services.yml | 6 + e2e/src/full-sync.spec.ts | 80 +++++++----- e2e/src/helpers/shop-contents.ts | 5 +- .../NewRepository/OrderDetailRepository.php | 121 ++++++++++++++++++ .../NewRepository/OrderHistoryRepository.php | 10 +- src/Repository/OrderDetailsRepository.php | 97 -------------- .../ShopContent/OrderCartRulesService.php | 33 +++-- .../ShopContent/OrderDetailsService.php | 111 ++++++++++++++++ .../ShopContent/OrderHistoriesService.php | 38 +++--- src/Service/ShopContent/OrdersService.php | 32 ++--- 12 files changed, 353 insertions(+), 188 deletions(-) create mode 100644 src/Repository/NewRepository/OrderDetailRepository.php delete mode 100644 src/Repository/OrderDetailsRepository.php create mode 100644 src/Service/ShopContent/OrderDetailsService.php diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index a61bdcdf..8d64c837 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -10,3 +10,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index bd2c8946..59fe9882 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -68,8 +68,8 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderDetailsRepository + PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' diff --git a/config/front/services.yml b/config/front/services.yml index 2ea84edd..57c26aba 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -72,3 +72,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 4dde48ed..4ec84c0b 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -3,7 +3,7 @@ import * as matchers from "jest-extended"; import { dumpUploadData, logAxiosError } from "./helpers/log-helper"; import axios, { AxiosError } from "axios"; import { doFullSync, probe, PsEventbusSyncUpload } from "./helpers/mock-probe"; -import { concatMap, from, lastValueFrom, map, toArray, zip } from "rxjs"; +import { concatMap, from, lastValueFrom, map, TimeoutError, toArray, zip } from "rxjs"; import { generatePredictableModuleId, loadFixture, @@ -148,22 +148,35 @@ describe('Full Sync', () => { }) ); - const results = await lastValueFrom( - zip(message$, request$).pipe( - map((result) => ({ - probeMessage: result[0], - psEventbusReq: result[1], - })), - toArray() - ) - ); - - // assert - expect(results.length).toEqual(1); - expect(results[0].probeMessage.method).toBe("POST"); - expect(results[0].probeMessage.headers).toMatchObject({ - "full-sync-requested": "1", - }); + // check if shopcontent have items lenght > 0 + request$.subscribe(async (request) => { + if (request.data.total_objects != 0) { + let results; + + try { + results = await lastValueFrom( + zip(message$, request$).pipe( + map((result) => ({ + probeMessage: result[0], + psEventbusReq: result[1], + })), + toArray() + ) + ); + } catch (error) { + if (error instanceof TimeoutError) { + throw new Error(`Upload to collector for "${shopContent}" throw TimeoutError with jobId "${jobId}"`) + } + } + + // assert + expect(results.length).toEqual(1); + expect(results[0].probeMessage.method).toBe("POST"); + expect(results[0].probeMessage.headers).toMatchObject({ + "full-sync-requested": "1", + }); + } + }) }); } @@ -172,21 +185,30 @@ describe('Full Sync', () => { it.skip(`${shopContent} should upload complete dataset to collector`, () => {}); } else { it(`${shopContent} should upload complete dataset collector`, async () => { - // arrange const fullSync$ = doFullSync(jobId, shopContent, { timeout: 4000 }); const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); - - // act - const syncedData: PsEventbusSyncUpload[] = await lastValueFrom( - zip(fullSync$, message$).pipe( - map((msg) => msg[1].body.file), - concatMap((syncedPage) => { - return from(syncedPage); - }), - toArray() - ) - ); + + let syncedData: PsEventbusSyncUpload[]; + + try { + // act + syncedData = await lastValueFrom( + zip(fullSync$, message$).pipe( + map((msg) => { + return msg[1].body.file + }), + concatMap((syncedPage) => { + return from(syncedPage); + }), + toArray() + ) + ); + } catch (error) { + if (error instanceof TimeoutError) { + throw new Error(`Upload complete dataset collector for "${shopContent}" throw TimeoutError with jobId "${jobId}"`) + } + } // dump data for easier debugging or updating fixtures if (testConfig.dumpFullSyncData) { diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 5dc033e6..bf8a9bfe 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -15,10 +15,6 @@ import R from "ramda"; 'customers': 'customers', 'taxonomies': 'taxonomies', 'modules': 'modules', - 'orders': 'orders', - 'order_details': 'order-details', - 'order_histories': 'order-histories', - 'order_cart_rules': 'order-cart-rules', 'products': 'products', 'shops': 'info', 'stores': 'stores', @@ -42,6 +38,7 @@ export const shopContentMapping = { 'orders': 'orders', 'order_histories': 'order-histories', 'order_cart_rules': 'order-cart-rules', + 'order_details': 'order-details' } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php new file mode 100644 index 00000000..9803b38c --- /dev/null +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -0,0 +1,121 @@ +shop === null) { + throw new \PrestaShopException('No shop context'); + } + + $this->query = new \DbQuery(); + + $this->query + ->from(self::TABLE_NAME, 'od') + ->where('od.id_shop = ' . $context->shop->id) + ->innerJoin('orders', 'o', 'od.id_order = o.id_order') + ->leftJoin('order_slip_detail', 'osd', 'od.id_order_detail = osd.id_order_detail') + ->leftJoin('product_shop', 'ps', 'od.product_id = ps.id_product AND ps.id_shop = ' . (int) $context->shop->id) + ->leftJoin('currency', 'c', 'c.id_currency = o.id_currency') + ->leftJoin('lang', 'l', 'o.id_lang = l.id_lang') + ->groupBy('od.id_order_detail') + ; + + $this->query + ->select('od.id_order_detail') + ->select('od.id_order') + ->select('od.product_id') + ->select('od.product_attribute_id') + ->select('od.product_quantity') + ->select('od.unit_price_tax_incl') + ->select('od.unit_price_tax_excl') + ->select('SUM(osd.total_price_tax_incl) as refund') + ->select('SUM(osd.total_price_tax_excl) as refund_tax_excl') + ->select('c.iso_code as currency') + ->select('ps.id_category_default as category') + ->select('l.iso_code') + ->select('o.conversion_rate as conversion_rate') + ; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateBaseQuery($langIso); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateBaseQuery($langIso); + + $this->query + ->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + + if (!is_array($result) || empty($result)) { + return 0; + } + + return count($result); + } +} diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php index 854847a2..dcb742d0 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -32,11 +32,11 @@ public function generateBaseQuery($langIso) ->select('oh.date_add') ->select('oh.id_order') ->select('oh.id_order_history') - ->select('os.logable') - ->select('os.delivery') - ->select('os.shipped') - ->select('os.paid') - ->select('os.deleted') + ->select('os.logable AS is_validated') + ->select('os.delivery AS is_delivered') + ->select('os.shipped AS is_shipped') + ->select('os.paid AS is_paid') + ->select('os.deleted AS is_deleted') ; } diff --git a/src/Repository/OrderDetailsRepository.php b/src/Repository/OrderDetailsRepository.php deleted file mode 100644 index b019ae87..00000000 --- a/src/Repository/OrderDetailsRepository.php +++ /dev/null @@ -1,97 +0,0 @@ -context = $context; - $this->db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - - $query->from(self::TABLE_NAME, 'od') - ->where('od.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param array $orderIds - * @param int $shopId - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getOrderDetails($orderIds, $shopId) - { - if (!$orderIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('od.id_order_detail, od.id_order, od.product_id, od.product_attribute_id'); - $query->select('od.product_quantity, od.unit_price_tax_incl, od.unit_price_tax_excl, SUM(osd.total_price_tax_incl) as refund'); - $query->select('SUM(osd.total_price_tax_excl) as refund_tax_excl, c.iso_code as currency, ps.id_category_default as category'); - $query->select('l.iso_code, o.conversion_rate as conversion_rate') - ->leftJoin('order_slip_detail', 'osd', 'od.id_order_detail = osd.id_order_detail') - ->leftJoin('product_shop', 'ps', 'od.product_id = ps.id_product AND ps.id_shop = ' . (int) $shopId) - ->innerJoin('orders', 'o', 'od.id_order = o.id_order') - ->leftJoin('currency', 'c', 'c.id_currency = o.id_currency') - ->leftJoin('lang', 'l', 'o.id_lang = l.id_lang') - ->where('od.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')') - ->groupBy('od.id_order_detail'); - - return $this->db->executeS($query); - } - - /** - * @param array $orderIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getOrderDetailIdsByOrderIds($orderIds) - { - if (!$orderIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('od.id_order_detail as id') - ->where('od.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')') - ->groupBy('od.id_order_detail'); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } -} diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index 9b2c9153..5d1b2f7a 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -10,9 +10,8 @@ class OrderCartRulesService implements ShopContentServiceInterface /** @var OrderCartRuleRepository */ private $orderCartRuleRepository; - public function __construct( - OrderCartRuleRepository $orderCartRuleRepository - ) { + public function __construct(OrderCartRuleRepository $orderCartRuleRepository) + { $this->orderCartRuleRepository = $orderCartRuleRepository; } @@ -26,21 +25,21 @@ public function __construct( */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $orderCartRules = $this->orderCartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderCartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); - if (empty($orderCartRules)) { + if (empty($result)) { return []; } - $this->castOrderCartRules($orderCartRules); + $this->castOrderCartRules($result); - return array_map(function ($orderCartRule) { + return array_map(function ($item) { return [ - 'id' => $orderCartRule['id_order_cart_rule'], + 'id' => $item['id_order_cart_rule'], 'collection' => Config::COLLECTION_ORDER_CART_RULES, - 'properties' => $orderCartRule, + 'properties' => $item, ]; - }, $orderCartRules); + }, $result); } /** @@ -53,21 +52,21 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $orderCartRules = $this->orderCartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderCartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); - if (empty($orderCartRules)) { + if (empty($result)) { return []; } - $this->castOrderCartRules($orderCartRules); + $this->castOrderCartRules($result); - return array_map(function ($orderCartRule) { + return array_map(function ($item) { return [ - 'id' => $orderCartRule['id_order_cart_rule'], + 'id' => $item['id_order_cart_rule'], 'collection' => Config::COLLECTION_ORDER_CART_RULES, - 'properties' => $orderCartRule, + 'properties' => $item, ]; - }, $orderCartRules); + }, $result); } /** diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php new file mode 100644 index 00000000..bc85c068 --- /dev/null +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -0,0 +1,111 @@ +orderDetailRepository = $orderDetailRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->orderDetailRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castOrderDetails($result, $langIso, $debug); + + return array_map(function ($item) { + return [ + 'id' => $item['id_order_detail'], + 'collection' => Config::COLLECTION_ORDER_DETAILS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $orderDetailIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $debug) + { + $result = $this->orderDetailRepository->getContentsForIncremental($limit, $orderDetailIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castOrderDetails($result, $langIso, $debug); + + return array_map(function ($item) { + return [ + 'id' => $item['id_order_detail'], + 'collection' => Config::COLLECTION_ORDER_DETAILS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + return (int) $this->orderDetailRepository->countFullSyncContentLeft($offset, $langIso, $debug); + } + + /** + * @param array $orderDetails + * @param string $langIso + * @param bool $debug + * + * @return void + */ + private function castOrderDetails(&$orderDetails, $langIso, $debug) + { + foreach ($orderDetails as &$orderDetail) { + $orderDetail['id_order_detail'] = (int) $orderDetail['id_order_detail']; + $orderDetail['id_order'] = (int) $orderDetail['id_order']; + $orderDetail['product_id'] = (int) $orderDetail['product_id']; + $orderDetail['product_attribute_id'] = (int) $orderDetail['product_attribute_id']; + $orderDetail['product_quantity'] = (int) $orderDetail['product_quantity']; + $orderDetail['unit_price_tax_incl'] = (float) $orderDetail['unit_price_tax_incl']; + $orderDetail['unit_price_tax_excl'] = (float) $orderDetail['unit_price_tax_excl']; + $orderDetail['refund'] = (float) $orderDetail['refund'] > 0 ? -1 * (float) $orderDetail['refund'] : 0; + $orderDetail['refund_tax_excl'] = (float) $orderDetail['refund_tax_excl'] > 0 ? -1 * (float) $orderDetail['refund_tax_excl'] : 0; + $orderDetail['category'] = (int) $orderDetail['category']; + $orderDetail['unique_product_id'] = "{$orderDetail['product_id']}-{$orderDetail['product_attribute_id']}-{$orderDetail['iso_code']}"; + $orderDetail['conversion_rate'] = (float) $orderDetail['conversion_rate']; + + // remove extra properties + unset($orderDetail['iso_code']); + } + } +} diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index c32f13e4..235a8be7 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -25,21 +25,21 @@ public function __construct(OrderHistoryRepository $orderHistoryRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $orderHistories = $this->orderHistoryRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderHistoryRepository->getContentsForFull($offset, $limit, $langIso, $debug); - if (empty($orderHistories)) { + if (empty($result)) { return []; } - $this->castOrderHistories($orderHistories); + $this->castOrderHistories($result); - return array_map(function ($orderHistory) { + return array_map(function ($item) { return [ - 'id' => $orderHistory['id_order_history'], + 'id' => $item['id_order_history'], 'collection' => Config::COLLECTION_ORDER_HISTORIES, - 'properties' => $orderHistory, + 'properties' => $item, ]; - }, $orderHistories); + }, $result); } /** @@ -52,21 +52,21 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $orderHistories = $this->orderHistoryRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderHistoryRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); - if (empty($orderHistories)) { + if (empty($result)) { return []; } - $this->castOrderHistories($orderHistories); + $this->castOrderHistories($result); - return array_map(function ($orderHistory) { + return array_map(function ($item) { return [ - 'id' => $orderHistory['id_order_history'], + 'id' => $item['id_order_history'], 'collection' => Config::COLLECTION_ORDER_HISTORIES, - 'properties' => $orderHistory, + 'properties' => $item, ]; - }, $orderHistories); + }, $result); } /** @@ -95,11 +95,11 @@ public function castOrderHistories(&$orderHistories) $orderHistory['name'] = (string) $orderHistory['name']; $orderHistory['template'] = (string) $orderHistory['template']; $orderHistory['date_add'] = $orderHistory['date_add']; - $orderHistory['is_validated'] = (bool) $orderHistory['logable']; - $orderHistory['is_delivered'] = (bool) $orderHistory['delivery']; - $orderHistory['is_shipped'] = (bool) $orderHistory['shipped']; - $orderHistory['is_paid'] = (bool) $orderHistory['paid']; - $orderHistory['is_deleted'] = (bool) $orderHistory['deleted']; + $orderHistory['is_validated'] = (bool) $orderHistory['is_validated']; + $orderHistory['is_delivered'] = (bool) $orderHistory['is_delivered']; + $orderHistory['is_shipped'] = (bool) $orderHistory['is_shipped']; + $orderHistory['is_paid'] = (bool) $orderHistory['is_paid']; + $orderHistory['is_deleted'] = (bool) $orderHistory['is_deleted']; $orderHistory['created_at'] = $orderHistory['date_add']; $orderHistory['updated_at'] = $orderHistory['date_add']; } diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 5af0e9f6..07f99733 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -38,21 +38,21 @@ public function __construct( */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $orders = $this->orderRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderRepository->getContentsForFull($offset, $limit, $langIso, $debug); - if (empty($orders)) { + if (empty($result)) { return []; } - $this->castOrders($orders, $langIso, $debug); + $this->castOrders($result, $langIso, $debug); - return array_map(function ($order) { + return array_map(function ($item) { return [ - 'id' => $order['id_order'], + 'id' => $item['id_order'], 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, + 'properties' => $item, ]; - }, $orders); + }, $result); } /** @@ -65,21 +65,21 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $orders = $this->orderRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); - if (empty($orders)) { + if (empty($result)) { return []; } - $this->castOrders($orders, $langIso, $debug); + $this->castOrders($result, $langIso, $debug); - return array_map(function ($order) { + return array_map(function ($item) { return [ - 'id' => $order['id_order'], + 'id' => $item['id_order'], 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $order, + 'properties' => $item, ]; - }, $orders); + }, $result); } /** @@ -144,6 +144,8 @@ public function castOrders(&$orders, $langIso, $debug) $order['valid'] = (bool) $order['valid']; $this->castAddressIsoCodes($order); + + // remove extra properties unset($order['address_iso']); } } @@ -167,7 +169,7 @@ private function castIsPaidValue($orders, $order, $langIso, $debug) foreach ($orderHistoryStatuss as &$orderHistoryStatus) { if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { - $isPaid = (bool) $orderHistoryStatus['paid']; + $isPaid = (bool) $orderHistoryStatus['is_paid']; $dateAdd = $orderHistoryStatus['date_add']; } } From 2b47db39ce71676e96c01d5a69b8c7f9b0cfff57 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:33:26 +0200 Subject: [PATCH 065/162] feat: pseventbus v4 carriers (#353) --- OLD/Provider/CarrierDataProvider.php | 137 ---------- config/common/builder.yml | 2 +- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 8 + e2e/src/full-sync.spec.ts | 5 +- e2e/src/helpers/shop-contents.ts | 6 +- e2e/src/reject-invalid-job-id.spec.ts | 5 +- src/Builder/CarrierBuilder.php | 152 ++++++++--- src/Config/Config.php | 2 + src/DTO/Carrier.php | 81 ++---- src/Repository/CarrierRepository.php | 235 ------------------ .../NewRepository/CarrierRepository.php | 103 ++++++++ src/Service/ShopContent/CarriersService.php | 113 +++++++++ src/Service/SynchronizationService.php | 6 +- src/Traits/UseHooks.php | 9 + 16 files changed, 389 insertions(+), 485 deletions(-) delete mode 100644 OLD/Provider/CarrierDataProvider.php delete mode 100644 src/Repository/CarrierRepository.php create mode 100644 src/Repository/NewRepository/CarrierRepository.php create mode 100644 src/Service/ShopContent/CarriersService.php diff --git a/OLD/Provider/CarrierDataProvider.php b/OLD/Provider/CarrierDataProvider.php deleted file mode 100644 index 1a4a709f..00000000 --- a/OLD/Provider/CarrierDataProvider.php +++ /dev/null @@ -1,137 +0,0 @@ -configurationRepository = $configurationRepository; - $this->carrierBuilder = $carrierBuilder; - $this->carrierRepository = $carrierRepository; - $this->languageRepository = $languageRepository; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); - - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - /** @var array $carriers */ - $carriers = $this->carrierRepository->getAllCarrierProperties($offset, $limit, $langId); - - /** @var string $configurationPsWeightUnit */ - $configurationPsWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); - /** @var EventBusCarrier[] $eventBusCarriers */ - $eventBusCarriers = $this->carrierBuilder->buildCarriers( - $carriers, - $langId, - $currency, - $configurationPsWeightUnit - ); - - return $eventBusCarriers; - } - - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - /** @var array $shippingIncremental */ - $shippingIncremental = $this->carrierRepository->getShippingIncremental(Config::COLLECTION_CARRIERS, $langIso); - - if (!$shippingIncremental) { - return []; - } - - $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); - - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - $carrierIds = array_column($shippingIncremental, 'id_object'); - /** @var array $carriers */ - $carriers = $this->carrierRepository->getCarrierProperties($carrierIds, $langId); - - /** @var string $configurationPsWeightUnit */ - $configurationPsWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); - /** @var EventBusCarrier[] $eventBusCarriers */ - $eventBusCarriers = $this->carrierBuilder->buildCarriers( - $carriers, - $langId, - $currency, - $configurationPsWeightUnit - ); - - return $eventBusCarriers; - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - * - * @@throws \PrestaShopDatabaseException - */ - public function getRemainingObjectsCount($offset, $langIso) - { - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - return (int) $this->carrierRepository->getRemainingCarriersCount($offset, $langId); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - return $this->carrierRepository->getQueryForDebug($offset, $limit, $langId); - } -} diff --git a/config/common/builder.yml b/config/common/builder.yml index 1caea5db..7e4e036c 100644 --- a/config/common/builder.yml +++ b/config/common/builder.yml @@ -3,8 +3,8 @@ services: class: PrestaShop\Module\PsEventbus\Builder\CarrierBuilder public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CarrierRepository' - '@PrestaShop\Module\PsEventbus\Repository\CountryRepository' - '@PrestaShop\Module\PsEventbus\Repository\StateRepository' - '@PrestaShop\Module\PsEventbus\Repository\TaxRepository' - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' + - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 8d64c837..fc336efc 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -14,3 +14,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 59fe9882..471dd2c5 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -127,12 +127,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CarrierRepository: - class: PrestaShop\Module\PsEventbus\Repository\CarrierRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository: class: PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 57c26aba..4f02827a 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -78,3 +78,11 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' + - '@PrestaShop\Module\PsEventbus\Builder\CarrierBuilder' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 4ec84c0b..6a3f4e23 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -50,7 +50,7 @@ const specialFieldAssert: { [index: string]: (val) => void } = { } describe('Full Sync', () => { - let testIndex = 0; + let testTimestamp = 0; // gérer les cas ou un shopContent n'existe pas (pas de fixture du coup) const shopContents: ShopContent[] = shopContentList.filter( @@ -60,7 +60,8 @@ describe('Full Sync', () => { let jobId: string; beforeEach(() => { - jobId = `valid-job-full-${testIndex++}`; + testTimestamp = Date.now(); + jobId = `valid-job-full-${testTimestamp}`; }); // TODO : some versions of prestashop include ps_facebook out of the box, this test can't reliably be run for all versions diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index bf8a9bfe..7ed2ce5c 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -3,7 +3,6 @@ import R from "ramda"; // TEMPORARY DISABLED, WAIT ADD ALL SHOP CONTENT // AFTER UNCOMMENT THIS, CHANGE ALL "as ShopContent"CAST IN FULLSYNC TEST /* export const shopContentMapping = { - 'carriers': 'carriers', 'carrier_details': 'carrier-details', 'carts' : 'carts', 'cart_products': 'carts', @@ -35,10 +34,11 @@ import R from "ramda"; } as const; */ export const shopContentMapping = { + 'carriers': 'carriers', 'orders': 'orders', - 'order_histories': 'order-histories', 'order_cart_rules': 'order-cart-rules', - 'order_details': 'order-details' + 'order_details': 'order-details', + 'order_histories': 'order-histories' } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/e2e/src/reject-invalid-job-id.spec.ts b/e2e/src/reject-invalid-job-id.spec.ts index 807e133f..a0aee8f4 100644 --- a/e2e/src/reject-invalid-job-id.spec.ts +++ b/e2e/src/reject-invalid-job-id.spec.ts @@ -6,14 +6,15 @@ import {probe} from "./helpers/mock-probe"; import { ShopContent, shopContentList } from "./helpers/shop-contents"; describe('Reject invalid job-id', () => { - let testIndex = 0; + let testTimestamp = 0; const shopContents: ShopContent[] = shopContentList let jobId: string; beforeEach(() => { - jobId = `invalid-job-id-${testIndex++}` + testTimestamp = Date.now(); + jobId = `invalid-job-id-${testTimestamp}` }); it.each(shopContents)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (shopContent) => { diff --git a/src/Builder/CarrierBuilder.php b/src/Builder/CarrierBuilder.php index aeb65fed..63ba7a62 100644 --- a/src/Builder/CarrierBuilder.php +++ b/src/Builder/CarrierBuilder.php @@ -5,66 +5,60 @@ use PrestaShop\Module\PsEventbus\DTO\Carrier as EventBusCarrier; use PrestaShop\Module\PsEventbus\DTO\CarrierDetail; use PrestaShop\Module\PsEventbus\DTO\CarrierTax; -use PrestaShop\Module\PsEventbus\Repository\CarrierRepository; use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\CountryRepository; +use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\StateRepository; use PrestaShop\Module\PsEventbus\Repository\TaxRepository; +use PrestaShopDatabaseException; +use PrestaShopException; class CarrierBuilder { - /** - * @var CarrierRepository - */ - private $carrierRepository; - - /** - * @var CountryRepository - */ + /** @var CountryRepository */ private $countryRepository; - /** - * @var StateRepository - */ + /** @var StateRepository */ private $stateRepository; - /** - * @var TaxRepository - */ + /** @var TaxRepository */ private $taxRepository; - /** - * @var ConfigurationRepository - */ + /** @var ConfigurationRepository */ private $configurationRepository; + /** @var LanguageRepository */ + private $languageRepository; + public function __construct( - CarrierRepository $carrierRepository, CountryRepository $countryRepository, StateRepository $stateRepository, TaxRepository $taxRepository, - ConfigurationRepository $configurationRepository + ConfigurationRepository $configurationRepository, + LanguageRepository $languageRepository ) { - $this->carrierRepository = $carrierRepository; $this->countryRepository = $countryRepository; $this->stateRepository = $stateRepository; $this->taxRepository = $taxRepository; $this->configurationRepository = $configurationRepository; + $this->languageRepository = $languageRepository; } /** * @param array $carriers - * @param int $langId + * @param string $langIso * @param \Currency $currency * @param string $weightUnit * * @return array * - * @@throws \PrestaShopDatabaseException - * @@throws \PrestaShopException + * @@throws PrestaShopDatabaseException + * @@throws PrestaShopException */ - public function buildCarriers($carriers, $langId, \Currency $currency, $weightUnit) + public function buildCarriers($carriers, $langIso, \Currency $currency, $weightUnit) { + $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); + $eventBusCarriers = []; foreach ($carriers as $carrier) { $eventBusCarriers[] = $this->buildCarrier( @@ -74,15 +68,9 @@ public function buildCarriers($carriers, $langId, \Currency $currency, $weightUn ); } - $formattedCarriers = []; - /** @var EventBusCarrier $eventBusCarrier */ - foreach ($eventBusCarriers as $eventBusCarrier) { - /** @var array $eventBusCarrierSerialized */ - $eventBusCarrierSerialized = $eventBusCarrier->jsonSerialize(); - $formattedCarriers = array_merge($formattedCarriers, $eventBusCarrierSerialized); - } - - return $formattedCarriers; + return array_map(function ($eventBusCarrier) { + return $eventBusCarrier->jsonSerialize(); + }, $eventBusCarriers); } /** @@ -92,8 +80,8 @@ public function buildCarriers($carriers, $langId, \Currency $currency, $weightUn * * @return EventBusCarrier * - * @@throws \PrestaShopDatabaseException - * @@throws \PrestaShopException + * @@throws PrestaShopDatabaseException + * @@throws PrestaShopException */ public function buildCarrier(\Carrier $carrier, $currencyIsoCode, $weightUnit) { @@ -128,7 +116,7 @@ public function buildCarrier(\Carrier $carrier, $currencyIsoCode, $weightUnit) ->setCurrency($currencyIsoCode) ->setWeightUnit($weightUnit); - $deliveryPriceByRanges = $this->carrierRepository->getDeliveryPriceByRange($carrier); + $deliveryPriceByRanges = $this->getDeliveryPriceByRange($carrier); if (!$deliveryPriceByRanges) { return $eventBusCarrier; @@ -137,7 +125,7 @@ public function buildCarrier(\Carrier $carrier, $currencyIsoCode, $weightUnit) $carrierDetails = []; $carrierTaxes = []; foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { - $range = $this->carrierRepository->getCarrierRange($deliveryPriceByRange); + $range = $this->getCarrierRange($deliveryPriceByRange); if (!$range) { continue; } @@ -162,6 +150,90 @@ public function buildCarrier(\Carrier $carrier, $currencyIsoCode, $weightUnit) return $eventBusCarrier; } + /** + * @param \Carrier $carrierObj + * + * @return array|false + */ + public function getDeliveryPriceByRange(\Carrier $carrierObj) + { + $rangeTable = $carrierObj->getRangeTable(); + switch ($rangeTable) { + case 'range_weight': + return $this->getCarrierByWeightRange($carrierObj, 'range_weight'); + case 'range_price': + return $this->getCarrierByPriceRange($carrierObj, 'range_price'); + default: + return false; + } + } + + /** + * @param \Carrier $carrierObj + * @param string $rangeTable + * + * @return array + */ + private function getCarrierByPriceRange( + \Carrier $carrierObj, + $rangeTable + ) { + $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); + + $filteredRanges = []; + foreach ($deliveryPriceByRange as $range) { + $filteredRanges[$range['id_range_price']]['id_range_price'] = $range['id_range_price']; + $filteredRanges[$range['id_range_price']]['id_carrier'] = $range['id_carrier']; + $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; + $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['price'] = $range['price']; + } + + return $filteredRanges; + } + + /** + * @param \Carrier $carrierObj + * @param string $rangeTable + * + * @return array + */ + private function getCarrierByWeightRange( + \Carrier $carrierObj, + $rangeTable + ) { + $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); + + $filteredRanges = []; + foreach ($deliveryPriceByRange as $range) { + $filteredRanges[$range['id_range_weight']]['id_range_weight'] = $range['id_range_weight']; + $filteredRanges[$range['id_range_weight']]['id_carrier'] = $range['id_carrier']; + $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; + $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['price'] = $range['price']; + } + + return $filteredRanges; + } + + /** + * @param array $deliveryPriceByRange + * + * @return false|\RangeWeight|\RangePrice + * + * @throws \PrestaShopDatabaseException + * @throws \PrestaShopException + */ + public function getCarrierRange($deliveryPriceByRange) + { + if (isset($deliveryPriceByRange['id_range_weight'])) { + return new \RangeWeight($deliveryPriceByRange['id_range_weight']); + } + if (isset($deliveryPriceByRange['id_range_price'])) { + return new \RangePrice($deliveryPriceByRange['id_range_price']); + } + + return false; + } + /** * @param \Carrier $carrier * @param \RangeWeight|\RangePrice $range @@ -169,7 +241,7 @@ public function buildCarrier(\Carrier $carrier, $currencyIsoCode, $weightUnit) * * @return false|CarrierDetail * - * @@throws \PrestaShopDatabaseException + * @@throws PrestaShopDatabaseException */ private function buildCarrierDetails(\Carrier $carrier, $range, $zone) { @@ -206,7 +278,7 @@ private function buildCarrierDetails(\Carrier $carrier, $range, $zone) * * @return CarrierTax|null * - * @@throws \PrestaShopDatabaseException + * @@throws PrestaShopDatabaseException */ private function buildCarrierTaxes(\Carrier $carrier, $zoneId, $rangeId) { diff --git a/src/Config/Config.php b/src/Config/Config.php index 39ad3e95..8ddb35a8 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -34,6 +34,7 @@ class Config const COLLECTION_CARRIERS = 'carriers'; const COLLECTION_CARRIER_DETAILS = 'carrier_details'; + const COLLECTION_CARRIER_TAXES = 'carrier_taxes'; const COLLECTION_CARTS = 'carts'; const COLLECTION_CART_PRODUCTS = 'cart_products'; const COLLECTION_CART_RULES = 'cart_rules'; @@ -73,6 +74,7 @@ class Config const SHOP_CONTENTS = [ self::COLLECTION_CARRIERS, self::COLLECTION_CARRIER_DETAILS, + self::COLLECTION_CARRIER_TAXES, self::COLLECTION_CARTS, self::COLLECTION_CART_PRODUCTS, self::COLLECTION_CART_RULES, diff --git a/src/DTO/Carrier.php b/src/DTO/Carrier.php index 7f8e5976..8d86b337 100644 --- a/src/DTO/Carrier.php +++ b/src/DTO/Carrier.php @@ -4,11 +4,6 @@ class Carrier implements \JsonSerializable { - /** - * @var string - */ - private $collection = 'carriers'; - /** * @var int */ @@ -139,14 +134,6 @@ class Carrier implements \JsonSerializable */ private $carrierTaxes = []; - /** - * @return string - */ - public function getCollection() - { - return $this->collection; - } - /** * @return int */ @@ -683,49 +670,31 @@ public function jsonSerialize() */ error_reporting(E_ALL ^ E_WARNING); - $return = []; - - $return[] = [ - 'collection' => $this->getCollection(), - 'id' => (string) $this->getIdReference(), - 'properties' => [ - 'id_carrier' => (string) $this->getIdCarrier(), - 'id_reference' => (string) $this->getIdReference(), - 'name' => (string) $this->getName(), - 'carrier_taxes_rates_group_id' => (string) $this->getTaxesRatesGroupId(), - 'url' => (string) $this->getUrl(), - 'active' => (bool) $this->isActive(), - 'deleted' => (bool) $this->isDeleted(), - 'shipping_handling' => (float) $this->getShippingHandling(), - 'free_shipping_starts_at_price' => (float) $this->getFreeShippingStartsAtPrice(), - 'free_shipping_starts_at_weight' => (float) $this->getFreeShippingStartsAtWeight(), - 'disable_carrier_when_out_of_range' => (bool) $this->isDisableCarrierWhenOutOfRange(), - 'is_module' => (bool) $this->isModule(), - 'is_free' => (bool) $this->isFree(), - 'shipping_external' => (bool) $this->isShippingExternal(), - 'need_range' => (bool) $this->isNeedRange(), - 'external_module_name' => (string) $this->getExternalModuleName(), - 'max_width' => (float) $this->getMaxWidth(), - 'max_height' => (float) $this->getMaxHeight(), - 'max_depth' => (float) $this->getMaxDepth(), - 'max_weight' => (float) $this->getMaxWeight(), - 'grade' => (int) $this->getGrade(), - 'delay' => (string) $this->getDelay(), - 'currency' => (string) $this->getCurrency(), - 'weight_unit' => (string) $this->getWeightUnit(), - ], + return [ + 'id_carrier' => (string) $this->getIdCarrier(), + 'id_reference' => (string) $this->getIdReference(), + 'name' => (string) $this->getName(), + 'carrier_taxes_rates_group_id' => (string) $this->getTaxesRatesGroupId(), + 'url' => (string) $this->getUrl(), + 'active' => (bool) $this->isActive(), + 'deleted' => (bool) $this->isDeleted(), + 'shipping_handling' => (float) $this->getShippingHandling(), + 'free_shipping_starts_at_price' => (float) $this->getFreeShippingStartsAtPrice(), + 'free_shipping_starts_at_weight' => (float) $this->getFreeShippingStartsAtWeight(), + 'disable_carrier_when_out_of_range' => (bool) $this->isDisableCarrierWhenOutOfRange(), + 'is_module' => (bool) $this->isModule(), + 'is_free' => (bool) $this->isFree(), + 'shipping_external' => (bool) $this->isShippingExternal(), + 'need_range' => (bool) $this->isNeedRange(), + 'external_module_name' => (string) $this->getExternalModuleName(), + 'max_width' => (float) $this->getMaxWidth(), + 'max_height' => (float) $this->getMaxHeight(), + 'max_depth' => (float) $this->getMaxDepth(), + 'max_weight' => (float) $this->getMaxWeight(), + 'grade' => (int) $this->getGrade(), + 'delay' => (string) $this->getDelay(), + 'currency' => (string) $this->getCurrency(), + 'weight_unit' => (string) $this->getWeightUnit(), ]; - - $carrierDetails = []; - foreach ($this->getCarrierDetails() as $carrierDetail) { - $carrierDetails[] = $carrierDetail->jsonSerialize(); - } - - $carrierTaxRates = []; - foreach ($this->getCarrierTaxes() as $carrierTax) { - $carrierTaxRates[] = $carrierTax->jsonSerialize(); - } - - return array_merge($return, $carrierDetails, $carrierTaxRates); } } diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php deleted file mode 100644 index f36d8c89..00000000 --- a/src/Repository/CarrierRepository.php +++ /dev/null @@ -1,235 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - - /** - * @param \Carrier $carrierObj - * - * @return array|false - */ - public function getDeliveryPriceByRange(\Carrier $carrierObj) - { - $rangeTable = $carrierObj->getRangeTable(); - switch ($rangeTable) { - case 'range_weight': - return $this->getCarrierByWeightRange($carrierObj, 'range_weight'); - case 'range_price': - return $this->getCarrierByPriceRange($carrierObj, 'range_price'); - default: - return false; - } - } - - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - private function getCarrierByPriceRange( - \Carrier $carrierObj, - $rangeTable - ) { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_price']]['id_range_price'] = $range['id_range_price']; - $filteredRanges[$range['id_range_price']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['price'] = $range['price']; - } - - return $filteredRanges; - } - - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - private function getCarrierByWeightRange( - \Carrier $carrierObj, - $rangeTable - ) { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_weight']]['id_range_weight'] = $range['id_range_weight']; - $filteredRanges[$range['id_range_weight']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['price'] = $range['price']; - } - - return $filteredRanges; - } - - /** - * @param int $offset - * @param int $limit - * @param int $langId - * - * @return \DbQuery - */ - private function getAllCarriersQuery($offset, $limit, $langId) - { - $query = new \DbQuery(); - $query->from('carrier', 'c'); - $query->select('c.id_carrier'); - $query->leftJoin('carrier_lang', 'cl', 'cl.id_carrier = c.id_carrier AND cl.id_lang = ' . (int) $langId); - $query->leftJoin('carrier_shop', 'cs', 'cs.id_carrier = c.id_carrier'); - $query->where('cs.id_shop = ' . $this->shopId); - $query->where('deleted=0'); - $query->limit($limit, $offset); - - return $query; - } - - /** - * @param string $type - * @param string $langIso - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getShippingIncremental($type, $langIso) - { - $query = new \DbQuery(); - $query->from(IncrementalSyncRepository::INCREMENTAL_SYNC_TABLE, 'aic'); - $query->leftJoin(EventbusSyncRepository::TYPE_SYNC_TABLE_NAME, 'ts', 'ts.type = aic.type'); - $query->where('aic.type = "' . pSQL($type) . '"'); - $query->where('ts.id_shop = ' . $this->shopId); - $query->where('ts.lang_iso = "' . pSQL($langIso) . '"'); - - return $this->db->executeS($query); - } - - /** - * @param array $deliveryPriceByRange - * - * @return false|\RangeWeight|\RangePrice - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public function getCarrierRange($deliveryPriceByRange) - { - if (isset($deliveryPriceByRange['id_range_weight'])) { - return new \RangeWeight($deliveryPriceByRange['id_range_weight']); - } - if (isset($deliveryPriceByRange['id_range_price'])) { - return new \RangePrice($deliveryPriceByRange['id_range_price']); - } - - return false; - } - - /** - * @param int[] $carrierIds - * @param int $langId - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCarrierProperties($carrierIds, $langId) - { - if (!$carrierIds) { - return []; - } - $query = new \DbQuery(); - $query->from('carrier', 'c'); - $query->select('c.*, cl.delay'); - $query->leftJoin('carrier_lang', 'cl', 'cl.id_carrier = c.id_carrier AND cl.id_lang = ' . (int) $langId); - $query->leftJoin('carrier_shop', 'cs', 'cs.id_carrier = c.id_carrier'); - $query->where('c.id_carrier IN (' . implode(',', array_map('intval', $carrierIds)) . ')'); - $query->where('cs.id_shop = ' . $this->shopId); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * @param int $langId - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getAllCarrierProperties($offset, $limit, $langId) - { - return $this->db->executeS($this->getAllCarriersQuery($offset, $limit, $langId)); - } - - /** - * @param int $offset - * @param int $langId - * - * @return int - * - * @throws \PrestaShopDatabaseException - */ - public function getRemainingCarriersCount($offset, $langId) - { - $carriers = $this->getAllCarrierProperties($offset, 1, $langId); - - if (!is_array($carriers) || empty($carriers)) { - return 0; - } - - return count($carriers); - } - - /** - * @param int $offset - * @param int $limit - * @param int $langId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langId) - { - $query = $this->getAllCarriersQuery($offset, $limit, $langId); - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } -} diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php new file mode 100644 index 00000000..27bd0d59 --- /dev/null +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -0,0 +1,103 @@ +shop === null) { + throw new \PrestaShopException('No shop context'); + } + + $this->query = new \DbQuery(); + + $this->query->from('carrier', 'c') + ->leftJoin('carrier_lang', 'cl', 'cl.id_carrier = c.id_carrier AND cl.id_lang = ' . $langId) + ->leftJoin('carrier_shop', 'cs', 'cs.id_carrier = c.id_carrier') + ->where('cs.id_shop = ' . $context->shop->id) + ->where('deleted=0') + ; + + $this->query->select('c.*'); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateBaseQuery($langIso); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateBaseQuery($langIso); + + $this->query + ->where('c.id_carrier IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit); + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + + if (!is_array($result) || empty($result)) { + return 0; + } + + return count($result); + } +} diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php new file mode 100644 index 00000000..da6a8225 --- /dev/null +++ b/src/Service/ShopContent/CarriersService.php @@ -0,0 +1,113 @@ +carrierRepository = $carrierRepository; + $this->configurationRepository = $configurationRepository; + $this->carrierBuilder = $carrierBuilder; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); + + /** @var array $carriers */ + $carriers = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + /** @var string $psWeightUnit */ + $psWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); + + $eventBusCarriers = $this->carrierBuilder->buildCarriers( + $carriers, + $langIso, + $currency, + $psWeightUnit + ); + + return array_map(function ($item) { + return [ + 'id' => $item['id_reference'], + 'collection' => Config::COLLECTION_CARRIERS, + 'properties' => $item, + ]; + }, $eventBusCarriers); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->carrierRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); + + /** @var string $psWeightUnit */ + $psWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); + + $eventBusCarriers = $this->carrierBuilder->buildCarriers( + $result, + $langIso, + $currency, + $psWeightUnit + ); + + return array_map(function ($item) { + return [ + 'id' => $item['id_reference'], + 'collection' => Config::COLLECTION_CARRIERS, + 'properties' => $item, + ]; + }, $eventBusCarriers); + } + + /** + * @param int $offset + * @param string $langIso + * @param bool $debug + * + * @return int + */ + public function countFullSyncContentLeft($offset, $langIso, $debug) + { + return (int) $this->carrierRepository->countFullSyncContentLeft($offset, $langIso, $debug); + } +} diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 6024d5d9..a7daf7af 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -72,7 +72,7 @@ public function __construct( * * @return array * - * @@throws \PrestaShopDatabaseException|EnvVarException|ApiException + * @@throws PrestaShopDatabaseException|EnvVarException|ApiException */ public function sendFullSync( string $shopContent, @@ -139,7 +139,7 @@ public function sendFullSync( * * @return array * - * @@throws \PrestaShopDatabaseException|EnvVarException + * @@throws PrestaShopDatabaseException|EnvVarException */ public function sendIncrementalSync( string $shopContent, @@ -301,7 +301,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, * * @return bool * - * @@throws \PrestaShopDatabaseException + * @@throws PrestaShopDatabaseException */ private function debounceLiveSync($shopContentName) // @phpstan-ignore method.unused { diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index a465a352..db0d0572 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -1128,6 +1128,9 @@ public function hookActionObjectCarrierAddAfter($parameters) $this->shopId, false ); + + // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER DETAILS + // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER TAXES } } @@ -1153,6 +1156,9 @@ public function hookActionObjectCarrierUpdateAfter($parameters) $this->shopId, false ); + + // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER DETAILS + // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER TAXES } } @@ -1177,6 +1183,9 @@ public function hookActionObjectCarrierDeleteAfter($parameters) $this->shopId, false ); + + // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER DETAILS + // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER TAXES } } From e99ffb620bc985088bda80aa6c4303f5d37c1167 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:35:09 +0200 Subject: [PATCH 066/162] feat: pseventbus v4 carrier details and taxes (#354) --- config/common/builder.yml | 10 - config/common/repository.yml | 4 +- config/front/services.yml | 14 +- controllers/front/apiFront.php | 6 +- e2e/src/fixtures/1.6/carrier_taxes.json | 1 + e2e/src/fixtures/1.7/carrier_taxes.json | 1 + e2e/src/fixtures/8/carrier_taxes.json | 1 + e2e/src/fixtures/9/carrier_taxes.json | 1 + e2e/src/helpers/shop-contents.ts | 2 + src/Builder/CarrierBuilder.php | 320 -------- src/DTO/Carrier.php | 700 ------------------ src/DTO/CarrierDetail.php | 292 -------- src/DTO/CarrierTax.php | 211 ------ src/Helper/CarrierHelper.php | 222 ++++++ .../NewRepository/CarrierRepository.php | 37 +- .../NewRepository/OrderCartRuleRepository.php | 37 +- .../NewRepository/OrderDetailRepository.php | 35 +- .../NewRepository/OrderHistoryRepository.php | 37 +- .../NewRepository/OrderRepository.php | 33 +- .../NewRepository/RepositoryInterface.php | 11 +- .../{TaxRepository.php => TaxeRepository.php} | 2 +- src/Service/FrontApiService.php | 21 +- .../ShopContent/CarrierDetailsService.php | 115 +++ .../ShopContent/CarrierTaxesService.php | 112 +++ src/Service/ShopContent/CarriersService.php | 107 ++- .../ShopContent/OrderCartRulesService.php | 8 +- .../ShopContent/OrderDetailsService.php | 17 +- .../ShopContent/OrderHistoriesService.php | 8 +- src/Service/ShopContent/OrdersService.php | 8 +- .../ShopContentServiceInterface.php | 4 +- src/Service/SynchronizationService.php | 2 +- 31 files changed, 684 insertions(+), 1695 deletions(-) delete mode 100644 config/common/builder.yml create mode 100644 e2e/src/fixtures/1.6/carrier_taxes.json create mode 100644 e2e/src/fixtures/1.7/carrier_taxes.json create mode 100644 e2e/src/fixtures/8/carrier_taxes.json create mode 100644 e2e/src/fixtures/9/carrier_taxes.json delete mode 100644 src/Builder/CarrierBuilder.php delete mode 100644 src/DTO/Carrier.php delete mode 100644 src/DTO/CarrierDetail.php delete mode 100644 src/DTO/CarrierTax.php create mode 100644 src/Helper/CarrierHelper.php rename src/Repository/{TaxRepository.php => TaxeRepository.php} (99%) create mode 100644 src/Service/ShopContent/CarrierDetailsService.php create mode 100644 src/Service/ShopContent/CarrierTaxesService.php diff --git a/config/common/builder.yml b/config/common/builder.yml deleted file mode 100644 index 7e4e036c..00000000 --- a/config/common/builder.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - PrestaShop\Module\PsEventbus\Builder\CarrierBuilder: - class: PrestaShop\Module\PsEventbus\Builder\CarrierBuilder - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CountryRepository' - - '@PrestaShop\Module\PsEventbus\Repository\StateRepository' - - '@PrestaShop\Module\PsEventbus\Repository\TaxRepository' - - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' diff --git a/config/common/repository.yml b/config/common/repository.yml index 471dd2c5..97c6a558 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -121,8 +121,8 @@ services: class: PrestaShop\Module\PsEventbus\Repository\StateRepository public: true - PrestaShop\Module\PsEventbus\Repository\TaxRepository: - class: PrestaShop\Module\PsEventbus\Repository\TaxRepository + PrestaShop\Module\PsEventbus\Repository\TaxeRepository: + class: PrestaShop\Module\PsEventbus\Repository\TaxeRepository public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' diff --git a/config/front/services.yml b/config/front/services.yml index 4f02827a..2f0b31bc 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -4,7 +4,6 @@ imports: - { resource: ../common/decorator.yml } - { resource: ../common/repository.yml } - { resource: ../common/new-repository.yml } - - { resource: ../common/builder.yml } services: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: @@ -85,4 +84,15 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsEventbus\Builder\CarrierBuilder' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index e2344373..16aa24e5 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -23,8 +23,8 @@ public function postProcess() /** @var int $limit */ $limit = Tools::getValue('limit', 50); - /** @var bool $isFull */ - $isFull = Tools::getValue('full', 0) == 1; + /** @var bool $fullSyncRequested */ + $fullSyncRequested = Tools::getValue('full', 0) == 1; /** @var bool $debug */ $debug = Tools::getValue('debug') == 1; @@ -41,6 +41,6 @@ public function postProcess() // edit shopContent for matching Config.php const $shopContentEdited = str_replace('-', '_', $shopContent); - $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $isFull, $debug, $ise2e); + $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $fullSyncRequested, $debug, $ise2e); } } diff --git a/e2e/src/fixtures/1.6/carrier_taxes.json b/e2e/src/fixtures/1.6/carrier_taxes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/carrier_taxes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/carrier_taxes.json b/e2e/src/fixtures/1.7/carrier_taxes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/carrier_taxes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/carrier_taxes.json b/e2e/src/fixtures/8/carrier_taxes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/carrier_taxes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/9/carrier_taxes.json b/e2e/src/fixtures/9/carrier_taxes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/carrier_taxes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 7ed2ce5c..687187c6 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -35,6 +35,8 @@ import R from "ramda"; export const shopContentMapping = { 'carriers': 'carriers', + 'carrier_details': 'carrier-details', + 'carrier_taxes': 'carrier-taxes', 'orders': 'orders', 'order_cart_rules': 'order-cart-rules', 'order_details': 'order-details', diff --git a/src/Builder/CarrierBuilder.php b/src/Builder/CarrierBuilder.php deleted file mode 100644 index 63ba7a62..00000000 --- a/src/Builder/CarrierBuilder.php +++ /dev/null @@ -1,320 +0,0 @@ -countryRepository = $countryRepository; - $this->stateRepository = $stateRepository; - $this->taxRepository = $taxRepository; - $this->configurationRepository = $configurationRepository; - $this->languageRepository = $languageRepository; - } - - /** - * @param array $carriers - * @param string $langIso - * @param \Currency $currency - * @param string $weightUnit - * - * @return array - * - * @@throws PrestaShopDatabaseException - * @@throws PrestaShopException - */ - public function buildCarriers($carriers, $langIso, \Currency $currency, $weightUnit) - { - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - $eventBusCarriers = []; - foreach ($carriers as $carrier) { - $eventBusCarriers[] = $this->buildCarrier( - new \Carrier($carrier['id_carrier'], $langId), - $currency->iso_code, - $weightUnit - ); - } - - return array_map(function ($eventBusCarrier) { - return $eventBusCarrier->jsonSerialize(); - }, $eventBusCarriers); - } - - /** - * @param \Carrier $carrier - * @param string $currencyIsoCode - * @param string $weightUnit - * - * @return EventBusCarrier - * - * @@throws PrestaShopDatabaseException - * @@throws PrestaShopException - */ - public function buildCarrier(\Carrier $carrier, $currencyIsoCode, $weightUnit) - { - $eventBusCarrier = new EventBusCarrier(); - $freeShippingStartsAtPrice = (float) $this->configurationRepository->get('PS_SHIPPING_FREE_PRICE'); - $freeShippingStartsAtWeight = (float) $this->configurationRepository->get('PS_SHIPPING_FREE_WEIGHT'); - $eventBusCarrier->setFreeShippingStartsAtPrice($freeShippingStartsAtPrice); - $eventBusCarrier->setFreeShippingStartsAtWeight($freeShippingStartsAtWeight); - - $eventBusCarrier->setShippingHandling($this->getShippingHandlePrice((bool) $carrier->shipping_handling)); - - $eventBusCarrier - ->setIdCarrier((int) $carrier->id) - ->setIdReference((int) $carrier->id_reference) - ->setName($carrier->name) - ->setTaxesRatesGroupId((int) $carrier->getIdTaxRulesGroup()) - ->setUrl($carrier->url) - ->setActive($carrier->active) - ->setDeleted($carrier->deleted) - ->setDisableCarrierWhenOutOfRange((bool) $carrier->range_behavior) - ->setIsModule($carrier->is_module) - ->setIsFree($carrier->is_free) - ->setShippingExternal($carrier->shipping_external) - ->setNeedRange($carrier->need_range) - ->setExternalModuleName($carrier->external_module_name) - ->setMaxWidth($carrier->max_width) - ->setMaxHeight($carrier->max_height) - ->setMaxDepth($carrier->max_depth) - ->setMaxWeight($carrier->max_weight) - ->setGrade($carrier->grade) - ->setDelay($carrier->delay) - ->setCurrency($currencyIsoCode) - ->setWeightUnit($weightUnit); - - $deliveryPriceByRanges = $this->getDeliveryPriceByRange($carrier); - - if (!$deliveryPriceByRanges) { - return $eventBusCarrier; - } - - $carrierDetails = []; - $carrierTaxes = []; - foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { - $range = $this->getCarrierRange($deliveryPriceByRange); - if (!$range) { - continue; - } - foreach ($deliveryPriceByRange['zones'] as $zone) { - $carrierDetail = $this->buildCarrierDetails($carrier, $range, $zone); - if ($carrierDetail) { - $carrierDetails[] = $carrierDetail; - } - - /** @var int $rangeId */ - $rangeId = $range->id; - $carrierTax = $this->buildCarrierTaxes($carrier, $zone['id_zone'], $rangeId); - if ($carrierTax) { - $carrierTaxes[] = $carrierTax; - } - } - } - - $eventBusCarrier->setCarrierDetails($carrierDetails); - $eventBusCarrier->setCarrierTaxes($carrierTaxes); - - return $eventBusCarrier; - } - - /** - * @param \Carrier $carrierObj - * - * @return array|false - */ - public function getDeliveryPriceByRange(\Carrier $carrierObj) - { - $rangeTable = $carrierObj->getRangeTable(); - switch ($rangeTable) { - case 'range_weight': - return $this->getCarrierByWeightRange($carrierObj, 'range_weight'); - case 'range_price': - return $this->getCarrierByPriceRange($carrierObj, 'range_price'); - default: - return false; - } - } - - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - private function getCarrierByPriceRange( - \Carrier $carrierObj, - $rangeTable - ) { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_price']]['id_range_price'] = $range['id_range_price']; - $filteredRanges[$range['id_range_price']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['price'] = $range['price']; - } - - return $filteredRanges; - } - - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - private function getCarrierByWeightRange( - \Carrier $carrierObj, - $rangeTable - ) { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_weight']]['id_range_weight'] = $range['id_range_weight']; - $filteredRanges[$range['id_range_weight']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['price'] = $range['price']; - } - - return $filteredRanges; - } - - /** - * @param array $deliveryPriceByRange - * - * @return false|\RangeWeight|\RangePrice - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public function getCarrierRange($deliveryPriceByRange) - { - if (isset($deliveryPriceByRange['id_range_weight'])) { - return new \RangeWeight($deliveryPriceByRange['id_range_weight']); - } - if (isset($deliveryPriceByRange['id_range_price'])) { - return new \RangePrice($deliveryPriceByRange['id_range_price']); - } - - return false; - } - - /** - * @param \Carrier $carrier - * @param \RangeWeight|\RangePrice $range - * @param array $zone - * - * @return false|CarrierDetail - * - * @@throws PrestaShopDatabaseException - */ - private function buildCarrierDetails(\Carrier $carrier, $range, $zone) - { - /** @var int $rangeId */ - $rangeId = $range->id; - $carrierDetail = new CarrierDetail(); - $carrierDetail->setShippingMethod($carrier->getRangeTable()); - $carrierDetail->setCarrierDetailId($rangeId); - $carrierDetail->setDelimiter1($range->delimiter1); - $carrierDetail->setDelimiter2($range->delimiter2); - $carrierDetail->setPrice($zone['price']); - $carrierDetail->setCarrierReference($carrier->id_reference); - $carrierDetail->setZoneId($zone['id_zone']); - $carrierDetail->setRangeId($rangeId); - - /** @var array $countryIsoCodes */ - $countryIsoCodes = $this->countryRepository->getCountyIsoCodesByZoneId($zone['id_zone'], true); - if (!$countryIsoCodes) { - return false; - } - $carrierDetail->setCountryIsoCodes($countryIsoCodes); - - /** @var array $stateIsoCodes */ - $stateIsoCodes = $this->stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); - $carrierDetail->setStateIsoCodes($stateIsoCodes); - - return $carrierDetail; - } - - /** - * @param \Carrier $carrier - * @param int $zoneId - * @param int $rangeId - * - * @return CarrierTax|null - * - * @@throws PrestaShopDatabaseException - */ - private function buildCarrierTaxes(\Carrier $carrier, $zoneId, $rangeId) - { - $taxRulesGroupId = (int) $carrier->getIdTaxRulesGroup(); - /** @var array $carrierTaxesByZone */ - $carrierTaxesByZone = $this->taxRepository->getCarrierTaxesByZone($zoneId, $taxRulesGroupId, true); - - if (!$carrierTaxesByZone[0]['country_iso_code']) { - return null; - } - - $carrierTaxesByZone = $carrierTaxesByZone[0]; - - $carrierTax = new CarrierTax(); - $carrierTax->setCarrierReference($carrier->id_reference); - $carrierTax->setRangeId($rangeId); - $carrierTax->setTaxRulesGroupId($taxRulesGroupId); - $carrierTax->setZoneId($zoneId); - $carrierTax->setCountryIsoCode($carrierTaxesByZone['country_iso_code']); - $carrierTax->setStateIsoCodes($carrierTaxesByZone['state_iso_code']); - $carrierTax->setTaxRate($carrierTaxesByZone['rate']); - - return $carrierTax; - } - - /** - * @param bool $shippingHandling - * - * @return float - */ - private function getShippingHandlePrice($shippingHandling) - { - if ($shippingHandling) { - return (float) $this->configurationRepository->get('PS_SHIPPING_HANDLING'); - } - - return 0.0; - } -} diff --git a/src/DTO/Carrier.php b/src/DTO/Carrier.php deleted file mode 100644 index 8d86b337..00000000 --- a/src/DTO/Carrier.php +++ /dev/null @@ -1,700 +0,0 @@ -idCarrier; - } - - /** - * @param int $idCarrier - * - * @return Carrier - */ - public function setIdCarrier($idCarrier) - { - $this->idCarrier = $idCarrier; - - return $this; - } - - /** - * @return int - */ - public function getIdReference() - { - return $this->idReference; - } - - /** - * @param int $idReference - * - * @return Carrier - */ - public function setIdReference($idReference) - { - $this->idReference = $idReference; - - return $this; - } - - /** - * @return int - */ - public function getTaxesRatesGroupId() - { - return $this->taxesRatesGroupId; - } - - /** - * @param int $taxesRatesGroupId - * - * @return Carrier - */ - public function setTaxesRatesGroupId($taxesRatesGroupId) - { - $this->taxesRatesGroupId = $taxesRatesGroupId; - - return $this; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - * - * @return Carrier - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * @param string $url - * - * @return Carrier - */ - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->active; - } - - /** - * @param bool $active - * - * @return Carrier - */ - public function setActive($active) - { - $this->active = $active; - - return $this; - } - - /** - * @return bool - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * @param bool $deleted - * - * @return Carrier - */ - public function setDeleted($deleted) - { - $this->deleted = $deleted; - - return $this; - } - - /** - * @return float - */ - public function getShippingHandling() - { - return $this->shippingHandling; - } - - /** - * @param float $shippingHandling - * - * @return Carrier - */ - public function setShippingHandling($shippingHandling) - { - $this->shippingHandling = $shippingHandling; - - return $this; - } - - /** - * @return float - */ - public function getFreeShippingStartsAtPrice() - { - return $this->freeShippingStartsAtPrice; - } - - /** - * @param float $freeShippingStartsAtPrice - * - * @return Carrier - */ - public function setFreeShippingStartsAtPrice($freeShippingStartsAtPrice) - { - $this->freeShippingStartsAtPrice = $freeShippingStartsAtPrice; - - return $this; - } - - /** - * @return float - */ - public function getFreeShippingStartsAtWeight() - { - return $this->freeShippingStartsAtWeight; - } - - /** - * @param float $freeShippingStartsAtWeight - * - * @return Carrier - */ - public function setFreeShippingStartsAtWeight($freeShippingStartsAtWeight) - { - $this->freeShippingStartsAtWeight = $freeShippingStartsAtWeight; - - return $this; - } - - /** - * @return bool - */ - public function isDisableCarrierWhenOutOfRange() - { - return $this->disableCarrierWhenOutOfRange; - } - - /** - * @param bool $disableCarrierWhenOutOfRange - * - * @return Carrier - */ - public function setDisableCarrierWhenOutOfRange($disableCarrierWhenOutOfRange) - { - $this->disableCarrierWhenOutOfRange = $disableCarrierWhenOutOfRange; - - return $this; - } - - /** - * @return bool - */ - public function isModule() - { - return $this->isModule; - } - - /** - * @param bool $isModule - * - * @return Carrier - */ - public function setIsModule($isModule) - { - $this->isModule = $isModule; - - return $this; - } - - /** - * @return bool - */ - public function isFree() - { - return $this->isFree; - } - - /** - * @param bool $isFree - * - * @return Carrier - */ - public function setIsFree($isFree) - { - $this->isFree = $isFree; - - return $this; - } - - /** - * @return bool - */ - public function isShippingExternal() - { - return $this->shippingExternal; - } - - /** - * @param bool $shippingExternal - * - * @return Carrier - */ - public function setShippingExternal($shippingExternal) - { - $this->shippingExternal = $shippingExternal; - - return $this; - } - - /** - * @return bool - */ - public function isNeedRange() - { - return $this->needRange; - } - - /** - * @param bool $needRange - * - * @return Carrier - */ - public function setNeedRange($needRange) - { - $this->needRange = $needRange; - - return $this; - } - - /** - * @return string - */ - public function getExternalModuleName() - { - return $this->externalModuleName; - } - - /** - * @param string $externalModuleName - * - * @return Carrier - */ - public function setExternalModuleName($externalModuleName) - { - $this->externalModuleName = $externalModuleName; - - return $this; - } - - /** - * @return float - */ - public function getMaxWidth() - { - return $this->maxWidth; - } - - /** - * @param float $maxWidth - * - * @return Carrier - */ - public function setMaxWidth($maxWidth) - { - $this->maxWidth = $maxWidth; - - return $this; - } - - /** - * @return float - */ - public function getMaxHeight() - { - return $this->maxHeight; - } - - /** - * @param float $maxHeight - * - * @return Carrier - */ - public function setMaxHeight($maxHeight) - { - $this->maxHeight = $maxHeight; - - return $this; - } - - /** - * @return float - */ - public function getMaxDepth() - { - return $this->maxDepth; - } - - /** - * @param float $maxDepth - * - * @return Carrier - */ - public function setMaxDepth($maxDepth) - { - $this->maxDepth = $maxDepth; - - return $this; - } - - /** - * @return float - */ - public function getMaxWeight() - { - return $this->maxWeight; - } - - /** - * @param float $maxWeight - * - * @return Carrier - */ - public function setMaxWeight($maxWeight) - { - $this->maxWeight = $maxWeight; - - return $this; - } - - /** - * @return int - */ - public function getGrade() - { - return $this->grade; - } - - /** - * @param int $grade - * - * @return Carrier - */ - public function setGrade($grade) - { - $this->grade = $grade; - - return $this; - } - - /** - * @return string - */ - public function getDelay() - { - return $this->delay; - } - - /** - * @param string $delay - * - * @return Carrier - */ - public function setDelay($delay) - { - $this->delay = $delay; - - return $this; - } - - /** - * @return string - */ - public function getCurrency() - { - return $this->currency; - } - - /** - * @param string $currency - * - * @return Carrier - */ - public function setCurrency($currency) - { - $this->currency = $currency; - - return $this; - } - - /** - * @return string - */ - public function getWeightUnit() - { - return $this->weightUnit; - } - - /** - * @param string $weightUnit - * - * @return Carrier - */ - public function setWeightUnit($weightUnit) - { - $this->weightUnit = $weightUnit; - - return $this; - } - - /** - * @return CarrierDetail[] - */ - public function getCarrierDetails() - { - return $this->carrierDetails; - } - - /** - * @param CarrierDetail[] $carrierDetails - * - * @return Carrier - */ - public function setCarrierDetails($carrierDetails) - { - $this->carrierDetails = $carrierDetails; - - return $this; - } - - /** - * @return CarrierTax[] - */ - public function getCarrierTaxes() - { - return $this->carrierTaxes; - } - - /** - * @param CarrierTax[] $carrierTaxes - * - * @return Carrier - */ - public function setCarrierTaxes($carrierTaxes) - { - $this->carrierTaxes = $carrierTaxes; - - return $this; - } - - public function jsonSerialize() - { - /* - * Hide this, the time to fix it - * otherwise the HTML in the JSON will cause the request to be discarded cloud-side: - * - *
- * Warning: Array to string conversion in /var/www/html/modules/ps_eventbus/src/DTO/Carrier.php on line 724
- * - * Which at the time of this writing correspond to this line: - * 'delay' => (string) $this->getDelay(), - * - * @TODO clean this up please. - */ - error_reporting(E_ALL ^ E_WARNING); - - return [ - 'id_carrier' => (string) $this->getIdCarrier(), - 'id_reference' => (string) $this->getIdReference(), - 'name' => (string) $this->getName(), - 'carrier_taxes_rates_group_id' => (string) $this->getTaxesRatesGroupId(), - 'url' => (string) $this->getUrl(), - 'active' => (bool) $this->isActive(), - 'deleted' => (bool) $this->isDeleted(), - 'shipping_handling' => (float) $this->getShippingHandling(), - 'free_shipping_starts_at_price' => (float) $this->getFreeShippingStartsAtPrice(), - 'free_shipping_starts_at_weight' => (float) $this->getFreeShippingStartsAtWeight(), - 'disable_carrier_when_out_of_range' => (bool) $this->isDisableCarrierWhenOutOfRange(), - 'is_module' => (bool) $this->isModule(), - 'is_free' => (bool) $this->isFree(), - 'shipping_external' => (bool) $this->isShippingExternal(), - 'need_range' => (bool) $this->isNeedRange(), - 'external_module_name' => (string) $this->getExternalModuleName(), - 'max_width' => (float) $this->getMaxWidth(), - 'max_height' => (float) $this->getMaxHeight(), - 'max_depth' => (float) $this->getMaxDepth(), - 'max_weight' => (float) $this->getMaxWeight(), - 'grade' => (int) $this->getGrade(), - 'delay' => (string) $this->getDelay(), - 'currency' => (string) $this->getCurrency(), - 'weight_unit' => (string) $this->getWeightUnit(), - ]; - } -} diff --git a/src/DTO/CarrierDetail.php b/src/DTO/CarrierDetail.php deleted file mode 100644 index 4fc71145..00000000 --- a/src/DTO/CarrierDetail.php +++ /dev/null @@ -1,292 +0,0 @@ - - */ - private $countryIsoCodes; - - /** - * @var array - */ - private $stateIsoCodes; - - /** - * @var float - */ - private $price; - - /** - * @return string - */ - public function getCollection() - { - return $this->collection; - } - - /** - * @return string|bool - */ - public function getShippingMethod() - { - return $this->shippingMethod; - } - - /** - * @param bool|string $shippingMethod - * - * @return CarrierDetail - */ - public function setShippingMethod($shippingMethod) - { - $this->shippingMethod = $shippingMethod; - - return $this; - } - - /** - * @return int - */ - public function getCarrierReference() - { - return $this->carrierReference; - } - - /** - * @param int $carrierReference - * - * @return CarrierDetail - */ - public function setCarrierReference($carrierReference) - { - $this->carrierReference = $carrierReference; - - return $this; - } - - /** - * @return int - */ - public function getCarrierDetailId() - { - return $this->CarrierDetailId; - } - - /** - * @param int $CarrierDetailId - * - * @return CarrierDetail - */ - public function setCarrierDetailId($CarrierDetailId) - { - $this->CarrierDetailId = $CarrierDetailId; - - return $this; - } - - /** - * @return int - */ - public function getZoneId() - { - return $this->zoneId; - } - - /** - * @param int $zoneId - * - * @return CarrierDetail - */ - public function setZoneId($zoneId) - { - $this->zoneId = $zoneId; - - return $this; - } - - /** - * @return int - */ - public function getRangeId() - { - return $this->rangeId; - } - - /** - * @param int $rangeId - * - * @return CarrierDetail - */ - public function setRangeId($rangeId) - { - $this->rangeId = $rangeId; - - return $this; - } - - /** - * @return float - */ - public function getDelimiter1() - { - return $this->delimiter1; - } - - /** - * @param float $delimiter1 - * - * @return CarrierDetail - */ - public function setDelimiter1($delimiter1) - { - $this->delimiter1 = $delimiter1; - - return $this; - } - - /** - * @return float - */ - public function getDelimiter2() - { - return $this->delimiter2; - } - - /** - * @param float $delimiter2 - * - * @return CarrierDetail - */ - public function setDelimiter2($delimiter2) - { - $this->delimiter2 = $delimiter2; - - return $this; - } - - /** - * @return array - */ - public function getCountryIsoCodes() - { - return $this->countryIsoCodes; - } - - /** - * @param array $countryIsoCodes - * - * @return CarrierDetail - */ - public function setCountryIsoCodes($countryIsoCodes) - { - $this->countryIsoCodes = $countryIsoCodes; - - return $this; - } - - /** - * @return array - */ - public function getStateIsoCodes() - { - return $this->stateIsoCodes; - } - - /** - * @param array $stateIsoCodes - * - * @return CarrierDetail - */ - public function setStateIsoCodes($stateIsoCodes) - { - $this->stateIsoCodes = $stateIsoCodes; - - return $this; - } - - /** - * @return float - */ - public function getPrice() - { - return $this->price; - } - - /** - * @param float $price - * - * @return CarrierDetail - */ - public function setPrice($price) - { - $this->price = $price; - - return $this; - } - - public function jsonSerialize() - { - $countryIds = implode(',', $this->getCountryIsoCodes()); - $stateIds = implode(',', $this->getStateIsoCodes()); - - return [ - 'collection' => $this->getCollection(), - 'id' => $this->getCarrierReference() . '-' . $this->getZoneId() . '-' . $this->getShippingMethod() . '-' . $this->getRangeId(), - 'properties' => [ - 'id_reference' => (string) $this->getCarrierReference(), - 'id_zone' => (string) $this->getZoneId(), - 'id_range' => (string) $this->getRangeId(), - 'id_carrier_detail' => (string) $this->getCarrierDetailId(), - 'shipping_method' => (string) $this->getShippingMethod(), - 'delimiter1' => (float) $this->getDelimiter1(), - 'delimiter2' => (float) $this->getDelimiter2(), - 'country_ids' => (string) $countryIds, - 'state_ids' => (string) $stateIds, - 'price' => (float) $this->getPrice(), - ], - ]; - } -} diff --git a/src/DTO/CarrierTax.php b/src/DTO/CarrierTax.php deleted file mode 100644 index 648f062e..00000000 --- a/src/DTO/CarrierTax.php +++ /dev/null @@ -1,211 +0,0 @@ -collection; - } - - /** - * @return int - */ - public function getCarrierReference() - { - return $this->carrierReference; - } - - /** - * @param int $carrierReference - * - * @return CarrierTax - */ - public function setCarrierReference($carrierReference) - { - $this->carrierReference = $carrierReference; - - return $this; - } - - /** - * @return int - */ - public function getRangeId() - { - return $this->rangeId; - } - - /** - * @param int $rangeId - * - * @return CarrierTax - */ - public function setRangeId($rangeId) - { - $this->rangeId = $rangeId; - - return $this; - } - - /** - * @return int - */ - public function getTaxRulesGroupId() - { - return $this->taxRulesGroupId; - } - - /** - * @param int $taxRulesGroupId - * - * @return CarrierTax - */ - public function setTaxRulesGroupId($taxRulesGroupId) - { - $this->taxRulesGroupId = $taxRulesGroupId; - - return $this; - } - - /** - * @return int - */ - public function getZoneId() - { - return $this->zoneId; - } - - /** - * @param int $zoneId - * - * @return CarrierTax - */ - public function setZoneId($zoneId) - { - $this->zoneId = $zoneId; - - return $this; - } - - /** - * @return string - */ - public function getCountryIsoCode() - { - return $this->countryIsoCode; - } - - /** - * @param string $countryIsoCode - * - * @return CarrierTax - */ - public function setCountryIsoCode($countryIsoCode) - { - $this->countryIsoCode = $countryIsoCode; - - return $this; - } - - /** - * @return string - */ - public function getStateIsoCodes() - { - return $this->stateIsoCodes; - } - - /** - * @param string $stateIsoCodes - * - * @return CarrierTax - */ - public function setStateIsoCodes($stateIsoCodes) - { - $this->stateIsoCodes = $stateIsoCodes; - - return $this; - } - - /** - * @return float - */ - public function getTaxRate() - { - return $this->taxRate; - } - - /** - * @param float $taxRate - * - * @return CarrierTax - */ - public function setTaxRate($taxRate) - { - $this->taxRate = $taxRate; - - return $this; - } - - public function jsonSerialize() - { - return [ - 'collection' => $this->getCollection(), - 'id' => $this->getCarrierReference() . '-' . $this->getZoneId() . '-' . $this->getRangeId(), - 'properties' => [ - 'id_reference' => (string) $this->getCarrierReference(), - 'id_zone' => (string) $this->getZoneId(), - 'id_range' => (string) $this->getRangeId(), - 'id_carrier_tax' => (string) $this->getTaxRulesGroupId(), - 'country_id' => (string) $this->getCountryIsoCode(), - 'state_ids' => (string) $this->getStateIsoCodes(), - 'tax_rate' => (float) $this->getTaxRate(), - ], - ]; - } -} diff --git a/src/Helper/CarrierHelper.php b/src/Helper/CarrierHelper.php new file mode 100644 index 00000000..74042afa --- /dev/null +++ b/src/Helper/CarrierHelper.php @@ -0,0 +1,222 @@ + $carrierData + * + * @return array + * + * @throws \PrestaShopDatabaseException + * @throws \PrestaShopException + */ + public static function buildCarrierDetails($carrierData) + { + /** @var \Ps_eventbus $module */ + $module = \Module::getInstanceByName('ps_eventbus'); + + /** @var CountryRepository $countryRepository */ + $countryRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\CountryRepository'); + + /** @var StateRepository $stateRepository */ + $stateRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\StateRepository'); + + $carrier = new \Carrier($carrierData['id_reference']); + + $deliveryPriceByRanges = CarrierHelper::getDeliveryPriceByRange($carrier); + + if (!$deliveryPriceByRanges) { + return []; + } + + $carrierDetails = []; + + foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { + $range = CarrierHelper::getCarrierRange($deliveryPriceByRange); + + if (!$range) { + continue; + } + + foreach ($deliveryPriceByRange['zones'] as $zone) { + /** @var array $countryIsoCodes */ + $countryIsoCodes = $countryRepository->getCountyIsoCodesByZoneId($zone['id_zone'], true); + + /** @var array $stateIsoCodes */ + $stateIsoCodes = $stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); + + $carrierDetail = []; + $carrierDetail['id_reference'] = $carrier->id_reference; + $carrierDetail['id_zone'] = $zone['id_zone']; + $carrierDetail['id_range'] = $range->id; + $carrierDetail['id_carrier_detail'] = $range->id; + $carrierDetail['shipping_method'] = $carrier->getRangeTable(); + $carrierDetail['delimiter1'] = $range->delimiter1; + $carrierDetail['delimiter2'] = $range->delimiter2; + $carrierDetail['country_ids'] = implode(',', $countryIsoCodes); + $carrierDetail['state_ids'] = implode(',', $stateIsoCodes); + $carrierDetail['price'] = $zone['price']; + + array_push($carrierDetails, $carrierDetail); + } + } + + return $carrierDetails; + } + + /** + * Build a CarrierTaxes from Carrier + * + * @param array $carrierData + * + * @return array + * + * @throws \PrestaShopDatabaseException + * @throws \PrestaShopException + */ + public static function buildCarrierTaxes($carrierData) + { + /** @var \Ps_eventbus $module */ + $module = \Module::getInstanceByName('ps_eventbus'); + + /** @var TaxeRepository $taxeRepository */ + $taxeRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\TaxeRepository'); + + $carrier = new \Carrier($carrierData['id_reference']); + + $deliveryPriceByRanges = CarrierHelper::getDeliveryPriceByRange($carrier); + + if (!$deliveryPriceByRanges) { + return []; + } + + $carrierTaxes = []; + + foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { + $range = CarrierHelper::getCarrierRange($deliveryPriceByRange); + + if (!$range) { + continue; + } + + foreach ($deliveryPriceByRange['zones'] as $zone) { + $taxRulesGroupId = (int) $carrier->getIdTaxRulesGroup(); + + /** @var array $carrierTaxesByZone */ + $carrierTaxesByZone = $taxeRepository->getCarrierTaxesByZone($zone['id_zone'], $taxRulesGroupId, true); + + if (!$carrierTaxesByZone[0]['country_iso_code']) { + continue; + } + + $carrierTaxesByZone = $carrierTaxesByZone[0]; + + $carrierTaxe = []; + + $carrierTaxe['id_reference'] = $carrier->id_reference; + $carrierTaxe['id_zone'] = $zone['id_zone']; + $carrierTaxe['id_range'] = $range->id; + $carrierTaxe['id_carrier_tax'] = $taxRulesGroupId; + $carrierTaxe['country_id'] = $carrierTaxesByZone['country_iso_code']; + $carrierTaxe['state_ids'] = $carrierTaxesByZone['state_iso_code']; + $carrierTaxe['tax_rate'] = $carrierTaxesByZone['rate']; + + array_push($carrierTaxes, $carrierTaxe); + } + } + + return $carrierTaxes; + } + + /** + * @param array $deliveryPriceByRange + * + * @return false|\RangeWeight|\RangePrice + * + * @throws \PrestaShopDatabaseException + * @throws \PrestaShopException + */ + private static function getCarrierRange($deliveryPriceByRange) + { + if (isset($deliveryPriceByRange['id_range_weight'])) { + return new \RangeWeight($deliveryPriceByRange['id_range_weight']); + } + if (isset($deliveryPriceByRange['id_range_price'])) { + return new \RangePrice($deliveryPriceByRange['id_range_price']); + } + + return false; + } + + /** + * @param \Carrier $carrierObj + * + * @return array|false + */ + private static function getDeliveryPriceByRange(\Carrier $carrierObj) + { + $rangeTable = $carrierObj->getRangeTable(); + + switch ($rangeTable) { + case 'range_weight': + return CarrierHelper::getCarrierByWeightRange($carrierObj, 'range_weight'); + case 'range_price': + return CarrierHelper::getCarrierByPriceRange($carrierObj, 'range_price'); + default: + return false; + } + } + + /** + * @param \Carrier $carrierObj + * @param string $rangeTable + * + * @return array + */ + private static function getCarrierByWeightRange(\Carrier $carrierObj, $rangeTable) + { + $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); + + $filteredRanges = []; + + foreach ($deliveryPriceByRange as $range) { + $filteredRanges[$range['id_range_weight']]['id_range_weight'] = $range['id_range_weight']; + $filteredRanges[$range['id_range_weight']]['id_carrier'] = $range['id_carrier']; + $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; + $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['price'] = $range['price']; + } + + return $filteredRanges; + } + + /** + * @param \Carrier $carrierObj + * @param string $rangeTable + * + * @return array + */ + private static function getCarrierByPriceRange(\Carrier $carrierObj, $rangeTable) + { + $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); + + $filteredRanges = []; + + foreach ($deliveryPriceByRange as $range) { + $filteredRanges[$range['id_range_price']]['id_range_price'] = $range['id_range_price']; + $filteredRanges[$range['id_range_price']]['id_carrier'] = $range['id_carrier']; + $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; + $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['price'] = $range['price']; + } + + return $filteredRanges; + } +} diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index 27bd0d59..ea8c5d74 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -6,6 +6,16 @@ class CarrierRepository extends AbstractRepository implements RepositoryInterfac { const TABLE_NAME = 'carrier'; + /** + * @return void + */ + public function generateMinimalQuery() + { + $this->query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'c'); + } + /** * @param string $langIso * @@ -13,7 +23,7 @@ class CarrierRepository extends AbstractRepository implements RepositoryInterfac * * @throws \PrestaShopException */ - public function generateBaseQuery($langIso) + public function generateFullQuery($langIso) { $langId = (int) \Language::getIdByIso($langIso); $context = \Context::getContext(); @@ -26,16 +36,17 @@ public function generateBaseQuery($langIso) throw new \PrestaShopException('No shop context'); } - $this->query = new \DbQuery(); + $this->generateMinimalQuery(); - $this->query->from('carrier', 'c') + $this->query ->leftJoin('carrier_lang', 'cl', 'cl.id_carrier = c.id_carrier AND cl.id_lang = ' . $langId) ->leftJoin('carrier_shop', 'cs', 'cs.id_carrier = c.id_carrier') ->where('cs.id_shop = ' . $context->shop->id) ->where('deleted=0') ; - $this->query->select('c.*'); + $this->query->select('c.*') + ->select('cl.delay AS delay'); } /** @@ -51,7 +62,7 @@ public function generateBaseQuery($langIso) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query->limit((int) $limit, (int) $offset); @@ -71,7 +82,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query ->where('c.id_carrier IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -82,22 +93,20 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + $this->generateMinimalQuery(); - if (!is_array($result) || empty($result)) { - return 0; - } + $this->query->select('(COUNT(c.id_carrier) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); - return count($result); + return $result[0]['count']; } } diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/NewRepository/OrderCartRuleRepository.php index b7cfe543..57817572 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/NewRepository/OrderCartRuleRepository.php @@ -6,6 +6,16 @@ class OrderCartRuleRepository extends AbstractRepository implements RepositoryIn { const TABLE_NAME = 'order_cart_rule'; + /** + * @return void + */ + public function generateMinimalQuery() + { + $this->query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'ocr'); + } + /** * @param string $langIso * @@ -13,12 +23,9 @@ class OrderCartRuleRepository extends AbstractRepository implements RepositoryIn * * @throws \PrestaShopException */ - public function generateBaseQuery($langIso) + public function generateFullQuery($langIso) { - $this->query = new \DbQuery(); - - $this->query - ->from(self::TABLE_NAME, 'ocr'); + $this->generateMinimalQuery(); $this->query ->select('ocr.id_order_cart_rule') @@ -48,7 +55,7 @@ public function generateBaseQuery($langIso) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query->limit((int) $limit, (int) $offset); @@ -68,10 +75,10 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query - ->where('ocr.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('ocr.id_order_cart_rule IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); return $this->runQuery($debug); @@ -79,22 +86,20 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + $this->generateMinimalQuery(); - if (!is_array($result) || empty($result)) { - return 0; - } + $this->query->select('(COUNT(ocr.id_order_cart_rule) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); - return count($result); + return $result[0]['count']; } } diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php index 9803b38c..477deda2 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -6,6 +6,16 @@ class OrderDetailRepository extends AbstractRepository implements RepositoryInte { const TABLE_NAME = 'order_detail'; + /** + * @return void + */ + public function generateMinimalQuery() + { + $this->query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'od'); + } + /** * @param string $langIso * @@ -13,7 +23,7 @@ class OrderDetailRepository extends AbstractRepository implements RepositoryInte * * @throws \PrestaShopException */ - public function generateBaseQuery($langIso) + public function generateFullQuery($langIso) { $context = \Context::getContext(); @@ -25,10 +35,9 @@ public function generateBaseQuery($langIso) throw new \PrestaShopException('No shop context'); } - $this->query = new \DbQuery(); + $this->generateMinimalQuery(); $this->query - ->from(self::TABLE_NAME, 'od') ->where('od.id_shop = ' . $context->shop->id) ->innerJoin('orders', 'o', 'od.id_order = o.id_order') ->leftJoin('order_slip_detail', 'osd', 'od.id_order_detail = osd.id_order_detail') @@ -68,7 +77,7 @@ public function generateBaseQuery($langIso) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query->limit((int) $limit, (int) $offset); @@ -88,10 +97,10 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query - ->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('od.id_order_detail IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; @@ -100,22 +109,20 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + $this->generateMinimalQuery(); - if (!is_array($result) || empty($result)) { - return 0; - } + $this->query->select('(COUNT(od.id_order_detail) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); - return count($result); + return $result[0]['count']; } } diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php index dcb742d0..1ee496fa 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -6,6 +6,16 @@ class OrderHistoryRepository extends AbstractRepository implements RepositoryInt { const TABLE_NAME = 'order_history'; + /** + * @return void + */ + public function generateMinimalQuery() + { + $this->query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'oh'); + } + /** * @param string $langIso * @@ -13,14 +23,13 @@ class OrderHistoryRepository extends AbstractRepository implements RepositoryInt * * @throws \PrestaShopException */ - public function generateBaseQuery($langIso) + public function generateFullQuery($langIso) { $langId = (int) \Language::getIdByIso($langIso); - $this->query = new \DbQuery(); + $this->generateMinimalQuery(); $this->query - ->from(self::TABLE_NAME, 'oh') ->innerJoin('order_state', 'os', 'os.id_order_state = oh.id_order_State') ->innerJoin('order_state_lang', 'osl', 'osl.id_order_state = os.id_order_State AND osl.id_lang = ' . (int) $langId) ; @@ -53,7 +62,7 @@ public function generateBaseQuery($langIso) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query->limit((int) $limit, (int) $offset); @@ -73,10 +82,10 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query - ->where('oh.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('oh.id_order_state IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; @@ -85,23 +94,21 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + $this->generateMinimalQuery(); - if (!is_array($result) || empty($result)) { - return 0; - } + $this->query->select('(COUNT(oh.id_order_state) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); - return count($result); + return $result[0]['count']; } /** @@ -119,7 +126,7 @@ public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $debug) return []; } - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query->where('oh.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')'); diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php index 29053013..a8de0203 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -6,6 +6,16 @@ class OrderRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'orders'; + /** + * @return void + */ + public function generateMinimalQuery() + { + $this->query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'o'); + } + /** * @param string $langIso * @@ -13,12 +23,11 @@ class OrderRepository extends AbstractRepository implements RepositoryInterface * * @throws \PrestaShopException */ - public function generateBaseQuery($langIso) + public function generateFullQuery($langIso) { - $this->query = new \DbQuery(); + $this->generateMinimalQuery(); $this->query - ->from(self::TABLE_NAME, 'o') ->leftJoin('currency', 'c', 'o.id_currency = c.id_currency') ->leftJoin('order_slip', 'os', 'o.id_order = os.id_order') ->leftJoin('address', 'ad', 'ad.id_address = o.id_address_delivery') @@ -98,7 +107,7 @@ public function generateBaseQuery($langIso) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query->limit((int) $limit, (int) $offset); @@ -118,7 +127,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateBaseQuery($langIso); + $this->generateFullQuery($langIso); $this->query ->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -130,22 +139,20 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - $result = $this->getContentsForFull($offset, 1, $langIso, $debug); + $this->generateMinimalQuery(); + + $this->query->select('(COUNT(o.id_order) - ' . (int) $offset . ') as count'); - if (!is_array($result) || empty($result)) { - return 0; - } + $result = $this->runQuery(false); - return count($result); + return $result[0]['count']; } } diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php index d6ec5a21..7316228d 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -7,12 +7,17 @@ */ interface RepositoryInterface { + /** + * @return void + */ + public function generateMinimalQuery(); + /** * @param string $langIso * * @return mixed */ - public function generateBaseQuery($langIso); + public function generateFullQuery($langIso); /** * @param int $offset @@ -36,10 +41,8 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int */ - public function countFullSyncContentLeft($offset, $langIso, $debug); + public function countFullSyncContentLeft($offset); } diff --git a/src/Repository/TaxRepository.php b/src/Repository/TaxeRepository.php similarity index 99% rename from src/Repository/TaxRepository.php rename to src/Repository/TaxeRepository.php index a0fbd029..5bcf0e90 100644 --- a/src/Repository/TaxRepository.php +++ b/src/Repository/TaxeRepository.php @@ -2,7 +2,7 @@ namespace PrestaShop\Module\PsEventbus\Repository; -class TaxRepository +class TaxeRepository { /** * @var \Db diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index cf9f7ea7..2ba0b259 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -70,13 +70,13 @@ public function __construct( * @param string $jobId * @param string $langIso * @param int $limit - * @param bool $isFull + * @param bool $fullSyncRequested * @param bool $debug * @param bool $ise2e * * @return void */ - public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $debug, $ise2e) + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested, $debug, $ise2e) { try { if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { @@ -84,8 +84,8 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } $isHealthCheck = $shopContent == Config::COLLECTION_HEALTHCHECK; - $isAuthentified = $this->authorize($jobId, $isHealthCheck); + $isIncrementalSync = false; if ($isHealthCheck) { /** @var HealthCheckService $healthCheckService */ @@ -118,9 +118,12 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); if (is_array($typeSync)) { - if (!$isFull) { - $offset = (int) $typeSync['offset']; - } else { + $offset = (int) $typeSync['offset']; + + if ((int) $typeSync['full_sync_finished'] === 1 && !$fullSyncRequested) { + $isIncrementalSync = true; + } elseif ($fullSyncRequested) { + $offset = 0; $this->eventbusSyncRepository->updateTypeSync( $shopContent, $offset, @@ -134,10 +137,10 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, } else { $this->eventbusSyncRepository->insertTypeSync($shopContent, $offset, $dateNow, $langIso); - $isFull = true; + $fullSyncRequested = true; } - if ($isFull) { + if (!$isIncrementalSync) { $response = $this->synchronizationService->sendFullSync( $shopContent, $jobId, @@ -164,7 +167,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $isFull, [ 'job_id' => $jobId, 'object_type' => $shopContent, - 'syncType' => $isFull ? 'full' : 'incremental', + 'syncType' => $fullSyncRequested ? 'full' : 'incremental', ], $response ) diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php new file mode 100644 index 00000000..07cb1ade --- /dev/null +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -0,0 +1,115 @@ +carrierRepository = $carrierRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $carrierDetails = []; + + foreach ($result as $carrierData) { + $carrierDetails = array_merge($carrierDetails, CarrierHelper::buildCarrierDetails($carrierData)); + } + + $this->castCarrierDetails($carrierDetails); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['shipping_method'] . '-' . $item['id_range'], + 'collection' => Config::COLLECTION_CARRIER_DETAILS, + 'properties' => $item, + ]; + }, $carrierDetails); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->carrierRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $carrierDetails = []; + + foreach ($result as $carrierData) { + $carrierDetails = array_merge($carrierDetails, CarrierHelper::buildCarrierDetails($carrierData)); + } + + $this->castCarrierDetails($carrierDetails); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['shipping_method'] . '-' . $item['id_range'], + 'collection' => Config::COLLECTION_CARRIER_DETAILS, + 'properties' => $item, + ]; + }, $carrierDetails); + } + + /** + * @param int $offset + * + * @return int + */ + public function countFullSyncContentLeft($offset) + { + return (int) $this->carrierRepository->countFullSyncContentLeft($offset); + } + + /** + * @param array $carrierDetails + * + * @return void + */ + private function castCarrierDetails(&$carrierDetails) + { + foreach ($carrierDetails as &$carrierDetail) { + $carrierDetail['id_reference'] = (string) $carrierDetail['id_reference']; + $carrierDetail['id_zone'] = (string) $carrierDetail['id_zone']; + $carrierDetail['id_range'] = (string) $carrierDetail['id_range']; + $carrierDetail['id_carrier_detail'] = (string) $carrierDetail['id_carrier_detail']; + $carrierDetail['shipping_method'] = (string) $carrierDetail['shipping_method']; + $carrierDetail['delimiter1'] = (float) $carrierDetail['delimiter1']; + $carrierDetail['delimiter2'] = (float) $carrierDetail['delimiter2']; + $carrierDetail['country_ids'] = (string) $carrierDetail['country_ids']; + $carrierDetail['state_ids'] = (string) $carrierDetail['state_ids']; + $carrierDetail['price'] = (float) $carrierDetail['price']; + } + } +} diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php new file mode 100644 index 00000000..de1c4760 --- /dev/null +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -0,0 +1,112 @@ +carrierRepository = $carrierRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $carrierTaxes = []; + + foreach ($result as $carrierData) { + $carrierTaxes = array_merge($carrierTaxes, CarrierHelper::buildCarrierTaxes($carrierData)); + } + + $this->castCarrierTaxes($carrierTaxes); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['id_range'], + 'collection' => Config::COLLECTION_CARRIER_TAXES, + 'properties' => $item, + ]; + }, $carrierTaxes); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->carrierRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $carrierTaxes = []; + + foreach ($result as $carrierData) { + $carrierTaxes = array_merge($carrierTaxes, CarrierHelper::buildCarrierDetails($carrierData)); + } + + $this->castCarrierTaxes($carrierTaxes); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['id_range'], + 'collection' => Config::COLLECTION_CARRIER_TAXES, + 'properties' => $item, + ]; + }, $carrierTaxes); + } + + /** + * @param int $offset + * + * @return int + */ + public function countFullSyncContentLeft($offset) + { + return $this->carrierRepository->countFullSyncContentLeft($offset); + } + + /** + * @param array $carrierTaxes + * + * @return void + */ + private function castCarrierTaxes(&$carrierTaxes) + { + foreach ($carrierTaxes as &$carrierTaxe) { + $carrierTaxe['id_reference'] = (string) $carrierTaxe['id_reference']; + $carrierTaxe['id_zone'] = (string) $carrierTaxe['id_zone']; + $carrierTaxe['id_range'] = (string) $carrierTaxe['id_range']; + $carrierTaxe['id_carrier_tax'] = (string) $carrierTaxe['id_carrier_tax']; + $carrierTaxe['country_ids'] = (string) $carrierTaxe['country_ids']; + $carrierTaxe['state_ids'] = (string) $carrierTaxe['state_ids']; + $carrierTaxe['tax_rate'] = (float) $carrierTaxe['tax_rate']; + } + } +} diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index da6a8225..be82418e 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -2,7 +2,6 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; -use PrestaShop\Module\PsEventbus\Builder\CarrierBuilder; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository; @@ -15,17 +14,12 @@ class CarriersService implements ShopContentServiceInterface /** @var ConfigurationRepository */ private $configurationRepository; - /** @var CarrierBuilder */ - private $carrierBuilder; - public function __construct( CarrierRepository $carrierRepository, - ConfigurationRepository $configurationRepository, - CarrierBuilder $carrierBuilder, + ConfigurationRepository $configurationRepository ) { $this->carrierRepository = $carrierRepository; $this->configurationRepository = $configurationRepository; - $this->carrierBuilder = $carrierBuilder; } /** @@ -38,28 +32,21 @@ public function __construct( */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); + $result = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); - /** @var array $carriers */ - $carriers = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); - - /** @var string $psWeightUnit */ - $psWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); + if (empty($result)) { + return []; + } - $eventBusCarriers = $this->carrierBuilder->buildCarriers( - $carriers, - $langIso, - $currency, - $psWeightUnit - ); + $this->castCarriers($result); return array_map(function ($item) { return [ - 'id' => $item['id_reference'], + 'id' => (string) $item['id_reference'], 'collection' => Config::COLLECTION_CARRIERS, 'properties' => $item, ]; - }, $eventBusCarriers); + }, $result); } /** @@ -78,36 +65,80 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); - - /** @var string $psWeightUnit */ - $psWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); - - $eventBusCarriers = $this->carrierBuilder->buildCarriers( - $result, - $langIso, - $currency, - $psWeightUnit - ); + $this->castCarriers($result); return array_map(function ($item) { return [ - 'id' => $item['id_reference'], + 'id' => (string) $item['id_reference'], 'collection' => Config::COLLECTION_CARRIERS, 'properties' => $item, ]; - }, $eventBusCarriers); + }, $result); } /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - return (int) $this->carrierRepository->countFullSyncContentLeft($offset, $langIso, $debug); + return $this->carrierRepository->countFullSyncContentLeft($offset); + } + + /** + * @param array $carriers + * + * @return void + */ + private function castCarriers(&$carriers) + { + $context = \Context::getContext(); + + if ($context === null) { + throw new \PrestaShopException('Context is null'); + } + + $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); + $freeShippingStartsAtPrice = (float) $this->configurationRepository->get('PS_SHIPPING_FREE_PRICE'); + $freeShippingStartsAtWeight = (float) $this->configurationRepository->get('PS_SHIPPING_FREE_WEIGHT'); + + /** @var string $psWeightUnit */ + $psWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); + + foreach ($carriers as &$carrier) { + $carrierTaxesRatesGroupId = \Carrier::getIdTaxRulesGroupByIdCarrier((int) $carrier['id_carrier'], \Context::getContext()); + + $shippingHandling = 0.0; + + if ($carrier['shipping_handling']) { + $shippingHandling = (float) $this->configurationRepository->get('PS_SHIPPING_HANDLING'); + } + + $carrier['id_carrier'] = (string) $carrier['id_carrier']; + $carrier['id_reference'] = (string) $carrier['id_reference']; + $carrier['name'] = (string) $carrier['name']; + $carrier['carrier_taxes_rates_group_id'] = (string) $carrierTaxesRatesGroupId; + $carrier['url'] = (string) $carrier['url']; + $carrier['active'] = (bool) $carrier['active']; + $carrier['deleted'] = (bool) $carrier['deleted']; + $carrier['shipping_handling'] = (float) $shippingHandling; + $carrier['free_shipping_starts_at_price'] = (float) $freeShippingStartsAtPrice; + $carrier['free_shipping_starts_at_weight'] = (float) $freeShippingStartsAtWeight; + $carrier['disable_carrier_when_out_of_range'] = (bool) $carrier['range_behavior']; + $carrier['is_module'] = (bool) $carrier['is_module']; + $carrier['is_free'] = (bool) $carrier['is_free']; + $carrier['shipping_external'] = (bool) $carrier['shipping_external']; + $carrier['need_range'] = (bool) $carrier['need_range']; + $carrier['external_module_name'] = (string) $carrier['external_module_name']; + $carrier['max_width'] = (float) $carrier['max_width']; + $carrier['max_height'] = (float) $carrier['max_height']; + $carrier['max_depth'] = (float) $carrier['max_depth']; + $carrier['max_weight'] = (float) $carrier['max_weight']; + $carrier['grade'] = (int) $carrier['grade']; + $carrier['delay'] = (string) $carrier['delay']; + $carrier['currency'] = (string) $currency->iso_code; + $carrier['weight_unit'] = (string) $psWeightUnit; + } } } diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index 5d1b2f7a..f52ac30b 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -71,14 +71,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - return (int) $this->orderCartRuleRepository->countFullSyncContentLeft($offset, $langIso, $debug); + return $this->orderCartRuleRepository->countFullSyncContentLeft($offset); } /** @@ -86,7 +84,7 @@ public function countFullSyncContentLeft($offset, $langIso, $debug) * * @return void */ - public function castOrderCartRules(&$orderCartRules) + private function castOrderCartRules(&$orderCartRules) { foreach ($orderCartRules as &$orderCartRule) { $orderCartRule['id_cart_rule'] = (int) $orderCartRule['id_cart_rule']; diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index bc85c068..123533a2 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -31,7 +31,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castOrderDetails($result, $langIso, $debug); + $this->castOrderDetails($result); return array_map(function ($item) { return [ @@ -58,7 +58,7 @@ public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $de return []; } - $this->castOrderDetails($result, $langIso, $debug); + $this->castOrderDetails($result); return array_map(function ($item) { return [ @@ -71,24 +71,20 @@ public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $de /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - return (int) $this->orderDetailRepository->countFullSyncContentLeft($offset, $langIso, $debug); + return $this->orderDetailRepository->countFullSyncContentLeft($offset); } /** * @param array $orderDetails - * @param string $langIso - * @param bool $debug * * @return void */ - private function castOrderDetails(&$orderDetails, $langIso, $debug) + private function castOrderDetails(&$orderDetails) { foreach ($orderDetails as &$orderDetail) { $orderDetail['id_order_detail'] = (int) $orderDetail['id_order_detail']; @@ -103,9 +99,6 @@ private function castOrderDetails(&$orderDetails, $langIso, $debug) $orderDetail['category'] = (int) $orderDetail['category']; $orderDetail['unique_product_id'] = "{$orderDetail['product_id']}-{$orderDetail['product_attribute_id']}-{$orderDetail['iso_code']}"; $orderDetail['conversion_rate'] = (float) $orderDetail['conversion_rate']; - - // remove extra properties - unset($orderDetail['iso_code']); } } } diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index 235a8be7..dac67740 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -71,14 +71,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - return (int) $this->orderHistoryRepository->countFullSyncContentLeft($offset, $langIso, $debug); + return $this->orderHistoryRepository->countFullSyncContentLeft($offset); } /** @@ -86,7 +84,7 @@ public function countFullSyncContentLeft($offset, $langIso, $debug) * * @return void */ - public function castOrderHistories(&$orderHistories) + private function castOrderHistories(&$orderHistories) { foreach ($orderHistories as &$orderHistory) { $orderHistory['id_order_state'] = (int) $orderHistory['id_order_state']; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 07f99733..d4fee405 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -84,14 +84,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int */ - public function countFullSyncContentLeft($offset, $langIso, $debug) + public function countFullSyncContentLeft($offset) { - return (int) $this->orderRepository->countFullSyncContentLeft($offset, $langIso, $debug); + return $this->orderRepository->countFullSyncContentLeft($offset); } /** @@ -101,7 +99,7 @@ public function countFullSyncContentLeft($offset, $langIso, $debug) * * @return void */ - public function castOrders(&$orders, $langIso, $debug) + private function castOrders(&$orders, $langIso, $debug) { foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index 718e7fa3..301ccd2f 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -26,10 +26,8 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset - * @param string $langIso - * @param bool $debug * * @return int */ - public function countFullSyncContentLeft($offset, $langIso, $debug); + public function countFullSyncContentLeft($offset); } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index a7daf7af..38c7c0e8 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -117,7 +117,7 @@ public function sendFullSync( } } - $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $langIso, $debug); + $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset); if ($remainingObjects <= 0) { $remainingObjects = 0; From 226d177babbd8eef5b3881dce501c2841e629382 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:41:18 +0200 Subject: [PATCH 067/162] feat: pseventbus v4 carts (#355) --- config/common/new-repository.yml | 4 + config/front/services.yml | 6 + e2e/src/helpers/shop-contents.ts | 1 + src/Repository/CartRepository.php | 129 ------------------ .../NewRepository/CarrierRepository.php | 2 +- .../NewRepository/CartRepository.php | 100 ++++++++++++++ .../NewRepository/OrderDetailRepository.php | 2 +- src/Service/ShopContent/CarriersService.php | 2 +- src/Service/ShopContent/CartsService.php | 95 +++++++++++++ 9 files changed, 209 insertions(+), 132 deletions(-) delete mode 100644 src/Repository/CartRepository.php create mode 100644 src/Repository/NewRepository/CartRepository.php create mode 100644 src/Service/ShopContent/CartsService.php diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index fc336efc..7583357d 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -18,3 +18,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository + public: true diff --git a/config/front/services.yml b/config/front/services.yml index 2f0b31bc..cf2dce09 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -96,3 +96,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 687187c6..deca7881 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -37,6 +37,7 @@ export const shopContentMapping = { 'carriers': 'carriers', 'carrier_details': 'carrier-details', 'carrier_taxes': 'carrier-taxes', + 'carts': 'carts', 'orders': 'orders', 'order_cart_rules': 'order-cart-rules', 'order_details': 'order-details', diff --git a/src/Repository/CartRepository.php b/src/Repository/CartRepository.php deleted file mode 100644 index 77df6184..00000000 --- a/src/Repository/CartRepository.php +++ /dev/null @@ -1,129 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - - $query->from('cart', 'c') - ->where('c.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCarts($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingCartsCount($offset) - { - $query = $this->getBaseQuery(); - - $query->select('(COUNT(c.id_cart) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $cartIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getCartsIncremental($limit, $cartIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('c.id_cart IN(' . implode(',', array_map('intval', $cartIds)) . ')') - ->limit($limit); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('c.id_cart, date_add as created_at, date_upd as updated_at'); - } -} diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index ea8c5d74..41f30bc6 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -28,7 +28,7 @@ public function generateFullQuery($langIso) $langId = (int) \Language::getIdByIso($langIso); $context = \Context::getContext(); - if ($context === null) { + if ($context == null) { throw new \PrestaShopException('Context is null'); } diff --git a/src/Repository/NewRepository/CartRepository.php b/src/Repository/NewRepository/CartRepository.php new file mode 100644 index 00000000..f72bc3ec --- /dev/null +++ b/src/Repository/NewRepository/CartRepository.php @@ -0,0 +1,100 @@ +query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'c'); + } + + /** + * @param string $langIso + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso) + { + $this->generateMinimalQuery(); + + $this->query->where('c.id_shop = ' . (int) parent::getShopId()); + + $this->query + ->select('c.id_cart') + ->select('date_add as created_at') + ->select('date_upd as updated_at') + ; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso); + + $this->query + ->where('c.id_cart IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset) + { + $this->generateMinimalQuery(); + + $this->query->select('(COUNT(c.id_cart) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php index 477deda2..ef5b5a6b 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -27,7 +27,7 @@ public function generateFullQuery($langIso) { $context = \Context::getContext(); - if ($context === null) { + if ($context == null) { throw new \PrestaShopException('Context is null'); } diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index be82418e..52bf6944 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -95,7 +95,7 @@ private function castCarriers(&$carriers) { $context = \Context::getContext(); - if ($context === null) { + if ($context == null) { throw new \PrestaShopException('Context is null'); } diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php new file mode 100644 index 00000000..ff7cf82c --- /dev/null +++ b/src/Service/ShopContent/CartsService.php @@ -0,0 +1,95 @@ +cartRepository = $cartRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->cartRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCarts($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_cart'], + 'collection' => Config::COLLECTION_CARTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->cartRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCarts($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_cart'], + 'collection' => Config::COLLECTION_CARTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * + * @return int + */ + public function countFullSyncContentLeft($offset) + { + return $this->cartRepository->countFullSyncContentLeft($offset); + } + + /** + * @param array $carts + * + * @return void + */ + private function castCarts(&$carts) + { + foreach ($carts as &$cart) { + $cart['id_cart'] = (string) $cart['id_cart']; + $cart['created_at'] = (string) $cart['created_at']; + $cart['updated_at'] = (string) $cart['updated_at']; + } + } +} From bf42d620f539b1d039c9f171d1be9b2e41ae7525 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:02:08 +0200 Subject: [PATCH 068/162] feat: pseventbus v4 cart products (#356) --- .github/workflows/quality-check.yml | 5 +- .php-cs-fixer.dist.php | 1 + config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 6 + e2e/src/fixtures/1.7/carrier_details.json | 228 +++++++++++++++++- e2e/src/fixtures/1.7/carriers.json | 2 +- e2e/src/full-sync.spec.ts | 39 +-- e2e/src/helpers/shop-contents.ts | 1 + e2e/src/reject-invalid-job-id.spec.ts | 6 +- ps_eventbus.php | 1 - sql/install.sql | 14 +- sql/migrate.sql | 13 - sql/uninstall.sql | 1 - src/Module/Install.php | 32 --- src/Repository/CartProductRepository.php | 60 ----- src/Repository/DeletedObjectsRepository.php | 94 -------- src/Repository/EventbusSyncRepository.php | 51 +--- .../NewRepository/CarrierRepository.php | 14 +- .../NewRepository/CartProductRepository.php | 102 ++++++++ src/Service/FrontApiService.php | 82 +++---- .../ShopContent/CarrierDetailsService.php | 4 +- .../ShopContent/CarrierTaxesService.php | 8 +- src/Service/ShopContent/CarriersService.php | 4 +- .../ShopContent/CartProductsService.php | 99 ++++++++ src/Service/ShopContent/CartsService.php | 4 +- .../ShopContent/OrderCartRulesService.php | 4 +- .../ShopContent/OrderDetailsService.php | 4 +- .../ShopContent/OrderHistoriesService.php | 4 +- src/Service/ShopContent/OrdersService.php | 4 +- .../ShopContentServiceInterface.php | 4 +- src/Service/SynchronizationService.php | 6 +- upgrade/Upgrade-4.0.0.php | 9 + 33 files changed, 569 insertions(+), 347 deletions(-) delete mode 100644 sql/migrate.sql delete mode 100644 src/Repository/CartProductRepository.php delete mode 100644 src/Repository/DeletedObjectsRepository.php create mode 100644 src/Repository/NewRepository/CartProductRepository.php create mode 100644 src/Service/ShopContent/CartProductsService.php diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index db0fcc83..cbdab736 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -56,7 +56,7 @@ jobs: strategy: matrix: # @TODO: "1.6.1.24" is temporarily disabled here - ps_version: ["1.6.1.11", "1.7.8.10", "8.1.6"] + ps_version: ["1.7.8.10", "8.1.6"] steps: - name: Checkout uses: actions/checkout@v4 @@ -90,7 +90,8 @@ jobs: if: ${{ github.event_name == 'pull_request' }} strategy: matrix: - ps_version: ["1.6.1.11", "1.7.8.10", "8.1.4", "nightly"] + # @TODO: "1.6.1.24" is temporarily disabled here + ps_version: ["1.7.8.10", "8.1.4", "nightly"] steps: - name: Checkout the repository uses: actions/checkout@v4 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index aacacbf4..d73df30c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -9,6 +9,7 @@ ->exclude('vendor'); $config = (new PrestaShop\CodingStandards\CsFixer\Config()) + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setUsingCache(false) ->setFinder($finder); diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 7583357d..574aff63 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -22,3 +22,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 97c6a558..14e6429a 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -94,12 +94,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository public: true - PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository: - class: PrestaShop\Module\PsEventbus\Repository\DeletedObjectsRepository - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' - PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index cf2dce09..67f31ff2 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -102,3 +102,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CartProductsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartProductsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository' diff --git a/e2e/src/fixtures/1.7/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json index fe51488c..c40966a4 100644 --- a/e2e/src/fixtures/1.7/carrier_details.json +++ b/e2e/src/fixtures/1.7/carrier_details.json @@ -1 +1,227 @@ -[] +[ + { + "id": "2-1-range_weight-1", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "1", + "id_range": "1", + "id_carrier_detail": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "", + "state_ids": "", + "price": 5 + } + }, + { + "id": "2-2-range_weight-1", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "2", + "id_range": "1", + "id_carrier_detail": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "", + "state_ids": "", + "price": 5 + } + }, + { + "id": "3-2-range_price-2", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "2", + "id_carrier_detail": "2", + "shipping_method": "range_price", + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "", + "state_ids": "", + "price": 4 + } + }, + { + "id": "3-1-range_price-2", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "2", + "id_carrier_detail": "2", + "shipping_method": "range_price", + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "", + "state_ids": "", + "price": 3 + } + }, + { + "id": "3-2-range_price-3", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "3", + "id_carrier_detail": "3", + "shipping_method": "range_price", + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "", + "state_ids": "", + "price": 2 + } + }, + { + "id": "3-1-range_price-3", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "3", + "id_carrier_detail": "3", + "shipping_method": "range_price", + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "", + "state_ids": "", + "price": 1 + } + }, + { + "id": "3-2-range_price-4", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "4", + "id_carrier_detail": "4", + "shipping_method": "range_price", + "delimiter1": 100, + "delimiter2": 200, + "country_ids": "", + "state_ids": "", + "price": 0 + } + }, + { + "id": "3-1-range_price-4", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "4", + "id_carrier_detail": "4", + "shipping_method": "range_price", + "delimiter1": 100, + "delimiter2": 200, + "country_ids": "", + "state_ids": "", + "price": 0 + } + }, + { + "id": "4-2-range_weight-2", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "2", + "id_carrier_detail": "2", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 1, + "country_ids": "", + "state_ids": "", + "price": 0 + } + }, + { + "id": "4-1-range_weight-2", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "2", + "id_carrier_detail": "2", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 1, + "country_ids": "", + "state_ids": "", + "price": 0 + } + }, + { + "id": "4-2-range_weight-3", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "3", + "id_carrier_detail": "3", + "shipping_method": "range_weight", + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "", + "state_ids": "", + "price": 3 + } + }, + { + "id": "4-1-range_weight-3", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "3", + "id_carrier_detail": "3", + "shipping_method": "range_weight", + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "", + "state_ids": "", + "price": 2 + } + }, + { + "id": "4-2-range_weight-4", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "4", + "id_carrier_detail": "4", + "shipping_method": "range_weight", + "delimiter1": 3, + "delimiter2": 10000, + "country_ids": "", + "state_ids": "", + "price": 6 + } + }, + { + "id": "4-1-range_weight-4", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "4", + "id_carrier_detail": "4", + "shipping_method": "range_weight", + "delimiter1": 3, + "delimiter2": 10000, + "country_ids": "", + "state_ids": "", + "price": 5 + } + } +] + \ No newline at end of file diff --git a/e2e/src/fixtures/1.7/carriers.json b/e2e/src/fixtures/1.7/carriers.json index 2d329af0..bef1dd4a 100644 --- a/e2e/src/fixtures/1.7/carriers.json +++ b/e2e/src/fixtures/1.7/carriers.json @@ -65,7 +65,7 @@ "properties": { "id_carrier": "1", "id_reference": "1", - "name": "PrestaShop", + "name": "0", "carrier_taxes_rates_group_id": "1", "url": "", "active": true, diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 6a3f4e23..9198bfc6 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -11,6 +11,8 @@ import { sortUploadData, } from "./helpers/data-helper"; import { ShopContent, shopContentList } from "./helpers/shop-contents"; +import { exit } from "process"; +import { cp } from "fs"; expect.extend(matchers); @@ -50,7 +52,7 @@ const specialFieldAssert: { [index: string]: (val) => void } = { } describe('Full Sync', () => { - let testTimestamp = 0; + let generatedNumber = 0; // gérer les cas ou un shopContent n'existe pas (pas de fixture du coup) const shopContents: ShopContent[] = shopContentList.filter( @@ -60,8 +62,8 @@ describe('Full Sync', () => { let jobId: string; beforeEach(() => { - testTimestamp = Date.now(); - jobId = `valid-job-full-${testTimestamp}`; + generatedNumber = Date.now() + Math.trunc(Math.random() * 100000000000000); + jobId = `valid-job-full-${generatedNumber}`; }); // TODO : some versions of prestashop include ps_facebook out of the box, this test can't reliably be run for all versions @@ -191,26 +193,35 @@ describe('Full Sync', () => { const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); let syncedData: PsEventbusSyncUpload[]; + let hasData = false; try { // act - syncedData = await lastValueFrom( - zip(fullSync$, message$).pipe( - map((msg) => { - return msg[1].body.file - }), - concatMap((syncedPage) => { - return from(syncedPage); - }), - toArray() - ) - ); + hasData = (await lastValueFrom(fullSync$)).total_objects != 0; + + if (hasData) { + syncedData = await lastValueFrom( + zip(fullSync$, message$).pipe( + map((msg) => { + return msg[1].body.file + }), + concatMap((syncedPage) => { + return from(syncedPage); + }), + toArray() + ) + ); + } } catch (error) { if (error instanceof TimeoutError) { throw new Error(`Upload complete dataset collector for "${shopContent}" throw TimeoutError with jobId "${jobId}"`) } } + if (!hasData) { + return; + } + // dump data for easier debugging or updating fixtures if (testConfig.dumpFullSyncData) { await dumpUploadData(syncedData, shopContent); diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index deca7881..a5ad147c 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -38,6 +38,7 @@ export const shopContentMapping = { 'carrier_details': 'carrier-details', 'carrier_taxes': 'carrier-taxes', 'carts': 'carts', + 'cart_products': 'cart-products', 'orders': 'orders', 'order_cart_rules': 'order-cart-rules', 'order_details': 'order-details', diff --git a/e2e/src/reject-invalid-job-id.spec.ts b/e2e/src/reject-invalid-job-id.spec.ts index a0aee8f4..85ed0a97 100644 --- a/e2e/src/reject-invalid-job-id.spec.ts +++ b/e2e/src/reject-invalid-job-id.spec.ts @@ -6,15 +6,15 @@ import {probe} from "./helpers/mock-probe"; import { ShopContent, shopContentList } from "./helpers/shop-contents"; describe('Reject invalid job-id', () => { - let testTimestamp = 0; + let generatedNumber = 0; const shopContents: ShopContent[] = shopContentList let jobId: string; beforeEach(() => { - testTimestamp = Date.now(); - jobId = `invalid-job-id-${testTimestamp}` + generatedNumber = Date.now() + Math.trunc(Math.random() * 100000000000000); + jobId = `invalid-job-id-${generatedNumber}` }); it.each(shopContents)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (shopContent) => { diff --git a/ps_eventbus.php b/ps_eventbus.php index 73801480..7ee7f455 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -58,7 +58,6 @@ class Ps_eventbus extends Module const REQUIRED_TABLES = [ 'eventbus_type_sync', 'eventbus_job', - 'eventbus_deleted_objects', 'eventbus_incremental_sync', ]; diff --git a/sql/install.sql b/sql/install.sql index 45b38aab..ed2f9b5c 100644 --- a/sql/install.sql +++ b/sql/install.sql @@ -5,7 +5,8 @@ CREATE TABLE IF NOT EXISTS `PREFIX_eventbus_type_sync` `id_shop` INT(10) UNSIGNED NOT NULL, `lang_iso` VARCHAR(3), `full_sync_finished` TINYINT(1) NOT NULL DEFAULT 0, - `last_sync_date` DATETIME NOT NULL + `last_sync_date` DATETIME NOT NULL, + PRIMARY KEY (`type`, `id_shop`, `lang_iso`) ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8; @@ -16,19 +17,10 @@ CREATE TABLE IF NOT EXISTS `PREFIX_eventbus_job` ) ENGINE = ENGINE_TYPE DEFAULT CHARSET = utf8; -CREATE TABLE IF NOT EXISTS `PREFIX_eventbus_deleted_objects` -( - `type` VARCHAR(50) NOT NULL, - `id_object` INT(10) UNSIGNED NOT NULL, - `id_shop` INT(10) UNSIGNED NOT NULL, - `created_at` DATETIME NOT NULL, - PRIMARY KEY (`type`, `id_object`, `id_shop`) -) ENGINE = ENGINE_TYPE - DEFAULT CHARSET = utf8; - CREATE TABLE IF NOT EXISTS `PREFIX_eventbus_incremental_sync` ( `type` VARCHAR(50) NOT NULL, + `action` VARCHAR(50) NOT NULL, `id_object` INT(10) UNSIGNED NOT NULL, `id_shop` INT(10) UNSIGNED NOT NULL, `lang_iso` VARCHAR(3), diff --git a/sql/migrate.sql b/sql/migrate.sql deleted file mode 100644 index 419720b8..00000000 --- a/sql/migrate.sql +++ /dev/null @@ -1,13 +0,0 @@ -INSERT INTO `PREFIX_eventbus_type_sync` -SELECT * FROM `PREFIX_accounts_type_sync`; - -INSERT INTO `PREFIX_eventbus_deleted_objects` -SELECT * FROM `PREFIX_accounts_deleted_objects`; - -INSERT INTO `PREFIX_eventbus_incremental_sync` -SELECT * FROM `PREFIX_accounts_incremental_sync`; - -DROP TABLE IF EXISTS `PREFIX_accounts_type_sync`; -DROP TABLE IF EXISTS `PREFIX_accounts_deleted_objects`; -DROP TABLE IF EXISTS `PREFIX_accounts_incremental_sync`; -DROP TABLE IF EXISTS `PREFIX_accounts_sync`; \ No newline at end of file diff --git a/sql/uninstall.sql b/sql/uninstall.sql index 436d0d28..38e84e7e 100644 --- a/sql/uninstall.sql +++ b/sql/uninstall.sql @@ -1,5 +1,4 @@ DROP TABLE IF EXISTS `PREFIX_eventbus_type_sync`; DROP TABLE IF EXISTS `PREFIX_eventbus_job`; -DROP TABLE IF EXISTS `PREFIX_eventbus_deleted_objects`; DROP TABLE IF EXISTS `PREFIX_eventbus_incremental_sync`; DROP TABLE IF EXISTS `PREFIX_eventbus_live_sync`; diff --git a/src/Module/Install.php b/src/Module/Install.php index c5fdb128..b6360ff2 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -70,38 +70,6 @@ public function installDatabaseTables() } } - $this->copyDataFromPsAccounts(); - return true; } - - /** - * @return void - */ - private function copyDataFromPsAccounts() - { - $dbInstallFile = "{$this->module->getLocalPath()}/sql/migrate.sql"; - - if (!file_exists($dbInstallFile)) { - return; - } - - $sql = \Tools::file_get_contents($dbInstallFile); - - if (empty($sql) || !is_string($sql)) { - return; - } - - $sql = str_replace(['PREFIX_', 'ENGINE_TYPE'], [_DB_PREFIX_, _MYSQL_ENGINE_], $sql); - $sql = preg_split("/;\s*[\r\n]+/", trim($sql)); - - if (!empty($sql)) { - foreach ($sql as $query) { - try { - $this->db->execute($query); - } catch (\Exception $exception) { - } - } - } - } } diff --git a/src/Repository/CartProductRepository.php b/src/Repository/CartProductRepository.php deleted file mode 100644 index fa33e5e6..00000000 --- a/src/Repository/CartProductRepository.php +++ /dev/null @@ -1,60 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - - $query->from('cart_product', 'cp') - ->where('cp.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param array $cartIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCartProducts($cartIds) - { - $query = $this->getBaseQuery(); - - $query->select('cp.id_cart, cp.id_product, cp.id_product_attribute, cp.quantity, cp.date_add as created_at'); - - if (!empty($cartIds)) { - $query->where('cp.id_cart IN (' . implode(',', array_map('intval', $cartIds)) . ')'); - } - - return $this->db->executeS($query); - } -} diff --git a/src/Repository/DeletedObjectsRepository.php b/src/Repository/DeletedObjectsRepository.php deleted file mode 100644 index 67634c89..00000000 --- a/src/Repository/DeletedObjectsRepository.php +++ /dev/null @@ -1,94 +0,0 @@ -db = \Db::getInstance(); - $this->errorHandler = $errorHandler; - } - - /** - * @param int $shopId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getDeletedObjectsGrouped($shopId) - { - $query = new \DbQuery(); - - $query->select('type, GROUP_CONCAT(id_object SEPARATOR ";") as ids') - ->from(self::DELETED_OBJECTS_TABLE) - ->where('id_shop = ' . (int) $shopId) - ->groupBy('type'); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $objectId - * @param string $objectType - * @param string $date - * @param int $shopId - * - * @return bool - */ - public function insertDeletedObject($objectId, $objectType, $date, $shopId) - { - try { - return $this->db->insert( - self::DELETED_OBJECTS_TABLE, - [ - 'id_shop' => $shopId, - 'id_object' => $objectId, - 'type' => $objectType, - 'created_at' => $date, - ], - false, - true, - \Db::ON_DUPLICATE_KEY - ); - } catch (\PrestaShopDatabaseException $e) { - $this->errorHandler->handle($e); - - return false; - } - } - - /** - * @param string $type - * @param array $objectIds - * @param int $shopId - * - * @return bool - */ - public function removeDeletedObjects($type, $objectIds, $shopId) - { - return $this->db->delete( - self::DELETED_OBJECTS_TABLE, - 'type = "' . pSQL($type) . '" - AND id_shop = ' . (int) $shopId . ' - AND id_object IN(' . implode(',', array_map('intval', $objectIds)) . ')' - ); - } -} diff --git a/src/Repository/EventbusSyncRepository.php b/src/Repository/EventbusSyncRepository.php index a9d33384..e262b8c5 100644 --- a/src/Repository/EventbusSyncRepository.php +++ b/src/Repository/EventbusSyncRepository.php @@ -2,8 +2,6 @@ namespace PrestaShop\Module\PsEventbus\Repository; -use PrestaShop\Module\PsEventbus\Config\Config; - class EventbusSyncRepository { const TYPE_SYNC_TABLE_NAME = 'eventbus_type_sync'; @@ -38,31 +36,28 @@ public function __construct(\Context $context) /** * @param string $type * @param int $offset - * @param string $lastSyncDate + * @param string $date + * @param bool $fullSyncFinished * @param string $langIso * * @return bool - * - * @throws \PrestaShopDatabaseException */ - public function insertTypeSync($type, $offset, $lastSyncDate, $langIso = null) + public function upsertTypeSync($type, $offset, $date, $fullSyncFinished, $langIso = null) { - $result = $this->db->insert( + return $this->db->insert( self::TYPE_SYNC_TABLE_NAME, [ - 'id_shop' => $this->shopId, 'type' => pSQL((string) $type), 'offset' => (int) $offset, - 'last_sync_date' => pSQL((string) $lastSyncDate), + 'id_shop' => $this->shopId, 'lang_iso' => pSQL((string) $langIso), - ] + 'full_sync_finished' => (int) $fullSyncFinished, + 'last_sync_date' => pSQL($date), + ], + false, + true, + \Db::ON_DUPLICATE_KEY ); - - if (!$result) { - throw new \PrestaShopDatabaseException('Failed to insert type sync', Config::DATABASE_INSERT_ERROR_CODE); - } - - return $result; } /** @@ -117,30 +112,6 @@ public function findTypeSync($type, $langIso = null) return $this->db->getRow($query); } - /** - * @param string $type - * @param int $offset - * @param string $date - * @param bool $fullSyncFinished - * @param string $langIso - * - * @return bool - */ - public function updateTypeSync($type, $offset, $date, $fullSyncFinished, $langIso = null) - { - return $this->db->update( - self::TYPE_SYNC_TABLE_NAME, - [ - 'offset' => (int) $offset, - 'full_sync_finished' => (int) $fullSyncFinished, - 'last_sync_date' => pSQL($date), - ], - 'type = "' . pSQL($type) . '" - AND lang_iso = "' . pSQL((string) $langIso) . '" - AND id_shop = ' . $this->shopId - ); - } - /** * @param string $type * @param string $langIso diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index 41f30bc6..ffb0fd1b 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -26,22 +26,16 @@ public function generateMinimalQuery() public function generateFullQuery($langIso) { $langId = (int) \Language::getIdByIso($langIso); - $context = \Context::getContext(); - - if ($context == null) { - throw new \PrestaShopException('Context is null'); - } - - if ($context->shop === null) { - throw new \PrestaShopException('No shop context'); - } $this->generateMinimalQuery(); $this->query ->leftJoin('carrier_lang', 'cl', 'cl.id_carrier = c.id_carrier AND cl.id_lang = ' . $langId) ->leftJoin('carrier_shop', 'cs', 'cs.id_carrier = c.id_carrier') - ->where('cs.id_shop = ' . $context->shop->id) + ; + + $this->query + ->where('cs.id_shop = ' . (int) parent::getShopId()) ->where('deleted=0') ; diff --git a/src/Repository/NewRepository/CartProductRepository.php b/src/Repository/NewRepository/CartProductRepository.php new file mode 100644 index 00000000..aa428460 --- /dev/null +++ b/src/Repository/NewRepository/CartProductRepository.php @@ -0,0 +1,102 @@ +query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'cp'); + } + + /** + * @param string $langIso + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso) + { + $this->generateMinimalQuery(); + + $this->query->where('cp.id_shop = ' . (int) parent::getShopId()); + + $this->query + ->select('cp.id_cart') + ->select('cp.id_product') + ->select('cp.id_product_attribute') + ->select('cp.quantity') + ->select('cp.date_add as created_at') + ; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso); + + $this->query + ->where('cp.id_cart IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset) + { + $this->generateMinimalQuery(); + + $this->query->select('(COUNT(cp.id_cart) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 2ba0b259..aa25ce95 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -15,36 +15,25 @@ class FrontApiService { - /** - * Timestamp when script started - * - * @var int - */ + /** @var int */ public $startTime; - /** - * @var ApiAuthorizationService - */ + /** @var ApiAuthorizationService */ private $apiAuthorizationService; - /** - * @var EventbusSyncRepository - */ + + /** @var EventbusSyncRepository */ private $eventbusSyncRepository; - /** - * @var PsAccountsAdapterService - */ + + /** @var PsAccountsAdapterService */ private $psAccountsAdapterService; - /** - * @var SynchronizationService - */ + + /** @var SynchronizationService */ private $synchronizationService; - /** - * @var \Ps_eventbus - */ + + /** @var \Ps_eventbus */ private $module; - /** - * @var ErrorHandler - */ + + /** @var ErrorHandler */ private $errorHandler; public function __construct( @@ -85,7 +74,6 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $isHealthCheck = $shopContent == Config::COLLECTION_HEALTHCHECK; $isAuthentified = $this->authorize($jobId, $isHealthCheck); - $isIncrementalSync = false; if ($isHealthCheck) { /** @var HealthCheckService $healthCheckService */ @@ -109,38 +97,42 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); - $langIso = $langIso ? $langIso : $languageRepository->getDefaultLanguageIsoCode(); - $offset = 0; $response = []; $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); - if (is_array($typeSync)) { - $offset = (int) $typeSync['offset']; - - if ((int) $typeSync['full_sync_finished'] === 1 && !$fullSyncRequested) { - $isIncrementalSync = true; - } elseif ($fullSyncRequested) { - $offset = 0; - $this->eventbusSyncRepository->updateTypeSync( - $shopContent, - $offset, - $dateNow, - false, - $langIso - ); + // If no typesync exist, or if fullsync is requested by user + if (!is_array($typeSync) || $fullSyncRequested) { + $isFullSync = true; + $fullSyncIsFinished = false; + $offset = 0; + if ($typeSync) { $incrementalSyncRepository->removeIncrementaSyncObjectByType($shopContent); } - } else { - $this->eventbusSyncRepository->insertTypeSync($shopContent, $offset, $dateNow, $langIso); - $fullSyncRequested = true; + $this->eventbusSyncRepository->upsertTypeSync( + $shopContent, + $offset, + $dateNow, + $fullSyncIsFinished, + $langIso + ); + // Else if fullsync is not finished + } elseif (!boolval($typeSync['full_sync_finished'])) { + $isFullSync = true; + $fullSyncIsFinished = false; + $offset = (int) $typeSync['offset']; + // Else, we are in incremental sync + } else { + $isFullSync = false; + $fullSyncIsFinished = $typeSync['full_sync_finished']; + $offset = (int) $typeSync['offset']; } - if (!$isIncrementalSync) { + if ($isFullSync) { $response = $this->synchronizationService->sendFullSync( $shopContent, $jobId, @@ -167,7 +159,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync [ 'job_id' => $jobId, 'object_type' => $shopContent, - 'syncType' => $fullSyncRequested ? 'full' : 'incremental', + 'syncType' => $isFullSync ? 'full' : 'incremental', ], $response ) diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index 07cb1ade..513dcf9e 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -84,10 +84,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { return (int) $this->carrierRepository->countFullSyncContentLeft($offset); } diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index de1c4760..6ffc866d 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -84,12 +84,16 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - return $this->carrierRepository->countFullSyncContentLeft($offset); + $data = $this->getContentsForFull($offset, 50, $langIso, false); + + return count($data); } /** diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 52bf6944..d39f1aba 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -78,10 +78,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { return $this->carrierRepository->countFullSyncContentLeft($offset); } diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php new file mode 100644 index 00000000..b6dbb9ab --- /dev/null +++ b/src/Service/ShopContent/CartProductsService.php @@ -0,0 +1,99 @@ +cartProductRepository = $cartProductRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->cartProductRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCartProducts($result); + + return array_map(function ($item) { + return [ + 'id' => "{$item['id_cart']}-{$item['id_product']}-{$item['id_product_attribute']}", + 'collection' => Config::COLLECTION_CART_PRODUCTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->cartProductRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCartProducts($result); + + return array_map(function ($item) { + return [ + 'id' => "{$item['id_cart']}-{$item['id_product']}-{$item['id_product_attribute']}", + 'collection' => Config::COLLECTION_CART_PRODUCTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->cartProductRepository->countFullSyncContentLeft($offset); + } + + /** + * @param array $cartProducts + * + * @return void + */ + private function castCartProducts(&$cartProducts) + { + foreach ($cartProducts as &$cartProduct) { + $cartProduct['id_cart_product'] = (string) "{$cartProduct['id_cart']}-{$cartProduct['id_product']}-{$cartProduct['id_product_attribute']}"; + $cartProduct['id_cart'] = (string) $cartProduct['id_cart']; + $cartProduct['id_product'] = (string) $cartProduct['id_product']; + $cartProduct['id_product_attribute'] = (string) $cartProduct['id_product_attribute']; + $cartProduct['quantity'] = (int) $cartProduct['quantity']; + } + } +} diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index ff7cf82c..79655225 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -71,10 +71,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { return $this->cartRepository->countFullSyncContentLeft($offset); } diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index f52ac30b..b968ae24 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -71,10 +71,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { return $this->orderCartRuleRepository->countFullSyncContentLeft($offset); } diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index 123533a2..fde74fff 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -71,10 +71,12 @@ public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $de /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { return $this->orderDetailRepository->countFullSyncContentLeft($offset); } diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index dac67740..ce97ab51 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -71,10 +71,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { return $this->orderHistoryRepository->countFullSyncContentLeft($offset); } diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index d4fee405..025a20dc 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -84,10 +84,12 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { return $this->orderRepository->countFullSyncContentLeft($offset); } diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index 301ccd2f..f087807d 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -26,8 +26,10 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int */ - public function countFullSyncContentLeft($offset); + public function countFullSyncContentLeft($offset, $limit, $langIso); } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 38c7c0e8..a4300296 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -117,14 +117,14 @@ public function sendFullSync( } } - $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset); + $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $limit, $langIso); if ($remainingObjects <= 0) { $remainingObjects = 0; $offset = 0; } - $this->eventbusSyncRepository->updateTypeSync($shopContent, $offset, $dateNow, $remainingObjects === 0, $langIso); + $this->eventbusSyncRepository->upsertTypeSync($shopContent, $offset, $dateNow, $remainingObjects === 0, $langIso); return $this->returnSyncResponse($data, $response, $remainingObjects); } @@ -237,7 +237,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); if ($hasDeleted) { - $this->eventbusSyncRepository->updateTypeSync( + $this->eventbusSyncRepository->upsertTypeSync( $contentType, 0, $createdAt, diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index 8ee106b3..7785ff4c 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -7,6 +7,15 @@ function upgrade_module_4_0_0() { $db = Db::getInstance(); + // Add primary key to eventbus_type_sync + $editTypeSyncTable = 'ALTER TABLE `' . _DB_PREFIX_ . 'eventbus_type_sync` ADD PRIMARY KEY (type, id_shop, lang_iso);'; + $editTypeSyncTableResult = $db->query($editTypeSyncTable); + + // If ALTER is failed, stop update process + if (!$editTypeSyncTableResult) { + return false; + } + // Update eventbus_incremental_sync and add 'action' column $editIncrementalTable = 'ALTER TABLE `' . _DB_PREFIX_ . 'eventbus_incremental_sync` ADD action varchar(50) NOT NULL;'; $editIncrementalTableResult = $db->query($editIncrementalTable); From 51383dbfc1177ea8e97625ebe13365811c59b195 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 12 Sep 2024 17:31:23 +0200 Subject: [PATCH 069/162] fix: bug --- config/common/repository.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/config/common/repository.yml b/config/common/repository.yml index 14e6429a..f850c11d 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -74,18 +74,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CartRepository: - class: PrestaShop\Module\PsEventbus\Repository\CartRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Repository\CartProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\CartProductRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CartRuleRepository: class: PrestaShop\Module\PsEventbus\Repository\CartRuleRepository public: true From a11a6ee4f9bd44bc9fa2418ccee9cd85c4ba2df8 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:18:04 +0200 Subject: [PATCH 070/162] feat: pseventbus v4 cart rules (#358) --- config/common/new-repository.yml | 4 + config/common/repository.yml | 10 -- config/front/services.yml | 6 + e2e/src/helpers/shop-contents.ts | 1 + src/Repository/CartRuleRepository.php | 121 ---------------- .../NewRepository/CartRuleRepository.php | 131 ++++++++++++++++++ src/Service/ShopContent/CartRulesService.php | 121 ++++++++++++++++ 7 files changed, 263 insertions(+), 131 deletions(-) delete mode 100644 src/Repository/CartRuleRepository.php create mode 100644 src/Repository/NewRepository/CartRuleRepository.php create mode 100644 src/Service/ShopContent/CartRulesService.php diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 574aff63..58a8124e 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -26,3 +26,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index f850c11d..35eea5f8 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -68,16 +68,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Repository\CartRuleRepository: - class: PrestaShop\Module\PsEventbus\Repository\CartRuleRepository - public: true - PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository: class: PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 67f31ff2..bc81d958 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -108,3 +108,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CartRulesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartRulesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index a5ad147c..a548114c 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -39,6 +39,7 @@ export const shopContentMapping = { 'carrier_taxes': 'carrier-taxes', 'carts': 'carts', 'cart_products': 'cart-products', + 'cart_rules': 'cart-rules', 'orders': 'orders', 'order_cart_rules': 'order-cart-rules', 'order_details': 'order-details', diff --git a/src/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php deleted file mode 100644 index 6dab844d..00000000 --- a/src/Repository/CartRuleRepository.php +++ /dev/null @@ -1,121 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - $query = new \DbQuery(); - - $query->from('cart_rule', 'cr'); - - return $query; - } - - /** - * @param int $limit - * @param int $offset - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCartRules($limit, $offset) - { - $query = $this->getBaseQuery(); - - $query->select('cr.id_cart_rule,cr.id_customer, cr.code, cr.date_from AS "from",cr.date_to AS "to",cr.description,cr.quantity'); - $query->select('cr.quantity_per_user,cr.priority,cr.partial_use,cr.minimum_amount,cr.minimum_amount_tax,cr.minimum_amount_currency'); - $query->select('cr.minimum_amount_shipping,cr.country_restriction,cr.carrier_restriction,cr.group_restriction,cr.cart_rule_restriction'); - $query->select('cr.product_restriction,cr.shop_restriction,cr.free_shipping,cr.reduction_percent,cr.reduction_amount,cr.reduction_tax'); - $query->select('cr.reduction_currency,cr.reduction_product,cr.gift_product,cr.gift_product_attribute'); - $query->select('cr.highlight,cr.active,cr.date_add AS created_at,cr.date_upd AS updated_at'); - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $query->select('cr.reduction_exclude_special'); - } - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $limit - * @param array $cartRuleIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCartRulesIncremental($limit, $cartRuleIds) - { - $query = $this->getBaseQuery(); - - $query->where('cr.id_cart_rule IN(' . implode(',', array_map('intval', $cartRuleIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingCartRulesCount($offset) - { - $query = $this->getBaseQuery(); - - $query->select('(COUNT(cr.id_cart_rule) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param int $offset - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($limit, $offset) - { - $query = $this->getBaseQuery(); - - $query->select('cr.id_cart_rule,cr.id_customer, cr.code, cr.date_from AS "from",cr.date_to AS "to",cr.description,cr.quantity'); - $query->select('cr.quantity_per_user,cr.priority,cr.partial_use,cr.minimum_amount,cr.minimum_amount_tax,cr.minimum_amount_currency'); - $query->select('cr.minimum_amount_shipping,cr.country_restriction,cr.carrier_restriction,cr.group_restriction,cr.cart_rule_restriction'); - $query->select('cr.product_restriction,cr.shop_restriction,cr.free_shipping,cr.reduction_percent,cr.reduction_amount,cr.reduction_tax'); - $query->select('cr.reduction_currency,cr.reduction_product,cr.gift_product,cr.gift_product_attribute'); - $query->select('cr.highlight,cr.active,cr.date_add AS created_at,cr.date_upd AS updated_at'); - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $query->select('cr.reduction_exclude_special'); - } - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } -} diff --git a/src/Repository/NewRepository/CartRuleRepository.php b/src/Repository/NewRepository/CartRuleRepository.php new file mode 100644 index 00000000..48d63d7b --- /dev/null +++ b/src/Repository/NewRepository/CartRuleRepository.php @@ -0,0 +1,131 @@ +query = new \DbQuery(); + + $this->query->from(self::TABLE_NAME, 'cr'); + } + + /** + * @param string $langIso + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso) + { + $this->generateMinimalQuery(); + + $this->query + ->select('cr.id_cart_rule') + ->select('cr.id_customer') + ->select('cr.code') + ->select('cr.date_from AS "from"') + ->select('cr.date_to AS "to"') + ->select('cr.description') + ->select('cr.quantity') + ->select('cr.quantity_per_user') + ->select('cr.priority') + ->select('cr.partial_use') + ->select('cr.minimum_amount') + ->select('cr.minimum_amount_tax') + ->select('cr.minimum_amount_currency') + ->select('cr.minimum_amount_shipping') + ->select('cr.country_restriction') + ->select('cr.carrier_restriction') + ->select('cr.group_restriction') + ->select('cr.cart_rule_restriction') + ->select('cr.product_restriction') + ->select('cr.shop_restriction') + ->select('cr.free_shipping') + ->select('cr.reduction_percent') + ->select('cr.reduction_amount') + ->select('cr.reduction_tax') + ->select('cr.reduction_currency') + ->select('cr.reduction_product') + ->select('cr.gift_product') + ->select('cr.gift_product_attribute') + ->select('cr.highlight') + ->select('cr.active') + ->select('cr.date_add AS created_at') + ->select('cr.date_upd AS updated_at') + ; + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { + $this->query->select('cr.reduction_exclude_special'); + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso); + + $this->query + ->where('cr.id_cart_rule IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset) + { + $this->generateMinimalQuery(); + + $this->query->select('(COUNT(cr.id_cart_rule) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php new file mode 100644 index 00000000..2806bdab --- /dev/null +++ b/src/Service/ShopContent/CartRulesService.php @@ -0,0 +1,121 @@ +cartRuleRepository = $cartRuleRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->cartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCartRules($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_cart_rule'], + 'collection' => Config::COLLECTION_CART_RULES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->cartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCartRules($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_cart_rule'], + 'collection' => Config::COLLECTION_CART_RULES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->cartRuleRepository->countFullSyncContentLeft($offset); + } + + /** + * @param array $cartRules + * + * @return void + */ + private function castCartRules(&$cartRules) + { + foreach ($cartRules as &$cartRule) { + $cartRule['id_cart_rule'] = (int) $cartRule['id_cart_rule']; + $cartRule['id_customer'] = (int) $cartRule['id_customer']; + $cartRule['quantity'] = (int) $cartRule['quantity']; + $cartRule['quantity_per_user'] = (int) $cartRule['quantity_per_user']; + $cartRule['priority'] = (int) $cartRule['priority']; + $cartRule['partial_use'] = (bool) $cartRule['partial_use']; + $cartRule['minimum_amount'] = (float) $cartRule['minimum_amount']; + $cartRule['minimum_amount_tax'] = (bool) $cartRule['minimum_amount_tax']; + $cartRule['minimum_amount_currency'] = (int) $cartRule['minimum_amount_currency']; + $cartRule['minimum_amount_shipping'] = (bool) $cartRule['minimum_amount_shipping']; + $cartRule['country_restriction'] = (bool) $cartRule['country_restriction']; + $cartRule['carrier_restriction'] = (bool) $cartRule['carrier_restriction']; + $cartRule['group_restriction'] = (bool) $cartRule['group_restriction']; + $cartRule['cart_rule_restriction'] = (bool) $cartRule['cart_rule_restriction']; + $cartRule['product_restriction'] = (bool) $cartRule['product_restriction']; + $cartRule['shop_restriction'] = (bool) $cartRule['shop_restriction']; + $cartRule['free_shipping'] = (bool) $cartRule['free_shipping']; + $cartRule['reduction_percent'] = (float) $cartRule['reduction_percent']; + $cartRule['reduction_amount'] = (float) $cartRule['reduction_amount']; + $cartRule['reduction_tax'] = (bool) $cartRule['reduction_tax']; + $cartRule['reduction_currency'] = (int) $cartRule['reduction_currency']; + $cartRule['reduction_product'] = (int) $cartRule['reduction_product']; + $cartRule['reduction_exclude_special'] = (bool) $cartRule['reduction_exclude_special']; + $cartRule['gift_product'] = (int) $cartRule['gift_product']; + $cartRule['gift_product_attribute'] = (int) $cartRule['gift_product_attribute']; + $cartRule['highlight'] = (bool) $cartRule['highlight']; + $cartRule['active'] = (bool) $cartRule['active']; + } + } +} From 6d4ee3bf4f3fa4dc4b91c1f6533ef9ba8a2ad531 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:59:51 +0200 Subject: [PATCH 071/162] feat: pseventbus v4 products (#361) Co-authored-by: Benoit Houdayer --- OLD/Provider/ProductDataProvider.php | 35 +- OLD/decorator/ProductDecorator.php | 107 + README.md | 7 +- config/common/decorator.yml | 11 - config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 9 + e2e/pnpm-lock.yaml | 2935 +++++++++-------- e2e/src/full-sync.spec.ts | 130 +- e2e/src/helpers/mock-probe.ts | 131 +- e2e/src/helpers/shop-contents.ts | 29 +- .../NewRepository/AbstractRepository.php | 14 +- .../NewRepository/CarrierRepository.php | 36 +- .../NewRepository/CartProductRepository.php | 50 +- .../NewRepository/CartRepository.php | 42 +- .../NewRepository/CartRuleRepository.php | 106 +- .../NewRepository/OrderCartRuleRepository.php | 56 +- .../NewRepository/OrderDetailRepository.php | 63 +- .../NewRepository/OrderHistoryRepository.php | 58 +- .../NewRepository/OrderRepository.php | 139 +- .../NewRepository/ProductRepository.php | 299 ++ .../NewRepository/RepositoryInterface.php | 19 +- src/Repository/ProductRepository.php | 360 -- .../ShopContent/CarrierDetailsService.php | 8 +- .../ShopContent/CarrierTaxesService.php | 6 +- src/Service/ShopContent/CarriersService.php | 8 +- .../ShopContent/CartProductsService.php | 8 +- src/Service/ShopContent/CartRulesService.php | 8 +- src/Service/ShopContent/CartsService.php | 8 +- .../ShopContent/OrderCartRulesService.php | 8 +- .../ShopContent/OrderDetailsService.php | 8 +- .../ShopContent/OrderHistoriesService.php | 8 +- src/Service/ShopContent/OrdersService.php | 8 +- .../ShopContent/ProductsService.php} | 273 +- .../ShopContentServiceInterface.php | 2 +- src/Service/SynchronizationService.php | 2 +- 36 files changed, 2717 insertions(+), 2284 deletions(-) create mode 100644 OLD/decorator/ProductDecorator.php create mode 100644 src/Repository/NewRepository/ProductRepository.php delete mode 100644 src/Repository/ProductRepository.php rename src/{Decorator/ProductDecorator.php => Service/ShopContent/ProductsService.php} (60%) diff --git a/OLD/Provider/ProductDataProvider.php b/OLD/Provider/ProductDataProvider.php index 8480bd81..2a836675 100644 --- a/OLD/Provider/ProductDataProvider.php +++ b/OLD/Provider/ProductDataProvider.php @@ -57,7 +57,7 @@ public function getFormattedData($offset, $limit, $langIso) return []; } - $this->productDecorator->decorateProducts($products, $langIso, $langId); + $this->productDecorator->decorateProducts($products, $langIso); $bundles = $this->productDecorator->getBundles($products); @@ -74,21 +74,6 @@ public function getFormattedData($offset, $limit, $langIso) return array_merge($products, $bundles, $productSuppliers); } - /** - * @param int $offset - * @param string $langIso - * - * @return int - * - * @@throws \PrestaShopDatabaseException - */ - public function getRemainingObjectsCount($offset, $langIso) - { - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - return (int) $this->productRepository->getRemainingProductsCount($offset, $langId); - } - /** * @param int $limit * @param string $langIso @@ -105,7 +90,7 @@ public function getFormattedDataIncremental($limit, $langIso, $objectIds) $products = $this->productRepository->getProductsIncremental($limit, $langId, $objectIds); if (!empty($products)) { - $this->productDecorator->decorateProducts($products, $langIso, $langId); + $this->productDecorator->decorateProducts($products, $langIso); } else { return []; } @@ -124,20 +109,4 @@ public function getFormattedDataIncremental($limit, $langIso, $objectIds) return array_merge($products, $bundles, $productSuppliers); } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - return $this->productRepository->getQueryForDebug($offset, $limit, $langId); - } } diff --git a/OLD/decorator/ProductDecorator.php b/OLD/decorator/ProductDecorator.php new file mode 100644 index 00000000..95433bf0 --- /dev/null +++ b/OLD/decorator/ProductDecorator.php @@ -0,0 +1,107 @@ +context = $context; + $this->languageRepository = $languageRepository; + $this->productRepository = $productRepository; + $this->categoryRepository = $categoryRepository; + $this->arrayFormatter = $arrayFormatter; + $this->bundleRepository = $bundleRepository; + + if ($this->context->shop === null) { + throw new \PrestaShopException('No shop context'); + } + + $this->shopId = (int) $this->context->shop->id; + } + + /** + * @param array $products + * + * @return array + */ + public function getBundles($products) + { + $bundles = []; + foreach ($products as $product) { + if ($product['is_bundle']) { + $bundles = array_merge($bundles, $this->getBundleCollection($product)); + } + } + + return $bundles; + } + + /** + * @param array $product + * + * @return array + */ + private function getBundleCollection($product) + { + $bundleProducts = $this->bundleRepository->getBundleProducts($product['id_product']); + $uniqueProductId = $product['unique_product_id']; + + return array_map(function ($bundleProduct) use ($uniqueProductId) { + return [ + 'id' => $bundleProduct['id_bundle'], + 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, + 'properties' => [ + 'id_bundle' => $bundleProduct['id_bundle'], + 'id_product' => $bundleProduct['id_product'], + 'id_product_attribute' => $bundleProduct['id_product_attribute'], + 'unique_product_id' => $uniqueProductId, + 'quantity' => $bundleProduct['quantity'], + ], + ]; + }, $bundleProducts); + } +} diff --git a/README.md b/README.md index 66b7c371..9592fb2c 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,10 @@ Or an up to date [Docker engine](https://docs.docker.com/engine/install). | store_lang | table missing | 1.7.3.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004) | | wishlist¹ | table missing | n/a | [Prestashop Addons](https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html) | | taxonomy² | table missing | n/a | [Prestashop Addons](https://addons.prestashop.com/fr/produits-sur-facebook-reseaux-sociaux/50291-prestashop-social-with-facebook-instagram.htmll) | -| stock_available. physical_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) | -| stock_available. reserved_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) | -| languages.locale | row missing in table | 1.7.0.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/481111b8274ed005e1c4a8ce2cf2b3ebbeb9a270#diff-c123d3d30d9c9e012a826a21887fccce6600a2f2a848a58d5910e55f0f8f5093R41) | +| stock_available. physical_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) | +| stock_available. reserved_quantity | row missing in table | 1.7.2.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186) | +| languages.locale | row missing in table | 1.7.0.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/481111b8274ed005e1c4a8ce2cf2b3ebbeb9a270#diff-c123d3d30d9c9e012a826a21887fccce6600a2f2a848a58d5910e55f0f8f5093R41) | +| products.mpn | row missing in table | 1.7.7.0 | [github](https://github.com/PrestaShop/PrestaShop/commit/75fcc335a85c4e3acb2444ef9584590a59fc2d62#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R1615) | ¹ Feature enabled only with PsWishlist module
² Feature enabled only with PsFacebook module diff --git a/config/common/decorator.yml b/config/common/decorator.yml index 690012ea..68ae3d0d 100644 --- a/config/common/decorator.yml +++ b/config/common/decorator.yml @@ -1,15 +1,4 @@ services: - PrestaShop\Module\PsEventbus\Decorator\ProductDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\ProductDecorator - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' - - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' - - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - - '@PrestaShop\Module\PsEventbus\Repository\BundleRepository' - PrestaShop\Module\PsEventbus\Decorator\CategoryDecorator: class: PrestaShop\Module\PsEventbus\Decorator\CategoryDecorator public: true diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 58a8124e..613ad1c4 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -30,3 +30,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 35eea5f8..75638643 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -35,12 +35,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ModuleRepository public: true - PrestaShop\Module\PsEventbus\Repository\ProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index bc81d958..d4e92702 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -114,3 +114,12 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index f6e33a9b..0fbefb91 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -1,90 +1,1340 @@ -lockfileVersion: '6.0' +lockfileVersion: '9.0' settings: autoInstallPeers: true excludeLinksFromLockfile: false -dependencies: - semver: - specifier: ^7.6.2 - version: 7.6.2 - -devDependencies: - '@jest/globals': - specifier: ^29.7.0 - version: 29.7.0 - '@types/jest': - specifier: ^29.5.12 - version: 29.5.12 - '@types/node': - specifier: ^20.12.12 - version: 20.12.12 - '@types/ramda': - specifier: ^0.30.0 - version: 0.30.0 - '@types/semver': - specifier: ^7.5.8 - version: 7.5.8 - '@types/ws': - specifier: ^8.5.10 - version: 8.5.10 - axios: - specifier: ^1.6.8 - version: 1.6.8 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.12.12) - jest-expect-message: - specifier: ^1.1.3 - version: 1.1.3 - jest-extended: - specifier: ^4.0.2 - version: 4.0.2(jest@29.7.0) - jest-mock-extended: - specifier: ^3.0.7 - version: 3.0.7(jest@29.7.0)(typescript@5.4.5) - ramda: - specifier: ^0.30.0 - version: 0.30.0 - rxjs: - specifier: ^7.8.1 - version: 7.8.1 - ts-jest: - specifier: ^29.1.2 - version: 29.1.2(@babel/core@7.25.2)(jest@29.7.0)(typescript@5.4.5) - typescript: - specifier: ^5.4.5 - version: 5.4.5 - ws: - specifier: ^8.17.1 - version: 8.17.1 +importers: + + .: + dependencies: + semver: + specifier: ^7.6.2 + version: 7.6.2 + devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 + '@types/jest': + specifier: ^29.5.12 + version: 29.5.12 + '@types/node': + specifier: ^20.12.12 + version: 20.12.12 + '@types/ramda': + specifier: ^0.30.0 + version: 0.30.0 + '@types/semver': + specifier: ^7.5.8 + version: 7.5.8 + '@types/ws': + specifier: ^8.5.10 + version: 8.5.10 + axios: + specifier: ^1.6.8 + version: 1.6.8 + jest: + specifier: ^29.7.0 + version: 29.7.0(@types/node@20.12.12) + jest-expect-message: + specifier: ^1.1.3 + version: 1.1.3 + jest-extended: + specifier: ^4.0.2 + version: 4.0.2(jest@29.7.0) + jest-mock-extended: + specifier: ^3.0.7 + version: 3.0.7(jest@29.7.0)(typescript@5.4.5) + ramda: + specifier: ^0.30.0 + version: 0.30.0 + rxjs: + specifier: ^7.8.1 + version: 7.8.1 + ts-jest: + specifier: ^29.1.2 + version: 29.1.2(@babel/core@7.25.2)(jest@29.7.0)(typescript@5.4.5) + typescript: + specifier: ^5.4.5 + version: 5.4.5 + ws: + specifier: ^8.17.1 + version: 8.17.1 packages: - /@ampproject/remapping@2.3.0: - resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} - engines: {node: '>=6.0.0'} + '@ampproject/remapping@2.3.0': + resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} + engines: {node: '>=6.0.0'} + + '@babel/code-frame@7.24.7': + resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==} + engines: {node: '>=6.9.0'} + + '@babel/compat-data@7.25.4': + resolution: {integrity: sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==} + engines: {node: '>=6.9.0'} + + '@babel/core@7.25.2': + resolution: {integrity: sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==} + engines: {node: '>=6.9.0'} + + '@babel/generator@7.25.5': + resolution: {integrity: sha512-abd43wyLfbWoxC6ahM8xTkqLpGB2iWBVyuKC9/srhFunCd1SDNrV1s72bBpK4hLj8KLzHBBcOblvLQZBNw9r3w==} + engines: {node: '>=6.9.0'} + + '@babel/helper-compilation-targets@7.25.2': + resolution: {integrity: sha512-U2U5LsSaZ7TAt3cfaymQ8WHh0pxvdHoEk6HVpaexxixjyEquMh0L0YNJNM6CTGKMXV1iksi0iZkGw4AcFkPaaw==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-imports@7.24.7': + resolution: {integrity: sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-transforms@7.25.2': + resolution: {integrity: sha512-BjyRAbix6j/wv83ftcVJmBt72QtHI56C7JXZoG2xATiLpmoC7dpd8WnkikExHDVPpi/3qCmO6WY1EaXOluiecQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + + '@babel/helper-plugin-utils@7.24.8': + resolution: {integrity: sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==} + engines: {node: '>=6.9.0'} + + '@babel/helper-simple-access@7.24.7': + resolution: {integrity: sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==} + engines: {node: '>=6.9.0'} + + '@babel/helper-string-parser@7.24.8': + resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-identifier@7.24.7': + resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-option@7.24.8': + resolution: {integrity: sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==} + engines: {node: '>=6.9.0'} + + '@babel/helpers@7.25.0': + resolution: {integrity: sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==} + engines: {node: '>=6.9.0'} + + '@babel/highlight@7.24.7': + resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} + engines: {node: '>=6.9.0'} + + '@babel/parser@7.25.4': + resolution: {integrity: sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==} + engines: {node: '>=6.0.0'} + hasBin: true + + '@babel/plugin-syntax-async-generators@7.8.4': + resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-bigint@7.8.3': + resolution: {integrity: sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-class-properties@7.12.13': + resolution: {integrity: sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-class-static-block@7.14.5': + resolution: {integrity: sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-import-attributes@7.24.7': + resolution: {integrity: sha512-hbX+lKKeUMGihnK8nvKqmXBInriT3GVjzXKFriV3YC6APGxMbP8RZNFwy91+hocLXq90Mta+HshoB31802bb8A==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-import-meta@7.10.4': + resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-json-strings@7.8.3': + resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-jsx@7.24.7': + resolution: {integrity: sha512-6ddciUPe/mpMnOKv/U+RSd2vvVy+Yw/JfBB0ZHYjEZt9NLHmCUylNYlsbqCCS1Bffjlb0fCwC9Vqz+sBz6PsiQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-logical-assignment-operators@7.10.4': + resolution: {integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-nullish-coalescing-operator@7.8.3': + resolution: {integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-numeric-separator@7.10.4': + resolution: {integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-object-rest-spread@7.8.3': + resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-optional-catch-binding@7.8.3': + resolution: {integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-optional-chaining@7.8.3': + resolution: {integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-private-property-in-object@7.14.5': + resolution: {integrity: sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-top-level-await@7.14.5': + resolution: {integrity: sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-typescript@7.25.4': + resolution: {integrity: sha512-uMOCoHVU52BsSWxPOMVv5qKRdeSlPuImUCB2dlPuBSU+W2/ROE7/Zg8F2Kepbk+8yBa68LlRKxO+xgEVWorsDg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/template@7.25.0': + resolution: {integrity: sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==} + engines: {node: '>=6.9.0'} + + '@babel/traverse@7.25.4': + resolution: {integrity: sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==} + engines: {node: '>=6.9.0'} + + '@babel/types@7.25.4': + resolution: {integrity: sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==} + engines: {node: '>=6.9.0'} + + '@bcoe/v8-coverage@0.2.3': + resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + + '@istanbuljs/load-nyc-config@1.1.0': + resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} + engines: {node: '>=8'} + + '@istanbuljs/schema@0.1.3': + resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} + engines: {node: '>=8'} + + '@jest/console@29.7.0': + resolution: {integrity: sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/core@29.7.0': + resolution: {integrity: sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + + '@jest/environment@29.7.0': + resolution: {integrity: sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/expect-utils@29.7.0': + resolution: {integrity: sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/expect@29.7.0': + resolution: {integrity: sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/fake-timers@29.7.0': + resolution: {integrity: sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/globals@29.7.0': + resolution: {integrity: sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/reporters@29.7.0': + resolution: {integrity: sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + + '@jest/schemas@29.6.3': + resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/source-map@29.6.3': + resolution: {integrity: sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/test-result@29.7.0': + resolution: {integrity: sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/test-sequencer@29.7.0': + resolution: {integrity: sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/transform@29.7.0': + resolution: {integrity: sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/types@29.6.3': + resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jridgewell/gen-mapping@0.3.5': + resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} + engines: {node: '>=6.0.0'} + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/set-array@1.2.1': + resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.5.0': + resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} + + '@jridgewell/trace-mapping@0.3.25': + resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + + '@sinclair/typebox@0.27.8': + resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + + '@sinonjs/commons@3.0.1': + resolution: {integrity: sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==} + + '@sinonjs/fake-timers@10.3.0': + resolution: {integrity: sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==} + + '@types/babel__core@7.20.5': + resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} + + '@types/babel__generator@7.6.8': + resolution: {integrity: sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==} + + '@types/babel__template@7.4.4': + resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} + + '@types/babel__traverse@7.20.6': + resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} + + '@types/graceful-fs@4.1.9': + resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} + + '@types/istanbul-lib-coverage@2.0.6': + resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} + + '@types/istanbul-lib-report@3.0.3': + resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} + + '@types/istanbul-reports@3.0.4': + resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} + + '@types/jest@29.5.12': + resolution: {integrity: sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==} + + '@types/node@20.12.12': + resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + + '@types/ramda@0.30.0': + resolution: {integrity: sha512-DQtfqUbSB18iM9NHbQ++kVUDuBWHMr6T2FpW1XTiksYRGjq4WnNPZLt712OEHEBJs7aMyJ68Mf2kGMOP1srVVw==} + + '@types/semver@7.5.8': + resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} + + '@types/stack-utils@2.0.3': + resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} + + '@types/ws@8.5.10': + resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} + + '@types/yargs-parser@21.0.3': + resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} + + '@types/yargs@17.0.33': + resolution: {integrity: sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==} + + ansi-escapes@4.3.2: + resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} + engines: {node: '>=8'} + + ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + + ansi-styles@3.2.1: + resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} + engines: {node: '>=4'} + + ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + + ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + + anymatch@3.1.3: + resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} + engines: {node: '>= 8'} + + argparse@1.0.10: + resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + + asynckit@0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + + axios@1.6.8: + resolution: {integrity: sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==} + + babel-jest@29.7.0: + resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + '@babel/core': ^7.8.0 + + babel-plugin-istanbul@6.1.1: + resolution: {integrity: sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==} + engines: {node: '>=8'} + + babel-plugin-jest-hoist@29.6.3: + resolution: {integrity: sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + babel-preset-current-node-syntax@1.1.0: + resolution: {integrity: sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==} + peerDependencies: + '@babel/core': ^7.0.0 + + babel-preset-jest@29.6.3: + resolution: {integrity: sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + '@babel/core': ^7.0.0 + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + brace-expansion@1.1.11: + resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} + + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + + browserslist@4.23.3: + resolution: {integrity: sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + + bs-logger@0.2.6: + resolution: {integrity: sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==} + engines: {node: '>= 6'} + + bser@2.1.1: + resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} + + buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + + callsites@3.1.0: + resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} + engines: {node: '>=6'} + + camelcase@5.3.1: + resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} + engines: {node: '>=6'} + + camelcase@6.3.0: + resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} + engines: {node: '>=10'} + + caniuse-lite@1.0.30001653: + resolution: {integrity: sha512-XGWQVB8wFQ2+9NZwZ10GxTYC5hk0Fa+q8cSkr0tgvMhYhMHP/QC+WTgrePMDBWiWc/pV+1ik82Al20XOK25Gcw==} + + chalk@2.4.2: + resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} + engines: {node: '>=4'} + + chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + + char-regex@1.0.2: + resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} + engines: {node: '>=10'} + + ci-info@3.9.0: + resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} + engines: {node: '>=8'} + + cjs-module-lexer@1.4.0: + resolution: {integrity: sha512-N1NGmowPlGBLsOZLPvm48StN04V4YvQRL0i6b7ctrVY3epjP/ct7hFLOItz6pDIvRjwpfPxi52a2UWV2ziir8g==} + + cliui@8.0.1: + resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} + engines: {node: '>=12'} + + co@4.6.0: + resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} + engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} + + collect-v8-coverage@1.0.2: + resolution: {integrity: sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==} + + color-convert@1.9.3: + resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} + + color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + + color-name@1.1.3: + resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} + + color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + + combined-stream@1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + + concat-map@0.0.1: + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + + convert-source-map@2.0.0: + resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + + create-jest@29.7.0: + resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + hasBin: true + + cross-spawn@7.0.3: + resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + engines: {node: '>= 8'} + + debug@4.3.6: + resolution: {integrity: sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + dedent@1.5.3: + resolution: {integrity: sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==} + peerDependencies: + babel-plugin-macros: ^3.1.0 + peerDependenciesMeta: + babel-plugin-macros: + optional: true + + deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} + engines: {node: '>=0.10.0'} + + delayed-stream@1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + + detect-newline@3.1.0: + resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} + engines: {node: '>=8'} + + diff-sequences@29.6.3: + resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + electron-to-chromium@1.5.13: + resolution: {integrity: sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q==} + + emittery@0.13.1: + resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==} + engines: {node: '>=12'} + + emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + + error-ex@1.3.2: + resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} + + escalade@3.1.2: + resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} + engines: {node: '>=6'} + + escape-string-regexp@1.0.5: + resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} + engines: {node: '>=0.8.0'} + + escape-string-regexp@2.0.0: + resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} + engines: {node: '>=8'} + + esprima@4.0.1: + resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} + engines: {node: '>=4'} + hasBin: true + + execa@5.1.1: + resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} + engines: {node: '>=10'} + + exit@0.1.2: + resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} + engines: {node: '>= 0.8.0'} + + expect@29.7.0: + resolution: {integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + fast-json-stable-stringify@2.1.0: + resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} + + fb-watchman@2.0.2: + resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==} + + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + + find-up@4.1.0: + resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} + engines: {node: '>=8'} + + follow-redirects@1.15.6: + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + + form-data@4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + + fs.realpath@1.0.0: + resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + + gensync@1.0.0-beta.2: + resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} + engines: {node: '>=6.9.0'} + + get-caller-file@2.0.5: + resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} + engines: {node: 6.* || 8.* || >= 10.*} + + get-package-type@0.1.0: + resolution: {integrity: sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==} + engines: {node: '>=8.0.0'} + + get-stream@6.0.1: + resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} + engines: {node: '>=10'} + + glob@7.2.3: + resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported + + globals@11.12.0: + resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} + engines: {node: '>=4'} + + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + has-flag@3.0.0: + resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} + engines: {node: '>=4'} + + has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + + hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} + engines: {node: '>= 0.4'} + + html-escaper@2.0.2: + resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} + + human-signals@2.1.0: + resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} + engines: {node: '>=10.17.0'} + + import-local@3.2.0: + resolution: {integrity: sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==} + engines: {node: '>=8'} + hasBin: true + + imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + + inflight@1.0.6: + resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. + + inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + + is-arrayish@0.2.1: + resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} + + is-core-module@2.15.1: + resolution: {integrity: sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==} + engines: {node: '>= 0.4'} + + is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + + is-generator-fn@2.1.0: + resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==} + engines: {node: '>=6'} + + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + + is-stream@2.0.1: + resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} + engines: {node: '>=8'} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + istanbul-lib-coverage@3.2.2: + resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} + engines: {node: '>=8'} + + istanbul-lib-instrument@5.2.1: + resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} + engines: {node: '>=8'} + + istanbul-lib-instrument@6.0.3: + resolution: {integrity: sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==} + engines: {node: '>=10'} + + istanbul-lib-report@3.0.1: + resolution: {integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==} + engines: {node: '>=10'} + + istanbul-lib-source-maps@4.0.1: + resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} + engines: {node: '>=10'} + + istanbul-reports@3.1.7: + resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==} + engines: {node: '>=8'} + + jest-changed-files@29.7.0: + resolution: {integrity: sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-circus@29.7.0: + resolution: {integrity: sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-cli@29.7.0: + resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + hasBin: true + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + + jest-config@29.7.0: + resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + '@types/node': '*' + ts-node: '>=9.0.0' + peerDependenciesMeta: + '@types/node': + optional: true + ts-node: + optional: true + + jest-diff@29.7.0: + resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-docblock@29.7.0: + resolution: {integrity: sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-each@29.7.0: + resolution: {integrity: sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-environment-node@29.7.0: + resolution: {integrity: sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-expect-message@1.1.3: + resolution: {integrity: sha512-bTK77T4P+zto+XepAX3low8XVQxDgaEqh3jSTQOG8qvPpD69LsIdyJTa+RmnJh3HNSzJng62/44RPPc7OIlFxg==} + + jest-extended@4.0.2: + resolution: {integrity: sha512-FH7aaPgtGYHc9mRjriS0ZEHYM5/W69tLrFTIdzm+yJgeoCmmrSB/luSfMSqWP9O29QWHPEmJ4qmU6EwsZideog==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + jest: '>=27.2.5' + peerDependenciesMeta: + jest: + optional: true + + jest-get-type@29.6.3: + resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-haste-map@29.7.0: + resolution: {integrity: sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-leak-detector@29.7.0: + resolution: {integrity: sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-matcher-utils@29.7.0: + resolution: {integrity: sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-message-util@29.7.0: + resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-mock-extended@3.0.7: + resolution: {integrity: sha512-7lsKdLFcW9B9l5NzZ66S/yTQ9k8rFtnwYdCNuRU/81fqDWicNDVhitTSPnrGmNeNm0xyw0JHexEOShrIKRCIRQ==} + peerDependencies: + jest: ^24.0.0 || ^25.0.0 || ^26.0.0 || ^27.0.0 || ^28.0.0 || ^29.0.0 + typescript: ^3.0.0 || ^4.0.0 || ^5.0.0 + + jest-mock@29.7.0: + resolution: {integrity: sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-pnp-resolver@1.2.3: + resolution: {integrity: sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==} + engines: {node: '>=6'} + peerDependencies: + jest-resolve: '*' + peerDependenciesMeta: + jest-resolve: + optional: true + + jest-regex-util@29.6.3: + resolution: {integrity: sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-resolve-dependencies@29.7.0: + resolution: {integrity: sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-resolve@29.7.0: + resolution: {integrity: sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-runner@29.7.0: + resolution: {integrity: sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-runtime@29.7.0: + resolution: {integrity: sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-snapshot@29.7.0: + resolution: {integrity: sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-util@29.7.0: + resolution: {integrity: sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-validate@29.7.0: + resolution: {integrity: sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-watcher@29.7.0: + resolution: {integrity: sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-worker@29.7.0: + resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest@29.7.0: + resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + hasBin: true + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + js-yaml@3.14.1: + resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} + hasBin: true + + jsesc@2.5.2: + resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} + engines: {node: '>=4'} + hasBin: true + + json-parse-even-better-errors@2.3.1: + resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} + + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + + kleur@3.0.3: + resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} + engines: {node: '>=6'} + + leven@3.1.0: + resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} + engines: {node: '>=6'} + + lines-and-columns@1.2.4: + resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + + locate-path@5.0.0: + resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} + engines: {node: '>=8'} + + lodash.memoize@4.1.2: + resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} + + lru-cache@5.1.1: + resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + + make-dir@4.0.0: + resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} + engines: {node: '>=10'} + + make-error@1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + + makeerror@1.0.12: + resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} + + merge-stream@2.0.0: + resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + + mime-db@1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + + mime-types@2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + + mimic-fn@2.1.0: + resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} + engines: {node: '>=6'} + + minimatch@3.1.2: + resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + + ms@2.1.2: + resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + + natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + + node-int64@0.4.0: + resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} + + node-releases@2.0.18: + resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==} + + normalize-path@3.0.0: + resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} + engines: {node: '>=0.10.0'} + + npm-run-path@4.0.1: + resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} + engines: {node: '>=8'} + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + + onetime@5.1.2: + resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} + engines: {node: '>=6'} + + p-limit@2.3.0: + resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} + engines: {node: '>=6'} + + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + + p-locate@4.1.0: + resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} + engines: {node: '>=8'} + + p-try@2.2.0: + resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} + engines: {node: '>=6'} + + parse-json@5.2.0: + resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} + engines: {node: '>=8'} + + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + + path-is-absolute@1.0.1: + resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} + engines: {node: '>=0.10.0'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + + picocolors@1.0.1: + resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} + + picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + + pirates@4.0.6: + resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} + engines: {node: '>= 6'} + + pkg-dir@4.2.0: + resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} + engines: {node: '>=8'} + + pretty-format@29.7.0: + resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + prompts@2.4.2: + resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} + engines: {node: '>= 6'} + + proxy-from-env@1.1.0: + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + + pure-rand@6.1.0: + resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==} + + ramda@0.30.0: + resolution: {integrity: sha512-13Y0iMhIQuAm/wNGBL/9HEqIfRGmNmjKnTPlKWfA9f7dnDkr8d45wQ+S7+ZLh/Pq9PdcGxkqKUEA7ySu1QSd9Q==} + + react-is@18.3.1: + resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} + + require-directory@2.1.1: + resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} + engines: {node: '>=0.10.0'} + + resolve-cwd@3.0.0: + resolution: {integrity: sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==} + engines: {node: '>=8'} + + resolve-from@5.0.0: + resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} + engines: {node: '>=8'} + + resolve.exports@2.0.2: + resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==} + engines: {node: '>=10'} + + resolve@1.22.8: + resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} + hasBin: true + + rxjs@7.8.1: + resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + + semver@6.3.1: + resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} + hasBin: true + + semver@7.6.2: + resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==} + engines: {node: '>=10'} + hasBin: true + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + signal-exit@3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + + sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + + slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + + source-map-support@0.5.13: + resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + sprintf-js@1.0.3: + resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + + stack-utils@2.0.6: + resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} + engines: {node: '>=10'} + + string-length@4.0.2: + resolution: {integrity: sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==} + engines: {node: '>=10'} + + string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + + strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + + strip-bom@4.0.0: + resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} + engines: {node: '>=8'} + + strip-final-newline@2.0.0: + resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} + engines: {node: '>=6'} + + strip-json-comments@3.1.1: + resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} + engines: {node: '>=8'} + + supports-color@5.5.0: + resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} + engines: {node: '>=4'} + + supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + + supports-color@8.1.1: + resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} + engines: {node: '>=10'} + + supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + + test-exclude@6.0.0: + resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} + engines: {node: '>=8'} + + tmpl@1.0.5: + resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} + + to-fast-properties@2.0.0: + resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} + engines: {node: '>=4'} + + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + + ts-essentials@10.0.2: + resolution: {integrity: sha512-Xwag0TULqriaugXqVdDiGZ5wuZpqABZlpwQ2Ho4GDyiu/R2Xjkp/9+zcFxL7uzeLl/QCPrflnvpVYyS3ouT7Zw==} + peerDependencies: + typescript: '>=4.5.0' + peerDependenciesMeta: + typescript: + optional: true + + ts-jest@29.1.2: + resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==} + engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@babel/core': '>=7.0.0-beta.0 <8' + '@jest/types': ^29.0.0 + babel-jest: ^29.0.0 + esbuild: '*' + jest: ^29.0.0 + typescript: '>=4.3 <6' + peerDependenciesMeta: + '@babel/core': + optional: true + '@jest/types': + optional: true + babel-jest: + optional: true + esbuild: + optional: true + + ts-toolbelt@9.6.0: + resolution: {integrity: sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==} + + tslib@2.7.0: + resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==} + + type-detect@4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} + engines: {node: '>=4'} + + type-fest@0.21.3: + resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} + engines: {node: '>=10'} + + types-ramda@0.30.1: + resolution: {integrity: sha512-1HTsf5/QVRmLzcGfldPFvkVsAdi1db1BBKzi7iW3KBUlOICg/nKnFS+jGqDJS3YD8VsWbAh7JiHeBvbsw8RPxA==} + + typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + engines: {node: '>=14.17'} + hasBin: true + + undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + + update-browserslist-db@1.1.0: + resolution: {integrity: sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + + v8-to-istanbul@9.3.0: + resolution: {integrity: sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==} + engines: {node: '>=10.12.0'} + + walker@1.0.8: + resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + + write-file-atomic@4.0.2: + resolution: {integrity: sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + + ws@8.17.1: + resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + y18n@5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} + + yallist@3.1.1: + resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} + + yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + + yargs@17.7.2: + resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} + engines: {node: '>=12'} + + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + +snapshots: + + '@ampproject/remapping@2.3.0': dependencies: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 - dev: true - /@babel/code-frame@7.24.7: - resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==} - engines: {node: '>=6.9.0'} + '@babel/code-frame@7.24.7': dependencies: '@babel/highlight': 7.24.7 picocolors: 1.0.1 - dev: true - /@babel/compat-data@7.25.4: - resolution: {integrity: sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==} - engines: {node: '>=6.9.0'} - dev: true + '@babel/compat-data@7.25.4': {} - /@babel/core@7.25.2: - resolution: {integrity: sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==} - engines: {node: '>=6.9.0'} + '@babel/core@7.25.2': dependencies: '@ampproject/remapping': 2.3.0 '@babel/code-frame': 7.24.7 @@ -103,44 +1353,30 @@ packages: semver: 6.3.1 transitivePeerDependencies: - supports-color - dev: true - /@babel/generator@7.25.5: - resolution: {integrity: sha512-abd43wyLfbWoxC6ahM8xTkqLpGB2iWBVyuKC9/srhFunCd1SDNrV1s72bBpK4hLj8KLzHBBcOblvLQZBNw9r3w==} - engines: {node: '>=6.9.0'} + '@babel/generator@7.25.5': dependencies: '@babel/types': 7.25.4 '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 jsesc: 2.5.2 - dev: true - /@babel/helper-compilation-targets@7.25.2: - resolution: {integrity: sha512-U2U5LsSaZ7TAt3cfaymQ8WHh0pxvdHoEk6HVpaexxixjyEquMh0L0YNJNM6CTGKMXV1iksi0iZkGw4AcFkPaaw==} - engines: {node: '>=6.9.0'} + '@babel/helper-compilation-targets@7.25.2': dependencies: '@babel/compat-data': 7.25.4 '@babel/helper-validator-option': 7.24.8 browserslist: 4.23.3 lru-cache: 5.1.1 semver: 6.3.1 - dev: true - /@babel/helper-module-imports@7.24.7: - resolution: {integrity: sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==} - engines: {node: '>=6.9.0'} + '@babel/helper-module-imports@7.24.7': dependencies: '@babel/traverse': 7.25.4 '@babel/types': 7.25.4 transitivePeerDependencies: - supports-color - dev: true - /@babel/helper-module-transforms@7.25.2(@babel/core@7.25.2): - resolution: {integrity: sha512-BjyRAbix6j/wv83ftcVJmBt72QtHI56C7JXZoG2xATiLpmoC7dpd8WnkikExHDVPpi/3qCmO6WY1EaXOluiecQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 + '@babel/helper-module-transforms@7.25.2(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-module-imports': 7.24.7 @@ -149,235 +1385,130 @@ packages: '@babel/traverse': 7.25.4 transitivePeerDependencies: - supports-color - dev: true - /@babel/helper-plugin-utils@7.24.8: - resolution: {integrity: sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==} - engines: {node: '>=6.9.0'} - dev: true + '@babel/helper-plugin-utils@7.24.8': {} - /@babel/helper-simple-access@7.24.7: - resolution: {integrity: sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==} - engines: {node: '>=6.9.0'} + '@babel/helper-simple-access@7.24.7': dependencies: '@babel/traverse': 7.25.4 '@babel/types': 7.25.4 transitivePeerDependencies: - supports-color - dev: true - /@babel/helper-string-parser@7.24.8: - resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==} - engines: {node: '>=6.9.0'} - dev: true + '@babel/helper-string-parser@7.24.8': {} - /@babel/helper-validator-identifier@7.24.7: - resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} - engines: {node: '>=6.9.0'} - dev: true + '@babel/helper-validator-identifier@7.24.7': {} - /@babel/helper-validator-option@7.24.8: - resolution: {integrity: sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==} - engines: {node: '>=6.9.0'} - dev: true + '@babel/helper-validator-option@7.24.8': {} - /@babel/helpers@7.25.0: - resolution: {integrity: sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==} - engines: {node: '>=6.9.0'} + '@babel/helpers@7.25.0': dependencies: '@babel/template': 7.25.0 '@babel/types': 7.25.4 - dev: true - /@babel/highlight@7.24.7: - resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} - engines: {node: '>=6.9.0'} + '@babel/highlight@7.24.7': dependencies: '@babel/helper-validator-identifier': 7.24.7 chalk: 2.4.2 js-tokens: 4.0.0 picocolors: 1.0.1 - dev: true - /@babel/parser@7.25.4: - resolution: {integrity: sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==} - engines: {node: '>=6.0.0'} - hasBin: true + '@babel/parser@7.25.4': dependencies: '@babel/types': 7.25.4 - dev: true - /@babel/plugin-syntax-async-generators@7.8.4(@babel/core@7.25.2): - resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-async-generators@7.8.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-bigint@7.8.3(@babel/core@7.25.2): - resolution: {integrity: sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-bigint@7.8.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.25.2): - resolution: {integrity: sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-class-static-block@7.14.5(@babel/core@7.25.2): - resolution: {integrity: sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-class-static-block@7.14.5(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-import-attributes@7.24.7(@babel/core@7.25.2): - resolution: {integrity: sha512-hbX+lKKeUMGihnK8nvKqmXBInriT3GVjzXKFriV3YC6APGxMbP8RZNFwy91+hocLXq90Mta+HshoB31802bb8A==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-import-attributes@7.24.7(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.25.2): - resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.25.2): - resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-jsx@7.24.7(@babel/core@7.25.2): - resolution: {integrity: sha512-6ddciUPe/mpMnOKv/U+RSd2vvVy+Yw/JfBB0ZHYjEZt9NLHmCUylNYlsbqCCS1Bffjlb0fCwC9Vqz+sBz6PsiQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-jsx@7.24.7(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-logical-assignment-operators@7.10.4(@babel/core@7.25.2): - resolution: {integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-logical-assignment-operators@7.10.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(@babel/core@7.25.2): - resolution: {integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-numeric-separator@7.10.4(@babel/core@7.25.2): - resolution: {integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-numeric-separator@7.10.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.25.2): - resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-optional-catch-binding@7.8.3(@babel/core@7.25.2): - resolution: {integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-optional-catch-binding@7.8.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-optional-chaining@7.8.3(@babel/core@7.25.2): - resolution: {integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-optional-chaining@7.8.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-private-property-in-object@7.14.5(@babel/core@7.25.2): - resolution: {integrity: sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-private-property-in-object@7.14.5(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-top-level-await@7.14.5(@babel/core@7.25.2): - resolution: {integrity: sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-top-level-await@7.14.5(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/plugin-syntax-typescript@7.25.4(@babel/core@7.25.2): - resolution: {integrity: sha512-uMOCoHVU52BsSWxPOMVv5qKRdeSlPuImUCB2dlPuBSU+W2/ROE7/Zg8F2Kepbk+8yBa68LlRKxO+xgEVWorsDg==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-typescript@7.25.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - dev: true - /@babel/template@7.25.0: - resolution: {integrity: sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==} - engines: {node: '>=6.9.0'} + '@babel/template@7.25.0': dependencies: '@babel/code-frame': 7.24.7 '@babel/parser': 7.25.4 '@babel/types': 7.25.4 - dev: true - /@babel/traverse@7.25.4: - resolution: {integrity: sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==} - engines: {node: '>=6.9.0'} + '@babel/traverse@7.25.4': dependencies: '@babel/code-frame': 7.24.7 '@babel/generator': 7.25.5 @@ -388,40 +1519,26 @@ packages: globals: 11.12.0 transitivePeerDependencies: - supports-color - dev: true - /@babel/types@7.25.4: - resolution: {integrity: sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==} - engines: {node: '>=6.9.0'} + '@babel/types@7.25.4': dependencies: '@babel/helper-string-parser': 7.24.8 '@babel/helper-validator-identifier': 7.24.7 to-fast-properties: 2.0.0 - dev: true - /@bcoe/v8-coverage@0.2.3: - resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} - dev: true + '@bcoe/v8-coverage@0.2.3': {} - /@istanbuljs/load-nyc-config@1.1.0: - resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} - engines: {node: '>=8'} + '@istanbuljs/load-nyc-config@1.1.0': dependencies: camelcase: 5.3.1 find-up: 4.1.0 get-package-type: 0.1.0 js-yaml: 3.14.1 resolve-from: 5.0.0 - dev: true - /@istanbuljs/schema@0.1.3: - resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} - engines: {node: '>=8'} - dev: true + '@istanbuljs/schema@0.1.3': {} - /@jest/console@29.7.0: - resolution: {integrity: sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/console@29.7.0': dependencies: '@jest/types': 29.6.3 '@types/node': 20.12.12 @@ -429,16 +1546,8 @@ packages: jest-message-util: 29.7.0 jest-util: 29.7.0 slash: 3.0.0 - dev: true - /@jest/core@29.7.0: - resolution: {integrity: sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true + '@jest/core@29.7.0': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -472,38 +1581,26 @@ packages: - babel-plugin-macros - supports-color - ts-node - dev: true - /@jest/environment@29.7.0: - resolution: {integrity: sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/environment@29.7.0': dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 '@types/node': 20.12.12 jest-mock: 29.7.0 - dev: true - /@jest/expect-utils@29.7.0: - resolution: {integrity: sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/expect-utils@29.7.0': dependencies: jest-get-type: 29.6.3 - dev: true - /@jest/expect@29.7.0: - resolution: {integrity: sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/expect@29.7.0': dependencies: expect: 29.7.0 jest-snapshot: 29.7.0 transitivePeerDependencies: - supports-color - dev: true - /@jest/fake-timers@29.7.0: - resolution: {integrity: sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/fake-timers@29.7.0': dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 @@ -511,11 +1608,8 @@ packages: jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 - dev: true - /@jest/globals@29.7.0: - resolution: {integrity: sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/globals@29.7.0': dependencies: '@jest/environment': 29.7.0 '@jest/expect': 29.7.0 @@ -523,16 +1617,8 @@ packages: jest-mock: 29.7.0 transitivePeerDependencies: - supports-color - dev: true - /@jest/reporters@29.7.0: - resolution: {integrity: sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true + '@jest/reporters@29.7.0': dependencies: '@bcoe/v8-coverage': 0.2.3 '@jest/console': 29.7.0 @@ -560,47 +1646,32 @@ packages: v8-to-istanbul: 9.3.0 transitivePeerDependencies: - supports-color - dev: true - /@jest/schemas@29.6.3: - resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/schemas@29.6.3': dependencies: '@sinclair/typebox': 0.27.8 - dev: true - /@jest/source-map@29.6.3: - resolution: {integrity: sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/source-map@29.6.3': dependencies: '@jridgewell/trace-mapping': 0.3.25 callsites: 3.1.0 graceful-fs: 4.2.11 - dev: true - /@jest/test-result@29.7.0: - resolution: {integrity: sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/test-result@29.7.0': dependencies: '@jest/console': 29.7.0 '@jest/types': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 collect-v8-coverage: 1.0.2 - dev: true - /@jest/test-sequencer@29.7.0: - resolution: {integrity: sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/test-sequencer@29.7.0': dependencies: '@jest/test-result': 29.7.0 graceful-fs: 4.2.11 jest-haste-map: 29.7.0 slash: 3.0.0 - dev: true - /@jest/transform@29.7.0: - resolution: {integrity: sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/transform@29.7.0': dependencies: '@babel/core': 7.25.2 '@jest/types': 29.6.3 @@ -619,11 +1690,8 @@ packages: write-file-atomic: 4.0.2 transitivePeerDependencies: - supports-color - dev: true - /@jest/types@29.6.3: - resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jest/types@29.6.3': dependencies: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 @@ -631,212 +1699,132 @@ packages: '@types/node': 20.12.12 '@types/yargs': 17.0.33 chalk: 4.1.2 - dev: true - /@jridgewell/gen-mapping@0.3.5: - resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} - engines: {node: '>=6.0.0'} + '@jridgewell/gen-mapping@0.3.5': dependencies: '@jridgewell/set-array': 1.2.1 '@jridgewell/sourcemap-codec': 1.5.0 '@jridgewell/trace-mapping': 0.3.25 - dev: true - /@jridgewell/resolve-uri@3.1.2: - resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} - engines: {node: '>=6.0.0'} - dev: true + '@jridgewell/resolve-uri@3.1.2': {} - /@jridgewell/set-array@1.2.1: - resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} - engines: {node: '>=6.0.0'} - dev: true + '@jridgewell/set-array@1.2.1': {} - /@jridgewell/sourcemap-codec@1.5.0: - resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} - dev: true + '@jridgewell/sourcemap-codec@1.5.0': {} - /@jridgewell/trace-mapping@0.3.25: - resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + '@jridgewell/trace-mapping@0.3.25': dependencies: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - dev: true - /@sinclair/typebox@0.27.8: - resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} - dev: true + '@sinclair/typebox@0.27.8': {} - /@sinonjs/commons@3.0.1: - resolution: {integrity: sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==} + '@sinonjs/commons@3.0.1': dependencies: type-detect: 4.0.8 - dev: true - /@sinonjs/fake-timers@10.3.0: - resolution: {integrity: sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==} + '@sinonjs/fake-timers@10.3.0': dependencies: '@sinonjs/commons': 3.0.1 - dev: true - /@types/babel__core@7.20.5: - resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} + '@types/babel__core@7.20.5': dependencies: '@babel/parser': 7.25.4 '@babel/types': 7.25.4 '@types/babel__generator': 7.6.8 '@types/babel__template': 7.4.4 '@types/babel__traverse': 7.20.6 - dev: true - /@types/babel__generator@7.6.8: - resolution: {integrity: sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==} + '@types/babel__generator@7.6.8': dependencies: '@babel/types': 7.25.4 - dev: true - /@types/babel__template@7.4.4: - resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} + '@types/babel__template@7.4.4': dependencies: '@babel/parser': 7.25.4 '@babel/types': 7.25.4 - dev: true - /@types/babel__traverse@7.20.6: - resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} + '@types/babel__traverse@7.20.6': dependencies: '@babel/types': 7.25.4 - dev: true - /@types/graceful-fs@4.1.9: - resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} + '@types/graceful-fs@4.1.9': dependencies: '@types/node': 20.12.12 - dev: true - /@types/istanbul-lib-coverage@2.0.6: - resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} - dev: true + '@types/istanbul-lib-coverage@2.0.6': {} - /@types/istanbul-lib-report@3.0.3: - resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} + '@types/istanbul-lib-report@3.0.3': dependencies: '@types/istanbul-lib-coverage': 2.0.6 - dev: true - /@types/istanbul-reports@3.0.4: - resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} + '@types/istanbul-reports@3.0.4': dependencies: '@types/istanbul-lib-report': 3.0.3 - dev: true - /@types/jest@29.5.12: - resolution: {integrity: sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==} + '@types/jest@29.5.12': dependencies: expect: 29.7.0 pretty-format: 29.7.0 - dev: true - /@types/node@20.12.12: - resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + '@types/node@20.12.12': dependencies: undici-types: 5.26.5 - dev: true - /@types/ramda@0.30.0: - resolution: {integrity: sha512-DQtfqUbSB18iM9NHbQ++kVUDuBWHMr6T2FpW1XTiksYRGjq4WnNPZLt712OEHEBJs7aMyJ68Mf2kGMOP1srVVw==} + '@types/ramda@0.30.0': dependencies: types-ramda: 0.30.1 - dev: true - /@types/semver@7.5.8: - resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} - dev: true + '@types/semver@7.5.8': {} - /@types/stack-utils@2.0.3: - resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} - dev: true + '@types/stack-utils@2.0.3': {} - /@types/ws@8.5.10: - resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} + '@types/ws@8.5.10': dependencies: '@types/node': 20.12.12 - dev: true - /@types/yargs-parser@21.0.3: - resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} - dev: true + '@types/yargs-parser@21.0.3': {} - /@types/yargs@17.0.33: - resolution: {integrity: sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==} + '@types/yargs@17.0.33': dependencies: '@types/yargs-parser': 21.0.3 - dev: true - /ansi-escapes@4.3.2: - resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} - engines: {node: '>=8'} + ansi-escapes@4.3.2: dependencies: type-fest: 0.21.3 - dev: true - /ansi-regex@5.0.1: - resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} - engines: {node: '>=8'} - dev: true + ansi-regex@5.0.1: {} - /ansi-styles@3.2.1: - resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} - engines: {node: '>=4'} + ansi-styles@3.2.1: dependencies: color-convert: 1.9.3 - dev: true - /ansi-styles@4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} + ansi-styles@4.3.0: dependencies: color-convert: 2.0.1 - dev: true - /ansi-styles@5.2.0: - resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} - engines: {node: '>=10'} - dev: true + ansi-styles@5.2.0: {} - /anymatch@3.1.3: - resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} - engines: {node: '>= 8'} + anymatch@3.1.3: dependencies: normalize-path: 3.0.0 picomatch: 2.3.1 - dev: true - /argparse@1.0.10: - resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + argparse@1.0.10: dependencies: sprintf-js: 1.0.3 - dev: true - /asynckit@0.4.0: - resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} - dev: true + asynckit@0.4.0: {} - /axios@1.6.8: - resolution: {integrity: sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==} + axios@1.6.8: dependencies: follow-redirects: 1.15.6 form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: - debug - dev: true - /babel-jest@29.7.0(@babel/core@7.25.2): - resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@babel/core': ^7.8.0 + babel-jest@29.7.0(@babel/core@7.25.2): dependencies: '@babel/core': 7.25.2 '@jest/transform': 29.7.0 @@ -848,11 +1836,8 @@ packages: slash: 3.0.0 transitivePeerDependencies: - supports-color - dev: true - /babel-plugin-istanbul@6.1.1: - resolution: {integrity: sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==} - engines: {node: '>=8'} + babel-plugin-istanbul@6.1.1: dependencies: '@babel/helper-plugin-utils': 7.24.8 '@istanbuljs/load-nyc-config': 1.1.0 @@ -861,22 +1846,15 @@ packages: test-exclude: 6.0.0 transitivePeerDependencies: - supports-color - dev: true - /babel-plugin-jest-hoist@29.6.3: - resolution: {integrity: sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + babel-plugin-jest-hoist@29.6.3: dependencies: '@babel/template': 7.25.0 '@babel/types': 7.25.4 '@types/babel__core': 7.20.5 '@types/babel__traverse': 7.20.6 - dev: true - /babel-preset-current-node-syntax@1.1.0(@babel/core@7.25.2): - resolution: {integrity: sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==} - peerDependencies: - '@babel/core': ^7.0.0 + babel-preset-current-node-syntax@1.1.0(@babel/core@7.25.2): dependencies: '@babel/core': 7.25.2 '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.25.2) @@ -894,173 +1872,97 @@ packages: '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.25.2) '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.25.2) '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.25.2) - dev: true - /babel-preset-jest@29.6.3(@babel/core@7.25.2): - resolution: {integrity: sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@babel/core': ^7.0.0 + babel-preset-jest@29.6.3(@babel/core@7.25.2): dependencies: '@babel/core': 7.25.2 babel-plugin-jest-hoist: 29.6.3 babel-preset-current-node-syntax: 1.1.0(@babel/core@7.25.2) - dev: true - /balanced-match@1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - dev: true + balanced-match@1.0.2: {} - /brace-expansion@1.1.11: - resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} + brace-expansion@1.1.11: dependencies: balanced-match: 1.0.2 concat-map: 0.0.1 - dev: true - /braces@3.0.3: - resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} - engines: {node: '>=8'} + braces@3.0.3: dependencies: fill-range: 7.1.1 - dev: true - /browserslist@4.23.3: - resolution: {integrity: sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==} - engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} - hasBin: true + browserslist@4.23.3: dependencies: caniuse-lite: 1.0.30001653 electron-to-chromium: 1.5.13 node-releases: 2.0.18 update-browserslist-db: 1.1.0(browserslist@4.23.3) - dev: true - /bs-logger@0.2.6: - resolution: {integrity: sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==} - engines: {node: '>= 6'} + bs-logger@0.2.6: dependencies: fast-json-stable-stringify: 2.1.0 - dev: true - /bser@2.1.1: - resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} + bser@2.1.1: dependencies: node-int64: 0.4.0 - dev: true - /buffer-from@1.1.2: - resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - dev: true + buffer-from@1.1.2: {} - /callsites@3.1.0: - resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} - engines: {node: '>=6'} - dev: true + callsites@3.1.0: {} - /camelcase@5.3.1: - resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} - engines: {node: '>=6'} - dev: true + camelcase@5.3.1: {} - /camelcase@6.3.0: - resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} - engines: {node: '>=10'} - dev: true + camelcase@6.3.0: {} - /caniuse-lite@1.0.30001653: - resolution: {integrity: sha512-XGWQVB8wFQ2+9NZwZ10GxTYC5hk0Fa+q8cSkr0tgvMhYhMHP/QC+WTgrePMDBWiWc/pV+1ik82Al20XOK25Gcw==} - dev: true + caniuse-lite@1.0.30001653: {} - /chalk@2.4.2: - resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} - engines: {node: '>=4'} + chalk@2.4.2: dependencies: ansi-styles: 3.2.1 escape-string-regexp: 1.0.5 supports-color: 5.5.0 - dev: true - /chalk@4.1.2: - resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} - engines: {node: '>=10'} + chalk@4.1.2: dependencies: ansi-styles: 4.3.0 supports-color: 7.2.0 - dev: true - /char-regex@1.0.2: - resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} - engines: {node: '>=10'} - dev: true + char-regex@1.0.2: {} - /ci-info@3.9.0: - resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} - engines: {node: '>=8'} - dev: true + ci-info@3.9.0: {} - /cjs-module-lexer@1.4.0: - resolution: {integrity: sha512-N1NGmowPlGBLsOZLPvm48StN04V4YvQRL0i6b7ctrVY3epjP/ct7hFLOItz6pDIvRjwpfPxi52a2UWV2ziir8g==} - dev: true + cjs-module-lexer@1.4.0: {} - /cliui@8.0.1: - resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} - engines: {node: '>=12'} + cliui@8.0.1: dependencies: string-width: 4.2.3 strip-ansi: 6.0.1 wrap-ansi: 7.0.0 - dev: true - /co@4.6.0: - resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} - engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} - dev: true + co@4.6.0: {} - /collect-v8-coverage@1.0.2: - resolution: {integrity: sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==} - dev: true + collect-v8-coverage@1.0.2: {} - /color-convert@1.9.3: - resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} + color-convert@1.9.3: dependencies: color-name: 1.1.3 - dev: true - /color-convert@2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} + color-convert@2.0.1: dependencies: color-name: 1.1.4 - dev: true - /color-name@1.1.3: - resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - dev: true + color-name@1.1.3: {} - /color-name@1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true + color-name@1.1.4: {} - /combined-stream@1.0.8: - resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} - engines: {node: '>= 0.8'} + combined-stream@1.0.8: dependencies: delayed-stream: 1.0.0 - dev: true - /concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - dev: true + concat-map@0.0.1: {} - /convert-source-map@2.0.0: - resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} - dev: true + convert-source-map@2.0.0: {} - /create-jest@29.7.0(@types/node@20.12.12): - resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - hasBin: true + create-jest@29.7.0(@types/node@20.12.12): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 @@ -1074,101 +1976,46 @@ packages: - babel-plugin-macros - supports-color - ts-node - dev: true - /cross-spawn@7.0.3: - resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} - engines: {node: '>= 8'} + cross-spawn@7.0.3: dependencies: path-key: 3.1.1 shebang-command: 2.0.0 which: 2.0.2 - dev: true - /debug@4.3.6: - resolution: {integrity: sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true + debug@4.3.6: dependencies: ms: 2.1.2 - dev: true - /dedent@1.5.3: - resolution: {integrity: sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==} - peerDependencies: - babel-plugin-macros: ^3.1.0 - peerDependenciesMeta: - babel-plugin-macros: - optional: true - dev: true + dedent@1.5.3: {} - /deepmerge@4.3.1: - resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} - engines: {node: '>=0.10.0'} - dev: true + deepmerge@4.3.1: {} - /delayed-stream@1.0.0: - resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} - engines: {node: '>=0.4.0'} - dev: true + delayed-stream@1.0.0: {} - /detect-newline@3.1.0: - resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} - engines: {node: '>=8'} - dev: true + detect-newline@3.1.0: {} - /diff-sequences@29.6.3: - resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dev: true + diff-sequences@29.6.3: {} - /electron-to-chromium@1.5.13: - resolution: {integrity: sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q==} - dev: true + electron-to-chromium@1.5.13: {} - /emittery@0.13.1: - resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==} - engines: {node: '>=12'} - dev: true + emittery@0.13.1: {} - /emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true + emoji-regex@8.0.0: {} - /error-ex@1.3.2: - resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} + error-ex@1.3.2: dependencies: is-arrayish: 0.2.1 - dev: true - /escalade@3.1.2: - resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} - engines: {node: '>=6'} - dev: true + escalade@3.1.2: {} - /escape-string-regexp@1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - dev: true + escape-string-regexp@1.0.5: {} - /escape-string-regexp@2.0.0: - resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} - engines: {node: '>=8'} - dev: true + escape-string-regexp@2.0.0: {} - /esprima@4.0.1: - resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} - engines: {node: '>=4'} - hasBin: true - dev: true + esprima@4.0.1: {} - /execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} + execa@5.1.1: dependencies: cross-spawn: 7.0.3 get-stream: 6.0.1 @@ -1179,107 +2026,56 @@ packages: onetime: 5.1.2 signal-exit: 3.0.7 strip-final-newline: 2.0.0 - dev: true - /exit@0.1.2: - resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} - engines: {node: '>= 0.8.0'} - dev: true + exit@0.1.2: {} - /expect@29.7.0: - resolution: {integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + expect@29.7.0: dependencies: '@jest/expect-utils': 29.7.0 jest-get-type: 29.6.3 jest-matcher-utils: 29.7.0 jest-message-util: 29.7.0 jest-util: 29.7.0 - dev: true - /fast-json-stable-stringify@2.1.0: - resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} - dev: true + fast-json-stable-stringify@2.1.0: {} - /fb-watchman@2.0.2: - resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==} + fb-watchman@2.0.2: dependencies: bser: 2.1.1 - dev: true - /fill-range@7.1.1: - resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} - engines: {node: '>=8'} + fill-range@7.1.1: dependencies: to-regex-range: 5.0.1 - dev: true - /find-up@4.1.0: - resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} - engines: {node: '>=8'} + find-up@4.1.0: dependencies: locate-path: 5.0.0 path-exists: 4.0.0 - dev: true - /follow-redirects@1.15.6: - resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} - engines: {node: '>=4.0'} - peerDependencies: - debug: '*' - peerDependenciesMeta: - debug: - optional: true - dev: true + follow-redirects@1.15.6: {} - /form-data@4.0.0: - resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} - engines: {node: '>= 6'} + form-data@4.0.0: dependencies: asynckit: 0.4.0 combined-stream: 1.0.8 mime-types: 2.1.35 - dev: true - /fs.realpath@1.0.0: - resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - dev: true + fs.realpath@1.0.0: {} - /fsevents@2.3.3: - resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - requiresBuild: true - dev: true + fsevents@2.3.3: optional: true - /function-bind@1.1.2: - resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} - dev: true + function-bind@1.1.2: {} - /gensync@1.0.0-beta.2: - resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} - engines: {node: '>=6.9.0'} - dev: true + gensync@1.0.0-beta.2: {} - /get-caller-file@2.0.5: - resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} - engines: {node: 6.* || 8.* || >= 10.*} - dev: true + get-caller-file@2.0.5: {} - /get-package-type@0.1.0: - resolution: {integrity: sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==} - engines: {node: '>=8.0.0'} - dev: true + get-package-type@0.1.0: {} - /get-stream@6.0.1: - resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} - engines: {node: '>=10'} - dev: true + get-stream@6.0.1: {} - /glob@7.2.3: - resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - deprecated: Glob versions prior to v9 are no longer supported + glob@7.2.3: dependencies: fs.realpath: 1.0.0 inflight: 1.0.6 @@ -1287,112 +2083,56 @@ packages: minimatch: 3.1.2 once: 1.4.0 path-is-absolute: 1.0.1 - dev: true - /globals@11.12.0: - resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} - engines: {node: '>=4'} - dev: true + globals@11.12.0: {} - /graceful-fs@4.2.11: - resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - dev: true + graceful-fs@4.2.11: {} - /has-flag@3.0.0: - resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} - engines: {node: '>=4'} - dev: true + has-flag@3.0.0: {} - /has-flag@4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - dev: true + has-flag@4.0.0: {} - /hasown@2.0.2: - resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} - engines: {node: '>= 0.4'} + hasown@2.0.2: dependencies: function-bind: 1.1.2 - dev: true - /html-escaper@2.0.2: - resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} - dev: true + html-escaper@2.0.2: {} - /human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - dev: true + human-signals@2.1.0: {} - /import-local@3.2.0: - resolution: {integrity: sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==} - engines: {node: '>=8'} - hasBin: true + import-local@3.2.0: dependencies: pkg-dir: 4.2.0 resolve-cwd: 3.0.0 - dev: true - /imurmurhash@0.1.4: - resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} - engines: {node: '>=0.8.19'} - dev: true + imurmurhash@0.1.4: {} - /inflight@1.0.6: - resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. + inflight@1.0.6: dependencies: once: 1.4.0 wrappy: 1.0.2 - dev: true - /inherits@2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - dev: true + inherits@2.0.4: {} - /is-arrayish@0.2.1: - resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - dev: true + is-arrayish@0.2.1: {} - /is-core-module@2.15.1: - resolution: {integrity: sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==} - engines: {node: '>= 0.4'} + is-core-module@2.15.1: dependencies: hasown: 2.0.2 - dev: true - /is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - dev: true + is-fullwidth-code-point@3.0.0: {} - /is-generator-fn@2.1.0: - resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==} - engines: {node: '>=6'} - dev: true + is-generator-fn@2.1.0: {} - /is-number@7.0.0: - resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} - engines: {node: '>=0.12.0'} - dev: true + is-number@7.0.0: {} - /is-stream@2.0.1: - resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} - engines: {node: '>=8'} - dev: true + is-stream@2.0.1: {} - /isexe@2.0.0: - resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - dev: true + isexe@2.0.0: {} - /istanbul-lib-coverage@3.2.2: - resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} - engines: {node: '>=8'} - dev: true + istanbul-lib-coverage@3.2.2: {} - /istanbul-lib-instrument@5.2.1: - resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} - engines: {node: '>=8'} + istanbul-lib-instrument@5.2.1: dependencies: '@babel/core': 7.25.2 '@babel/parser': 7.25.4 @@ -1401,11 +2141,8 @@ packages: semver: 6.3.1 transitivePeerDependencies: - supports-color - dev: true - /istanbul-lib-instrument@6.0.3: - resolution: {integrity: sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==} - engines: {node: '>=10'} + istanbul-lib-instrument@6.0.3: dependencies: '@babel/core': 7.25.2 '@babel/parser': 7.25.4 @@ -1414,48 +2151,33 @@ packages: semver: 7.6.2 transitivePeerDependencies: - supports-color - dev: true - /istanbul-lib-report@3.0.1: - resolution: {integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==} - engines: {node: '>=10'} + istanbul-lib-report@3.0.1: dependencies: istanbul-lib-coverage: 3.2.2 make-dir: 4.0.0 supports-color: 7.2.0 - dev: true - /istanbul-lib-source-maps@4.0.1: - resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} - engines: {node: '>=10'} + istanbul-lib-source-maps@4.0.1: dependencies: debug: 4.3.6 istanbul-lib-coverage: 3.2.2 source-map: 0.6.1 transitivePeerDependencies: - supports-color - dev: true - /istanbul-reports@3.1.7: - resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==} - engines: {node: '>=8'} + istanbul-reports@3.1.7: dependencies: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 - dev: true - /jest-changed-files@29.7.0: - resolution: {integrity: sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-changed-files@29.7.0: dependencies: execa: 5.1.1 jest-util: 29.7.0 p-limit: 3.1.0 - dev: true - /jest-circus@29.7.0: - resolution: {integrity: sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-circus@29.7.0: dependencies: '@jest/environment': 29.7.0 '@jest/expect': 29.7.0 @@ -1480,17 +2202,8 @@ packages: transitivePeerDependencies: - babel-plugin-macros - supports-color - dev: true - /jest-cli@29.7.0(@types/node@20.12.12): - resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - hasBin: true - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true + jest-cli@29.7.0(@types/node@20.12.12): dependencies: '@jest/core': 29.7.0 '@jest/test-result': 29.7.0 @@ -1508,19 +2221,8 @@ packages: - babel-plugin-macros - supports-color - ts-node - dev: true - /jest-config@29.7.0(@types/node@20.12.12): - resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@types/node': '*' - ts-node: '>=9.0.0' - peerDependenciesMeta: - '@types/node': - optional: true - ts-node: - optional: true + jest-config@29.7.0(@types/node@20.12.12): dependencies: '@babel/core': 7.25.2 '@jest/test-sequencer': 29.7.0 @@ -1548,39 +2250,27 @@ packages: transitivePeerDependencies: - babel-plugin-macros - supports-color - dev: true - /jest-diff@29.7.0: - resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-diff@29.7.0: dependencies: chalk: 4.1.2 diff-sequences: 29.6.3 jest-get-type: 29.6.3 pretty-format: 29.7.0 - dev: true - /jest-docblock@29.7.0: - resolution: {integrity: sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-docblock@29.7.0: dependencies: detect-newline: 3.1.0 - dev: true - /jest-each@29.7.0: - resolution: {integrity: sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-each@29.7.0: dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 jest-get-type: 29.6.3 jest-util: 29.7.0 pretty-format: 29.7.0 - dev: true - /jest-environment-node@29.7.0: - resolution: {integrity: sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-environment-node@29.7.0: dependencies: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 @@ -1588,34 +2278,18 @@ packages: '@types/node': 20.12.12 jest-mock: 29.7.0 jest-util: 29.7.0 - dev: true - - /jest-expect-message@1.1.3: - resolution: {integrity: sha512-bTK77T4P+zto+XepAX3low8XVQxDgaEqh3jSTQOG8qvPpD69LsIdyJTa+RmnJh3HNSzJng62/44RPPc7OIlFxg==} - dev: true - - /jest-extended@4.0.2(jest@29.7.0): - resolution: {integrity: sha512-FH7aaPgtGYHc9mRjriS0ZEHYM5/W69tLrFTIdzm+yJgeoCmmrSB/luSfMSqWP9O29QWHPEmJ4qmU6EwsZideog==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - jest: '>=27.2.5' - peerDependenciesMeta: - jest: - optional: true + + jest-expect-message@1.1.3: {} + + jest-extended@4.0.2(jest@29.7.0): dependencies: jest: 29.7.0(@types/node@20.12.12) jest-diff: 29.7.0 jest-get-type: 29.6.3 - dev: true - /jest-get-type@29.6.3: - resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dev: true + jest-get-type@29.6.3: {} - /jest-haste-map@29.7.0: - resolution: {integrity: sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-haste-map@29.7.0: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 @@ -1630,29 +2304,20 @@ packages: walker: 1.0.8 optionalDependencies: fsevents: 2.3.3 - dev: true - /jest-leak-detector@29.7.0: - resolution: {integrity: sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-leak-detector@29.7.0: dependencies: jest-get-type: 29.6.3 pretty-format: 29.7.0 - dev: true - /jest-matcher-utils@29.7.0: - resolution: {integrity: sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-matcher-utils@29.7.0: dependencies: chalk: 4.1.2 jest-diff: 29.7.0 jest-get-type: 29.6.3 pretty-format: 29.7.0 - dev: true - /jest-message-util@29.7.0: - resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-message-util@29.7.0: dependencies: '@babel/code-frame': 7.24.7 '@jest/types': 29.6.3 @@ -1663,58 +2328,33 @@ packages: pretty-format: 29.7.0 slash: 3.0.0 stack-utils: 2.0.6 - dev: true - /jest-mock-extended@3.0.7(jest@29.7.0)(typescript@5.4.5): - resolution: {integrity: sha512-7lsKdLFcW9B9l5NzZ66S/yTQ9k8rFtnwYdCNuRU/81fqDWicNDVhitTSPnrGmNeNm0xyw0JHexEOShrIKRCIRQ==} - peerDependencies: - jest: ^24.0.0 || ^25.0.0 || ^26.0.0 || ^27.0.0 || ^28.0.0 || ^29.0.0 - typescript: ^3.0.0 || ^4.0.0 || ^5.0.0 + jest-mock-extended@3.0.7(jest@29.7.0)(typescript@5.4.5): dependencies: jest: 29.7.0(@types/node@20.12.12) ts-essentials: 10.0.2(typescript@5.4.5) typescript: 5.4.5 - dev: true - /jest-mock@29.7.0: - resolution: {integrity: sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-mock@29.7.0: dependencies: '@jest/types': 29.6.3 '@types/node': 20.12.12 jest-util: 29.7.0 - dev: true - /jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): - resolution: {integrity: sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==} - engines: {node: '>=6'} - peerDependencies: - jest-resolve: '*' - peerDependenciesMeta: - jest-resolve: - optional: true + jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): dependencies: jest-resolve: 29.7.0 - dev: true - /jest-regex-util@29.6.3: - resolution: {integrity: sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - dev: true + jest-regex-util@29.6.3: {} - /jest-resolve-dependencies@29.7.0: - resolution: {integrity: sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-resolve-dependencies@29.7.0: dependencies: jest-regex-util: 29.6.3 jest-snapshot: 29.7.0 transitivePeerDependencies: - supports-color - dev: true - /jest-resolve@29.7.0: - resolution: {integrity: sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-resolve@29.7.0: dependencies: chalk: 4.1.2 graceful-fs: 4.2.11 @@ -1725,11 +2365,8 @@ packages: resolve: 1.22.8 resolve.exports: 2.0.2 slash: 3.0.0 - dev: true - /jest-runner@29.7.0: - resolution: {integrity: sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-runner@29.7.0: dependencies: '@jest/console': 29.7.0 '@jest/environment': 29.7.0 @@ -1754,11 +2391,8 @@ packages: source-map-support: 0.5.13 transitivePeerDependencies: - supports-color - dev: true - /jest-runtime@29.7.0: - resolution: {integrity: sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-runtime@29.7.0: dependencies: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 @@ -1784,11 +2418,8 @@ packages: strip-bom: 4.0.0 transitivePeerDependencies: - supports-color - dev: true - /jest-snapshot@29.7.0: - resolution: {integrity: sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-snapshot@29.7.0: dependencies: '@babel/core': 7.25.2 '@babel/generator': 7.25.5 @@ -1812,11 +2443,8 @@ packages: semver: 7.6.2 transitivePeerDependencies: - supports-color - dev: true - /jest-util@29.7.0: - resolution: {integrity: sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 '@types/node': 20.12.12 @@ -1824,11 +2452,8 @@ packages: ci-info: 3.9.0 graceful-fs: 4.2.11 picomatch: 2.3.1 - dev: true - /jest-validate@29.7.0: - resolution: {integrity: sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-validate@29.7.0: dependencies: '@jest/types': 29.6.3 camelcase: 6.3.0 @@ -1836,11 +2461,8 @@ packages: jest-get-type: 29.6.3 leven: 3.1.0 pretty-format: 29.7.0 - dev: true - /jest-watcher@29.7.0: - resolution: {integrity: sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-watcher@29.7.0: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 @@ -1850,27 +2472,15 @@ packages: emittery: 0.13.1 jest-util: 29.7.0 string-length: 4.0.2 - dev: true - /jest-worker@29.7.0: - resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-worker@29.7.0: dependencies: '@types/node': 20.12.12 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 - dev: true - /jest@29.7.0(@types/node@20.12.12): - resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - hasBin: true - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true + jest@29.7.0(@types/node@20.12.12): dependencies: '@jest/core': 29.7.0 '@jest/types': 29.6.3 @@ -1881,485 +2491,248 @@ packages: - babel-plugin-macros - supports-color - ts-node - dev: true - /js-tokens@4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: true + js-tokens@4.0.0: {} - /js-yaml@3.14.1: - resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} - hasBin: true + js-yaml@3.14.1: dependencies: argparse: 1.0.10 esprima: 4.0.1 - dev: true - /jsesc@2.5.2: - resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} - engines: {node: '>=4'} - hasBin: true - dev: true + jsesc@2.5.2: {} - /json-parse-even-better-errors@2.3.1: - resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - dev: true + json-parse-even-better-errors@2.3.1: {} - /json5@2.2.3: - resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} - engines: {node: '>=6'} - hasBin: true - dev: true + json5@2.2.3: {} - /kleur@3.0.3: - resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} - engines: {node: '>=6'} - dev: true + kleur@3.0.3: {} - /leven@3.1.0: - resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} - engines: {node: '>=6'} - dev: true + leven@3.1.0: {} - /lines-and-columns@1.2.4: - resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - dev: true + lines-and-columns@1.2.4: {} - /locate-path@5.0.0: - resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} - engines: {node: '>=8'} + locate-path@5.0.0: dependencies: p-locate: 4.1.0 - dev: true - /lodash.memoize@4.1.2: - resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} - dev: true + lodash.memoize@4.1.2: {} - /lru-cache@5.1.1: - resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + lru-cache@5.1.1: dependencies: yallist: 3.1.1 - dev: true - /make-dir@4.0.0: - resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} - engines: {node: '>=10'} + make-dir@4.0.0: dependencies: semver: 7.6.2 - dev: true - /make-error@1.3.6: - resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - dev: true + make-error@1.3.6: {} - /makeerror@1.0.12: - resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} + makeerror@1.0.12: dependencies: tmpl: 1.0.5 - dev: true - /merge-stream@2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - dev: true + merge-stream@2.0.0: {} - /micromatch@4.0.8: - resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} - engines: {node: '>=8.6'} + micromatch@4.0.8: dependencies: braces: 3.0.3 picomatch: 2.3.1 - dev: true - /mime-db@1.52.0: - resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} - engines: {node: '>= 0.6'} - dev: true + mime-db@1.52.0: {} - /mime-types@2.1.35: - resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} - engines: {node: '>= 0.6'} + mime-types@2.1.35: dependencies: mime-db: 1.52.0 - dev: true - /mimic-fn@2.1.0: - resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} - engines: {node: '>=6'} - dev: true + mimic-fn@2.1.0: {} - /minimatch@3.1.2: - resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + minimatch@3.1.2: dependencies: brace-expansion: 1.1.11 - dev: true - /ms@2.1.2: - resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - dev: true + ms@2.1.2: {} - /natural-compare@1.4.0: - resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - dev: true + natural-compare@1.4.0: {} - /node-int64@0.4.0: - resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} - dev: true + node-int64@0.4.0: {} - /node-releases@2.0.18: - resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==} - dev: true + node-releases@2.0.18: {} - /normalize-path@3.0.0: - resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} - engines: {node: '>=0.10.0'} - dev: true + normalize-path@3.0.0: {} - /npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} + npm-run-path@4.0.1: dependencies: path-key: 3.1.1 - dev: true - /once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + once@1.4.0: dependencies: wrappy: 1.0.2 - dev: true - /onetime@5.1.2: - resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} - engines: {node: '>=6'} + onetime@5.1.2: dependencies: mimic-fn: 2.1.0 - dev: true - /p-limit@2.3.0: - resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} - engines: {node: '>=6'} + p-limit@2.3.0: dependencies: p-try: 2.2.0 - dev: true - /p-limit@3.1.0: - resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} - engines: {node: '>=10'} + p-limit@3.1.0: dependencies: yocto-queue: 0.1.0 - dev: true - /p-locate@4.1.0: - resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} - engines: {node: '>=8'} + p-locate@4.1.0: dependencies: p-limit: 2.3.0 - dev: true - /p-try@2.2.0: - resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} - engines: {node: '>=6'} - dev: true + p-try@2.2.0: {} - /parse-json@5.2.0: - resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} - engines: {node: '>=8'} + parse-json@5.2.0: dependencies: '@babel/code-frame': 7.24.7 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 - dev: true - /path-exists@4.0.0: - resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} - engines: {node: '>=8'} - dev: true + path-exists@4.0.0: {} - /path-is-absolute@1.0.1: - resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} - engines: {node: '>=0.10.0'} - dev: true + path-is-absolute@1.0.1: {} - /path-key@3.1.1: - resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} - engines: {node: '>=8'} - dev: true + path-key@3.1.1: {} - /path-parse@1.0.7: - resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} - dev: true + path-parse@1.0.7: {} - /picocolors@1.0.1: - resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} - dev: true + picocolors@1.0.1: {} - /picomatch@2.3.1: - resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} - engines: {node: '>=8.6'} - dev: true + picomatch@2.3.1: {} - /pirates@4.0.6: - resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} - engines: {node: '>= 6'} - dev: true + pirates@4.0.6: {} - /pkg-dir@4.2.0: - resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} - engines: {node: '>=8'} + pkg-dir@4.2.0: dependencies: find-up: 4.1.0 - dev: true - /pretty-format@29.7.0: - resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + pretty-format@29.7.0: dependencies: '@jest/schemas': 29.6.3 ansi-styles: 5.2.0 react-is: 18.3.1 - dev: true - /prompts@2.4.2: - resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} - engines: {node: '>= 6'} + prompts@2.4.2: dependencies: kleur: 3.0.3 sisteransi: 1.0.5 - dev: true - /proxy-from-env@1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - dev: true + proxy-from-env@1.1.0: {} - /pure-rand@6.1.0: - resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==} - dev: true + pure-rand@6.1.0: {} - /ramda@0.30.0: - resolution: {integrity: sha512-13Y0iMhIQuAm/wNGBL/9HEqIfRGmNmjKnTPlKWfA9f7dnDkr8d45wQ+S7+ZLh/Pq9PdcGxkqKUEA7ySu1QSd9Q==} - dev: true + ramda@0.30.0: {} - /react-is@18.3.1: - resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} - dev: true + react-is@18.3.1: {} - /require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - dev: true + require-directory@2.1.1: {} - /resolve-cwd@3.0.0: - resolution: {integrity: sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==} - engines: {node: '>=8'} + resolve-cwd@3.0.0: dependencies: resolve-from: 5.0.0 - dev: true - /resolve-from@5.0.0: - resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} - engines: {node: '>=8'} - dev: true + resolve-from@5.0.0: {} - /resolve.exports@2.0.2: - resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==} - engines: {node: '>=10'} - dev: true + resolve.exports@2.0.2: {} - /resolve@1.22.8: - resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} - hasBin: true + resolve@1.22.8: dependencies: is-core-module: 2.15.1 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - dev: true - /rxjs@7.8.1: - resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + rxjs@7.8.1: dependencies: tslib: 2.7.0 - dev: true - /semver@6.3.1: - resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} - hasBin: true - dev: true + semver@6.3.1: {} - /semver@7.6.2: - resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==} - engines: {node: '>=10'} - hasBin: true + semver@7.6.2: {} - /shebang-command@2.0.0: - resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} - engines: {node: '>=8'} + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 - dev: true - /shebang-regex@3.0.0: - resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} - engines: {node: '>=8'} - dev: true + shebang-regex@3.0.0: {} - /signal-exit@3.0.7: - resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} - dev: true + signal-exit@3.0.7: {} - /sisteransi@1.0.5: - resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - dev: true + sisteransi@1.0.5: {} - /slash@3.0.0: - resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} - engines: {node: '>=8'} - dev: true + slash@3.0.0: {} - /source-map-support@0.5.13: - resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==} + source-map-support@0.5.13: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 - dev: true - /source-map@0.6.1: - resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} - engines: {node: '>=0.10.0'} - dev: true + source-map@0.6.1: {} - /sprintf-js@1.0.3: - resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} - dev: true + sprintf-js@1.0.3: {} - /stack-utils@2.0.6: - resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} - engines: {node: '>=10'} + stack-utils@2.0.6: dependencies: escape-string-regexp: 2.0.0 - dev: true - /string-length@4.0.2: - resolution: {integrity: sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==} - engines: {node: '>=10'} + string-length@4.0.2: dependencies: char-regex: 1.0.2 strip-ansi: 6.0.1 - dev: true - /string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} + string-width@4.2.3: dependencies: emoji-regex: 8.0.0 is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - dev: true - /strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} + strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 - dev: true - /strip-bom@4.0.0: - resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} - engines: {node: '>=8'} - dev: true + strip-bom@4.0.0: {} - /strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - dev: true + strip-final-newline@2.0.0: {} - /strip-json-comments@3.1.1: - resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} - engines: {node: '>=8'} - dev: true + strip-json-comments@3.1.1: {} - /supports-color@5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} + supports-color@5.5.0: dependencies: has-flag: 3.0.0 - dev: true - /supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} + supports-color@7.2.0: dependencies: has-flag: 4.0.0 - dev: true - /supports-color@8.1.1: - resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} - engines: {node: '>=10'} + supports-color@8.1.1: dependencies: has-flag: 4.0.0 - dev: true - /supports-preserve-symlinks-flag@1.0.0: - resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} - engines: {node: '>= 0.4'} - dev: true + supports-preserve-symlinks-flag@1.0.0: {} - /test-exclude@6.0.0: - resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} - engines: {node: '>=8'} + test-exclude@6.0.0: dependencies: '@istanbuljs/schema': 0.1.3 glob: 7.2.3 minimatch: 3.1.2 - dev: true - /tmpl@1.0.5: - resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} - dev: true + tmpl@1.0.5: {} - /to-fast-properties@2.0.0: - resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} - engines: {node: '>=4'} - dev: true + to-fast-properties@2.0.0: {} - /to-regex-range@5.0.1: - resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} - engines: {node: '>=8.0'} + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 - dev: true - /ts-essentials@10.0.2(typescript@5.4.5): - resolution: {integrity: sha512-Xwag0TULqriaugXqVdDiGZ5wuZpqABZlpwQ2Ho4GDyiu/R2Xjkp/9+zcFxL7uzeLl/QCPrflnvpVYyS3ouT7Zw==} - peerDependencies: - typescript: '>=4.5.0' - peerDependenciesMeta: - typescript: - optional: true + ts-essentials@10.0.2(typescript@5.4.5): dependencies: typescript: 5.4.5 - dev: true - /ts-jest@29.1.2(@babel/core@7.25.2)(jest@29.7.0)(typescript@5.4.5): - resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==} - engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@babel/core': '>=7.0.0-beta.0 <8' - '@jest/types': ^29.0.0 - babel-jest: ^29.0.0 - esbuild: '*' - jest: ^29.0.0 - typescript: '>=4.3 <6' - peerDependenciesMeta: - '@babel/core': - optional: true - '@jest/types': - optional: true - babel-jest: - optional: true - esbuild: - optional: true + ts-jest@29.1.2(@babel/core@7.25.2)(jest@29.7.0)(typescript@5.4.5): dependencies: '@babel/core': 7.25.2 bs-logger: 0.2.6 @@ -2372,127 +2745,65 @@ packages: semver: 7.6.2 typescript: 5.4.5 yargs-parser: 21.1.1 - dev: true - /ts-toolbelt@9.6.0: - resolution: {integrity: sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==} - dev: true + ts-toolbelt@9.6.0: {} - /tslib@2.7.0: - resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==} - dev: true + tslib@2.7.0: {} - /type-detect@4.0.8: - resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} - engines: {node: '>=4'} - dev: true + type-detect@4.0.8: {} - /type-fest@0.21.3: - resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} - engines: {node: '>=10'} - dev: true + type-fest@0.21.3: {} - /types-ramda@0.30.1: - resolution: {integrity: sha512-1HTsf5/QVRmLzcGfldPFvkVsAdi1db1BBKzi7iW3KBUlOICg/nKnFS+jGqDJS3YD8VsWbAh7JiHeBvbsw8RPxA==} + types-ramda@0.30.1: dependencies: ts-toolbelt: 9.6.0 - dev: true - /typescript@5.4.5: - resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} - engines: {node: '>=14.17'} - hasBin: true - dev: true + typescript@5.4.5: {} - /undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - dev: true + undici-types@5.26.5: {} - /update-browserslist-db@1.1.0(browserslist@4.23.3): - resolution: {integrity: sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==} - hasBin: true - peerDependencies: - browserslist: '>= 4.21.0' + update-browserslist-db@1.1.0(browserslist@4.23.3): dependencies: browserslist: 4.23.3 escalade: 3.1.2 picocolors: 1.0.1 - dev: true - /v8-to-istanbul@9.3.0: - resolution: {integrity: sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==} - engines: {node: '>=10.12.0'} + v8-to-istanbul@9.3.0: dependencies: '@jridgewell/trace-mapping': 0.3.25 '@types/istanbul-lib-coverage': 2.0.6 convert-source-map: 2.0.0 - dev: true - /walker@1.0.8: - resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} + walker@1.0.8: dependencies: makeerror: 1.0.12 - dev: true - /which@2.0.2: - resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} - engines: {node: '>= 8'} - hasBin: true + which@2.0.2: dependencies: isexe: 2.0.0 - dev: true - /wrap-ansi@7.0.0: - resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} - engines: {node: '>=10'} + wrap-ansi@7.0.0: dependencies: ansi-styles: 4.3.0 string-width: 4.2.3 strip-ansi: 6.0.1 - dev: true - /wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - dev: true + wrappy@1.0.2: {} - /write-file-atomic@4.0.2: - resolution: {integrity: sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==} - engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + write-file-atomic@4.0.2: dependencies: imurmurhash: 0.1.4 signal-exit: 3.0.7 - dev: true - /ws@8.17.1: - resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==} - engines: {node: '>=10.0.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: '>=5.0.2' - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: true + ws@8.17.1: {} - /y18n@5.0.8: - resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} - engines: {node: '>=10'} - dev: true + y18n@5.0.8: {} - /yallist@3.1.1: - resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} - dev: true + yallist@3.1.1: {} - /yargs-parser@21.1.1: - resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} - engines: {node: '>=12'} - dev: true + yargs-parser@21.1.1: {} - /yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} + yargs@17.7.2: dependencies: cliui: 8.0.1 escalade: 3.1.2 @@ -2501,9 +2812,5 @@ packages: string-width: 4.2.3 y18n: 5.0.8 yargs-parser: 21.1.1 - dev: true - /yocto-queue@0.1.0: - resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} - engines: {node: '>=10'} - dev: true + yocto-queue@0.1.0: {} diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 9198bfc6..a3069b8f 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -3,7 +3,18 @@ import * as matchers from "jest-extended"; import { dumpUploadData, logAxiosError } from "./helpers/log-helper"; import axios, { AxiosError } from "axios"; import { doFullSync, probe, PsEventbusSyncUpload } from "./helpers/mock-probe"; -import { concatMap, from, lastValueFrom, map, TimeoutError, toArray, zip } from "rxjs"; +import { + combineLatest, + concatMap, + expand, + from, + lastValueFrom, + map, + of, + TimeoutError, + toArray, + zip, +} from "rxjs"; import { generatePredictableModuleId, loadFixture, @@ -35,28 +46,28 @@ const isString = (val) => const isNumber = (val) => val ? expect(val).toBeNumber() : expect(val).toBeNull(); const specialFieldAssert: { [index: string]: (val) => void } = { - 'created_at': isDateString, - 'updated_at': isDateString, - 'last_connection_date': isDateString, - 'folder_created_at': isDateString, - 'date_add': isDateString, - 'from': isDateString, - 'to': isDateString, - 'conversion_rate': isNumber, - 'cms_version': isString, - 'module_id': isString, - 'module_version': isString, - 'theme_version': isString, - 'php_version': isString, - 'http_server' : isString, -} - -describe('Full Sync', () => { + created_at: isDateString, + updated_at: isDateString, + last_connection_date: isDateString, + folder_created_at: isDateString, + date_add: isDateString, + from: isDateString, + to: isDateString, + conversion_rate: isNumber, + cms_version: isString, + module_id: isString, + module_version: isString, + theme_version: isString, + php_version: isString, + http_server: isString, +}; + +describe("Full Sync", () => { let generatedNumber = 0; // gérer les cas ou un shopContent n'existe pas (pas de fixture du coup) const shopContents: ShopContent[] = shopContentList.filter( - (it) => !EXCLUDED_API.includes(it) + (it) => !EXCLUDED_API.includes(it), ); let jobId: string; @@ -79,14 +90,14 @@ describe('Full Sync', () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; - const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; + const callId = { call_id: Math.random().toString(36).substring(2, 11) }; // act const response = await axios .post(url, callId, { - headers: { + headers: { Host: testConfig.prestaShopHostHeader, - 'Content-Type': 'application/x-www-form-urlencoded' // for compat PHP 5.6 + "Content-Type": "application/x-www-form-urlencoded", // for compat PHP 5.6 }, }) .catch((err) => { @@ -106,14 +117,14 @@ describe('Full Sync', () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; - const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; + const callId = { call_id: Math.random().toString(36).substring(2, 11) }; // act const response = await axios .post(url, callId, { headers: { Host: testConfig.prestaShopHostHeader, - 'Content-Type': 'application/x-www-form-urlencoded' // for compat PHP 5.6 + "Content-Type": "application/x-www-form-urlencoded", // for compat PHP 5.6 }, }) .catch((err) => { @@ -139,16 +150,16 @@ describe('Full Sync', () => { const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const message$ = probe({ url: `/upload/${jobId}` }); - const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; + const callId = { call_id: Math.random().toString(36).substring(2, 11) }; // act const request$ = from( axios.post(url, callId, { headers: { Host: testConfig.prestaShopHostHeader, - 'Content-Type': 'application/x-www-form-urlencoded' // for compat PHP 5.6 + "Content-Type": "application/x-www-form-urlencoded", // for compat PHP 5.6 }, - }) + }), ); // check if shopcontent have items lenght > 0 @@ -163,15 +174,17 @@ describe('Full Sync', () => { probeMessage: result[0], psEventbusReq: result[1], })), - toArray() - ) + toArray(), + ), ); } catch (error) { if (error instanceof TimeoutError) { - throw new Error(`Upload to collector for "${shopContent}" throw TimeoutError with jobId "${jobId}"`) - } + throw new Error( + `Upload to collector for "${shopContent}" throw TimeoutError with jobId "${jobId}"`, + ); + } } - + // assert expect(results.length).toEqual(1); expect(results[0].probeMessage.method).toBe("POST"); @@ -179,48 +192,31 @@ describe('Full Sync', () => { "full-sync-requested": "1", }); } - }) + }); }); } - if (MISSING_TEST_DATA.includes(shopContent)) { it.skip(`${shopContent} should upload complete dataset to collector`, () => {}); } else { - it(`${shopContent} should upload complete dataset collector`, async () => { + it.skip(`${shopContent} should upload complete dataset collector`, async () => { // arrange const fullSync$ = doFullSync(jobId, shopContent, { timeout: 4000 }); const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); - + let syncedData: PsEventbusSyncUpload[]; - let hasData = false; - - try { - // act - hasData = (await lastValueFrom(fullSync$)).total_objects != 0; - - if (hasData) { - syncedData = await lastValueFrom( - zip(fullSync$, message$).pipe( - map((msg) => { - return msg[1].body.file - }), - concatMap((syncedPage) => { - return from(syncedPage); - }), - toArray() - ) - ); - } - } catch (error) { - if (error instanceof TimeoutError) { - throw new Error(`Upload complete dataset collector for "${shopContent}" throw TimeoutError with jobId "${jobId}"`) - } - } - if (!hasData) { - return; - } + const [reponse, message] = await lastValueFrom( + combineLatest([ + fullSync$, + message$.pipe( + map((msg) => msg.body.file), + toArray(), + ), + ]), + ); + + syncedData = message.flat(); // dump data for easier debugging or updating fixtures if (testConfig.dumpFullSyncData) { @@ -232,18 +228,18 @@ describe('Full Sync', () => { // we need to process fixtures and data returned from ps_eventbus to make them easier to compare let processedData = syncedData; let processedFixture = fixture; - if (shopContent === "modules" as ShopContent) { + if (shopContent === ("modules" as ShopContent)) { processedData = generatePredictableModuleId(processedData); processedFixture = generatePredictableModuleId(processedFixture); } processedData = omitProperties( processedData, - Object.keys(specialFieldAssert) + Object.keys(specialFieldAssert), ); processedData = sortUploadData(processedData); processedFixture = omitProperties( processedFixture, - Object.keys(specialFieldAssert) + Object.keys(specialFieldAssert), ); processedFixture = sortUploadData(processedFixture); @@ -255,7 +251,7 @@ describe('Full Sync', () => { for (const specialFieldName of Object.keys(specialFieldAssert)) { if (data.properties[specialFieldName] !== undefined) { specialFieldAssert[specialFieldName]( - data.properties[specialFieldName] + data.properties[specialFieldName], ); } } diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index 645c2ff4..51f89d8a 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -1,23 +1,28 @@ -import WebSocket from 'ws'; -import {WebSocketSubject} from "rxjs/webSocket"; +import WebSocket from "ws"; +import { WebSocketSubject } from "rxjs/webSocket"; import { EMPTY, expand, - filter, firstValueFrom, + filter, + firstValueFrom, from, map, - Observable, take, - tap, throwIfEmpty, - timeout + Observable, + take, + takeUntil, + tap, + throwIfEmpty, + timeout, + timer, } from "rxjs"; -import R from 'ramda'; +import R from "ramda"; import testConfig from "./test.config"; import axios from "axios"; -import {ShopContent} from "./shop-contents"; -import {anyBoolean} from "jest-mock-extended"; +import { ShopContent } from "./shop-contents"; +import { anyBoolean } from "jest-mock-extended"; const DEFAULT_OPTIONS = { - timeout: 3000 + timeout: 3000, }; export type MockProbeOptions = typeof DEFAULT_OPTIONS; @@ -31,76 +36,90 @@ if (!global.WebSocket) { let wsConnection: Observable = null; function getProbeSocket(): Observable { if (!wsConnection) { - wsConnection = new WebSocketSubject('ws://localhost:8080'); + wsConnection = new WebSocketSubject( + "ws://localhost:8080", + ); } return wsConnection; } -export type MockProbeResponse = { - apiName: string, - method: string, - headers: Record, - url: string, - query: Record, - params: Record, - body: Record & { file: any[] } -} - -export function probe(match?: Partial, options?: MockProbeOptions): Observable { +export function probe( + match?: Partial, + options?: MockProbeOptions, +): Observable { options = R.mergeLeft(options, DEFAULT_OPTIONS); const socket = getProbeSocket(); return socket.pipe( - filter(message => match ? R.whereEq(match, message) : true), - timeout(options.timeout), - ) + filter((message) => (match ? R.whereEq(match, message) : true)), + takeUntil(timer(options.timeout)), + ); } export type PsEventbusSyncResponse = { - job_id: string, - object_type: string, - syncType: string, // 'full' | 'incremental' - total_objects: number, // may not always be accurate, can't be relied on - has_remaining_objects: boolean, // reliable - remaining_objects: number, // may not always be accurate, can't be relied on - md5: string, - status: boolean, - httpCode: number, - body: unknown, // not sure what this is - upload_url: string, -} + job_id: string; + object_type: string; + syncType: string; // 'full' | 'incremental' + total_objects: number; // may not always be accurate, can't be relied on + has_remaining_objects: boolean; // reliable + remaining_objects: number; // may not always be accurate, can't be relied on + md5: string; + status: boolean; + httpCode: number; + body: unknown; // not sure what this is + upload_url: string; +}; // TODO define collection as type literal -export type Collection = string +export type Collection = string; export type PsEventbusSyncUpload = { - collection: Collection, id: string, properties: any -} + collection: Collection; + id: string; + properties: any; +}; + +export type MockProbeResponse = { + apiName: string; + method: string; + headers: Record; + url: string; + query: Record; + params: Record; + body: Record & { file: PsEventbusSyncUpload[] }; +}; -export function doFullSync(jobId: string, shopContent: ShopContent, options?: MockClientOptions): Observable { +export function doFullSync( + jobId: string, + shopContent: ShopContent, + options?: MockClientOptions, +): Observable { options = R.mergeLeft(options, DEFAULT_OPTIONS); - - const callId = { 'call_id': Math.random().toString(36).substring(2, 11) }; - const requestNext = (full: number) => axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, - callId, - { - headers: { - 'Host': testConfig.prestaShopHostHeader, - 'Content-Type': 'application/x-www-form-urlencoded' // for compat PHP 5.6 - } - }); + const callId = { call_id: Math.random().toString(36).substring(2, 11) }; + + const requestNext = (full: number) => { + return axios.post( + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, + callId, + { + headers: { + Host: testConfig.prestaShopHostHeader, + "Content-Type": "application/x-www-form-urlencoded", // for compat PHP 5.6 + }, + }, + ); + }; return from(requestNext(1)).pipe( - expand(response => { + expand((response) => { if (response.data.has_remaining_objects) { return from(requestNext(0)); } else { - return EMPTY + return EMPTY; } }), timeout(options.timeout), - map(response => response.data) - ) + map((response) => response.data), + ); } diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index a548114c..2c807847 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -34,24 +34,25 @@ import R from "ramda"; } as const; */ export const shopContentMapping = { - 'carriers': 'carriers', - 'carrier_details': 'carrier-details', - 'carrier_taxes': 'carrier-taxes', - 'carts': 'carts', - 'cart_products': 'cart-products', - 'cart_rules': 'cart-rules', - 'orders': 'orders', - 'order_cart_rules': 'order-cart-rules', - 'order_details': 'order-details', - 'order_histories': 'order-histories' + carriers: "carriers", + carrier_details: "carrier-details", + carrier_taxes: "carrier-taxes", + carts: "carts", + cart_products: "cart-products", + cart_rules: "cart-rules", + orders: "orders", + order_cart_rules: "order-cart-rules", + order_details: "order-details", + order_histories: "order-histories", + products: "products", } as const; type ShopContentMapping = typeof shopContentMapping; export type Content = keyof ShopContentMapping; -export const contentList = Object.keys(shopContentMapping) as Content[]; +export const contentList = Object.keys(shopContentMapping) as Content[]; export type ShopContent = ShopContentMapping[Content]; -export const shopContentList = R.uniq(Object.values(shopContentMapping)) as ShopContent[]; - - +export const shopContentList = R.uniq( + Object.values(shopContentMapping), +) as ShopContent[]; diff --git a/src/Repository/NewRepository/AbstractRepository.php b/src/Repository/NewRepository/AbstractRepository.php index a54de804..f79b4b69 100644 --- a/src/Repository/NewRepository/AbstractRepository.php +++ b/src/Repository/NewRepository/AbstractRepository.php @@ -34,17 +34,25 @@ public function __construct() } /** - * @return int + * @return \Context + */ + public function getContext() + { + return $this->context; + } + + /** + * @return \Shop * * @throws \PrestaShopException */ - public function getShopId() + public function getShopContext() { if ($this->context->shop === null) { throw new \PrestaShopException('No shop context'); } - return (int) $this->context->shop->id; + return $this->context->shop; } /** diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index ffb0fd1b..d5bc0491 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -7,27 +7,31 @@ class CarrierRepository extends AbstractRepository implements RepositoryInterfac const TABLE_NAME = 'carrier'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'c'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { $langId = (int) \Language::getIdByIso($langIso); - $this->generateMinimalQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'c'); $this->query ->leftJoin('carrier_lang', 'cl', 'cl.id_carrier = c.id_carrier AND cl.id_lang = ' . $langId) @@ -35,12 +39,14 @@ public function generateFullQuery($langIso) ; $this->query - ->where('cs.id_shop = ' . (int) parent::getShopId()) + ->where('cs.id_shop = ' . (int) parent::getShopContext()->id) ->where('deleted=0') ; - $this->query->select('c.*') - ->select('cl.delay AS delay'); + if ($withSelecParameters) { + $this->query->select('c.*') + ->select('cl.delay AS delay'); + } } /** @@ -54,9 +60,9 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); @@ -74,9 +80,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('c.id_carrier IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -87,17 +93,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(c.id_carrier) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); diff --git a/src/Repository/NewRepository/CartProductRepository.php b/src/Repository/NewRepository/CartProductRepository.php index aa428460..7a0611e9 100644 --- a/src/Repository/NewRepository/CartProductRepository.php +++ b/src/Repository/NewRepository/CartProductRepository.php @@ -7,35 +7,41 @@ class CartProductRepository extends AbstractRepository implements RepositoryInte const TABLE_NAME = 'cart_product'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'cp'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { - $this->generateMinimalQuery(); - - $this->query->where('cp.id_shop = ' . (int) parent::getShopId()); - - $this->query - ->select('cp.id_cart') - ->select('cp.id_product') - ->select('cp.id_product_attribute') - ->select('cp.quantity') - ->select('cp.date_add as created_at') - ; + $this->generateMinimalQuery(self::TABLE_NAME, 'cp'); + + $this->query->where('cp.id_shop = ' . (int) parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('cp.id_cart') + ->select('cp.id_product') + ->select('cp.id_product_attribute') + ->select('cp.quantity') + ->select('cp.date_add as created_at') + ; + } } /** @@ -49,9 +55,9 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); @@ -69,9 +75,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('cp.id_cart IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -83,17 +89,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(cp.id_cart) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); diff --git a/src/Repository/NewRepository/CartRepository.php b/src/Repository/NewRepository/CartRepository.php index f72bc3ec..86618779 100644 --- a/src/Repository/NewRepository/CartRepository.php +++ b/src/Repository/NewRepository/CartRepository.php @@ -7,33 +7,39 @@ class CartRepository extends AbstractRepository implements RepositoryInterface const TABLE_NAME = 'cart'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'c'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { - $this->generateMinimalQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'c'); - $this->query->where('c.id_shop = ' . (int) parent::getShopId()); + $this->query->where('c.id_shop = ' . (int) parent::getShopContext()->id); - $this->query - ->select('c.id_cart') - ->select('date_add as created_at') - ->select('date_upd as updated_at') - ; + if ($withSelecParameters) { + $this->query + ->select('c.id_cart') + ->select('date_add as created_at') + ->select('date_upd as updated_at') + ; + } } /** @@ -47,9 +53,9 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); @@ -67,9 +73,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('c.id_cart IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -81,17 +87,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(c.id_cart) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); diff --git a/src/Repository/NewRepository/CartRuleRepository.php b/src/Repository/NewRepository/CartRuleRepository.php index 48d63d7b..ae2e66ee 100644 --- a/src/Repository/NewRepository/CartRuleRepository.php +++ b/src/Repository/NewRepository/CartRuleRepository.php @@ -7,63 +7,69 @@ class CartRuleRepository extends AbstractRepository implements RepositoryInterfa const TABLE_NAME = 'cart_rule'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'cr'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { - $this->generateMinimalQuery(); - - $this->query - ->select('cr.id_cart_rule') - ->select('cr.id_customer') - ->select('cr.code') - ->select('cr.date_from AS "from"') - ->select('cr.date_to AS "to"') - ->select('cr.description') - ->select('cr.quantity') - ->select('cr.quantity_per_user') - ->select('cr.priority') - ->select('cr.partial_use') - ->select('cr.minimum_amount') - ->select('cr.minimum_amount_tax') - ->select('cr.minimum_amount_currency') - ->select('cr.minimum_amount_shipping') - ->select('cr.country_restriction') - ->select('cr.carrier_restriction') - ->select('cr.group_restriction') - ->select('cr.cart_rule_restriction') - ->select('cr.product_restriction') - ->select('cr.shop_restriction') - ->select('cr.free_shipping') - ->select('cr.reduction_percent') - ->select('cr.reduction_amount') - ->select('cr.reduction_tax') - ->select('cr.reduction_currency') - ->select('cr.reduction_product') - ->select('cr.gift_product') - ->select('cr.gift_product_attribute') - ->select('cr.highlight') - ->select('cr.active') - ->select('cr.date_add AS created_at') - ->select('cr.date_upd AS updated_at') - ; - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $this->query->select('cr.reduction_exclude_special'); + $this->generateMinimalQuery(self::TABLE_NAME, 'cr'); + + if ($withSelecParameters) { + $this->query + ->select('cr.id_cart_rule') + ->select('cr.id_customer') + ->select('cr.code') + ->select('cr.date_from AS "from"') + ->select('cr.date_to AS "to"') + ->select('cr.description') + ->select('cr.quantity') + ->select('cr.quantity_per_user') + ->select('cr.priority') + ->select('cr.partial_use') + ->select('cr.minimum_amount') + ->select('cr.minimum_amount_tax') + ->select('cr.minimum_amount_currency') + ->select('cr.minimum_amount_shipping') + ->select('cr.country_restriction') + ->select('cr.carrier_restriction') + ->select('cr.group_restriction') + ->select('cr.cart_rule_restriction') + ->select('cr.product_restriction') + ->select('cr.shop_restriction') + ->select('cr.free_shipping') + ->select('cr.reduction_percent') + ->select('cr.reduction_amount') + ->select('cr.reduction_tax') + ->select('cr.reduction_currency') + ->select('cr.reduction_product') + ->select('cr.gift_product') + ->select('cr.gift_product_attribute') + ->select('cr.highlight') + ->select('cr.active') + ->select('cr.date_add AS created_at') + ->select('cr.date_upd AS updated_at') + ; + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { + $this->query->select('cr.reduction_exclude_special'); + } } } @@ -78,9 +84,9 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); @@ -98,9 +104,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('cr.id_cart_rule IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -112,17 +118,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(cr.id_cart_rule) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/NewRepository/OrderCartRuleRepository.php index 57817572..b9673c55 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/NewRepository/OrderCartRuleRepository.php @@ -7,38 +7,44 @@ class OrderCartRuleRepository extends AbstractRepository implements RepositoryIn const TABLE_NAME = 'order_cart_rule'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'ocr'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { - $this->generateMinimalQuery(); - - $this->query - ->select('ocr.id_order_cart_rule') - ->select('ocr.id_order') - ->select('ocr.id_cart_rule') - ->select('ocr.id_order_invoice') - ->select('ocr.name') - ->select('ocr.value') - ->select('ocr.value_tax_excl') - ->select('ocr.free_shipping'); - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.7.0', '>=')) { - $this->query->select('ocr.deleted'); + $this->generateMinimalQuery(self::TABLE_NAME, 'ocr'); + + if ($withSelecParameters) { + $this->query + ->select('ocr.id_order_cart_rule') + ->select('ocr.id_order') + ->select('ocr.id_cart_rule') + ->select('ocr.id_order_invoice') + ->select('ocr.name') + ->select('ocr.value') + ->select('ocr.value_tax_excl') + ->select('ocr.free_shipping'); + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.7.0', '>=')) { + $this->query->select('ocr.deleted'); + } } } @@ -53,9 +59,9 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); @@ -73,9 +79,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('ocr.id_order_cart_rule IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -86,17 +92,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(ocr.id_order_cart_rule) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php index ef5b5a6b..9fd6562a 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -7,23 +7,27 @@ class OrderDetailRepository extends AbstractRepository implements RepositoryInte const TABLE_NAME = 'order_detail'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'od'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { $context = \Context::getContext(); @@ -35,7 +39,7 @@ public function generateFullQuery($langIso) throw new \PrestaShopException('No shop context'); } - $this->generateMinimalQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'od'); $this->query ->where('od.id_shop = ' . $context->shop->id) @@ -44,24 +48,25 @@ public function generateFullQuery($langIso) ->leftJoin('product_shop', 'ps', 'od.product_id = ps.id_product AND ps.id_shop = ' . (int) $context->shop->id) ->leftJoin('currency', 'c', 'c.id_currency = o.id_currency') ->leftJoin('lang', 'l', 'o.id_lang = l.id_lang') - ->groupBy('od.id_order_detail') ; - $this->query - ->select('od.id_order_detail') - ->select('od.id_order') - ->select('od.product_id') - ->select('od.product_attribute_id') - ->select('od.product_quantity') - ->select('od.unit_price_tax_incl') - ->select('od.unit_price_tax_excl') - ->select('SUM(osd.total_price_tax_incl) as refund') - ->select('SUM(osd.total_price_tax_excl) as refund_tax_excl') - ->select('c.iso_code as currency') - ->select('ps.id_category_default as category') - ->select('l.iso_code') - ->select('o.conversion_rate as conversion_rate') - ; + if ($withSelecParameters) { + $this->query + ->select('od.id_order_detail') + ->select('od.id_order') + ->select('od.product_id') + ->select('od.product_attribute_id') + ->select('od.product_quantity') + ->select('od.unit_price_tax_incl') + ->select('od.unit_price_tax_excl') + ->select('SUM(osd.total_price_tax_incl) as refund') + ->select('SUM(osd.total_price_tax_excl) as refund_tax_excl') + ->select('c.iso_code as currency') + ->select('ps.id_category_default as category') + ->select('l.iso_code') + ->select('o.conversion_rate as conversion_rate') + ; + } } /** @@ -75,9 +80,11 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); + + $this->query->groupBy('od.id_order_detail'); $this->query->limit((int) $limit, (int) $offset); @@ -95,9 +102,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('od.id_order_detail IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -109,17 +116,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(od.id_order_detail) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php index 1ee496fa..a5f32a27 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -7,46 +7,52 @@ class OrderHistoryRepository extends AbstractRepository implements RepositoryInt const TABLE_NAME = 'order_history'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'oh'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { $langId = (int) \Language::getIdByIso($langIso); - $this->generateMinimalQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'oh'); $this->query ->innerJoin('order_state', 'os', 'os.id_order_state = oh.id_order_State') ->innerJoin('order_state_lang', 'osl', 'osl.id_order_state = os.id_order_State AND osl.id_lang = ' . (int) $langId) ; - $this->query - ->select('oh.id_order_state') - ->select('osl.name') - ->select('osl.template') - ->select('oh.date_add') - ->select('oh.id_order') - ->select('oh.id_order_history') - ->select('os.logable AS is_validated') - ->select('os.delivery AS is_delivered') - ->select('os.shipped AS is_shipped') - ->select('os.paid AS is_paid') - ->select('os.deleted AS is_deleted') - ; + if ($withSelecParameters) { + $this->query + ->select('oh.id_order_state') + ->select('osl.name') + ->select('osl.template') + ->select('oh.date_add') + ->select('oh.id_order') + ->select('oh.id_order_history') + ->select('os.logable AS is_validated') + ->select('os.delivery AS is_delivered') + ->select('os.shipped AS is_shipped') + ->select('os.paid AS is_paid') + ->select('os.deleted AS is_deleted') + ; + } } /** @@ -60,9 +66,9 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); @@ -80,9 +86,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('oh.id_order_state IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -94,17 +100,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(oh.id_order_state) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); @@ -126,7 +134,7 @@ public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $debug) return []; } - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query->where('oh.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')'); diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php index a8de0203..96724d9f 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -7,25 +7,29 @@ class OrderRepository extends AbstractRepository implements RepositoryInterface const TABLE_NAME = 'orders'; /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery() + public function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); - $this->query->from(self::TABLE_NAME, 'o'); + $this->query->from($tableName, $alias); } /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed * * @throws \PrestaShopException */ - public function generateFullQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { - $this->generateMinimalQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'o'); $this->query ->leftJoin('currency', 'c', 'o.id_currency = c.id_currency') @@ -36,62 +40,63 @@ public function generateFullQuery($langIso) ->leftJoin('country', 'cnti', 'cnti.id_country = ai.id_country') ->leftJoin('order_state_lang', 'osl', 'o.current_state = osl.id_order_state') ->leftJoin('order_state', 'ost', 'o.current_state = ost.id_order_state') - ->where('o.id_shop = ' . (int) parent::getShopId()) - ->groupBy('o.id_order') + ->where('o.id_shop = ' . (int) parent::getShopContext()->id) ; - $this->query - ->select('o.id_order') - ->select('o.reference') - ->select('o.id_customer') - ->select('o.id_cart') - ->select('o.current_state') - ->select('o.conversion_rate') - ->select('o.total_paid_tax_excl') - ->select('o.total_paid_tax_incl') - ->select('c.iso_code as currency') - ->select('o.module as payment_module') - ->select('o.payment as payment_mode') - ->select('o.total_paid_real') - ->select('o.total_shipping as shipping_cost') - ->select('o.date_add as created_at') - ->select('o.date_upd as updated_at') - ->select('o.id_carrier') - ->select('o.payment as payment_name') - ->select('o.valid as is_validated') - ->select('ost.paid as is_paid') - ->select('ost.shipped as is_shipped') - ->select('osl.name as status_label') - ->select('o.module as payment_name') - ->select('o.id_shop_group') - ->select('o.id_shop') - ->select('o.id_lang') - ->select('o.id_currency') - ->select('o.recyclable') - ->select('o.gift') - ->select('o.total_discounts') - ->select('o.total_discounts_tax_incl') - ->select('o.total_discounts_tax_excl') - ->select('o.total_products') - ->select('o.total_products_wt') - ->select('o.total_shipping_tax_incl') - ->select('o.total_shipping_tax_excl') - ->select('o.carrier_tax_rate') - ->select('o.total_wrapping') - ->select('o.total_wrapping_tax_incl') - ->select('o.total_wrapping_tax_excl') - ->select('o.round_mode') - ->select('o.round_type') - ->select('o.invoice_number') - ->select('o.delivery_number') - ->select('o.invoice_date') - ->select('o.delivery_date') - ->select('o.valid') - ->select('SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund') - ->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl') - ->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso') - ->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer') - ; + if ($withSelecParameters) { + $this->query + ->select('o.id_order') + ->select('o.reference') + ->select('o.id_customer') + ->select('o.id_cart') + ->select('o.current_state') + ->select('o.conversion_rate') + ->select('o.total_paid_tax_excl') + ->select('o.total_paid_tax_incl') + ->select('c.iso_code as currency') + ->select('o.module as payment_module') + ->select('o.payment as payment_mode') + ->select('o.total_paid_real') + ->select('o.total_shipping as shipping_cost') + ->select('o.date_add as created_at') + ->select('o.date_upd as updated_at') + ->select('o.id_carrier') + ->select('o.payment as payment_name') + ->select('o.valid as is_validated') + ->select('ost.paid as is_paid') + ->select('ost.shipped as is_shipped') + ->select('osl.name as status_label') + ->select('o.module as payment_name') + ->select('o.id_shop_group') + ->select('o.id_shop') + ->select('o.id_lang') + ->select('o.id_currency') + ->select('o.recyclable') + ->select('o.gift') + ->select('o.total_discounts') + ->select('o.total_discounts_tax_incl') + ->select('o.total_discounts_tax_excl') + ->select('o.total_products') + ->select('o.total_products_wt') + ->select('o.total_shipping_tax_incl') + ->select('o.total_shipping_tax_excl') + ->select('o.carrier_tax_rate') + ->select('o.total_wrapping') + ->select('o.total_wrapping_tax_incl') + ->select('o.total_wrapping_tax_excl') + ->select('o.round_mode') + ->select('o.round_type') + ->select('o.invoice_number') + ->select('o.delivery_number') + ->select('o.invoice_date') + ->select('o.delivery_date') + ->select('o.valid') + ->select('SUM(os.total_products_tax_incl + os.total_shipping_tax_incl) as refund') + ->select('SUM(os.total_products_tax_excl + os.total_shipping_tax_excl) as refund_tax_excl') + ->select('CONCAT(CONCAT("delivery", ":", cntd.iso_code), ",", CONCAT("invoice", ":", cnti.iso_code)) as address_iso') + ->select('IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = o.id_customer AND so.id_order < o.id_order LIMIT 1) > 0, 0, 1) as new_customer') + ; + } } /** @@ -105,9 +110,11 @@ public function generateFullQuery($langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); + + $this->query->groupBy('o.id_order'); $this->query->limit((int) $limit, (int) $offset); @@ -125,9 +132,9 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $this->generateFullQuery($langIso); + $this->generateFullQuery($langIso, true); $this->query ->where('o.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') @@ -139,17 +146,19 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $this->generateMinimalQuery(); + $this->generateFullQuery($langIso, false); - $this->query->select('(COUNT(o.id_order) - ' . (int) $offset . ') as count'); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); $result = $this->runQuery(false); diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/NewRepository/ProductRepository.php new file mode 100644 index 00000000..af8415f1 --- /dev/null +++ b/src/Repository/NewRepository/ProductRepository.php @@ -0,0 +1,299 @@ +query = new \DbQuery(); + + $this->query->from($tableName, $alias); + } + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $shopIdGroup = (int) parent::getShopContext()->id_shop_group; + $langId = (int) \Language::getIdByIso($langIso); + + // WTF IS THAT ? + if (!parent::getContext()->employee instanceof \Employee) { + if (($employees = \Employee::getEmployees()) !== false) { + parent::getContext()->employee = new \Employee($employees[0]['id_employee']); + } + } + + $this->generateMinimalQuery(self::TABLE_NAME, 'p'); + + $this->query + ->innerJoin('product_shop', 'ps', 'ps.id_product = p.id_product AND ps.id_shop = ' . parent::getShopContext()->id) + ->innerJoin('product_lang', 'pl', 'pl.id_product = ps.id_product AND pl.id_shop = ps.id_shop AND pl.id_lang = ' . $langId) + ->leftJoin('product_attribute_shop', 'pas', 'pas.id_product = p.id_product AND pas.id_shop = ps.id_shop') + ->leftJoin('product_attribute', 'pa', 'pas.id_product_attribute = pa.id_product_attribute') + ->leftJoin('category_lang', 'cl', 'ps.id_category_default = cl.id_category AND ps.id_shop = cl.id_shop AND cl.id_lang = ' . $langId) + ->leftJoin('manufacturer', 'm', 'p.id_manufacturer = m.id_manufacturer'); + + if (parent::getShopContext()->getGroup()->share_stock) { + $this->query->leftJoin( + 'stock_available', + 'sa', + 'sa.id_product = p.id_product AND sa.id_product_attribute = IFNULL(pas.id_product_attribute, 0) AND sa.id_shop_group = ' . $shopIdGroup) + ; + } else { + $this->query->leftJoin( + 'stock_available', + 'sa', + 'sa.id_product = p.id_product AND sa.id_product_attribute = IFNULL(pas.id_product_attribute, 0) AND sa.id_shop = ps.id_shop') + ; + } + + if ($withSelecParameters) { + $this->query + ->select('p.id_product') + ->select('p.id_manufacturer') + ->select('p.id_supplier') + ->select('IFNULL(pas.id_product_attribute, 0) as id_attribute') + ->select('pas.default_on as is_default_attribute') + ->select('pl.name') + ->select('pl.description') + ->select('pl.description_short') + ->select('pl.link_rewrite') + ->select('cl.name as default_category') + ->select('ps.id_category_default') + ->select('IFNULL(NULLIF(pa.reference, ""), p.reference) as reference') + ->select('IFNULL(NULLIF(pa.upc, ""), p.upc) as upc') + ->select('IFNULL(NULLIF(pa.ean13, ""), p.ean13) as ean') + ->select('ps.condition') + ->select('ps.visibility') + ->select('ps.active') + ->select('sa.quantity') + ->select('m.name as manufacturer') + ->select('(p.weight + IFNULL(pas.weight, 0)) as weight') + ->select('(ps.price + IFNULL(pas.price, 0)) as price_tax_excl') + ->select('p.date_add as created_at') + ->select('p.date_upd as updated_at') + ->select('p.available_for_order') + ->select('p.available_date') + ->select('p.cache_is_pack as is_bundle') + ->select('p.is_virtual') + ->select('p.unity') + ->select('p.unit_price_ratio') + ->select('p.width') + ->select('p.height') + ->select('p.depth') + ->select('p.additional_shipping_cost'); + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { + $this->query->select('IFNULL(NULLIF(pa.isbn, ""), p.isbn) as isbn'); + } + + // https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.3.0', '>=')) { + $this->query + ->select('p.additional_delivery_times') + ->select('pl.delivery_in_stock') + ->select('pl.delivery_out_stock') + ; + } + + // https://github.com/PrestaShop/PrestaShop/commit/75fcc335a85c4e3acb2444ef9584590a59fc2d62#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R1615 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.7.0', '>=')) { + $this->query->select('p.mpn'); + } + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('p.id_product IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } + + /** + * @param array $attributeIds + * @param string $langIso + * + * @return array + * + * @throws \PrestaShopDatabaseException + */ + public function getProductAttributeValues($attributeIds, $langIso) + { + $langId = (int) \Language::getIdByIso($langIso); + + $this->generateMinimalQuery('product_attribute_shop', 'pas'); + + $this->query + ->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pas.id_product_attribute') + ->leftJoin('attribute', 'a', 'a.id_attribute = pac.id_attribute') + ->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = a.id_attribute_group AND agl.id_lang = ' . $langId) + ->leftJoin('attribute_lang', 'al', 'al.id_attribute = pac.id_attribute AND al.id_lang = agl.id_lang') + ->where('pas.id_product_attribute IN (' . implode(',', array_map('intval', $attributeIds)) . ') AND pas.id_shop = ' . parent::getShopContext()->id) + ; + + $this->query + ->select('pas.id_product_attribute, agl.name as name, al.name as value') + ->select('agl.name as name') + ->select('al.name as value') + ; + + $attributes = $this->runQuery(false); + + return array_reduce($attributes, function ($key, $attribute) { + return $attribute[$attribute['id_product_attribute']][$attribute['name']] = $attribute['value']; + }); + } + + /** + * @param array $productIds + * @param string $langIso + * + * @return array + * + * @throws \PrestaShopDatabaseException + */ + public function getProductFeatures($productIds, $langIso) + { + $langId = (int) \Language::getIdByIso($langIso); + + $this->generateMinimalQuery('feature_product', 'fp'); + + $this->query + ->leftJoin('feature_lang', 'fl', 'fl.id_feature = fp.id_feature AND fl.id_lang = ' . $langId) + ->leftJoin('feature_value_lang', 'fvl', 'fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = fl.id_lang') + ->where('fp.id_product IN (' . implode(',', array_map('intval', $productIds)) . ')') + ; + + $this->query + ->select('fp.id_product') + ->select('fl.name') + ->select('fvl.value') + ; + + $features = $this->runQuery(false); + + return array_reduce($features, function ($key, $feature) { + return $feature[$feature['id_product']][$feature['name']] = $feature['value']; + }); + } + + /** + * @param array $productIds + * + * @return array + * + * @throws \PrestaShopDatabaseException + */ + public function getProductImages($productIds) + { + $this->generateMinimalQuery('image_shop', 'imgs'); + + $this->query + ->where('imgs.id_shop = ' . parent::getShopContext()->id . ' AND imgs.id_product IN (' . implode(',', array_map('intval', $productIds)) . ')'); + + $this->query + ->select('imgs.id_product, imgs.id_image, IFNULL(imgs.cover, 0) as cover') + ->select('imgs.id_image') + ->select('IFNULL(imgs.cover, 0) as cover') + ; + + return $this->runQuery(false); + } + + /** + * @param array $attributeIds + * + * @return array + * + * @throws \PrestaShopDatabaseException + */ + public function getAttributeImages($attributeIds) + { + $this->generateMinimalQuery('product_attribute_image', 'pai'); + + $this->query + ->where('pai.id_product_attribute IN (' . implode(',', array_map('intval', $attributeIds)) . ')') + ; + + $this->query + ->select('id_product_attribute, id_image') + ->select('id_image') + ; + + return $this->runQuery(false); + } +} diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php index 7316228d..39a84941 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -8,16 +8,20 @@ interface RepositoryInterface { /** + * @param string $tableName + * @param string $alias + * * @return void */ - public function generateMinimalQuery(); + public function generateMinimalQuery($tableName, $alias); /** * @param string $langIso + * @param bool $withSelecParameters * * @return mixed */ - public function generateFullQuery($langIso); + public function generateFullQuery($langIso, $withSelecParameters); /** * @param int $offset @@ -27,7 +31,7 @@ public function generateFullQuery($langIso); * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug); + public function retrieveContentsForFull($offset, $limit, $langIso, $debug); /** * @param int $limit @@ -37,12 +41,17 @@ public function getContentsForFull($offset, $limit, $langIso, $debug); * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug); + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); /** * @param int $offset + * @param int $limit + * @param string $langIso * * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException */ - public function countFullSyncContentLeft($offset); + public function countFullSyncContentLeft($offset, $limit, $langIso); } diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php deleted file mode 100644 index 1da42b6d..00000000 --- a/src/Repository/ProductRepository.php +++ /dev/null @@ -1,360 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - - if (!$this->context->employee instanceof \Employee) { - if (($employees = \Employee::getEmployees()) !== false) { - $this->context->employee = new \Employee($employees[0]['id_employee']); - } - } - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - - /** - * @param int $langId - * - * @return \DbQuery - */ - private function getBaseQuery($langId) - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopIdGroup = (int) $this->context->shop->id_shop_group; - - $query = new \DbQuery(); - - $query->from('product', 'p') - ->innerJoin('product_shop', 'ps', 'ps.id_product = p.id_product AND ps.id_shop = ' . $this->shopId) - ->innerJoin('product_lang', 'pl', 'pl.id_product = ps.id_product AND pl.id_shop = ps.id_shop AND pl.id_lang = ' . (int) $langId) - ->leftJoin('product_attribute_shop', 'pas', 'pas.id_product = p.id_product AND pas.id_shop = ps.id_shop') - ->leftJoin('product_attribute', 'pa', 'pas.id_product_attribute = pa.id_product_attribute') - ->leftJoin('category_lang', 'cl', 'ps.id_category_default = cl.id_category AND ps.id_shop = cl.id_shop AND cl.id_lang = ' . (int) $langId) - ->leftJoin('manufacturer', 'm', 'p.id_manufacturer = m.id_manufacturer'); - - if ($this->context->shop->getGroup()->share_stock) { - $query->leftJoin('stock_available', 'sa', 'sa.id_product = p.id_product AND - sa.id_product_attribute = IFNULL(pas.id_product_attribute, 0) AND sa.id_shop_group = ' . $shopIdGroup); - } else { - $query->leftJoin('stock_available', 'sa', 'sa.id_product = p.id_product AND - sa.id_product_attribute = IFNULL(pas.id_product_attribute, 0) AND sa.id_shop = ps.id_shop'); - } - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * @param int $langId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getProducts($offset, $limit, $langId) - { - $query = $this->getBaseQuery($langId); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * @param int $langId - * - * @return int - * - * @throws \PrestaShopDatabaseException - */ - public function getRemainingProductsCount($offset, $langId) - { - $products = $this->getProducts($offset, 1, $langId); - - if (!is_array($products) || empty($products)) { - return 0; - } - - return count($products); - } - - /** - * @param array $attributeIds - * @param int $langId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getProductAttributeValues($attributeIds, $langId) - { - if (!$attributeIds) { - return []; - } - $query = new \DbQuery(); - - $query->select('pas.id_product_attribute, agl.name as name, al.name as value') - ->from('product_attribute_shop', 'pas') - ->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pas.id_product_attribute') - ->leftJoin('attribute', 'a', 'a.id_attribute = pac.id_attribute') - ->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = a.id_attribute_group AND agl.id_lang = ' . (int) $langId) - ->leftJoin('attribute_lang', 'al', 'al.id_attribute = pac.id_attribute AND al.id_lang = agl.id_lang') - ->where('pas.id_product_attribute IN (' . implode(',', array_map('intval', $attributeIds)) . ') AND pas.id_shop = ' . $this->shopId); - - $attributes = $this->db->executeS($query); - - if (is_array($attributes)) { - $resultArray = []; - - foreach ($attributes as $attribute) { - $resultArray[$attribute['id_product_attribute']][$attribute['name']] = $attribute['value']; - } - - return $resultArray; - } - - return []; - } - - /** - * @param array $productIds - * @param int $langId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getProductFeatures($productIds, $langId) - { - if (!$productIds) { - return []; - } - - $query = new \DbQuery(); - - $query->select('fp.id_product, fl.name, fvl.value') - ->from('feature_product', 'fp') - ->leftJoin('feature_lang', 'fl', 'fl.id_feature = fp.id_feature AND fl.id_lang = ' . (int) $langId) - ->leftJoin('feature_value_lang', 'fvl', 'fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = fl.id_lang') - ->where('fp.id_product IN (' . implode(',', array_map('intval', $productIds)) . ')'); - - $features = $this->db->executeS($query); - - if (is_array($features)) { - $resultArray = []; - - foreach ($features as $feature) { - $resultArray[$feature['id_product']][$feature['name']] = $feature['value']; - } - - return $resultArray; - } - - return []; - } - - /** - * @param array $productIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getProductImages($productIds) - { - if (!$productIds) { - return []; - } - - $query = new \DbQuery(); - - $query->select('imgs.id_product, imgs.id_image, IFNULL(imgs.cover, 0) as cover') - ->from('image_shop', 'imgs') - ->where('imgs.id_shop = ' . $this->shopId . ' AND imgs.id_product IN (' . implode(',', array_map('intval', $productIds)) . ')'); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param array $attributeIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getAttributeImages($attributeIds) - { - if (!$attributeIds) { - return []; - } - $query = new \DbQuery(); - - $query->select('id_product_attribute, id_image') - ->from('product_attribute_image', 'pai') - ->where('pai.id_product_attribute IN (' . implode(',', array_map('intval', $attributeIds)) . ')'); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $productId - * @param int $attributeId - * - * @return float|null - */ - public function getPriceTaxExcluded($productId, $attributeId) - { - return \Product::getPriceStatic($productId, false, $attributeId, 6, null, false, false); - } - - /** - * @param int $productId - * @param int $attributeId - * - * @return float|null - */ - public function getPriceTaxIncluded($productId, $attributeId) - { - return \Product::getPriceStatic($productId, true, $attributeId, 6, null, false, false); - } - - /** - * @param int $productId - * @param int $attributeId - * - * @return float|null - */ - public function getSalePriceTaxExcluded($productId, $attributeId) - { - return \Product::getPriceStatic($productId, false, $attributeId, 6); - } - - /** - * @param int $productId - * @param int $attributeId - * - * @return float|null - */ - public function getSalePriceTaxIncluded($productId, $attributeId) - { - return \Product::getPriceStatic($productId, true, $attributeId, 6); - } - - /** - * @param int $limit - * @param int $langId - * @param array $productIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getProductsIncremental($limit, $langId, $productIds) - { - $query = $this->getBaseQuery($langId); - - $this->addSelectParameters($query); - - $query->where('p.id_product IN(' . implode(',', array_map('intval', $productIds)) . ')') - ->limit($limit); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * @param int $limit - * @param int $langId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langId) - { - $query = $this->getBaseQuery($langId); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('p.id_product, p.id_manufacturer, p.id_supplier, IFNULL(pas.id_product_attribute, 0) as id_attribute, pas.default_on as is_default_attribute'); - $query->select('pl.name, pl.description, pl.description_short, pl.link_rewrite, cl.name as default_category'); - $query->select('ps.id_category_default, IFNULL(NULLIF(pa.reference, ""), p.reference) as reference, IFNULL(NULLIF(pa.upc, ""), p.upc) as upc'); - $query->select('IFNULL(NULLIF(pa.ean13, ""), p.ean13) as ean, ps.condition, ps.visibility, ps.active, sa.quantity, m.name as manufacturer'); - $query->select('(p.weight + IFNULL(pas.weight, 0)) as weight, (ps.price + IFNULL(pas.price, 0)) as price_tax_excl'); - $query->select('p.date_add as created_at, p.date_upd as updated_at'); - $query->select('p.available_for_order, p.available_date, p.cache_is_pack as is_bundle, p.is_virtual'); - $query->select('p.unity, p.unit_price_ratio'); - - if (property_exists(new \Product(), 'mpn')) { - $query->select('p.mpn'); - } - - // https://github.com/PrestaShop/PrestaShop/commit/10268af8db4163dc2a02edb8da93d02f37f814d8#diff-e94a594ba740485c7a4882b333984d3932a2f99c0d6d0005620745087cce7a10R260 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.3.0', '>=')) { - $query->select('p.additional_delivery_times'); - $query->select('pl.delivery_in_stock, pl.delivery_out_stock'); - } - - $query->select('p.width, p.height, p.depth, p.additional_shipping_cost'); - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $query->select('IFNULL(NULLIF(pa.isbn, ""), p.isbn) as isbn'); - } - } -} diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index 513dcf9e..f0d808fe 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -26,7 +26,7 @@ public function __construct(CarrierRepository $carrierRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -59,7 +59,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->carrierRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -89,9 +89,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return (int) $this->carrierRepository->countFullSyncContentLeft($offset); + return $this->carrierRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 6ffc866d..455e9826 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -26,7 +26,7 @@ public function __construct(CarrierRepository $carrierRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -59,7 +59,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->carrierRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -89,7 +89,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { $data = $this->getContentsForFull($offset, 50, $langIso, false); diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index d39f1aba..e9a69a25 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -32,7 +32,7 @@ public function __construct( */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->carrierRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -59,7 +59,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->carrierRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -83,9 +83,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->carrierRepository->countFullSyncContentLeft($offset); + return $this->carrierRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index b6dbb9ab..5740e404 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -25,7 +25,7 @@ public function __construct(CartProductRepository $cartProductRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->cartProductRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->cartProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -52,7 +52,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->cartProductRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->cartProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -76,9 +76,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->cartProductRepository->countFullSyncContentLeft($offset); + return $this->cartProductRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index 2806bdab..8acb0fcb 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -25,7 +25,7 @@ public function __construct(CartRuleRepository $cartRuleRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->cartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->cartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -52,7 +52,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->cartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->cartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -76,9 +76,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->cartRuleRepository->countFullSyncContentLeft($offset); + return $this->cartRuleRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 79655225..742c369a 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -25,7 +25,7 @@ public function __construct(CartRepository $cartRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->cartRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->cartRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -52,7 +52,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->cartRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->cartRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -76,9 +76,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->cartRepository->countFullSyncContentLeft($offset); + return $this->cartRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index b968ae24..d9b7d5da 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -25,7 +25,7 @@ public function __construct(OrderCartRuleRepository $orderCartRuleRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->orderCartRuleRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderCartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -52,7 +52,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->orderCartRuleRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderCartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -76,9 +76,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->orderCartRuleRepository->countFullSyncContentLeft($offset); + return $this->orderCartRuleRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index fde74fff..2ffee9e0 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -25,7 +25,7 @@ public function __construct(OrderDetailRepository $orderDetailRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->orderDetailRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderDetailRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -52,7 +52,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $debug) { - $result = $this->orderDetailRepository->getContentsForIncremental($limit, $orderDetailIds, $langIso, $debug); + $result = $this->orderDetailRepository->retrieveContentsForIncremental($limit, $orderDetailIds, $langIso, $debug); if (empty($result)) { return []; @@ -76,9 +76,9 @@ public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $de * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->orderDetailRepository->countFullSyncContentLeft($offset); + return $this->orderDetailRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index ce97ab51..e020ddf5 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -25,7 +25,7 @@ public function __construct(OrderHistoryRepository $orderHistoryRepository) */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->orderHistoryRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderHistoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -52,7 +52,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->orderHistoryRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -76,9 +76,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->orderHistoryRepository->countFullSyncContentLeft($offset); + return $this->orderHistoryRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 025a20dc..a1eb4038 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -38,7 +38,7 @@ public function __construct( */ public function getContentsForFull($offset, $limit, $langIso, $debug) { - $result = $this->orderRepository->getContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); if (empty($result)) { return []; @@ -65,7 +65,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $result = $this->orderRepository->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); if (empty($result)) { return []; @@ -89,9 +89,9 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso) + public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->orderRepository->countFullSyncContentLeft($offset); + return $this->orderRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** diff --git a/src/Decorator/ProductDecorator.php b/src/Service/ShopContent/ProductsService.php similarity index 60% rename from src/Decorator/ProductDecorator.php rename to src/Service/ShopContent/ProductsService.php index 89a33761..d428606a 100644 --- a/src/Decorator/ProductDecorator.php +++ b/src/Service/ShopContent/ProductsService.php @@ -1,60 +1,51 @@ context = $context; - $this->languageRepository = $languageRepository; $this->productRepository = $productRepository; $this->categoryRepository = $categoryRepository; + $this->languageRepository = $languageRepository; $this->arrayFormatter = $arrayFormatter; - $this->bundleRepository = $bundleRepository; + + $context = \Context::getContext(); + + if ($context == null) { + throw new \PrestaShopException('Context not found'); + } + + $this->context = $context; if ($this->context->shop === null) { throw new \PrestaShopException('No shop context'); @@ -63,19 +54,86 @@ public function __construct( $this->shopId = (int) $this->context->shop->id; } + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->productRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->decorateProducts($result, $langIso); + $this->castProducts($result); + + return array_map(function ($item) { + return [ + 'id' => $item['unique_product_id'], + 'collection' => Config::COLLECTION_PRODUCTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->productRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->decorateProducts($result, $langIso); + $this->castProducts($result); + + return array_map(function ($item) { + return [ + 'id' => $item['unique_product_id'], + 'collection' => Config::COLLECTION_PRODUCTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->productRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + /** * @param array $products * @param string $langIso - * @param int $langId * * @return void * * @@throws \PrestaShopDatabaseException */ - public function decorateProducts(&$products, $langIso, $langId) + private function decorateProducts(&$products, $langIso) { - $this->addFeatureValues($products, $langId); - $this->addAttributeValues($products, $langId); + $this->addFeatureValues($products, $langIso); + $this->addAttributeValues($products, $langIso); $this->addImages($products); foreach ($products as &$product) { @@ -86,25 +144,46 @@ public function decorateProducts(&$products, $langIso, $langId) $this->addProductPrices($product); $this->formatDescriptions($product); $this->addCategoryTree($product); - $this->castPropertyValues($product); } } /** * @param array $products * - * @return array + * @return void */ - public function getBundles($products) + private function castProducts(&$products) { - $bundles = []; - foreach ($products as $product) { - if ($product['is_bundle']) { - $bundles = array_merge($bundles, $this->getBundleCollection($product)); + foreach ($products as &$product) { + $product['id_product'] = (int) $product['id_product']; + $product['id_manufacturer'] = (int) $product['id_manufacturer']; + $product['id_supplier'] = (int) $product['id_supplier']; + $product['id_attribute'] = (int) $product['id_attribute']; + $product['id_category_default'] = (int) $product['id_category_default']; + $product['quantity'] = (int) $product['quantity']; + $product['weight'] = (float) $product['weight']; + $product['active'] = $product['active'] == '1'; + $product['manufacturer'] = (string) $product['manufacturer']; + $product['default_category'] = (string) $product['default_category']; + $product['isbn'] = isset($product['isbn']) ? (string) $product['isbn'] : ''; + $product['mpn'] = isset($product['mpn']) ? (string) $product['mpn'] : ''; + $product['ean'] = (string) $product['ean']; + $product['upc'] = (string) $product['upc']; + $product['is_default_attribute'] = $product['id_attribute'] === 0 ? true : $product['is_default_attribute'] == 1; + $product['available_for_order'] = $product['available_for_order'] == '1'; + $product['available_date'] = (string) $product['available_date']; + $product['is_bundle'] = $product['is_bundle'] == '1'; + $product['is_virtual'] = $product['is_virtual'] == '1'; + + if ($product['unit_price_ratio'] == 0) { + unset($product['unit_price_ratio']); + unset($product['unity']); + } else { + $product['unit_price_ratio'] = (float) $product['unit_price_ratio']; + $product['unity'] = (string) $product['unity']; + $product['price_per_unit'] = (float) ($product['price_tax_excl'] / $product['unit_price_ratio']); } } - - return $bundles; } /** @@ -114,11 +193,11 @@ public function getBundles($products) */ private function addLink(&$product) { - try { - if ($this->context->link === null) { - throw new \PrestaShopException('No link context'); - } + if ($this->context->link === null) { + throw new \PrestaShopException('No link context'); + } + try { $product['link'] = $this->context->link->getProductLink( $product, null, @@ -142,41 +221,16 @@ private function addProductPrices(&$product) { $product['price_tax_excl'] = (float) $product['price_tax_excl']; $product['price_tax_incl'] = - (float) $this->productRepository->getPriceTaxIncluded($product['id_product'], $product['id_attribute']); + (float) \Product::getPriceStatic($product['id_product'], true, $product['id_attribute'], 6, null, false, false); $product['sale_price_tax_excl'] = - (float) $this->productRepository->getSalePriceTaxExcluded($product['id_product'], $product['id_attribute']); + (float) \Product::getPriceStatic($product['id_product'], false, $product['id_attribute'], 6); $product['sale_price_tax_incl'] = - (float) $this->productRepository->getSalePriceTaxIncluded($product['id_product'], $product['id_attribute']); + (float) \Product::getPriceStatic($product['id_product'], true, $product['id_attribute'], 6); $product['tax'] = $product['price_tax_incl'] - $product['price_tax_excl']; $product['sale_tax'] = $product['sale_price_tax_incl'] - $product['sale_price_tax_excl']; } - /** - * @param array $product - * - * @return array - */ - private function getBundleCollection($product) - { - $bundleProducts = $this->bundleRepository->getBundleProducts($product['id_product']); - $uniqueProductId = $product['unique_product_id']; - - return array_map(function ($bundleProduct) use ($uniqueProductId) { - return [ - 'id' => $bundleProduct['id_bundle'], - 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, - 'properties' => [ - 'id_bundle' => $bundleProduct['id_bundle'], - 'id_product' => $bundleProduct['id_product'], - 'id_product_attribute' => $bundleProduct['id_product_attribute'], - 'unique_product_id' => $uniqueProductId, - 'quantity' => $bundleProduct['quantity'], - ], - ]; - }, $bundleProducts); - } - /** * @param array $product * @@ -205,42 +259,6 @@ private function addCategoryTree(&$product) $product['category_id_path'] = $categoryPaths['category_id_path']; } - /** - * @param array $product - * - * @return void - */ - private function castPropertyValues(&$product) - { - $product['id_product'] = (int) $product['id_product']; - $product['id_manufacturer'] = (int) $product['id_manufacturer']; - $product['id_supplier'] = (int) $product['id_supplier']; - $product['id_attribute'] = (int) $product['id_attribute']; - $product['id_category_default'] = (int) $product['id_category_default']; - $product['quantity'] = (int) $product['quantity']; - $product['weight'] = (float) $product['weight']; - $product['active'] = $product['active'] == '1'; - $product['manufacturer'] = (string) $product['manufacturer']; - $product['default_category'] = (string) $product['default_category']; - $product['isbn'] = isset($product['isbn']) ? (string) $product['isbn'] : ''; - $product['mpn'] = isset($product['mpn']) ? (string) $product['mpn'] : ''; - $product['ean'] = (string) $product['ean']; - $product['upc'] = (string) $product['upc']; - $product['is_default_attribute'] = $product['id_attribute'] === 0 ? true : $product['is_default_attribute'] == 1; - $product['available_for_order'] = $product['available_for_order'] == '1'; - $product['available_date'] = (string) $product['available_date']; - $product['is_bundle'] = $product['is_bundle'] == '1'; - $product['is_virtual'] = $product['is_virtual'] == '1'; - if ($product['unit_price_ratio'] == 0) { - unset($product['unit_price_ratio']); - unset($product['unity']); - } else { - $product['unit_price_ratio'] = (float) $product['unit_price_ratio']; - $product['unity'] = (string) $product['unity']; - $product['price_per_unit'] = (float) ($product['price_tax_excl'] / $product['unit_price_ratio']); - } - } - /** * @param array $product * @@ -274,16 +292,16 @@ private function addLanguageIsoCode(&$product, $langiso) /** * @param array $products - * @param int $langId + * @param string $langIso * * @return void * * @@throws \PrestaShopDatabaseException */ - private function addFeatureValues(&$products, $langId) + private function addFeatureValues(&$products, $langIso) { $productIds = $this->arrayFormatter->formatValueArray($products, 'id_product', true); - $features = $this->productRepository->getProductFeatures($productIds, $langId); + $features = $this->productRepository->getProductFeatures($productIds, $langIso); foreach ($products as &$product) { $product['features'] = isset($features[$product['id_product']]) ? $features[$product['id_product']] : ''; @@ -292,16 +310,16 @@ private function addFeatureValues(&$products, $langId) /** * @param array $products - * @param int $langId + * @param string $langIso * * @return void * * @@throws \PrestaShopDatabaseException */ - private function addAttributeValues(&$products, $langId) + private function addAttributeValues(&$products, $langIso) { $attributeIds = $this->arrayFormatter->formatValueArray($products, 'id_attribute', true); - $attributes = $this->productRepository->getProductAttributeValues($attributeIds, $langId); + $attributes = $this->productRepository->getProductAttributeValues($attributeIds, $langIso); foreach ($products as &$product) { $product['attributes'] = isset($attributes[$product['id_attribute']]) ? $attributes[$product['id_attribute']] : ''; @@ -365,19 +383,16 @@ private function addImages(&$products) $link = $this->context->link; /* - Ici pour certaines boutique on aurait un comporterment qui pourrait être adapté. - et aller chercher dans une table des images le bon libellé pour appeler ce que le marchand a. - */ - + * Ici pour certaines boutique on aurait un comportement qui pourrait être adapté. + * et aller chercher dans la table des images le bon libellé pour appeler ce que le marchand possède. + */ $product['images'] = $this->arrayFormatter->arrayToString( array_map(function ($imageId) use ($product, $link) { return $link->getImageLink($product['link_rewrite'], (string) $imageId); }, $productImageIds) ); - $product['cover'] = $coverImageId == '0' ? - '' : - $link->getImageLink($product['link_rewrite'], (string) $coverImageId); + $product['cover'] = $coverImageId == '0' ? '' : $link->getImageLink($product['link_rewrite'], (string) $coverImageId); } } } diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index f087807d..193c3f1e 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -31,5 +31,5 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) * * @return int */ - public function countFullSyncContentLeft($offset, $limit, $langIso); + public function getFullSyncContentLeft($offset, $limit, $langIso); } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index a4300296..2c9724f5 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -117,7 +117,7 @@ public function sendFullSync( } } - $remainingObjects = (int) $shopContentApiService->countFullSyncContentLeft($offset, $limit, $langIso); + $remainingObjects = (int) $shopContentApiService->getFullSyncContentLeft($offset, $limit, $langIso); if ($remainingObjects <= 0) { $remainingObjects = 0; From 54ea7aaf82ac53f01428ed40126d2509fb5f0d84 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:19:22 +0200 Subject: [PATCH 072/162] feat: pseventbus v4 product bundles (#363) --- config/common/new-repository.yml | 4 + config/front/services.yml | 6 + e2e/src/full-sync.spec.ts | 4 +- e2e/src/helpers/shop-contents.ts | 1 + src/Repository/BundleRepository.php | 62 --------- .../NewRepository/ProductBundleRepository.php | 118 ++++++++++++++++++ .../NewRepository/ProductRepository.php | 24 +++- .../ShopContent/ProductBundlesService.php | 104 +++++++++++++++ 8 files changed, 255 insertions(+), 68 deletions(-) delete mode 100644 src/Repository/BundleRepository.php create mode 100644 src/Repository/NewRepository/ProductBundleRepository.php create mode 100644 src/Service/ShopContent/ProductBundlesService.php diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 613ad1c4..cf4b9a54 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -34,3 +34,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository + public: true diff --git a/config/front/services.yml b/config/front/services.yml index d4e92702..de907d48 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -123,3 +123,9 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index a3069b8f..4346ad69 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -145,7 +145,7 @@ describe("Full Sync", () => { if (MISSING_TEST_DATA.includes(shopContent)) { it.skip(`${shopContent} should upload to collector`, () => {}); } else { - it(`${shopContent} should upload to collector`, async () => { + it.skip(`${shopContent} should upload to collector`, async () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const message$ = probe({ url: `/upload/${jobId}` }); @@ -199,7 +199,7 @@ describe("Full Sync", () => { if (MISSING_TEST_DATA.includes(shopContent)) { it.skip(`${shopContent} should upload complete dataset to collector`, () => {}); } else { - it.skip(`${shopContent} should upload complete dataset collector`, async () => { + it(`${shopContent} should upload complete dataset collector`, async () => { // arrange const fullSync$ = doFullSync(jobId, shopContent, { timeout: 4000 }); const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 2c807847..51204f39 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -45,6 +45,7 @@ export const shopContentMapping = { order_details: "order-details", order_histories: "order-histories", products: "products", + product_bundles: "product-bundles", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Repository/BundleRepository.php b/src/Repository/BundleRepository.php deleted file mode 100644 index 97b8d310..00000000 --- a/src/Repository/BundleRepository.php +++ /dev/null @@ -1,62 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @param int $productPackId - * - * @return \DbQuery - */ - private function getBaseQuery($productPackId) - { - $query = new \DbQuery(); - - $query->from('pack', 'pac') - ->innerJoin('product', 'p', 'p.id_product = pac.id_product_item'); - - $query->where('pac.id_product_pack = ' . (int) $productPackId); - - return $query; - } - - /** - * @param int $productPackId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getBundleProducts($productPackId) - { - $query = $this->getBaseQuery($productPackId); - - $this->addSelectParameters($query); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('pac.id_product_pack as id_bundle, pac.id_product_attribute_item as id_product_attribute'); - $query->select('p.id_product, pac.quantity'); - } -} diff --git a/src/Repository/NewRepository/ProductBundleRepository.php b/src/Repository/NewRepository/ProductBundleRepository.php new file mode 100644 index 00000000..8ef46be4 --- /dev/null +++ b/src/Repository/NewRepository/ProductBundleRepository.php @@ -0,0 +1,118 @@ +query = new \DbQuery(); + + $this->query->from($tableName, $alias); + } + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'pac'); + + $this->query + ->innerJoin('product', 'p', 'p.id_product = pac.id_product_pack') + ->innerJoin('product_shop', 'ps', 'ps.id_product = p.id_product AND ps.id_shop = ' . parent::getShopContext()->id) + ->leftJoin('product_attribute_shop', 'pas', 'pas.id_product = p.id_product AND pas.id_shop = ps.id_shop') + ->leftJoin('product_attribute', 'pa', 'pas.id_product_attribute = pa.id_product_attribute') + ->where('p.cache_is_pack=1') + ; + + if ($withSelecParameters) { + $this->query + ->select('p.id_product') + ->select('pac.id_product_item') + ->select('IFNULL(pas.id_product_attribute, 0) as product_id_attribute') + ->select('pac.id_product_pack as id_bundle') + ->select('pac.id_product_attribute_item as id_product_attribute') + ->select('p.id_product') + ->select('pac.quantity') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('p.id_bundle IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/NewRepository/ProductRepository.php index af8415f1..32ac6667 100644 --- a/src/Repository/NewRepository/ProductRepository.php +++ b/src/Repository/NewRepository/ProductRepository.php @@ -213,9 +213,17 @@ public function getProductAttributeValues($attributeIds, $langIso) $attributes = $this->runQuery(false); - return array_reduce($attributes, function ($key, $attribute) { + $resultArray = []; + + foreach ($attributes as $attribute) { + $resultArray[$attribute['id_product_attribute']][$attribute['name']] = $attribute['value']; + } + + return $resultArray; + + /* return array_reduce($attributes, function ($key, $attribute) { return $attribute[$attribute['id_product_attribute']][$attribute['name']] = $attribute['value']; - }); + }); */ } /** @@ -246,9 +254,17 @@ public function getProductFeatures($productIds, $langIso) $features = $this->runQuery(false); - return array_reduce($features, function ($key, $feature) { + $resultArray = []; + + foreach ($features as $feature) { + $resultArray[$feature['id_product']][$feature['name']] = $feature['value']; + } + + return $resultArray; + + /* return array_reduce($features, function ($key, $feature) { return $feature[$feature['id_product']][$feature['name']] = $feature['value']; - }); + }); */ } /** diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php new file mode 100644 index 00000000..9f8c28b6 --- /dev/null +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -0,0 +1,104 @@ +productBundleRepository = $productBundleRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->productBundleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castProductsBundles($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_bundle'], + 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->productBundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castProductsBundles($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_bundle'], + 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->productBundleRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $productBundles + * @param string $langIso + * + * @return void + */ + private function castProductsBundles(&$productBundles, $langIso) + { + foreach ($productBundles as &$productBundle) { + $productBundle['id_bundle'] = (int) $productBundle['id_bundle']; + $productBundle['id_product'] = (int) $productBundle['id_product_item']; + $productBundle['id_product_attribute'] = (int) $productBundle['id_product_attribute']; + $productBundle['unique_product_id'] = "{$productBundle['id_bundle']}-{$productBundle['product_id_attribute']}-{$langIso}"; + $productBundle['quantity'] = $productBundle['quantity']; + + unset($productBundle['product_id_attribute']); + unset($productBundle['id_product_item']); + unset($productBundle['id_product_attribute_item']); + } + } +} From b330408d0d8d7449d63c3c94cb1aac5a79d925c2 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 17 Sep 2024 18:18:06 +0200 Subject: [PATCH 073/162] fix: lint js --- e2e/src/fixtures/1.7/carrier_details.json | 1 - e2e/src/helpers/data-helper.ts | 8 +-- e2e/src/helpers/log-helper.ts | 25 ++++----- e2e/src/job-id-validation.spec.ts | 64 ++++++++++++++--------- e2e/src/type/carrier-details.ts | 2 +- e2e/src/type/cart-products.ts | 2 +- e2e/src/type/carts.ts | 2 +- e2e/src/type/categories.ts | 2 +- e2e/src/type/currency.ts | 2 +- e2e/src/type/customers.ts | 2 +- e2e/src/type/employees.ts | 2 +- e2e/src/type/image-type.ts | 2 +- e2e/src/type/images.ts | 2 +- e2e/src/type/languages.ts | 2 +- e2e/src/type/manufacturers.ts | 2 +- e2e/src/type/modules.ts | 2 +- e2e/src/type/order-details.ts | 2 +- e2e/src/type/order-status-history.ts | 6 +-- e2e/src/type/orders.ts | 2 +- e2e/src/type/product-supplier.ts | 2 +- e2e/src/type/products.ts | 2 +- e2e/src/type/shops.ts | 2 +- e2e/src/type/specific-prices.ts | 2 +- e2e/src/type/stocks.ts | 2 +- e2e/src/type/stores.ts | 2 +- e2e/src/type/suppliers.ts | 2 +- 26 files changed, 79 insertions(+), 67 deletions(-) diff --git a/e2e/src/fixtures/1.7/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json index c40966a4..e5081835 100644 --- a/e2e/src/fixtures/1.7/carrier_details.json +++ b/e2e/src/fixtures/1.7/carrier_details.json @@ -224,4 +224,3 @@ } } ] - \ No newline at end of file diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index cbab13a9..bd072533 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -59,7 +59,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck&job_id=valid-job-healthcheck` + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck&job_id=valid-job-healthcheck`, ); healthCheck = res.data; cachedHealthCheck = healthCheck; @@ -70,7 +70,7 @@ export async function getShopHealthCheck(options?: { const FIXTURE_DIR = "./src/fixtures"; export async function loadFixture( - shopContent: ShopContent + shopContent: ShopContent, ): Promise { const contents = getControllerContent(shopContent); const shopVersion = (await getShopHealthCheck()).prestashop_version; @@ -101,8 +101,8 @@ export async function loadFixture( const files = contents.map((content) => fs.promises.readFile( `${FIXTURE_DIR}/${useFixture}/${content}.json`, - "utf-8" - ) + "utf-8", + ), ); for await (const file of files) { diff --git a/e2e/src/helpers/log-helper.ts b/e2e/src/helpers/log-helper.ts index 8d366eb6..46beaa88 100644 --- a/e2e/src/helpers/log-helper.ts +++ b/e2e/src/helpers/log-helper.ts @@ -6,14 +6,13 @@ import { PsEventbusSyncUpload } from "./mock-probe"; import { getShopHealthCheck } from "./data-helper"; export function logAxiosError(err: Error) { - if(err instanceof AxiosError) { + if (err instanceof AxiosError) { const data = { - - ...R.pick(['url'], err.response.config), - ...R.pick(['status', 'statusText' ,'data'], err.response) - } + ...R.pick(["url"], err.response.config), + ...R.pick(["status", "statusText", "data"], err.response), + }; - console.log(data) + console.log(data); } } @@ -24,11 +23,13 @@ export async function dumpUploadData( const shopVersion = (await getShopHealthCheck()).prestashop_version; const dir = `./dumps/${testConfig.testRunTime}/${shopVersion}/${filename}`; - await fs.promises.mkdir(dir, {recursive: true}); - const groupedData = R.groupBy( el => el.collection, data ) - const files = Object.keys(groupedData).map(collection => { - return fs.promises.writeFile(`${dir}/${collection}.json`, - JSON.stringify(groupedData[collection], null, 2) + '\n'); - }) + await fs.promises.mkdir(dir, { recursive: true }); + const groupedData = R.groupBy((el) => el.collection, data); + const files = Object.keys(groupedData).map((collection) => { + return fs.promises.writeFile( + `${dir}/${collection}.json`, + JSON.stringify(groupedData[collection], null, 2) + "\n", + ); + }); await Promise.all(files); } diff --git a/e2e/src/job-id-validation.spec.ts b/e2e/src/job-id-validation.spec.ts index 85ed0a97..1ff5d819 100644 --- a/e2e/src/job-id-validation.spec.ts +++ b/e2e/src/job-id-validation.spec.ts @@ -1,54 +1,66 @@ -import testConfig from './helpers/test.config'; -import {beforeEach, describe, expect} from "@jest/globals"; +import testConfig from "./helpers/test.config"; +import { beforeEach, describe, expect } from "@jest/globals"; import axios from "axios"; -import {from, lastValueFrom, map, toArray, zip} from "rxjs"; -import {probe} from "./helpers/mock-probe"; +import { from, lastValueFrom, map, toArray, zip } from "rxjs"; +import { probe } from "./helpers/mock-probe"; import { ShopContent, shopContentList } from "./helpers/shop-contents"; -describe('Reject invalid job-id', () => { +describe("Reject invalid job-id", () => { let generatedNumber = 0; - const shopContents: ShopContent[] = shopContentList + const shopContents: ShopContent[] = shopContentList; let jobId: string; beforeEach(() => { generatedNumber = Date.now() + Math.trunc(Math.random() * 100000000000000); - jobId = `invalid-job-id-${generatedNumber}` + jobId = `invalid-job-id-${generatedNumber}`; }); - it.each(shopContents)(`%s should return 454 with an invalid job id (sync-api status 454)`, async (shopContent) => { + it.each(shopContents)( + `%s should return 454 with an invalid job id (sync-api status 454)`, + async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&job_id=${jobId}` - const message$ = probe({params: {id: jobId}}); + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&job_id=${jobId}`; + const message$ = probe({ params: { id: jobId } }); //act - const request$ = from(axios.get(url, { - headers: {'Host': testConfig.prestaShopHostHeader} - }).then(res => { - expect(res).toBeNull(); // fail test - }).catch(err => { - return err.response; - })) - - const results = await lastValueFrom(zip(message$, request$) - .pipe(map(result => ({ + const request$ = from( + axios + .get(url, { + headers: { Host: testConfig.prestaShopHostHeader }, + }) + .then((res) => { + expect(res).toBeNull(); // fail test + }) + .catch((err) => { + return err.response; + }), + ); + + const results = await lastValueFrom( + zip(message$, request$).pipe( + map((result) => ({ probeMessage: result[0], psEventbusReq: result[1], })), - toArray())); + toArray(), + ), + ); // assert expect(results.length).toEqual(1); - expect(results[0].probeMessage.method).toBe('GET'); - expect(results[0].probeMessage.url.split('/')).toContain(jobId); + expect(results[0].probeMessage.method).toBe("GET"); + expect(results[0].probeMessage.url.split("/")).toContain(jobId); expect(results[0].psEventbusReq.status).toEqual(454); - expect(results[0].psEventbusReq.headers).toMatchObject({'content-type': /json/}); + expect(results[0].psEventbusReq.headers).toMatchObject({ + "content-type": /json/, + }); expect(results[0].psEventbusReq.data).toMatchObject({ status: false, httpCode: 454, }); - } + }, ); -}) +}); diff --git a/e2e/src/type/carrier-details.ts b/e2e/src/type/carrier-details.ts index 3b2c4211..8675759a 100644 --- a/e2e/src/type/carrier-details.ts +++ b/e2e/src/type/carrier-details.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/carrier_details.json" +import fixture from "../fixtures/latest/carrier_details.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/cart-products.ts b/e2e/src/type/cart-products.ts index ea944117..9a00afcc 100644 --- a/e2e/src/type/cart-products.ts +++ b/e2e/src/type/cart-products.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/cart_products.json" +import fixture from "../fixtures/latest/cart_products.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/carts.ts b/e2e/src/type/carts.ts index d8f761c8..aba88a3b 100644 --- a/e2e/src/type/carts.ts +++ b/e2e/src/type/carts.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/carts.json" +import fixture from "../fixtures/latest/carts.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/categories.ts b/e2e/src/type/categories.ts index 88182970..ae160136 100644 --- a/e2e/src/type/categories.ts +++ b/e2e/src/type/categories.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/categories.json" +import fixture from "../fixtures/latest/categories.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/currency.ts b/e2e/src/type/currency.ts index 27672eb5..1b814f95 100644 --- a/e2e/src/type/currency.ts +++ b/e2e/src/type/currency.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/currencies.json" +import fixture from "../fixtures/latest/currencies.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/customers.ts b/e2e/src/type/customers.ts index 60ef9371..d405ae3a 100644 --- a/e2e/src/type/customers.ts +++ b/e2e/src/type/customers.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/customers.json" +import fixture from "../fixtures/latest/customers.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/employees.ts b/e2e/src/type/employees.ts index 6ca41b06..088472f6 100644 --- a/e2e/src/type/employees.ts +++ b/e2e/src/type/employees.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/employees.json' +import fixture from "../fixtures/latest/employees.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/image-type.ts b/e2e/src/type/image-type.ts index e1309cc1..d5f49677 100644 --- a/e2e/src/type/image-type.ts +++ b/e2e/src/type/image-type.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/image_types.json' +import fixture from "../fixtures/latest/image_types.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/images.ts b/e2e/src/type/images.ts index b1dfb6fa..90142a97 100644 --- a/e2e/src/type/images.ts +++ b/e2e/src/type/images.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/images.json' +import fixture from "../fixtures/latest/images.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/languages.ts b/e2e/src/type/languages.ts index 4fdae356..4dbbde11 100644 --- a/e2e/src/type/languages.ts +++ b/e2e/src/type/languages.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/languages.json' +import fixture from "../fixtures/latest/languages.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/manufacturers.ts b/e2e/src/type/manufacturers.ts index 3a0fe630..bc8e30a1 100644 --- a/e2e/src/type/manufacturers.ts +++ b/e2e/src/type/manufacturers.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/manufacturers.json' +import fixture from "../fixtures/latest/manufacturers.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/modules.ts b/e2e/src/type/modules.ts index daeb68d6..ccffeb95 100644 --- a/e2e/src/type/modules.ts +++ b/e2e/src/type/modules.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/modules.json' +import fixture from "../fixtures/latest/modules.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/order-details.ts b/e2e/src/type/order-details.ts index 32af2212..67fac876 100644 --- a/e2e/src/type/order-details.ts +++ b/e2e/src/type/order-details.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/order_details.json' +import fixture from "../fixtures/latest/order_details.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/order-status-history.ts b/e2e/src/type/order-status-history.ts index c1f5e34d..1bd46b21 100644 --- a/e2e/src/type/order-status-history.ts +++ b/e2e/src/type/order-status-history.ts @@ -1,12 +1,12 @@ -import fixture from '../fixtures/latest/order_histories.json' +import fixture from "../fixtures/latest/order_histories.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars const t: OrderHistory[] = fixture; export type OrderHistory = { - id: number, - collection: string, + id: number; + collection: string; properties: { created_at: string; date_add: string; diff --git a/e2e/src/type/orders.ts b/e2e/src/type/orders.ts index 3fd4e4aa..3a265cd7 100644 --- a/e2e/src/type/orders.ts +++ b/e2e/src/type/orders.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/orders.json' +import fixture from "../fixtures/latest/orders.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/product-supplier.ts b/e2e/src/type/product-supplier.ts index 515e38db..76fc7077 100644 --- a/e2e/src/type/product-supplier.ts +++ b/e2e/src/type/product-supplier.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/product_suppliers.json'; +import fixture from "../fixtures/latest/product_suppliers.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/products.ts b/e2e/src/type/products.ts index fbdc151d..662ad657 100644 --- a/e2e/src/type/products.ts +++ b/e2e/src/type/products.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/products.json' +import fixture from "../fixtures/latest/products.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/shops.ts b/e2e/src/type/shops.ts index 85143698..3e6d3b85 100644 --- a/e2e/src/type/shops.ts +++ b/e2e/src/type/shops.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/shops.json' +import fixture from "../fixtures/latest/shops.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/specific-prices.ts b/e2e/src/type/specific-prices.ts index 319e368b..d863d4ce 100644 --- a/e2e/src/type/specific-prices.ts +++ b/e2e/src/type/specific-prices.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/specific_prices.json' +import fixture from "../fixtures/latest/specific_prices.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/stocks.ts b/e2e/src/type/stocks.ts index fecc239e..f97665b4 100644 --- a/e2e/src/type/stocks.ts +++ b/e2e/src/type/stocks.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/stocks.json' +import fixture from "../fixtures/latest/stocks.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/stores.ts b/e2e/src/type/stores.ts index 464794a6..5dc6e77c 100644 --- a/e2e/src/type/stores.ts +++ b/e2e/src/type/stores.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/stores.json' +import fixture from "../fixtures/latest/stores.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/suppliers.ts b/e2e/src/type/suppliers.ts index 738dc046..57989f6a 100644 --- a/e2e/src/type/suppliers.ts +++ b/e2e/src/type/suppliers.ts @@ -1,4 +1,4 @@ -import fixture from '../fixtures/latest/suppliers.json' +import fixture from "../fixtures/latest/suppliers.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars From d8e692841aeeda5cc6f2994dadb4487b9f481338 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 17 Sep 2024 18:31:30 +0200 Subject: [PATCH 074/162] fix: test latest --- config/common/repository.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/common/repository.yml b/config/common/repository.yml index 75638643..d8732d04 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -99,10 +99,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\BundleRepository: - class: PrestaShop\Module\PsEventbus\Repository\BundleRepository - public: true - PrestaShop\Module\PsEventbus\Repository\WishlistRepository: class: PrestaShop\Module\PsEventbus\Repository\WishlistRepository public: true From 0073668944e4c33c74221a8369b11481554d46a3 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 18 Sep 2024 10:44:47 +0200 Subject: [PATCH 075/162] fix: disable type-cast for 1.7 --- src/Service/ShopContent/ProductBundlesService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index 9f8c28b6..2983a012 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -90,9 +90,9 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) private function castProductsBundles(&$productBundles, $langIso) { foreach ($productBundles as &$productBundle) { - $productBundle['id_bundle'] = (int) $productBundle['id_bundle']; - $productBundle['id_product'] = (int) $productBundle['id_product_item']; - $productBundle['id_product_attribute'] = (int) $productBundle['id_product_attribute']; + $productBundle['id_bundle'] = $productBundle['id_bundle']; + $productBundle['id_product'] = $productBundle['id_product_item']; + $productBundle['id_product_attribute'] = $productBundle['id_product_attribute']; $productBundle['unique_product_id'] = "{$productBundle['id_bundle']}-{$productBundle['product_id_attribute']}-{$langIso}"; $productBundle['quantity'] = $productBundle['quantity']; From ec50e4d1e134278623bf5c331721d46d8888f61e Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:21:02 +0200 Subject: [PATCH 076/162] feat: add product suppliers (#364) --- OLD/Provider/ProductDataProvider.php | 112 ----------------- OLD/Provider/ProductSupplierDataProvider.php | 107 ---------------- OLD/decorator/ProductDecorator.php | 107 ---------------- config/common/new-repository.yml | 4 + config/common/repository.yml | 4 - config/front/services.yml | 6 + e2e/src/helpers/shop-contents.ts | 1 + src/Decorator/ProductSupplierDecorator.php | 33 ----- .../ProductSupplierRepository.php | 110 +++++++++++++++++ src/Repository/ProductSupplierRepository.php | 114 ------------------ .../ShopContent/ProductSuppliersService.php | 101 ++++++++++++++++ 11 files changed, 222 insertions(+), 477 deletions(-) delete mode 100644 OLD/Provider/ProductDataProvider.php delete mode 100644 OLD/Provider/ProductSupplierDataProvider.php delete mode 100644 OLD/decorator/ProductDecorator.php delete mode 100644 src/Decorator/ProductSupplierDecorator.php create mode 100644 src/Repository/NewRepository/ProductSupplierRepository.php delete mode 100644 src/Repository/ProductSupplierRepository.php create mode 100644 src/Service/ShopContent/ProductSuppliersService.php diff --git a/OLD/Provider/ProductDataProvider.php b/OLD/Provider/ProductDataProvider.php deleted file mode 100644 index 2a836675..00000000 --- a/OLD/Provider/ProductDataProvider.php +++ /dev/null @@ -1,112 +0,0 @@ -productRepository = $productRepository; - $this->productDecorator = $productDecorator; - $this->productSupplierDataProvider = $productSupplierDataProvider; - $this->languageRepository = $languageRepository; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - $products = $this->productRepository->getProducts($offset, $limit, $langId); - - if (!$products) { - return []; - } - - $this->productDecorator->decorateProducts($products, $langIso); - - $bundles = $this->productDecorator->getBundles($products); - - $productSuppliers = $this->productSupplierDataProvider->getFormattedData($offset, $limit, $langIso); - - $products = array_map(function ($product) { - return [ - 'id' => $product['unique_product_id'], - 'collection' => Config::COLLECTION_PRODUCTS, - 'properties' => $product, - ]; - }, $products); - - return array_merge($products, $bundles, $productSuppliers); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $langId = $this->languageRepository->getLanguageIdByIsoCode($langIso); - - $products = $this->productRepository->getProductsIncremental($limit, $langId, $objectIds); - - if (!empty($products)) { - $this->productDecorator->decorateProducts($products, $langIso); - } else { - return []; - } - - $bundles = $this->productDecorator->getBundles($products); - - $productSuppliers = $this->productSupplierDataProvider->getFormattedDataIncremental($limit, $langIso, $objectIds); - - $products = array_map(function ($product) { - return [ - 'id' => $product['unique_product_id'], - 'collection' => Config::COLLECTION_PRODUCTS, - 'properties' => $product, - ]; - }, $products); - - return array_merge($products, $bundles, $productSuppliers); - } -} diff --git a/OLD/Provider/ProductSupplierDataProvider.php b/OLD/Provider/ProductSupplierDataProvider.php deleted file mode 100644 index f1fa6455..00000000 --- a/OLD/Provider/ProductSupplierDataProvider.php +++ /dev/null @@ -1,107 +0,0 @@ -productSupplierRepository = $productSupplierRepository; - $this->productSupplierDecorator = $productSupplierDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $productSuppliers = $this->productSupplierRepository->getProductSuppliers($offset, $limit); - - if (empty($productSuppliers)) { - return []; - } - $this->productSupplierDecorator->decorateProductSuppliers($productSuppliers); - - return array_map(function ($productSupplier) { - return [ - 'id' => $productSupplier['id_product_supplier'], - 'collection' => Config::COLLECTION_PRODUCT_SUPPLIERS, - 'properties' => $productSupplier, - ]; - }, $productSuppliers); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->productSupplierRepository->getRemainingProductSuppliersCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $productSuppliers = $this->productSupplierRepository->getProductSuppliersIncremental($limit, $objectIds); - - if (!is_array($productSuppliers) || empty($productSuppliers)) { - return []; - } - - $this->productSupplierDecorator->decorateProductSuppliers($productSuppliers); - - return array_map(function ($productSupplier) { - return [ - 'id' => $productSupplier['id_product_supplier'], - 'collection' => Config::COLLECTION_PRODUCT_SUPPLIERS, - 'properties' => $productSupplier, - ]; - }, $productSuppliers); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->productSupplierRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/OLD/decorator/ProductDecorator.php b/OLD/decorator/ProductDecorator.php deleted file mode 100644 index 95433bf0..00000000 --- a/OLD/decorator/ProductDecorator.php +++ /dev/null @@ -1,107 +0,0 @@ -context = $context; - $this->languageRepository = $languageRepository; - $this->productRepository = $productRepository; - $this->categoryRepository = $categoryRepository; - $this->arrayFormatter = $arrayFormatter; - $this->bundleRepository = $bundleRepository; - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - - /** - * @param array $products - * - * @return array - */ - public function getBundles($products) - { - $bundles = []; - foreach ($products as $product) { - if ($product['is_bundle']) { - $bundles = array_merge($bundles, $this->getBundleCollection($product)); - } - } - - return $bundles; - } - - /** - * @param array $product - * - * @return array - */ - private function getBundleCollection($product) - { - $bundleProducts = $this->bundleRepository->getBundleProducts($product['id_product']); - $uniqueProductId = $product['unique_product_id']; - - return array_map(function ($bundleProduct) use ($uniqueProductId) { - return [ - 'id' => $bundleProduct['id_bundle'], - 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, - 'properties' => [ - 'id_bundle' => $bundleProduct['id_bundle'], - 'id_product' => $bundleProduct['id_product'], - 'id_product_attribute' => $bundleProduct['id_product_attribute'], - 'unique_product_id' => $uniqueProductId, - 'quantity' => $bundleProduct['quantity'], - ], - ]; - }, $bundleProducts); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index cf4b9a54..d0c34efe 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -38,3 +38,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index d8732d04..7599ca8e 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -141,10 +141,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository - public: true - PrestaShop\Module\PsEventbus\Repository\EmployeeRepository: class: PrestaShop\Module\PsEventbus\Repository\EmployeeRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index de907d48..a02eeff8 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -129,3 +129,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 51204f39..45fb5bae 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -46,6 +46,7 @@ export const shopContentMapping = { order_histories: "order-histories", products: "products", product_bundles: "product-bundles", + product_suppliers: "product-suppliers", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Decorator/ProductSupplierDecorator.php b/src/Decorator/ProductSupplierDecorator.php deleted file mode 100644 index 9c6fa9ef..00000000 --- a/src/Decorator/ProductSupplierDecorator.php +++ /dev/null @@ -1,33 +0,0 @@ - $productSuppliers - * - * @return void - */ - public function decorateProductSuppliers(&$productSuppliers) - { - foreach ($productSuppliers as &$productSupplier) { - $this->castProductSupplierPropertyValues($productSupplier); - } - } - - /** - * @param array $productSupplier - * - * @return void - */ - private function castProductSupplierPropertyValues(&$productSupplier) - { - $productSupplier['id_product_supplier'] = (int) $productSupplier['id_product_supplier']; - $productSupplier['id_product'] = (int) $productSupplier['id_product']; - $productSupplier['id_product_attribute'] = (int) $productSupplier['id_product_attribute']; - $productSupplier['id_supplier'] = (int) $productSupplier['id_supplier']; - $productSupplier['product_supplier_price_te'] = (float) $productSupplier['product_supplier_price_te']; - $productSupplier['id_currency'] = (int) $productSupplier['id_currency']; - } -} diff --git a/src/Repository/NewRepository/ProductSupplierRepository.php b/src/Repository/NewRepository/ProductSupplierRepository.php new file mode 100644 index 00000000..5af97296 --- /dev/null +++ b/src/Repository/NewRepository/ProductSupplierRepository.php @@ -0,0 +1,110 @@ +query = new \DbQuery(); + + $this->query->from($tableName, $alias); + } + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'ps'); + + if ($withSelecParameters) { + $this->query + ->select('ps.id_product_supplier') + ->select('ps.id_product') + ->select('ps.id_product_attribute') + ->select('ps.id_supplier') + ->select('ps.product_supplier_reference') + ->select('ps.product_supplier_price_te') + ->select('ps.id_currency') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('ps.id_product_supplier IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php deleted file mode 100644 index b6bf7c24..00000000 --- a/src/Repository/ProductSupplierRepository.php +++ /dev/null @@ -1,114 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - $query = new \DbQuery(); - $query->from('product_supplier', 'ps'); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getProductSuppliers($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingProductSuppliersCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(ps.id_product_supplier) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $productIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getProductSuppliersIncremental($limit, $productIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('ps.id_product IN(' . implode(',', array_map('intval', $productIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('ps.id_product_supplier, ps.id_product, ps.id_product_attribute, ps.id_supplier, ps.product_supplier_reference'); - $query->select('ps.product_supplier_price_te, ps.id_currency'); - } -} diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php new file mode 100644 index 00000000..b7447b86 --- /dev/null +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -0,0 +1,101 @@ +productSupplierRepository = $productSupplierRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->productSupplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castProductsSuppliers($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_product_supplier'], + 'collection' => Config::COLLECTION_PRODUCT_SUPPLIERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->productSupplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castProductsSuppliers($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_product_supplier'], + 'collection' => Config::COLLECTION_PRODUCT_SUPPLIERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->productSupplierRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $productSuppliers + * @param string $langIso + * + * @return void + */ + private function castProductsSuppliers(&$productSuppliers, $langIso) + { + foreach ($productSuppliers as &$productSupplier) { + $productSupplier['id_product_supplier'] = (int) $productSupplier['id_product_supplier']; + $productSupplier['id_product'] = (int) $productSupplier['id_product']; + $productSupplier['id_product_attribute'] = (int) $productSupplier['id_product_attribute']; + $productSupplier['id_supplier'] = (int) $productSupplier['id_supplier']; + $productSupplier['product_supplier_price_te'] = (float) $productSupplier['product_supplier_price_te']; + $productSupplier['id_currency'] = (int) $productSupplier['id_currency']; + } + } +} From 7a72c72b0c324e472f8c542b872bfa2e872b1b12 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:17:31 +0200 Subject: [PATCH 077/162] feat: pseventbus v4 product carriers (#365) --- config/common/new-repository.yml | 4 + config/common/repository.yml | 7 +- config/front/services.yml | 6 + e2e/src/fixtures/1.6/product_carriers.json | 1 + e2e/src/fixtures/1.7/product_carriers.json | 1 + e2e/src/fixtures/1.7/product_suppliers.json | 260 +++++++++++++++ e2e/src/fixtures/8/product_carriers.json | 1 + e2e/src/fixtures/8/product_suppliers.json | 299 ++++++++++++++++++ e2e/src/fixtures/9/product_carriers.json | 1 + e2e/src/fixtures/9/product_suppliers.json | 299 ++++++++++++++++++ e2e/src/full-sync.spec.ts | 1 - e2e/src/helpers/shop-contents.ts | 1 + src/Config/Config.php | 4 +- .../NewRepository/AbstractRepository.php | 13 + .../NewRepository/CarrierRepository.php | 13 - .../NewRepository/CartProductRepository.php | 13 - .../NewRepository/CartRepository.php | 13 - .../NewRepository/CartRuleRepository.php | 13 - .../NewRepository/OrderCartRuleRepository.php | 13 - .../NewRepository/OrderDetailRepository.php | 13 - .../NewRepository/OrderHistoryRepository.php | 13 - .../NewRepository/OrderRepository.php | 13 - .../NewRepository/ProductBundleRepository.php | 13 - .../ProductCarrierRepository.php | 91 ++++++ .../NewRepository/ProductRepository.php | 13 - .../ProductSupplierRepository.php | 13 - .../NewRepository/RepositoryInterface.php | 8 - src/Repository/ProductCarrierRepository.php | 182 ----------- .../ShopContent/ProductCarriersService.php | 79 +++++ 29 files changed, 1059 insertions(+), 342 deletions(-) create mode 100644 e2e/src/fixtures/1.6/product_carriers.json create mode 100644 e2e/src/fixtures/1.7/product_carriers.json create mode 100644 e2e/src/fixtures/8/product_carriers.json create mode 100644 e2e/src/fixtures/9/product_carriers.json create mode 100644 src/Repository/NewRepository/ProductCarrierRepository.php delete mode 100644 src/Repository/ProductCarrierRepository.php create mode 100644 src/Service/ShopContent/ProductCarriersService.php diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index d0c34efe..c70954d4 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -42,3 +42,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 7599ca8e..512810f3 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -35,12 +35,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ModuleRepository public: true - PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository: class: PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository public: true @@ -141,6 +135,7 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' + PrestaShop\Module\PsEventbus\Repository\EmployeeRepository: class: PrestaShop\Module\PsEventbus\Repository\EmployeeRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index a02eeff8..41fff97b 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -135,3 +135,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository' diff --git a/e2e/src/fixtures/1.6/product_carriers.json b/e2e/src/fixtures/1.6/product_carriers.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/product_carriers.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/product_carriers.json b/e2e/src/fixtures/1.7/product_carriers.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/product_carriers.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/product_suppliers.json b/e2e/src/fixtures/1.7/product_suppliers.json index 8a7ec862..17a9024f 100644 --- a/e2e/src/fixtures/1.7/product_suppliers.json +++ b/e2e/src/fixtures/1.7/product_suppliers.json @@ -648,5 +648,265 @@ "product_supplier_price_te": 5.49, "id_currency": 0 } + }, + { + "id": 51, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 51, + "id_product": 10, + "id_product_attribute": 25, + "id_supplier": 2, + "product_supplier_reference": "demo_16_82", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 52, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 52, + "id_product": 11, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_17_83", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 53, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 53, + "id_product": 11, + "id_product_attribute": 26, + "id_supplier": 2, + "product_supplier_reference": "demo_17_83", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 54, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 54, + "id_product": 11, + "id_product_attribute": 27, + "id_supplier": 2, + "product_supplier_reference": "demo_17_84", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 55, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 55, + "id_product": 16, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_8_85", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 56, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 56, + "id_product": 16, + "id_product_attribute": 28, + "id_supplier": 2, + "product_supplier_reference": "demo_8_85", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 57, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 57, + "id_product": 16, + "id_product_attribute": 29, + "id_supplier": 2, + "product_supplier_reference": "demo_8_86", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 58, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 58, + "id_product": 16, + "id_product_attribute": 30, + "id_supplier": 2, + "product_supplier_reference": "demo_8_87", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 59, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 59, + "id_product": 16, + "id_product_attribute": 31, + "id_supplier": 2, + "product_supplier_reference": "demo_8_88", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 60, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 60, + "id_product": 17, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_9_89", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 61, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 61, + "id_product": 17, + "id_product_attribute": 32, + "id_supplier": 2, + "product_supplier_reference": "demo_9_89", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 62, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 62, + "id_product": 17, + "id_product_attribute": 33, + "id_supplier": 2, + "product_supplier_reference": "demo_9_90", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 63, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 63, + "id_product": 17, + "id_product_attribute": 34, + "id_supplier": 2, + "product_supplier_reference": "demo_9_91", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 64, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 64, + "id_product": 17, + "id_product_attribute": 35, + "id_supplier": 2, + "product_supplier_reference": "demo_9_92", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 65, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 65, + "id_product": 18, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_10_93", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 66, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 66, + "id_product": 18, + "id_product_attribute": 36, + "id_supplier": 2, + "product_supplier_reference": "demo_10_93", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 67, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 67, + "id_product": 18, + "id_product_attribute": 37, + "id_supplier": 2, + "product_supplier_reference": "demo_10_94", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 68, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 68, + "id_product": 18, + "id_product_attribute": 38, + "id_supplier": 2, + "product_supplier_reference": "demo_10_95", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 69, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 69, + "id_product": 18, + "id_product_attribute": 39, + "id_supplier": 2, + "product_supplier_reference": "demo_10_96", + "product_supplier_price_te": 5.49, + "id_currency": 0 + } + }, + { + "id": 70, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 70, + "id_product": 15, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "", + "product_supplier_price_te": 0, + "id_currency": 0 + } } ] diff --git a/e2e/src/fixtures/8/product_carriers.json b/e2e/src/fixtures/8/product_carriers.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/product_carriers.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/product_suppliers.json b/e2e/src/fixtures/8/product_suppliers.json index 4ac63997..365f801f 100644 --- a/e2e/src/fixtures/8/product_suppliers.json +++ b/e2e/src/fixtures/8/product_suppliers.json @@ -648,5 +648,304 @@ "product_supplier_price_te": 5.49, "id_currency": 1 } + }, + { + "id": 51, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 51, + "id_product": 9, + "id_product_attribute": 23, + "id_supplier": 2, + "product_supplier_reference": "demo_15_80", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 52, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 52, + "id_product": 10, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_16_81", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 53, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 53, + "id_product": 10, + "id_product_attribute": 24, + "id_supplier": 2, + "product_supplier_reference": "demo_16_81", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 54, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 54, + "id_product": 10, + "id_product_attribute": 25, + "id_supplier": 2, + "product_supplier_reference": "demo_16_82", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 55, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 55, + "id_product": 11, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_17_83", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 56, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 56, + "id_product": 11, + "id_product_attribute": 26, + "id_supplier": 2, + "product_supplier_reference": "demo_17_83", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 57, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 57, + "id_product": 11, + "id_product_attribute": 27, + "id_supplier": 2, + "product_supplier_reference": "demo_17_84", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 58, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 58, + "id_product": 16, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_8_85", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 59, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 59, + "id_product": 16, + "id_product_attribute": 28, + "id_supplier": 2, + "product_supplier_reference": "demo_8_85", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 60, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 60, + "id_product": 16, + "id_product_attribute": 29, + "id_supplier": 2, + "product_supplier_reference": "demo_8_86", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 61, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 61, + "id_product": 16, + "id_product_attribute": 30, + "id_supplier": 2, + "product_supplier_reference": "demo_8_87", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 62, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 62, + "id_product": 16, + "id_product_attribute": 31, + "id_supplier": 2, + "product_supplier_reference": "demo_8_88", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 63, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 63, + "id_product": 17, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_9_89", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 64, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 64, + "id_product": 17, + "id_product_attribute": 32, + "id_supplier": 2, + "product_supplier_reference": "demo_9_89", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 65, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 65, + "id_product": 17, + "id_product_attribute": 33, + "id_supplier": 2, + "product_supplier_reference": "demo_9_90", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 66, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 66, + "id_product": 17, + "id_product_attribute": 34, + "id_supplier": 2, + "product_supplier_reference": "demo_9_91", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 67, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 67, + "id_product": 17, + "id_product_attribute": 35, + "id_supplier": 2, + "product_supplier_reference": "demo_9_92", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 68, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 68, + "id_product": 18, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_10_93", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 69, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 69, + "id_product": 18, + "id_product_attribute": 36, + "id_supplier": 2, + "product_supplier_reference": "demo_10_93", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 70, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 70, + "id_product": 18, + "id_product_attribute": 37, + "id_supplier": 2, + "product_supplier_reference": "demo_10_94", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 71, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 71, + "id_product": 18, + "id_product_attribute": 38, + "id_supplier": 2, + "product_supplier_reference": "demo_10_95", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 72, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 72, + "id_product": 18, + "id_product_attribute": 39, + "id_supplier": 2, + "product_supplier_reference": "demo_10_96", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 73, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 73, + "id_product": 15, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "", + "product_supplier_price_te": 0, + "id_currency": 1 + } } ] diff --git a/e2e/src/fixtures/9/product_carriers.json b/e2e/src/fixtures/9/product_carriers.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/product_carriers.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/9/product_suppliers.json b/e2e/src/fixtures/9/product_suppliers.json index 4ac63997..365f801f 100644 --- a/e2e/src/fixtures/9/product_suppliers.json +++ b/e2e/src/fixtures/9/product_suppliers.json @@ -648,5 +648,304 @@ "product_supplier_price_te": 5.49, "id_currency": 1 } + }, + { + "id": 51, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 51, + "id_product": 9, + "id_product_attribute": 23, + "id_supplier": 2, + "product_supplier_reference": "demo_15_80", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 52, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 52, + "id_product": 10, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_16_81", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 53, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 53, + "id_product": 10, + "id_product_attribute": 24, + "id_supplier": 2, + "product_supplier_reference": "demo_16_81", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 54, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 54, + "id_product": 10, + "id_product_attribute": 25, + "id_supplier": 2, + "product_supplier_reference": "demo_16_82", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 55, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 55, + "id_product": 11, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_17_83", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 56, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 56, + "id_product": 11, + "id_product_attribute": 26, + "id_supplier": 2, + "product_supplier_reference": "demo_17_83", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 57, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 57, + "id_product": 11, + "id_product_attribute": 27, + "id_supplier": 2, + "product_supplier_reference": "demo_17_84", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 58, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 58, + "id_product": 16, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_8_85", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 59, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 59, + "id_product": 16, + "id_product_attribute": 28, + "id_supplier": 2, + "product_supplier_reference": "demo_8_85", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 60, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 60, + "id_product": 16, + "id_product_attribute": 29, + "id_supplier": 2, + "product_supplier_reference": "demo_8_86", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 61, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 61, + "id_product": 16, + "id_product_attribute": 30, + "id_supplier": 2, + "product_supplier_reference": "demo_8_87", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 62, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 62, + "id_product": 16, + "id_product_attribute": 31, + "id_supplier": 2, + "product_supplier_reference": "demo_8_88", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 63, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 63, + "id_product": 17, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_9_89", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 64, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 64, + "id_product": 17, + "id_product_attribute": 32, + "id_supplier": 2, + "product_supplier_reference": "demo_9_89", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 65, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 65, + "id_product": 17, + "id_product_attribute": 33, + "id_supplier": 2, + "product_supplier_reference": "demo_9_90", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 66, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 66, + "id_product": 17, + "id_product_attribute": 34, + "id_supplier": 2, + "product_supplier_reference": "demo_9_91", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 67, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 67, + "id_product": 17, + "id_product_attribute": 35, + "id_supplier": 2, + "product_supplier_reference": "demo_9_92", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 68, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 68, + "id_product": 18, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "demo_10_93", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 69, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 69, + "id_product": 18, + "id_product_attribute": 36, + "id_supplier": 2, + "product_supplier_reference": "demo_10_93", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 70, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 70, + "id_product": 18, + "id_product_attribute": 37, + "id_supplier": 2, + "product_supplier_reference": "demo_10_94", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 71, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 71, + "id_product": 18, + "id_product_attribute": 38, + "id_supplier": 2, + "product_supplier_reference": "demo_10_95", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 72, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 72, + "id_product": 18, + "id_product_attribute": 39, + "id_supplier": 2, + "product_supplier_reference": "demo_10_96", + "product_supplier_price_te": 5.49, + "id_currency": 1 + } + }, + { + "id": 73, + "collection": "product_suppliers", + "properties": { + "id_product_supplier": 73, + "id_product": 15, + "id_product_attribute": 0, + "id_supplier": 2, + "product_supplier_reference": "", + "product_supplier_price_te": 0, + "id_currency": 1 + } } ] diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 5046e3a9..56a2c92d 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -28,7 +28,6 @@ const EXCLUDED_API: ShopContent[] = ["taxonomies" as ShopContent]; // FIXME : these api can't send anything to the mock api because the database is empty from the factory const MISSING_TEST_DATA: ShopContent[] = [ "cart-rules" as ShopContent, - "custom-product-carriers" as ShopContent, "translations" as ShopContent, "wishlists" as ShopContent, ]; diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 45fb5bae..061755f5 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -47,6 +47,7 @@ export const shopContentMapping = { products: "products", product_bundles: "product-bundles", product_suppliers: "product-suppliers", + product_carriers: "product-carriers", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Config/Config.php b/src/Config/Config.php index 8ddb35a8..6121d566 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -40,7 +40,6 @@ class Config const COLLECTION_CART_RULES = 'cart_rules'; const COLLECTION_CATEGORIES = 'categories'; const COLLECTION_CURRENCIES = 'currencies'; - const COLLECTION_CUSTOM_PRODUCT_CARRIERS = 'custom_product_carriers'; const COLLECTION_CUSTOMERS = 'customers'; const COLLECTION_DELETED = 'deleted'; const COLLECTION_EMPLOYEES = 'employees'; @@ -58,6 +57,7 @@ class Config const COLLECTION_PRODUCTS = 'products'; const COLLECTION_PRODUCT_ATTRIBUTES = 'attributes'; const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; + const COLLECTION_PRODUCT_CARRIERS = 'product_carriers'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; const COLLECTION_SHOPS = 'shops'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; @@ -80,7 +80,6 @@ class Config self::COLLECTION_CART_RULES, self::COLLECTION_CATEGORIES, self::COLLECTION_CURRENCIES, - self::COLLECTION_CUSTOM_PRODUCT_CARRIERS, self::COLLECTION_CUSTOMERS, self::COLLECTION_DELETED, self::COLLECTION_EMPLOYEES, @@ -97,6 +96,7 @@ class Config self::COLLECTION_PRODUCTS, self::COLLECTION_PRODUCT_ATTRIBUTES, self::COLLECTION_PRODUCT_BUNDLES, + self::COLLECTION_PRODUCT_CARRIERS, self::COLLECTION_PRODUCT_SUPPLIERS, self::COLLECTION_SHOPS, self::COLLECTION_SPECIFIC_PRICES, diff --git a/src/Repository/NewRepository/AbstractRepository.php b/src/Repository/NewRepository/AbstractRepository.php index f79b4b69..bf4d1fb7 100644 --- a/src/Repository/NewRepository/AbstractRepository.php +++ b/src/Repository/NewRepository/AbstractRepository.php @@ -33,6 +33,19 @@ public function __construct() $this->db = \Db::getInstance(); } + /** + * @param string $tableName + * @param string $alias + * + * @return void + */ + public function generateMinimalQuery($tableName, $alias) + { + $this->query = new \DbQuery(); + + $this->query->from($tableName, $alias); + } + /** * @return \Context */ diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index d5bc0491..ab68ef85 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -6,19 +6,6 @@ class CarrierRepository extends AbstractRepository implements RepositoryInterfac { const TABLE_NAME = 'carrier'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/CartProductRepository.php b/src/Repository/NewRepository/CartProductRepository.php index 7a0611e9..203e9a29 100644 --- a/src/Repository/NewRepository/CartProductRepository.php +++ b/src/Repository/NewRepository/CartProductRepository.php @@ -6,19 +6,6 @@ class CartProductRepository extends AbstractRepository implements RepositoryInte { const TABLE_NAME = 'cart_product'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/CartRepository.php b/src/Repository/NewRepository/CartRepository.php index 86618779..c364c91a 100644 --- a/src/Repository/NewRepository/CartRepository.php +++ b/src/Repository/NewRepository/CartRepository.php @@ -6,19 +6,6 @@ class CartRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'cart'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/CartRuleRepository.php b/src/Repository/NewRepository/CartRuleRepository.php index ae2e66ee..76f0208b 100644 --- a/src/Repository/NewRepository/CartRuleRepository.php +++ b/src/Repository/NewRepository/CartRuleRepository.php @@ -6,19 +6,6 @@ class CartRuleRepository extends AbstractRepository implements RepositoryInterfa { const TABLE_NAME = 'cart_rule'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/NewRepository/OrderCartRuleRepository.php index b9673c55..c51a81de 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/NewRepository/OrderCartRuleRepository.php @@ -6,19 +6,6 @@ class OrderCartRuleRepository extends AbstractRepository implements RepositoryIn { const TABLE_NAME = 'order_cart_rule'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php index 9fd6562a..09a35694 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -6,19 +6,6 @@ class OrderDetailRepository extends AbstractRepository implements RepositoryInte { const TABLE_NAME = 'order_detail'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php index a5f32a27..ae753929 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -6,19 +6,6 @@ class OrderHistoryRepository extends AbstractRepository implements RepositoryInt { const TABLE_NAME = 'order_history'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php index 96724d9f..c0967bc7 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -6,19 +6,6 @@ class OrderRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'orders'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/ProductBundleRepository.php b/src/Repository/NewRepository/ProductBundleRepository.php index 8ef46be4..69037b61 100644 --- a/src/Repository/NewRepository/ProductBundleRepository.php +++ b/src/Repository/NewRepository/ProductBundleRepository.php @@ -6,19 +6,6 @@ class ProductBundleRepository extends AbstractRepository implements RepositoryIn { const TABLE_NAME = 'pack'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/ProductCarrierRepository.php b/src/Repository/NewRepository/ProductCarrierRepository.php new file mode 100644 index 00000000..9e4960e8 --- /dev/null +++ b/src/Repository/NewRepository/ProductCarrierRepository.php @@ -0,0 +1,91 @@ +generateMinimalQuery(self::TABLE_NAME, 'pc'); + + $this->query->where('pc.id_shop = ' . parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query->select('pc.*'); + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('pc.id_carrier_reference IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/NewRepository/ProductRepository.php index 32ac6667..9f4476c1 100644 --- a/src/Repository/NewRepository/ProductRepository.php +++ b/src/Repository/NewRepository/ProductRepository.php @@ -6,19 +6,6 @@ class ProductRepository extends AbstractRepository implements RepositoryInterfac { const TABLE_NAME = 'product'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/ProductSupplierRepository.php b/src/Repository/NewRepository/ProductSupplierRepository.php index 5af97296..f22f114c 100644 --- a/src/Repository/NewRepository/ProductSupplierRepository.php +++ b/src/Repository/NewRepository/ProductSupplierRepository.php @@ -6,19 +6,6 @@ class ProductSupplierRepository extends AbstractRepository implements Repository { const TABLE_NAME = 'product_supplier'; - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias) - { - $this->query = new \DbQuery(); - - $this->query->from($tableName, $alias); - } - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php index 39a84941..f0c0061f 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -7,14 +7,6 @@ */ interface RepositoryInterface { - /** - * @param string $tableName - * @param string $alias - * - * @return void - */ - public function generateMinimalQuery($tableName, $alias); - /** * @param string $langIso * @param bool $withSelecParameters diff --git a/src/Repository/ProductCarrierRepository.php b/src/Repository/ProductCarrierRepository.php deleted file mode 100644 index 861104fa..00000000 --- a/src/Repository/ProductCarrierRepository.php +++ /dev/null @@ -1,182 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - $query = new \DbQuery(); - - $query->from('product_carrier', 'pc'); - $query->where('pc.id_shop = ' . $this->shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getProductCarriers($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * - * @return int - * - * @throws \PrestaShopDatabaseException - */ - public function getRemainingProductCarriersCount($offset) - { - $productCarriers = $this->getProductCarriers($offset, 1); - - if (!is_array($productCarriers) || empty($productCarriers)) { - return 0; - } - - return count($productCarriers); - } - - /** - * @param string $type - * @param string $langIso - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getProductCarrierIncremental($type, $langIso) - { - $query = new \DbQuery(); - $query->from(IncrementalSyncRepository::INCREMENTAL_SYNC_TABLE, 'aic'); - $query->leftJoin(EventbusSyncRepository::TYPE_SYNC_TABLE_NAME, 'ts', 'ts.type = aic.type'); - $query->where('aic.type = "' . (string) $type . '"'); - $query->where('ts.id_shop = ' . $this->shopId); - $query->where('ts.lang_iso = "' . (string) $langIso . '"'); - - return $this->db->executeS($query); - } - - /** - * @param array $productIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getProductCarriersProperties($productIds) - { - if (!$productIds) { - return []; - } - $query = new \DbQuery(); - - $query->select('pc.*') - ->from('product_carrier', 'pc') - ->where('pc.id_product IN (' . implode(',', array_map('intval', $productIds)) . ')'); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param array $productIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getProductCarrierIdsByProductIds($productIds) - { - if (!$productIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('pc.id_carrier_reference as id'); - $query->where('pc.id_product IN (' . implode(',', array_map('intval', $productIds)) . ')'); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('pc.id_carrier_reference, pc.id_product'); - } -} diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/ProductCarriersService.php new file mode 100644 index 00000000..cfc4ff63 --- /dev/null +++ b/src/Service/ShopContent/ProductCarriersService.php @@ -0,0 +1,79 @@ +productCarrierRepository = $productCarrierRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->productCarrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + return array_map(function ($item) { + return [ + 'id' => $item['id_carrier_reference'], + 'collection' => Config::COLLECTION_PRODUCT_CARRIERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->productCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + return array_map(function ($item) { + return [ + 'id' => $item['id_product'] . '-' . $item['id_carrier_reference'], + 'collection' => Config::COLLECTION_PRODUCT_CARRIERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->productCarrierRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } +} From b00e71928be4925f21552a55bedc4393422c51f8 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:30:48 +0200 Subject: [PATCH 078/162] feat: pseventbus v4 categories (#366) --- Makefile | 2 +- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 10 +- e2e/src/fixtures/1.6/cart_rules.json | 1 + e2e/src/fixtures/1.7/cart_rules.json | 1 + e2e/src/fixtures/8/cart_rules.json | 1 + e2e/src/fixtures/9/cart_rules.json | 1 + e2e/src/full-sync.spec.ts | 154 ++++-------- e2e/src/helpers/mock-probe.ts | 2 +- e2e/src/helpers/shop-contents.ts | 1 + src/Decorator/CategoryDecorator.php | 40 --- src/Repository/CategoryRepository.php | 237 ------------------ .../NewRepository/CategoryRepository.php | 138 ++++++++++ src/Service/ShopContent/CategoriesService.php | 156 ++++++++++++ src/Service/ShopContent/ProductsService.php | 13 +- 16 files changed, 373 insertions(+), 394 deletions(-) create mode 100644 e2e/src/fixtures/1.6/cart_rules.json create mode 100644 e2e/src/fixtures/1.7/cart_rules.json create mode 100644 e2e/src/fixtures/8/cart_rules.json create mode 100644 e2e/src/fixtures/9/cart_rules.json delete mode 100644 src/Decorator/CategoryDecorator.php delete mode 100644 src/Repository/CategoryRepository.php create mode 100644 src/Repository/NewRepository/CategoryRepository.php create mode 100644 src/Service/ShopContent/CategoriesService.php diff --git a/Makefile b/Makefile index 168defc4..eb937fa7 100644 --- a/Makefile +++ b/Makefile @@ -151,7 +151,7 @@ docker-phpunit-cov: tools/vendor .PHONY: phpstan docker-phpstan phpstan: tools/vendor prestashop/prestashop-${PS_VERSION} phpstan analyse --memory-limit=-1 --configuration=./tests/phpstan/phpstan-local.neon; -docker-phpstan: +docker-phpstan: tools/vendor @$(call in_docker,/usr/bin/phpstan,analyse --memory-limit=-1 --configuration=./tests/phpstan/phpstan-docker.neon) define COMMENT diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index c70954d4..a71f147a 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -46,3 +46,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 512810f3..db5f2c2d 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -15,12 +15,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CategoryRepository: - class: PrestaShop\Module\PsEventbus\Repository\CategoryRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CustomerRepository: class: PrestaShop\Module\PsEventbus\Repository\CustomerRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 41fff97b..6cd3230a 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -119,9 +119,9 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' - - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService: @@ -141,3 +141,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository' diff --git a/e2e/src/fixtures/1.6/cart_rules.json b/e2e/src/fixtures/1.6/cart_rules.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/cart_rules.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/cart_rules.json b/e2e/src/fixtures/1.7/cart_rules.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/cart_rules.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/cart_rules.json b/e2e/src/fixtures/8/cart_rules.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/cart_rules.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/9/cart_rules.json b/e2e/src/fixtures/9/cart_rules.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/cart_rules.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 3b7a4b1d..1d127378 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -3,7 +3,7 @@ import * as matchers from "jest-extended"; import { dumpUploadData, logAxiosError } from "./helpers/log-helper"; import axios, { AxiosError } from "axios"; import { doFullSync, probe, PsEventbusSyncUpload } from "./helpers/mock-probe"; -import { from, lastValueFrom, toArray, withLatestFrom } from "rxjs"; +import { lastValueFrom, toArray, withLatestFrom } from "rxjs"; import { generatePredictableModuleId, loadFixture, @@ -17,13 +17,6 @@ expect.extend(matchers); // these ShopContent will be excluded from the following test suite const EXCLUDED_API: ShopContent[] = ["taxonomies" as ShopContent]; -// FIXME : these api can't send anything to the mock api because the database is empty from the factory -const MISSING_TEST_DATA: ShopContent[] = [ - "cart-rules" as ShopContent, - "translations" as ShopContent, - "wishlists" as ShopContent, -]; - // these fields change from test run to test run, so we replace them with a matcher to only ensure the type and format are correct const isDateString = (val) => val ? expect(val).toBeDateString() : expect(val).toBeNull(); @@ -70,8 +63,6 @@ describe("Full Sync", () => { // TODO : apiGoogleTaxonomies requires an additional module to be present : devise a specific test setup for this endpoint it.skip(`${shoContent} should accept full sync`, async () => {}); - it.skip(`${shoContent} should upload to collector`, async () => {}); - it(`${shoContent} should reject full sync when ps_facebook is not installed`, async () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; @@ -128,98 +119,61 @@ describe("Full Sync", () => { }); }); - if (MISSING_TEST_DATA.includes(shopContent)) { - it.skip(`${shopContent} should upload to collector`, () => {}); - } else { - it.skip(`${shopContent} should upload to collector`, async () => { - // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; - const message$ = probe({ url: `/upload/${jobId}` }); - - const callId = { call_id: Math.random().toString(36).substring(2, 11) }; - - // act - const request$ = from( - axios.post(url, callId, { - headers: { - Host: testConfig.prestaShopHostHeader, - "Content-Type": "application/x-www-form-urlencoded", // for compat PHP 5.6 - }, - }), - ); - - const probeMessage = await lastValueFrom( - request$.pipe(withLatestFrom(message$, (_, message) => message)), - ); - - // assert - expect(probeMessage).toBeTruthy(); - expect(probeMessage.method).toBe("POST"); - expect(probeMessage.headers).toMatchObject({ - "full-sync-requested": "1", - }); - }); - } - - if (MISSING_TEST_DATA.includes(shopContent)) { - it.skip(`${shopContent} should upload complete dataset to collector`, () => {}); - } else { - it(`${shopContent} should upload complete dataset collector`, async () => { - // arrange - const response$ = doFullSync(jobId, controller, { timeout: 4000 }); - const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); - - // this combines each response from ps_eventbus to the last request captured by the probe. - // it works because ps_eventbus sends a response after calling our mock collector server - // if ps_eventbus doesn't need to call the collector, the probe completes without value after its timeout - const messages = await lastValueFrom( - response$.pipe( - withLatestFrom(message$, (_, message) => message.body.file), - toArray(), - ), - ); - - const syncedData: PsEventbusSyncUpload[] = messages.flat(); - - // dump data for easier debugging or updating fixtures - let processedData = syncedData as PsEventbusSyncUpload[]; - if (testConfig.dumpFullSyncData) { - await dumpUploadData(syncedData, shopContent); - } - - const fixture = await loadFixture(shopContent); + it(`${shopContent} should upload complete dataset collector`, async () => { + // arrange + const response$ = doFullSync(jobId, shopContent, { timeout: 4000 }); + const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); + + // this combines each response from ps_eventbus to the last request captured by the probe. + // it works because ps_eventbus sends a response after calling our mock collector server + // if ps_eventbus doesn't need to call the collector, the probe completes without value after its timeout + const messages = await lastValueFrom( + response$.pipe( + withLatestFrom(message$, (_, message) => message.body.file), + toArray(), + ), + ); + + const syncedData: PsEventbusSyncUpload[] = messages.flat(); + + // dump data for easier debugging or updating fixtures + let processedData = syncedData as PsEventbusSyncUpload[]; + if (testConfig.dumpFullSyncData) { + await dumpUploadData(syncedData, shopContent); + } + + const fixture = await loadFixture(shopContent); + + // we need to process fixtures and data returned from ps_eventbus to make them easier to compare + let processedFixture = fixture; + if (shopContent === ("modules" as ShopContent)) { + processedData = generatePredictableModuleId(processedData); + processedFixture = generatePredictableModuleId(processedFixture); + } + processedData = omitProperties( + processedData, + Object.keys(specialFieldAssert), + ); + processedData = sortUploadData(processedData); + processedFixture = omitProperties( + processedFixture, + Object.keys(specialFieldAssert), + ); + processedFixture = sortUploadData(processedFixture); - // we need to process fixtures and data returned from ps_eventbus to make them easier to compare - let processedFixture = fixture; - if (shopContent === ("modules" as ShopContent)) { - processedData = generatePredictableModuleId(processedData); - processedFixture = generatePredictableModuleId(processedFixture); - } - processedData = omitProperties( - processedData, - Object.keys(specialFieldAssert), - ); - processedData = sortUploadData(processedData); - processedFixture = omitProperties( - processedFixture, - Object.keys(specialFieldAssert), - ); - processedFixture = sortUploadData(processedFixture); - - // assert - expect(processedData).toMatchObject(processedFixture); - - // assert special field using custom matcher - for (const data of processedData) { - for (const specialFieldName of Object.keys(specialFieldAssert)) { - if (data.properties[specialFieldName] !== undefined) { - specialFieldAssert[specialFieldName]( - data.properties[specialFieldName], - ); - } + // assert + expect(processedData).toMatchObject(processedFixture); + + // assert special field using custom matcher + for (const data of processedData) { + for (const specialFieldName of Object.keys(specialFieldAssert)) { + if (data.properties[specialFieldName] !== undefined) { + specialFieldAssert[specialFieldName]( + data.properties[specialFieldName], + ); } } - }); - } + } + }); }); }); diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index 77c5c825..cf633710 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -81,7 +81,7 @@ export function probe( return socket.pipe( filter((message) => (match ? R.whereEq(match, message) : true)), - takeUntil(timer(options.timeout)), + takeUntil(timer(options.timeout)) ); } diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 061755f5..7fb312a5 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -48,6 +48,7 @@ export const shopContentMapping = { product_bundles: "product-bundles", product_suppliers: "product-suppliers", product_carriers: "product-carriers", + categories: "categories" } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Decorator/CategoryDecorator.php b/src/Decorator/CategoryDecorator.php deleted file mode 100644 index 3842692d..00000000 --- a/src/Decorator/CategoryDecorator.php +++ /dev/null @@ -1,40 +0,0 @@ - $categories - * - * @return void - */ - public function decorateCategories(&$categories) - { - foreach ($categories as &$category) { - $this->castPropertyValues($category); - $this->formatDescription($category); - } - } - - /** - * @param array $category - * - * @return void - */ - private function castPropertyValues(&$category) - { - $category['id_category'] = (int) $category['id_category']; - $category['id_parent'] = (int) $category['id_parent']; - } - - /** - * @param array $category - * - * @return void - */ - private function formatDescription(&$category) - { - $category['description'] = base64_encode($category['description']); - } -} diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php deleted file mode 100644 index b96cdc54..00000000 --- a/src/Repository/CategoryRepository.php +++ /dev/null @@ -1,237 +0,0 @@ - - */ - private $categoryLangCache; - - /** - * @var \Context - */ - private $context; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @param string $langIso - * - * @return \DbQuery - */ - private function getBaseQuery($langIso) - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - $query->from('category_shop', 'cs') - ->innerJoin('category', 'c', 'cs.id_category = c.id_category') - ->leftJoin('category_lang', 'cl', 'cl.id_category = cs.id_category') - ->leftJoin('lang', 'l', 'l.id_lang = cl.id_lang') - ->where('cs.id_shop = ' . $shopId) - ->where('cl.id_shop = cs.id_shop') - ->where('l.iso_code = "' . pSQL($langIso) . '"'); - - return $query; - } - - /** - * @param int $topCategoryId - * @param int $langId - * @param int $shopId - * - * @return array - */ - public function getCategoryPaths($topCategoryId, $langId, $shopId) - { - if ((int) $topCategoryId === 0) { - return [ - 'category_path' => '', - 'category_id_path' => '', - ]; - } - - $categories = []; - - try { - $categoriesWithParentsInfo = $this->getCategoriesWithParentInfo($langId, $shopId); - } catch (\PrestaShopDatabaseException $e) { - return [ - 'category_path' => '', - 'category_id_path' => '', - ]; - } - - $this->buildCategoryPaths($categoriesWithParentsInfo, $topCategoryId, $categories); - - $categories = array_reverse($categories); - - return [ - 'category_path' => implode(' > ', array_map(function ($category) { - return $category['name']; - }, $categories)), - 'category_id_path' => implode(' > ', array_map(function ($category) { - return $category['id_category']; - }, $categories)), - ]; - } - - /** - * @param array $categoriesWithParentsInfo - * @param int $currentCategoryId - * @param array $categories - * - * @return void - */ - private function buildCategoryPaths($categoriesWithParentsInfo, $currentCategoryId, &$categories) - { - foreach ($categoriesWithParentsInfo as $category) { - if ($category['id_category'] == $currentCategoryId) { - $categories[] = $category; - $this->buildCategoryPaths($categoriesWithParentsInfo, $category['id_parent'], $categories); - } - } - } - - /** - * @param int $langId - * @param int $shopId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getCategoriesWithParentInfo($langId, $shopId) - { - if (!isset($this->categoryLangCache[$langId])) { - $query = new \DbQuery(); - - $query->select('c.id_category, cl.name, c.id_parent') - ->from('category', 'c') - ->leftJoin( - 'category_lang', - 'cl', - 'cl.id_category = c.id_category AND cl.id_shop = ' . (int) $shopId - ) - ->where('cl.id_lang = ' . (int) $langId) - ->orderBy('cl.id_category'); - - $result = $this->db->executeS($query); - - if (is_array($result)) { - $this->categoryLangCache[$langId] = $result; - } else { - throw new \PrestaShopDatabaseException('No categories found'); - } - } - - return $this->categoryLangCache[$langId]; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCategories($offset, $limit, $langIso) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingCategoriesCount($offset, $langIso) - { - $query = $this->getBaseQuery($langIso) - ->select('(COUNT(cs.id_category) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $categoryIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCategoriesIncremental($limit, $langIso, $categoryIds) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->where('c.id_category IN(' . implode(',', array_map('intval', $categoryIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('CONCAT(cs.id_category, "-", l.iso_code) as unique_category_id, cs.id_category'); - $query->select('c.id_parent, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description'); - $query->select('l.iso_code, c.date_add as created_at, c.date_upd as updated_at'); - } -} diff --git a/src/Repository/NewRepository/CategoryRepository.php b/src/Repository/NewRepository/CategoryRepository.php new file mode 100644 index 00000000..45b6f241 --- /dev/null +++ b/src/Repository/NewRepository/CategoryRepository.php @@ -0,0 +1,138 @@ +generateMinimalQuery(self::TABLE_NAME, 'cs'); + + $this->query + ->innerJoin('category', 'c', 'cs.id_category = c.id_category') + ->leftJoin('category_lang', 'cl', 'cl.id_category = cs.id_category') + ->leftJoin('lang', 'l', 'l.id_lang = cl.id_lang') + ->where('cs.id_shop = ' . parent::getShopContext()->id) + ->where('cl.id_shop = cs.id_shop') + ->where('l.iso_code = "' . pSQL($langIso) . '"') + ; + + if ($withSelecParameters) { + $this->query + ->select('CONCAT(cs.id_category, "-", l.iso_code) as unique_category_id') + ->select('cs.id_category') + ->select('c.id_parent') + ->select('cl.name') + ->select('cl.description') + ->select('cl.link_rewrite') + ->select('cl.meta_title') + ->select('cl.meta_keywords') + ->select('cl.meta_description') + ->select('l.iso_code') + ->select('c.date_add as created_at') + ->select('c.date_upd as updated_at') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('p.id_category IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } + + /** + * @param int $langId + * @param int $shopId + * + * @return array + * + * @throws \PrestaShopDatabaseException + */ + public function getCategoriesWithParentInfo($langId, $shopId) + { + $this->generateMinimalQuery('category', 'c'); + + $this->query + ->leftJoin('category_lang', 'cl', 'cl.id_category = c.id_category AND cl.id_shop = ' . (int) $shopId) + ->where('cl.id_lang = ' . (int) $langId) + ->orderBy('cl.id_category') + ; + + $this->query + ->select('c.id_category') + ->select('cl.name') + ->select('c.id_parent') + ; + + return $this->runQuery(false); + } +} diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php new file mode 100644 index 00000000..27e6b229 --- /dev/null +++ b/src/Service/ShopContent/CategoriesService.php @@ -0,0 +1,156 @@ +categoryRepository = $categoryRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->categoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCategories($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => "{$item['id_category']}-{$item['iso_code']}", + 'collection' => Config::COLLECTION_CATEGORIES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->categoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCategories($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => "{$item['id_category']}-{$item['iso_code']}", + 'collection' => Config::COLLECTION_CATEGORIES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->categoryRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param int $topCategoryId + * @param int $langId + * @param int $shopId + * + * @return array + */ + public function getCategoryPaths($topCategoryId, $langId, $shopId) + { + if ((int) $topCategoryId === 0) { + return [ + 'category_path' => '', + 'category_id_path' => '', + ]; + } + + $categories = []; + + try { + $categoriesWithParentsInfo = $this->categoryRepository->getCategoriesWithParentInfo($langId, $shopId); + } catch (\PrestaShopDatabaseException $e) { + return [ + 'category_path' => '', + 'category_id_path' => '', + ]; + } + + $this->buildCategoryPaths($categoriesWithParentsInfo, $topCategoryId, $categories); + + $categories = array_reverse($categories); + + return [ + 'category_path' => implode(' > ', array_map(function ($category) { + return $category['name']; + }, $categories)), + 'category_id_path' => implode(' > ', array_map(function ($category) { + return $category['id_category']; + }, $categories)), + ]; + } + + /** + * @param array $categoriesWithParentsInfo + * @param int $currentCategoryId + * @param array $categories + * + * @return void + */ + private function buildCategoryPaths($categoriesWithParentsInfo, $currentCategoryId, &$categories) + { + foreach ($categoriesWithParentsInfo as $category) { + if ($category['id_category'] == $currentCategoryId) { + $categories[] = $category; + $this->buildCategoryPaths($categoriesWithParentsInfo, $category['id_parent'], $categories); + } + } + } + + /** + * @param array $categories + * @param string $langIso + * + * @return void + */ + private function castCategories(&$categories, $langIso) + { + foreach ($categories as &$category) { + $category['id_category'] = (int) $category['id_category']; + $category['id_parent'] = (int) $category['id_parent']; + $category['description'] = base64_encode($category['description']); + } + } +} diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index cdb9150b..ae2258ba 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -4,7 +4,6 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Repository\CategoryRepository; use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository; @@ -13,12 +12,12 @@ class ProductsService implements ShopContentServiceInterface /** @var ProductRepository */ private $productRepository; - /** @var CategoryRepository */ - private $categoryRepository; - /** @var LanguageRepository */ private $languageRepository; + /** @var CategoriesService */ + private $categoriesService; + /** @var ArrayFormatter */ private $arrayFormatter; @@ -30,13 +29,13 @@ class ProductsService implements ShopContentServiceInterface public function __construct( ProductRepository $productRepository, - CategoryRepository $categoryRepository, LanguageRepository $languageRepository, + CategoriesService $categoriesService, ArrayFormatter $arrayFormatter ) { $this->productRepository = $productRepository; - $this->categoryRepository = $categoryRepository; $this->languageRepository = $languageRepository; + $this->categoriesService = $categoriesService; $this->arrayFormatter = $arrayFormatter; $context = \Context::getContext(); @@ -249,7 +248,7 @@ private function formatDescriptions(&$product) */ private function addCategoryTree(&$product) { - $categoryPaths = $this->categoryRepository->getCategoryPaths( + $categoryPaths = $this->categoriesService->getCategoryPaths( $product['id_category_default'], $this->languageRepository->getLanguageIdByIsoCode($product['iso_code']), $this->shopId From ea3c8278c102186b0b49c5b9780e490f1365378e Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:48:18 +0200 Subject: [PATCH 079/162] feat: pseventbus v4 customers (#367) --- OLD/Provider/CustomerDataProvider.php | 106 --------------- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 6 + e2e/src/helpers/mock-probe.ts | 2 +- e2e/src/helpers/shop-contents.ts | 3 +- src/Decorator/CustomerDecorator.php | 47 ------- src/Repository/CustomerRepository.php | 127 ------------------ .../NewRepository/CustomerRepository.php | 102 ++++++++++++++ src/Service/ShopContent/CustomersService.php | 105 +++++++++++++++ .../ShopContent/ProductCarriersService.php | 2 +- 11 files changed, 221 insertions(+), 289 deletions(-) delete mode 100644 OLD/Provider/CustomerDataProvider.php delete mode 100644 src/Decorator/CustomerDecorator.php delete mode 100644 src/Repository/CustomerRepository.php create mode 100644 src/Repository/NewRepository/CustomerRepository.php create mode 100644 src/Service/ShopContent/CustomersService.php diff --git a/OLD/Provider/CustomerDataProvider.php b/OLD/Provider/CustomerDataProvider.php deleted file mode 100644 index 75a682c1..00000000 --- a/OLD/Provider/CustomerDataProvider.php +++ /dev/null @@ -1,106 +0,0 @@ -customerRepository = $customerRepository; - $this->customerDecorator = $customerDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $customers = $this->customerRepository->getCustomers($offset, $limit); - - if (!is_array($customers)) { - return []; - } - - $this->customerDecorator->decorateCustomers($customers); - - return array_map(function ($customer) { - return [ - 'id' => "{$customer['id_customer']}", - 'collection' => Config::COLLECTION_CUSTOMERS, - 'properties' => $customer, - ]; - }, $customers); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->customerRepository->getRemainingCustomersCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $customers = $this->customerRepository->getCustomersIncremental($limit, $objectIds); - - if (!is_array($customers)) { - return []; - } - - $this->customerDecorator->decorateCustomers($customers); - - return array_map(function ($customer) { - return [ - 'id' => "{$customer['id_customer']}", - 'collection' => Config::COLLECTION_CUSTOMERS, - 'properties' => $customer, - ]; - }, $customers); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->customerRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index a71f147a..57f80799 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -50,3 +50,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index db5f2c2d..f986d80f 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -15,12 +15,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CustomerRepository: - class: PrestaShop\Module\PsEventbus\Repository\CustomerRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CurrencyRepository: class: PrestaShop\Module\PsEventbus\Repository\CurrencyRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 6cd3230a..6d8609cc 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -147,3 +147,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository' diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index cf633710..77c5c825 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -81,7 +81,7 @@ export function probe( return socket.pipe( filter((message) => (match ? R.whereEq(match, message) : true)), - takeUntil(timer(options.timeout)) + takeUntil(timer(options.timeout)), ); } diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 7fb312a5..38cf2246 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -48,7 +48,8 @@ export const shopContentMapping = { product_bundles: "product-bundles", product_suppliers: "product-suppliers", product_carriers: "product-carriers", - categories: "categories" + categories: "categories", + customers: "customers", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Decorator/CustomerDecorator.php b/src/Decorator/CustomerDecorator.php deleted file mode 100644 index 97cc6eea..00000000 --- a/src/Decorator/CustomerDecorator.php +++ /dev/null @@ -1,47 +0,0 @@ - $customers - * - * @return void - */ - public function decorateCustomers(&$customers) - { - foreach ($customers as &$customer) { - $this->castPropertyValues($customer); - $this->hashEmail($customer); - } - } - - /** - * @param array $customer - * - * @return void - */ - private function castPropertyValues(&$customer) - { - $customer['id_customer'] = (int) $customer['id_customer']; - $customer['id_lang'] = (int) $customer['id_lang']; - $customer['newsletter'] = (bool) $customer['newsletter']; - $customer['newsletter_date_add'] = (string) $customer['newsletter_date_add']; - $customer['optin'] = (bool) $customer['optin']; - $customer['active'] = (bool) $customer['active']; - $customer['is_guest'] = (bool) $customer['is_guest']; - $customer['deleted'] = (bool) $customer['deleted']; - } - - /** - * @param array $customer - * - * @return void - */ - private function hashEmail(&$customer) - { - $customer['email_hash'] = hash('sha256', $customer['email'] . 'dUj4GMBD6689pL9pyr'); - unset($customer['email']); - } -} diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php deleted file mode 100644 index 27d0d0de..00000000 --- a/src/Repository/CustomerRepository.php +++ /dev/null @@ -1,127 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - $query->from('customer', 'c') - ->where('c.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCustomers($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingCustomersCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(c.id_customer) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $customerIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCustomersIncremental($limit, $customerIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('c.id_customer IN(' . implode(',', array_map('intval', $customerIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('c.id_customer, c.id_lang, c.email, c.newsletter, c.newsletter_date_add'); - $query->select('c.optin, c.active, c.is_guest, c.deleted, c.date_add as created_at, c.date_upd as updated_at'); - } -} diff --git a/src/Repository/NewRepository/CustomerRepository.php b/src/Repository/NewRepository/CustomerRepository.php new file mode 100644 index 00000000..604334cd --- /dev/null +++ b/src/Repository/NewRepository/CustomerRepository.php @@ -0,0 +1,102 @@ +generateMinimalQuery(self::TABLE_NAME, 'c'); + + $this->query->where('c.id_shop = ' . parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query->select('c.id_customer') + ->select('c.id_lang') + ->select('c.email') + ->select('c.newsletter') + ->select('c.newsletter_date_add') + ->select('c.optin') + ->select('c.active') + ->select('c.is_guest') + ->select('c.deleted') + ->select('c.date_add as created_at') + ->select('c.date_upd as updated_at') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('c.id_customer IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php new file mode 100644 index 00000000..c703fa53 --- /dev/null +++ b/src/Service/ShopContent/CustomersService.php @@ -0,0 +1,105 @@ +customerRepository = $customerRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->customerRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCustomers($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_customer'], + 'collection' => Config::COLLECTION_CUSTOMERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->customerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCustomers($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_customer'], + 'collection' => Config::COLLECTION_CUSTOMERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->customerRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $customers + * + * @return void + */ + private function castCustomers(&$customers) + { + foreach ($customers as &$customer) { + $customer['id_customer'] = (int) $customer['id_customer']; + $customer['id_lang'] = (int) $customer['id_lang']; + $customer['newsletter'] = (bool) $customer['newsletter']; + $customer['newsletter_date_add'] = (string) $customer['newsletter_date_add']; + $customer['optin'] = (bool) $customer['optin']; + $customer['active'] = (bool) $customer['active']; + $customer['is_guest'] = (bool) $customer['is_guest']; + $customer['deleted'] = (bool) $customer['deleted']; + + $customer['email_hash'] = hash('sha256', $customer['email'] . 'dUj4GMBD6689pL9pyr'); + unset($customer['email']); + } + } +} diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/ProductCarriersService.php index cfc4ff63..da3742a7 100644 --- a/src/Service/ShopContent/ProductCarriersService.php +++ b/src/Service/ShopContent/ProductCarriersService.php @@ -33,7 +33,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return array_map(function ($item) { return [ - 'id' => $item['id_carrier_reference'], + 'id' => $item['id_product'] . '-' . $item['id_carrier_reference'], 'collection' => Config::COLLECTION_PRODUCT_CARRIERS, 'properties' => $item, ]; From 4ac48de7fa7a25f76212a8f6f4e5bd179d04940c Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:15:47 +0200 Subject: [PATCH 080/162] feat: pseventbus v4 currencies (#368) --- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 +- config/front/services.yml | 6 + e2e/src/helpers/shop-contents.ts | 1 + src/Decorator/CurrencyDecorator.php | 36 ---- src/Repository/CurrencyRepository.php | 155 ------------------ .../NewRepository/CurrencyRepository.php | 118 +++++++++++++ .../ServerInformationRepository.php | 15 +- src/Service/ShopContent/CurrenciesService.php | 125 ++++++++++++++ 9 files changed, 263 insertions(+), 203 deletions(-) delete mode 100644 src/Decorator/CurrencyDecorator.php delete mode 100644 src/Repository/CurrencyRepository.php create mode 100644 src/Repository/NewRepository/CurrencyRepository.php create mode 100644 src/Service/ShopContent/CurrenciesService.php diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 57f80799..a6ea9bbe 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -54,3 +54,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index f986d80f..7eaa0b12 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -15,10 +15,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CurrencyRepository: - class: PrestaShop\Module\PsEventbus\Repository\CurrencyRepository - public: true - PrestaShop\Module\PsEventbus\Repository\ModuleRepository: class: PrestaShop\Module\PsEventbus\Repository\ModuleRepository public: true @@ -29,10 +25,10 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - - '@PrestaShop\Module\PsEventbus\Repository\CurrencyRepository' - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' - '%ps_eventbus.sync_api_url%' - '%ps_eventbus.live_sync_api_url%' diff --git a/config/front/services.yml b/config/front/services.yml index 6d8609cc..2caf84ae 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -153,3 +153,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 38cf2246..d82316dd 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -50,6 +50,7 @@ export const shopContentMapping = { product_carriers: "product-carriers", categories: "categories", customers: "customers", + currencies: "currencies", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Decorator/CurrencyDecorator.php b/src/Decorator/CurrencyDecorator.php deleted file mode 100644 index 64060be8..00000000 --- a/src/Decorator/CurrencyDecorator.php +++ /dev/null @@ -1,36 +0,0 @@ - $currencies - * - * @return void - */ - public function decorateCurrencies(&$currencies) - { - foreach ($currencies as &$currency) { - $this->castPropertyValues($currency); - } - } - - /** - * @param array $currency - * - * @return void - */ - private function castPropertyValues(&$currency) - { - $currency['id_currency'] = (int) $currency['id_currency']; - $currency['conversion_rate'] = (float) $currency['conversion_rate']; - $currency['deleted'] = (bool) $currency['deleted']; - $currency['active'] = (bool) $currency['active']; - - // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { - $currency['precision'] = (int) $currency['precision']; - } - } -} diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php deleted file mode 100644 index 9116055c..00000000 --- a/src/Repository/CurrencyRepository.php +++ /dev/null @@ -1,155 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @return mixed - */ - private function isLangAvailable() - { - return defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6', '>='); - } - - /** - * @return array - */ - public function getCurrenciesIsoCodes() - { - $currencies = \Currency::getCurrencies(); - - return array_map(function ($currency) { - return $currency['iso_code']; - }, $currencies); - } - - /** - * @return string - */ - public function getDefaultCurrencyIsoCode() - { - $currency = \Currency::getDefaultCurrency(); - - return $currency instanceof \Currency ? $currency->iso_code : ''; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCurrencies($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingCurrenciesCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(c.id_currency) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $currencyIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getCurrenciesIncremental($limit, $currencyIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('c.id_currency IN(' . implode(',', array_map('intval', $currencyIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - $query = new \DbQuery(); - $query->from('currency', 'c'); - if ($this->isLangAvailable()) { - $query->innerJoin('currency_lang', 'cl', 'cl.id_currency = c.id_currency'); - } - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - if ($this->isLangAvailable()) { - $query->select('c.id_currency, cl.name, c.iso_code, c.conversion_rate, c.deleted, c.active'); - } else { - $query->select('c.id_currency, \'\' as name, c.iso_code, c.conversion_rate, c.deleted, c.active'); - } - - // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { - $query->select('c.precision'); - } - } -} diff --git a/src/Repository/NewRepository/CurrencyRepository.php b/src/Repository/NewRepository/CurrencyRepository.php new file mode 100644 index 00000000..0e20ace7 --- /dev/null +++ b/src/Repository/NewRepository/CurrencyRepository.php @@ -0,0 +1,118 @@ +generateMinimalQuery(self::TABLE_NAME, 'c'); + + if ($this->isCurrencyLangAvailable()) { + $this->query->innerJoin('currency_lang', 'cl', 'cl.id_currency = c.id_currency'); + } + + if ($withSelecParameters) { + $this->query + ->select('c.id_currency') + ->select('c.iso_code') + ->select('c.conversion_rate') + ->select('c.deleted') + ->select('c.active') + ; + + if ($this->isCurrencyLangAvailable()) { + $this->query->select('cl.name'); + } else { + $this->query->select('\'\' as name'); + } + + // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { + $this->query->select('c.precision'); + } + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('c.id_currency IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } + + /** + * @return mixed + */ + private function isCurrencyLangAvailable() + { + return defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6', '>='); + } +} diff --git a/src/Repository/ServerInformationRepository.php b/src/Repository/ServerInformationRepository.php index 02bd7e17..75403f0b 100644 --- a/src/Repository/ServerInformationRepository.php +++ b/src/Repository/ServerInformationRepository.php @@ -6,13 +6,14 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; +use PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService; class ServerInformationRepository { /** - * @var CurrencyRepository + * @var CurrenciesService */ - private $currencyRepository; + private $currenciesService; /** * @var LanguageRepository */ @@ -49,10 +50,10 @@ class ServerInformationRepository /** * @param \Context $context * @param PsAccountsAdapterService $psAccountsAdapterService - * @param CurrencyRepository $currencyRepository * @param LanguageRepository $languageRepository * @param ConfigurationRepository $configurationRepository * @param ShopRepository $shopRepository + * @param CurrenciesService $currenciesService * @param ErrorHandlerInterface $errorHandler * @param string $eventbusSyncApiUrl * @param string $eventbusLiveSyncApiUrl @@ -63,16 +64,16 @@ class ServerInformationRepository public function __construct( \Context $context, PsAccountsAdapterService $psAccountsAdapterService, - CurrencyRepository $currencyRepository, LanguageRepository $languageRepository, ConfigurationRepository $configurationRepository, ShopRepository $shopRepository, + CurrenciesService $currenciesService, ErrorHandlerInterface $errorHandler, $eventbusSyncApiUrl, $eventbusLiveSyncApiUrl, $eventbusProxyApiUrl ) { - $this->currencyRepository = $currencyRepository; + $this->currenciesService = $currenciesService; $this->languageRepository = $languageRepository; $this->configurationRepository = $configurationRepository; $this->shopRepository = $shopRepository; @@ -123,8 +124,8 @@ public function getServerInformation($langIso = '') 'cart_is_persistent' => $this->configurationRepository->get('PS_CART_FOLLOWING') == '1', 'default_language' => $this->languageRepository->getDefaultLanguageIsoCode(), 'languages' => implode(';', $this->languageRepository->getLanguagesIsoCodes()), - 'default_currency' => $this->currencyRepository->getDefaultCurrencyIsoCode(), - 'currencies' => implode(';', $this->currencyRepository->getCurrenciesIsoCodes()), + 'default_currency' => $this->currenciesService->getDefaultCurrencyIsoCode(), + 'currencies' => implode(';', $this->currenciesService->getCurrenciesIsoCodes()), 'weight_unit' => $this->configurationRepository->get('PS_WEIGHT_UNIT'), 'distance_unit' => $this->configurationRepository->get('PS_BASE_DISTANCE_UNIT'), 'volume_unit' => $this->configurationRepository->get('PS_VOLUME_UNIT'), diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php new file mode 100644 index 00000000..01e1582d --- /dev/null +++ b/src/Service/ShopContent/CurrenciesService.php @@ -0,0 +1,125 @@ +currencyRepository = $currencyRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->currencyRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCurrencies($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_currency'], + 'collection' => Config::COLLECTION_CURRENCIES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->currencyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCurrencies($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_currency'], + 'collection' => Config::COLLECTION_CURRENCIES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->currencyRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $currencies + * + * @return void + */ + private function castCurrencies(&$currencies) + { + foreach ($currencies as &$currency) { + $currency['id_currency'] = (int) $currency['id_currency']; + $currency['conversion_rate'] = (float) $currency['conversion_rate']; + $currency['deleted'] = (bool) $currency['deleted']; + $currency['active'] = (bool) $currency['active']; + + // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { + $currency['precision'] = (int) $currency['precision']; + } + } + } + + /** + * @return array + */ + public function getCurrenciesIsoCodes() + { + $currencies = \Currency::getCurrencies(); + + return array_map(function ($currency) { + return $currency['iso_code']; + }, $currencies); + } + + /** + * @return string + */ + public function getDefaultCurrencyIsoCode() + { + $currency = \Currency::getDefaultCurrency(); + + return $currency instanceof \Currency ? $currency->iso_code : ''; + } +} From 6884b2db763f23964a82a3bf61a79d30d8fa5646 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:53:45 +0200 Subject: [PATCH 081/162] Feat: pseventbus v4 employees (#369) --- OLD/Provider/CustomerDataProvider.php | 106 +++++++++++++ config/common/new-repository.yml | 4 + config/common/repository.yml | 7 - config/front/services.yml | 6 + e2e/src/helpers/shop-contents.ts | 1 + src/Decorator/CurrencyDecorator.php | 36 +++++ src/Decorator/CustomerDecorator.php | 47 ++++++ src/Repository/EmployeeRepository.php | 149 ------------------ .../NewRepository/EmployeeRepository.php | 117 ++++++++++++++ src/Service/ShopContent/EmployeesService.php | 125 +++++++++++++++ 10 files changed, 442 insertions(+), 156 deletions(-) create mode 100644 OLD/Provider/CustomerDataProvider.php create mode 100644 src/Decorator/CurrencyDecorator.php create mode 100644 src/Decorator/CustomerDecorator.php delete mode 100644 src/Repository/EmployeeRepository.php create mode 100644 src/Repository/NewRepository/EmployeeRepository.php create mode 100644 src/Service/ShopContent/EmployeesService.php diff --git a/OLD/Provider/CustomerDataProvider.php b/OLD/Provider/CustomerDataProvider.php new file mode 100644 index 00000000..75a682c1 --- /dev/null +++ b/OLD/Provider/CustomerDataProvider.php @@ -0,0 +1,106 @@ +customerRepository = $customerRepository; + $this->customerDecorator = $customerDecorator; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return array + * + * @@throws \PrestaShopDatabaseException + */ + public function getFormattedData($offset, $limit, $langIso) + { + $customers = $this->customerRepository->getCustomers($offset, $limit); + + if (!is_array($customers)) { + return []; + } + + $this->customerDecorator->decorateCustomers($customers); + + return array_map(function ($customer) { + return [ + 'id' => "{$customer['id_customer']}", + 'collection' => Config::COLLECTION_CUSTOMERS, + 'properties' => $customer, + ]; + }, $customers); + } + + /** + * @param int $offset + * @param string $langIso + * + * @return int + */ + public function getRemainingObjectsCount($offset, $langIso) + { + return (int) $this->customerRepository->getRemainingCustomersCount($offset); + } + + /** + * @param int $limit + * @param string $langIso + * @param array $objectIds + * + * @return array + * + * @@throws \PrestaShopDatabaseException + */ + public function getFormattedDataIncremental($limit, $langIso, $objectIds) + { + $customers = $this->customerRepository->getCustomersIncremental($limit, $objectIds); + + if (!is_array($customers)) { + return []; + } + + $this->customerDecorator->decorateCustomers($customers); + + return array_map(function ($customer) { + return [ + 'id' => "{$customer['id_customer']}", + 'collection' => Config::COLLECTION_CUSTOMERS, + 'properties' => $customer, + ]; + }, $customers); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return array + * + * @@throws \PrestaShopDatabaseException + */ + public function getQueryForDebug($offset, $limit, $langIso) + { + return $this->customerRepository->getQueryForDebug($offset, $limit); + } +} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index a6ea9bbe..e809572f 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -58,3 +58,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 7eaa0b12..3f3a6195 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -118,13 +118,6 @@ services: public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - - - PrestaShop\Module\PsEventbus\Repository\EmployeeRepository: - class: PrestaShop\Module\PsEventbus\Repository\EmployeeRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\ImageRepository: class: PrestaShop\Module\PsEventbus\Repository\ImageRepository diff --git a/config/front/services.yml b/config/front/services.yml index 2caf84ae..3a187e09 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -159,3 +159,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\EmployeesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\EmployeesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index d82316dd..5c2afc84 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -51,6 +51,7 @@ export const shopContentMapping = { categories: "categories", customers: "customers", currencies: "currencies", + employees: "employees", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Decorator/CurrencyDecorator.php b/src/Decorator/CurrencyDecorator.php new file mode 100644 index 00000000..64060be8 --- /dev/null +++ b/src/Decorator/CurrencyDecorator.php @@ -0,0 +1,36 @@ + $currencies + * + * @return void + */ + public function decorateCurrencies(&$currencies) + { + foreach ($currencies as &$currency) { + $this->castPropertyValues($currency); + } + } + + /** + * @param array $currency + * + * @return void + */ + private function castPropertyValues(&$currency) + { + $currency['id_currency'] = (int) $currency['id_currency']; + $currency['conversion_rate'] = (float) $currency['conversion_rate']; + $currency['deleted'] = (bool) $currency['deleted']; + $currency['active'] = (bool) $currency['active']; + + // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { + $currency['precision'] = (int) $currency['precision']; + } + } +} diff --git a/src/Decorator/CustomerDecorator.php b/src/Decorator/CustomerDecorator.php new file mode 100644 index 00000000..97cc6eea --- /dev/null +++ b/src/Decorator/CustomerDecorator.php @@ -0,0 +1,47 @@ + $customers + * + * @return void + */ + public function decorateCustomers(&$customers) + { + foreach ($customers as &$customer) { + $this->castPropertyValues($customer); + $this->hashEmail($customer); + } + } + + /** + * @param array $customer + * + * @return void + */ + private function castPropertyValues(&$customer) + { + $customer['id_customer'] = (int) $customer['id_customer']; + $customer['id_lang'] = (int) $customer['id_lang']; + $customer['newsletter'] = (bool) $customer['newsletter']; + $customer['newsletter_date_add'] = (string) $customer['newsletter_date_add']; + $customer['optin'] = (bool) $customer['optin']; + $customer['active'] = (bool) $customer['active']; + $customer['is_guest'] = (bool) $customer['is_guest']; + $customer['deleted'] = (bool) $customer['deleted']; + } + + /** + * @param array $customer + * + * @return void + */ + private function hashEmail(&$customer) + { + $customer['email_hash'] = hash('sha256', $customer['email'] . 'dUj4GMBD6689pL9pyr'); + unset($customer['email']); + } +} diff --git a/src/Repository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php deleted file mode 100644 index 82aefa5d..00000000 --- a/src/Repository/EmployeeRepository.php +++ /dev/null @@ -1,149 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - - $query->from('employee', 'e') - ->leftJoin('employee_shop', 'es', 'es.id_employee = e.id_employee'); - - $query->where('es.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getEmployees($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingEmployeesCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(e.id_employee) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $employeeIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getEmployeesIncremental($limit, $employeeIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('e.id_employee IN(' . implode(',', array_map('intval', $employeeIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('e.id_employee'); - $query->select('e.id_profile'); - $query->select('e.id_lang'); - $query->select('e.email'); - $query->select('e.bo_color'); - $query->select('e.bo_theme'); - $query->select('e.bo_css'); - $query->select('e.default_tab'); - $query->select('e.bo_width'); - $query->select('e.bo_menu'); - $query->select('e.active'); - $query->select('e.optin'); - $query->select('e.id_last_order'); - $query->select('e.id_last_customer_message'); - $query->select('e.id_last_customer'); - $query->select('e.last_connection_date'); - $query->select('es.id_shop as id_shop'); - - // https://github.com/PrestaShop/PrestaShop/commit/20f1d9fe8a03559dfa9d1f7109de1f70c99f1874#diff-cde6a9d4a58afb13ff068801ee09c0e712c5e90b0cbf5632a0cc965f15cb6802R107 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.8.0', '>=')) { - $query->select('e.has_enabled_gravatar'); - } - } -} diff --git a/src/Repository/NewRepository/EmployeeRepository.php b/src/Repository/NewRepository/EmployeeRepository.php new file mode 100644 index 00000000..e6dfc4de --- /dev/null +++ b/src/Repository/NewRepository/EmployeeRepository.php @@ -0,0 +1,117 @@ +generateMinimalQuery(self::TABLE_NAME, 'e'); + + $this->query + ->leftJoin('employee_shop', 'es', 'es.id_employee = e.id_employee') + ->where('es.id_shop = ' . parent::getShopContext()->id) + ; + + if ($withSelecParameters) { + $this->query + ->select('e.id_employee') + ->select('e.id_profile') + ->select('e.id_lang') + ->select('e.email') + ->select('e.bo_color') + ->select('e.bo_theme') + ->select('e.bo_css') + ->select('e.default_tab') + ->select('e.bo_width') + ->select('e.bo_menu') + ->select('e.active') + ->select('e.optin') + ->select('e.id_last_order') + ->select('e.id_last_customer_message') + ->select('e.id_last_customer') + ->select('e.last_connection_date') + ->select('es.id_shop as id_shop') + ; + + // https://github.com/PrestaShop/PrestaShop/commit/20f1d9fe8a03559dfa9d1f7109de1f70c99f1874#diff-cde6a9d4a58afb13ff068801ee09c0e712c5e90b0cbf5632a0cc965f15cb6802R107 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.8.0', '>=')) { + $this->query->select('e.has_enabled_gravatar'); + } + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('c.id_employee IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php new file mode 100644 index 00000000..50e67742 --- /dev/null +++ b/src/Service/ShopContent/EmployeesService.php @@ -0,0 +1,125 @@ +employeeRepository = $employeeRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->employeeRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castEmployees($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_employee'], + 'collection' => Config::COLLECTION_EMPLOYEES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->employeeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castEmployees($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_employee'], + 'collection' => Config::COLLECTION_EMPLOYEES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->employeeRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $currencies + * + * @return void + */ + private function castEmployees(&$currencies) + { + foreach ($currencies as &$employee) { + $employee['id_employee'] = (int) $employee['id_employee']; + $employee['id_profile'] = (int) $employee['id_profile']; + $employee['id_lang'] = (int) $employee['id_lang']; + + $employee['default_tab'] = (int) $employee['default_tab']; + $employee['bo_width'] = (int) $employee['bo_width']; + $employee['bo_menu'] = (bool) $employee['bo_menu']; + + $employee['optin'] = (bool) $employee['optin']; + $employee['active'] = (bool) $employee['active']; + + $employee['id_last_order'] = (int) $employee['id_last_order']; + $employee['id_last_customer_message'] = (int) $employee['id_last_customer_message']; + $employee['id_last_customer'] = (int) $employee['id_last_customer']; + + if ($employee['last_connection_date'] == '0000-00-00') { + $employee['last_connection_date'] = null; + } else { + $employee['last_connection_date'] = (string) $employee['last_connection_date']; + } + + $employee['id_shop'] = (int) $employee['id_shop']; + + // https://github.com/PrestaShop/PrestaShop/commit/20f1d9fe8a03559dfa9d1f7109de1f70c99f1874#diff-cde6a9d4a58afb13ff068801ee09c0e712c5e90b0cbf5632a0cc965f15cb6802R107 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.8.0', '>=')) { + $employee['has_enabled_gravatar'] = (bool) $employee['has_enabled_gravatar']; + } + + // FIXME : use a random salt generated during module install + $employee['email_hash'] = hash('sha256', $employee['email'] . 'dUj4GMBD6689pL9pyr'); + unset($employee['email']); + } + } +} From 7f9ea0b1729f9394397c10f03045b3ac1fb6a458 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:27:08 +0200 Subject: [PATCH 082/162] feat: pseventbus v4 images and images types (#370) --- OLD/Provider/CartDataProvider.php | 173 ----------------- OLD/Provider/CartRuleDataProvider.php | 137 -------------- OLD/Provider/CategoryDataProvider.php | 106 ----------- OLD/Provider/CurrencyDataProvider.php | 105 ----------- .../CustomProductCarrierDataProvider.php | 85 --------- OLD/Provider/CustomerDataProvider.php | 106 ----------- OLD/Provider/EmployeeDataProvider.php | 106 ----------- OLD/Provider/ImageDataProvider.php | 106 ----------- OLD/Provider/ImageTypeDataProvider.php | 106 ----------- config/common/decorator.yml | 28 --- config/common/new-repository.yml | 8 + config/common/repository.yml | 8 - config/front/services.yml | 12 ++ e2e/src/full-sync.spec.ts | 4 +- e2e/src/helpers/data-helper.ts | 2 +- e2e/src/helpers/mock-probe.ts | 2 +- e2e/src/helpers/shop-contents.ts | 16 +- e2e/src/job-id-validation.spec.ts | 2 +- src/Decorator/CurrencyDecorator.php | 36 ---- src/Decorator/CustomerDecorator.php | 47 ----- src/Decorator/EmployeeDecorator.php | 67 ------- src/Decorator/ImageDecorator.php | 34 ---- src/Decorator/ImageTypeDecorator.php | 36 ---- src/Repository/ImageRepository.php | 177 ------------------ src/Repository/ImageTypeRepository.php | 122 ------------ .../NewRepository/CategoryRepository.php | 2 +- .../NewRepository/EmployeeRepository.php | 2 +- .../NewRepository/ImageRepository.php | 101 ++++++++++ .../NewRepository/ImageTypeRepository.php | 99 ++++++++++ .../NewRepository/ProductBundleRepository.php | 2 +- src/Service/ShopContent/ImageTypesService.php | 103 ++++++++++ src/Service/ShopContent/ImagesService.php | 101 ++++++++++ 32 files changed, 434 insertions(+), 1607 deletions(-) delete mode 100644 OLD/Provider/CartDataProvider.php delete mode 100644 OLD/Provider/CartRuleDataProvider.php delete mode 100644 OLD/Provider/CategoryDataProvider.php delete mode 100644 OLD/Provider/CurrencyDataProvider.php delete mode 100644 OLD/Provider/CustomProductCarrierDataProvider.php delete mode 100644 OLD/Provider/CustomerDataProvider.php delete mode 100644 OLD/Provider/EmployeeDataProvider.php delete mode 100644 OLD/Provider/ImageDataProvider.php delete mode 100644 OLD/Provider/ImageTypeDataProvider.php delete mode 100644 src/Decorator/CurrencyDecorator.php delete mode 100644 src/Decorator/CustomerDecorator.php delete mode 100644 src/Decorator/EmployeeDecorator.php delete mode 100644 src/Decorator/ImageDecorator.php delete mode 100644 src/Decorator/ImageTypeDecorator.php delete mode 100644 src/Repository/ImageRepository.php delete mode 100644 src/Repository/ImageTypeRepository.php create mode 100644 src/Repository/NewRepository/ImageRepository.php create mode 100644 src/Repository/NewRepository/ImageTypeRepository.php create mode 100644 src/Service/ShopContent/ImageTypesService.php create mode 100644 src/Service/ShopContent/ImagesService.php diff --git a/OLD/Provider/CartDataProvider.php b/OLD/Provider/CartDataProvider.php deleted file mode 100644 index d31ab62e..00000000 --- a/OLD/Provider/CartDataProvider.php +++ /dev/null @@ -1,173 +0,0 @@ -cartRepository = $cartRepository; - $this->cartProductRepository = $cartProductRepository; - } - - public function getFormattedData($offset, $limit, $langIso) - { - $carts = $this->cartRepository->getCarts($offset, $limit); - - if (!is_array($carts)) { - return []; - } - - $cartProducts = $this->getCartProducts($carts); - - $this->castCartValues($carts); - - $carts = array_map(function ($cart) { - return [ - 'id' => $cart['id_cart'], - 'collection' => Config::COLLECTION_CARTS, - 'properties' => $cart, - ]; - }, $carts); - - return array_merge($carts, $cartProducts); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->cartRepository->getRemainingCartsCount($offset); - } - - /** - * @param array $carts - * - * @return void - */ - private function castCartValues(&$carts) - { - foreach ($carts as &$cart) { - $cart['id_cart'] = (string) $cart['id_cart']; - } - } - - /** - * @param array $cartProducts - * - * @return void - */ - private function castCartProductValues(&$cartProducts) - { - foreach ($cartProducts as &$cartProduct) { - $cartProduct['id_cart_product'] = (string) "{$cartProduct['id_cart']}-{$cartProduct['id_product']}-{$cartProduct['id_product_attribute']}"; - $cartProduct['id_cart'] = (string) $cartProduct['id_cart']; - $cartProduct['id_product'] = (string) $cartProduct['id_product']; - $cartProduct['id_product_attribute'] = (string) $cartProduct['id_product_attribute']; - $cartProduct['quantity'] = (int) $cartProduct['quantity']; - } - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $carts = $this->cartRepository->getCartsIncremental($limit, $objectIds); - - if (!is_array($carts) || empty($carts)) { - return []; - } - - $cartProducts = $this->getCartProducts($carts); - - $this->castCartValues($carts); - - $carts = array_map(function ($cart) { - return [ - 'id' => $cart['id_cart'], - 'collection' => Config::COLLECTION_CARTS, - 'properties' => $cart, - ]; - }, $carts); - - return array_merge($carts, $cartProducts); - } - - /** - * @param array $carts - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getCartProducts($carts) - { - $cartIds = array_map(function ($cart) { - return (string) $cart['id_cart']; - }, $carts); - - $cartProducts = $this->cartProductRepository->getCartProducts($cartIds); - - if (!is_array($cartProducts) || empty($cartProducts)) { - return []; - } - - $this->castCartProductValues($cartProducts); - - if (is_array($cartProducts)) { - return array_map(function ($cartProduct) { - return [ - 'id' => "{$cartProduct['id_cart']}-{$cartProduct['id_product']}-{$cartProduct['id_product_attribute']}", - 'collection' => Config::COLLECTION_CART_PRODUCTS, - 'properties' => $cartProduct, - ]; - }, $cartProducts); - } - - return []; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->cartRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/OLD/Provider/CartRuleDataProvider.php b/OLD/Provider/CartRuleDataProvider.php deleted file mode 100644 index fc1d9e85..00000000 --- a/OLD/Provider/CartRuleDataProvider.php +++ /dev/null @@ -1,137 +0,0 @@ -cartRuleRepository = $cartRuleRepository; - } - - public function getFormattedData($offset, $limit, $langIso) - { - $cartRules = $this->cartRuleRepository->getCartRules($limit, $offset); - - if (!is_array($cartRules) || empty($cartRules)) { - return []; - } - - $this->castCartRuleValues($cartRules); - - if (is_array($cartRules)) { - return array_map(function ($cartRule) { - return [ - 'id' => $cartRule['id_cart_rule'], - 'collection' => Config::COLLECTION_CART_RULES, - 'properties' => $cartRule, - ]; - }, $cartRules); - } - - return []; - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->cartRuleRepository->getRemainingCartRulesCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $cartRules = $this->cartRuleRepository->getCartRulesIncremental($limit, $objectIds); - - if (!is_array($cartRules)) { - return []; - } - - $this->castCartRuleValues($cartRules); - - return array_map(function ($cartRule) { - return [ - 'id' => $cartRule['id_cart_rule'], - 'collection' => Config::COLLECTION_CART_RULES, - 'properties' => $cartRule, - ]; - }, $cartRules); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->cartRuleRepository->getQueryForDebug($limit, $offset); - } - - /** - * @param array $cartRules - * - * @return void - */ - private function castCartRuleValues(&$cartRules) - { - foreach ($cartRules as &$cartRule) { - $cartRule['id_cart_rule'] = (int) $cartRule['id_cart_rule']; - $cartRule['id_customer'] = (int) $cartRule['id_customer']; - $cartRule['quantity'] = (int) $cartRule['quantity']; - $cartRule['quantity_per_user'] = (int) $cartRule['quantity_per_user']; - $cartRule['priority'] = (int) $cartRule['priority']; - $cartRule['partial_use'] = (bool) $cartRule['partial_use']; - $cartRule['minimum_amount'] = (float) $cartRule['minimum_amount']; - $cartRule['minimum_amount_tax'] = (bool) $cartRule['minimum_amount_tax']; - $cartRule['minimum_amount_currency'] = (int) $cartRule['minimum_amount_currency']; - $cartRule['minimum_amount_shipping'] = (bool) $cartRule['minimum_amount_shipping']; - $cartRule['country_restriction'] = (bool) $cartRule['country_restriction']; - $cartRule['carrier_restriction'] = (bool) $cartRule['carrier_restriction']; - $cartRule['group_restriction'] = (bool) $cartRule['group_restriction']; - $cartRule['cart_rule_restriction'] = (bool) $cartRule['cart_rule_restriction']; - $cartRule['product_restriction'] = (bool) $cartRule['product_restriction']; - $cartRule['shop_restriction'] = (bool) $cartRule['shop_restriction']; - $cartRule['free_shipping'] = (bool) $cartRule['free_shipping']; - $cartRule['reduction_percent'] = (float) $cartRule['reduction_percent']; - $cartRule['reduction_amount'] = (float) $cartRule['reduction_amount']; - $cartRule['reduction_tax'] = (bool) $cartRule['reduction_tax']; - $cartRule['reduction_currency'] = (int) $cartRule['reduction_currency']; - $cartRule['reduction_product'] = (int) $cartRule['reduction_product']; - $cartRule['reduction_exclude_special'] = (bool) $cartRule['reduction_exclude_special']; - $cartRule['gift_product'] = (int) $cartRule['gift_product']; - $cartRule['gift_product_attribute'] = (int) $cartRule['gift_product_attribute']; - $cartRule['highlight'] = (bool) $cartRule['highlight']; - $cartRule['active'] = (bool) $cartRule['active']; - } - } -} diff --git a/OLD/Provider/CategoryDataProvider.php b/OLD/Provider/CategoryDataProvider.php deleted file mode 100644 index 80cf9876..00000000 --- a/OLD/Provider/CategoryDataProvider.php +++ /dev/null @@ -1,106 +0,0 @@ -categoryRepository = $categoryRepository; - $this->categoryDecorator = $categoryDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $categories = $this->categoryRepository->getCategories($offset, $limit, $langIso); - - if (!is_array($categories)) { - return []; - } - - $this->categoryDecorator->decorateCategories($categories); - - return array_map(function ($category) { - return [ - 'id' => "{$category['id_category']}-{$category['iso_code']}", - 'collection' => Config::COLLECTION_CATEGORIES, - 'properties' => $category, - ]; - }, $categories); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->categoryRepository->getRemainingCategoriesCount($offset, $langIso); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $categories = $this->categoryRepository->getCategoriesIncremental($limit, $langIso, $objectIds); - - if (!is_array($categories)) { - return []; - } - - $this->categoryDecorator->decorateCategories($categories); - - return array_map(function ($category) { - return [ - 'id' => "{$category['id_category']}-{$category['iso_code']}", - 'collection' => Config::COLLECTION_CATEGORIES, - 'properties' => $category, - ]; - }, $categories); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->categoryRepository->getQueryForDebug($offset, $limit, $langIso); - } -} diff --git a/OLD/Provider/CurrencyDataProvider.php b/OLD/Provider/CurrencyDataProvider.php deleted file mode 100644 index 9ee19053..00000000 --- a/OLD/Provider/CurrencyDataProvider.php +++ /dev/null @@ -1,105 +0,0 @@ -currencyRepository = $currencyRepository; - $this->currencyDecorator = $currencyDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $currencies = $this->currencyRepository->getCurrencies($offset, $limit); - - if (!is_array($currencies)) { - return []; - } - $this->currencyDecorator->decorateCurrencies($currencies); - - return array_map(function ($currency) { - return [ - 'id' => $currency['id_currency'], - 'collection' => Config::COLLECTION_CURRENCIES, - 'properties' => $currency, - ]; - }, $currencies); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->currencyRepository->getRemainingCurrenciesCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $currencies = $this->currencyRepository->getCurrenciesIncremental($limit, $objectIds); - - if (!is_array($currencies)) { - return []; - } - $this->currencyDecorator->decorateCurrencies($currencies); - - return array_map(function ($currency) { - return [ - 'id' => $currency['id_currency'], - 'collection' => Config::COLLECTION_CURRENCIES, - 'properties' => $currency, - ]; - }, $currencies); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->currencyRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/OLD/Provider/CustomProductCarrierDataProvider.php b/OLD/Provider/CustomProductCarrierDataProvider.php deleted file mode 100644 index c0ef680b..00000000 --- a/OLD/Provider/CustomProductCarrierDataProvider.php +++ /dev/null @@ -1,85 +0,0 @@ -productCarrierRepository = $productCarrierRepository; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $productCarriers = $this->productCarrierRepository->getProductCarriers($offset, $limit); - $productCarriers = array_map(function ($productCarrier) { - return [ - 'id' => $productCarrier['id_product'] . '-' . $productCarrier['id_carrier_reference'], - 'collection' => Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, - 'properties' => $productCarrier, - ]; - }, $productCarriers); - - return $productCarriers; - } - - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - /** @var array $productCarrierIncremental */ - $productCarrierIncremental = $this->productCarrierRepository->getProductCarrierIncremental(Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, $langIso); - - if (!$productCarrierIncremental) { - return []; - } - - $productIds = array_column($productCarrierIncremental, 'id_object'); - - /** @var array $productCarriers */ - $productCarriers = $this->productCarrierRepository->getProductCarriersProperties($productIds); - - return array_map(function ($productCarrier) { - return [ - 'id' => "{$productCarrier['id_product']}-{$productCarrier['id_carrier_reference']}", - 'collection' => Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, - 'properties' => $productCarrier, - ]; - }, $productCarriers); - } - - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->productCarrierRepository->getRemainingProductCarriersCount($offset); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->productCarrierRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/OLD/Provider/CustomerDataProvider.php b/OLD/Provider/CustomerDataProvider.php deleted file mode 100644 index 75a682c1..00000000 --- a/OLD/Provider/CustomerDataProvider.php +++ /dev/null @@ -1,106 +0,0 @@ -customerRepository = $customerRepository; - $this->customerDecorator = $customerDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $customers = $this->customerRepository->getCustomers($offset, $limit); - - if (!is_array($customers)) { - return []; - } - - $this->customerDecorator->decorateCustomers($customers); - - return array_map(function ($customer) { - return [ - 'id' => "{$customer['id_customer']}", - 'collection' => Config::COLLECTION_CUSTOMERS, - 'properties' => $customer, - ]; - }, $customers); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->customerRepository->getRemainingCustomersCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $customers = $this->customerRepository->getCustomersIncremental($limit, $objectIds); - - if (!is_array($customers)) { - return []; - } - - $this->customerDecorator->decorateCustomers($customers); - - return array_map(function ($customer) { - return [ - 'id' => "{$customer['id_customer']}", - 'collection' => Config::COLLECTION_CUSTOMERS, - 'properties' => $customer, - ]; - }, $customers); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->customerRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/OLD/Provider/EmployeeDataProvider.php b/OLD/Provider/EmployeeDataProvider.php deleted file mode 100644 index df991457..00000000 --- a/OLD/Provider/EmployeeDataProvider.php +++ /dev/null @@ -1,106 +0,0 @@ -employeeRepository = $employeeRepository; - $this->employeeDecorator = $employeeDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $employees = $this->employeeRepository->getEmployees($offset, $limit); - - if (!is_array($employees)) { - return []; - } - - $this->employeeDecorator->decorateEmployees($employees); - - return array_map(function ($employee) { - return [ - 'id' => "{$employee['id_employee']}", - 'collection' => Config::COLLECTION_EMPLOYEES, - 'properties' => $employee, - ]; - }, $employees); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->employeeRepository->getRemainingEmployeesCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $employees = $this->employeeRepository->getEmployeesIncremental($limit, $objectIds); - - if (!is_array($employees)) { - return []; - } - - $this->employeeDecorator->decorateEmployees($employees); - - return array_map(function ($employee) { - return [ - 'id' => "{$employee['id_customer']}", - 'collection' => Config::COLLECTION_EMPLOYEES, - 'properties' => $employee, - ]; - }, $employees); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->employeeRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/OLD/Provider/ImageDataProvider.php b/OLD/Provider/ImageDataProvider.php deleted file mode 100644 index 89201986..00000000 --- a/OLD/Provider/ImageDataProvider.php +++ /dev/null @@ -1,106 +0,0 @@ -imageRepository = $imageRepository; - $this->imageDecorator = $imageDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $images = $this->imageRepository->getImages($offset, $limit); - - if (!is_array($images)) { - return []; - } - - $this->imageDecorator->decorateImages($images); - - return array_map(function ($image) { - return [ - 'id' => "{$image['id_image']}", - 'collection' => Config::COLLECTION_IMAGES, - 'properties' => $image, - ]; - }, $images); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->imageRepository->getRemainingImagesCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $images = $this->imageRepository->getImagesIncremental($limit, $objectIds); - - if (!is_array($images)) { - return []; - } - - $this->imageDecorator->decorateImages($images); - - return array_map(function ($image) { - return [ - 'id' => "{$image['id_image']}", - 'collection' => Config::COLLECTION_IMAGES, - 'properties' => $image, - ]; - }, $images); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->imageRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/OLD/Provider/ImageTypeDataProvider.php b/OLD/Provider/ImageTypeDataProvider.php deleted file mode 100644 index a15e8bac..00000000 --- a/OLD/Provider/ImageTypeDataProvider.php +++ /dev/null @@ -1,106 +0,0 @@ -imageTypeRepository = $imageTypeRepository; - $this->imageTypeDecorator = $imageTypeDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $imageTypes = $this->imageTypeRepository->getImageTypes($offset, $limit); - - if (!is_array($imageTypes)) { - return []; - } - - $this->imageTypeDecorator->decorateImageTypes($imageTypes); - - return array_map(function ($imageType) { - return [ - 'id' => "{$imageType['id_image_type']}", - 'collection' => Config::COLLECTION_IMAGE_TYPES, - 'properties' => $imageType, - ]; - }, $imageTypes); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->imageTypeRepository->getRemainingImageTypesCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $imageTypes = $this->imageTypeRepository->getImageTypesIncremental($limit, $objectIds); - - if (!is_array($imageTypes)) { - return []; - } - - $this->imageTypeDecorator->decorateImageTypes($imageTypes); - - return array_map(function ($imageType) { - return [ - 'id' => "{$imageType['id_image_type']}", - 'collection' => Config::COLLECTION_IMAGE_TYPES, - 'properties' => $imageType, - ]; - }, $imageTypes); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->imageTypeRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/config/common/decorator.yml b/config/common/decorator.yml index 68ae3d0d..1879f558 100644 --- a/config/common/decorator.yml +++ b/config/common/decorator.yml @@ -1,16 +1,4 @@ services: - PrestaShop\Module\PsEventbus\Decorator\CategoryDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\CategoryDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\CurrencyDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\CurrencyDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\CustomerDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\CustomerDecorator - public: true - PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator: class: PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator public: true @@ -44,26 +32,10 @@ services: class: PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator public: true - PrestaShop\Module\PsEventbus\Decorator\ProductSupplierDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\ProductSupplierDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\EmployeeDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\EmployeeDecorator - public: true - PrestaShop\Module\PsEventbus\Decorator\LanguageDecorator: class: PrestaShop\Module\PsEventbus\Decorator\LanguageDecorator public: true - PrestaShop\Module\PsEventbus\Decorator\ImageDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\ImageDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\ImageTypeDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\ImageTypeDecorator - public: true - PrestaShop\Module\PsEventbus\Decorator\TranslationDecorator: class: PrestaShop\Module\PsEventbus\Decorator\TranslationDecorator public: true diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index e809572f..a20793be 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -62,3 +62,11 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 3f3a6195..f599a512 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -119,14 +119,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\ImageRepository: - class: PrestaShop\Module\PsEventbus\Repository\ImageRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository: - class: PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository - public: true - PrestaShop\Module\PsEventbus\Repository\TranslationRepository: class: PrestaShop\Module\PsEventbus\Repository\TranslationRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 3a187e09..4ee036ff 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -165,3 +165,15 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ImagesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImagesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ImageTypesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImageTypesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 1d127378..655718db 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -65,7 +65,7 @@ describe("Full Sync", () => { it(`${shoContent} should reject full sync when ps_facebook is not installed`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; const callId = { call_id: Math.random().toString(36).substring(2, 11) }; @@ -92,7 +92,7 @@ describe("Full Sync", () => { describe.each(shopContents)("%s", (shopContent) => { it(`${shopContent} should accept full sync`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const callId = { call_id: Math.random().toString(36).substring(2, 11) }; diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index bd072533..9cf915b5 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -59,7 +59,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck&job_id=valid-job-healthcheck`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=healthcheck&job_id=valid-job-healthcheck`, ); healthCheck = res.data; cachedHealthCheck = healthCheck; diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index 77c5c825..75e66dd6 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -96,7 +96,7 @@ export function doFullSync( const requestNext = (full: number) => { return axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, callId, { headers: { diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 5c2afc84..73676bc8 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -3,34 +3,20 @@ import R from "ramda"; // TEMPORARY DISABLED, WAIT ADD ALL SHOP CONTENT // AFTER UNCOMMENT THIS, CHANGE ALL "as ShopContent"CAST IN FULLSYNC TEST /* export const shopContentMapping = { - 'carrier_details': 'carrier-details', - 'carts' : 'carts', - 'cart_products': 'carts', - 'cart_rules' : 'cart-rules', - 'categories' : 'categories', - 'currencies' : 'currencies', 'specific_prices': 'specific-prices', - 'custom_product_carriers' : 'custom-product-carriers', - 'customers': 'customers', 'taxonomies': 'taxonomies', 'modules': 'modules', - 'products': 'products', 'shops': 'info', 'stores': 'stores', 'themes': 'themes', - 'product_bundles': 'product-bundles', 'wishlists': 'wishlists', 'wishlist_products': 'wishlist-products', 'stocks': 'stocks', 'stock_movements': 'stock-movements', 'manufacturers': 'manufacturers', 'suppliers': 'suppliers', - 'product_suppliers': 'product-suppliers', 'languages': 'languages', - 'employees': 'employees', 'translations': 'translations', - 'images': 'images', - 'image_types': 'image-types' } as const; */ export const shopContentMapping = { @@ -52,6 +38,8 @@ export const shopContentMapping = { customers: "customers", currencies: "currencies", employees: "employees", + images: "images", + image_types: "image-types", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/e2e/src/job-id-validation.spec.ts b/e2e/src/job-id-validation.spec.ts index 1ff5d819..50bea911 100644 --- a/e2e/src/job-id-validation.spec.ts +++ b/e2e/src/job-id-validation.spec.ts @@ -22,7 +22,7 @@ describe("Reject invalid job-id", () => { async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shopContent}&limit=5&job_id=${jobId}`; const message$ = probe({ params: { id: jobId } }); //act diff --git a/src/Decorator/CurrencyDecorator.php b/src/Decorator/CurrencyDecorator.php deleted file mode 100644 index 64060be8..00000000 --- a/src/Decorator/CurrencyDecorator.php +++ /dev/null @@ -1,36 +0,0 @@ - $currencies - * - * @return void - */ - public function decorateCurrencies(&$currencies) - { - foreach ($currencies as &$currency) { - $this->castPropertyValues($currency); - } - } - - /** - * @param array $currency - * - * @return void - */ - private function castPropertyValues(&$currency) - { - $currency['id_currency'] = (int) $currency['id_currency']; - $currency['conversion_rate'] = (float) $currency['conversion_rate']; - $currency['deleted'] = (bool) $currency['deleted']; - $currency['active'] = (bool) $currency['active']; - - // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { - $currency['precision'] = (int) $currency['precision']; - } - } -} diff --git a/src/Decorator/CustomerDecorator.php b/src/Decorator/CustomerDecorator.php deleted file mode 100644 index 97cc6eea..00000000 --- a/src/Decorator/CustomerDecorator.php +++ /dev/null @@ -1,47 +0,0 @@ - $customers - * - * @return void - */ - public function decorateCustomers(&$customers) - { - foreach ($customers as &$customer) { - $this->castPropertyValues($customer); - $this->hashEmail($customer); - } - } - - /** - * @param array $customer - * - * @return void - */ - private function castPropertyValues(&$customer) - { - $customer['id_customer'] = (int) $customer['id_customer']; - $customer['id_lang'] = (int) $customer['id_lang']; - $customer['newsletter'] = (bool) $customer['newsletter']; - $customer['newsletter_date_add'] = (string) $customer['newsletter_date_add']; - $customer['optin'] = (bool) $customer['optin']; - $customer['active'] = (bool) $customer['active']; - $customer['is_guest'] = (bool) $customer['is_guest']; - $customer['deleted'] = (bool) $customer['deleted']; - } - - /** - * @param array $customer - * - * @return void - */ - private function hashEmail(&$customer) - { - $customer['email_hash'] = hash('sha256', $customer['email'] . 'dUj4GMBD6689pL9pyr'); - unset($customer['email']); - } -} diff --git a/src/Decorator/EmployeeDecorator.php b/src/Decorator/EmployeeDecorator.php deleted file mode 100644 index 46d89006..00000000 --- a/src/Decorator/EmployeeDecorator.php +++ /dev/null @@ -1,67 +0,0 @@ - $employees - * - * @return void - */ - public function decorateEmployees(&$employees) - { - foreach ($employees as &$employee) { - $this->castPropertyValues($employee); - $this->hashEmail($employee); - } - } - - /** - * @param array $employee - * - * @return void - */ - private function castPropertyValues(&$employee) - { - $employee['id_employee'] = (int) $employee['id_employee']; - $employee['id_profile'] = (int) $employee['id_profile']; - $employee['id_lang'] = (int) $employee['id_lang']; - - $employee['default_tab'] = (int) $employee['default_tab']; - $employee['bo_width'] = (int) $employee['bo_width']; - $employee['bo_menu'] = (bool) $employee['bo_menu']; - - $employee['optin'] = (bool) $employee['optin']; - $employee['active'] = (bool) $employee['active']; - - $employee['id_last_order'] = (int) $employee['id_last_order']; - $employee['id_last_customer_message'] = (int) $employee['id_last_customer_message']; - $employee['id_last_customer'] = (int) $employee['id_last_customer']; - - if ($employee['last_connection_date'] == '0000-00-00') { - $employee['last_connection_date'] = null; - } else { - $employee['last_connection_date'] = (string) $employee['last_connection_date']; - } - - $employee['id_shop'] = (int) $employee['id_shop']; - - // https://github.com/PrestaShop/PrestaShop/commit/20f1d9fe8a03559dfa9d1f7109de1f70c99f1874#diff-cde6a9d4a58afb13ff068801ee09c0e712c5e90b0cbf5632a0cc965f15cb6802R107 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.8.0', '>=')) { - $employee['has_enabled_gravatar'] = (bool) $employee['has_enabled_gravatar']; - } - } - - /** - * @param array $employee - * - * @return void - */ - private function hashEmail(&$employee) - { - // FIXME : use a random salt generated during module install - $employee['email_hash'] = hash('sha256', $employee['email'] . 'dUj4GMBD6689pL9pyr'); - unset($employee['email']); - } -} diff --git a/src/Decorator/ImageDecorator.php b/src/Decorator/ImageDecorator.php deleted file mode 100644 index 5e3a4fda..00000000 --- a/src/Decorator/ImageDecorator.php +++ /dev/null @@ -1,34 +0,0 @@ - $images - * - * @return void - */ - public function decorateImages(&$images) - { - foreach ($images as &$image) { - $this->castPropertyValues($image); - } - } - - /** - * @param array $image - * - * @return void - */ - private function castPropertyValues(&$image) - { - $image['id_image'] = (int) $image['id_image']; - $image['id_product'] = (int) $image['id_product']; - $image['id_lang'] = (int) $image['id_lang']; - $image['id_shop'] = (int) $image['id_shop']; - $image['position'] = (int) $image['position']; - $image['cover'] = (bool) $image['cover']; - $image['legend'] = (string) $image['legend']; - } -} diff --git a/src/Decorator/ImageTypeDecorator.php b/src/Decorator/ImageTypeDecorator.php deleted file mode 100644 index 82b42cbd..00000000 --- a/src/Decorator/ImageTypeDecorator.php +++ /dev/null @@ -1,36 +0,0 @@ - $imageTypes - * - * @return void - */ - public function decorateImageTypes(&$imageTypes) - { - foreach ($imageTypes as &$imageType) { - $this->castPropertyValues($imageType); - } - } - - /** - * @param array $imageType - * - * @return void - */ - private function castPropertyValues(&$imageType) - { - $imageType['id_image_type'] = (int) $imageType['id_image_type']; - $imageType['name'] = (string) $imageType['name']; - $imageType['width'] = (int) $imageType['width']; - $imageType['height'] = (int) $imageType['height']; - $imageType['products'] = (bool) $imageType['products']; - $imageType['categories'] = (bool) $imageType['categories']; - $imageType['manufacturers'] = (bool) $imageType['manufacturers']; - $imageType['suppliers'] = (bool) $imageType['suppliers']; - $imageType['stores'] = (bool) $imageType['stores']; - } -} diff --git a/src/Repository/ImageRepository.php b/src/Repository/ImageRepository.php deleted file mode 100644 index f93f8a3a..00000000 --- a/src/Repository/ImageRepository.php +++ /dev/null @@ -1,177 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - $query = new \DbQuery(); - - $query->from('image', 'i') - ->leftJoin('image_lang', 'il', 'il.id_image = i.id_image') - ->leftJoin('image_shop', 'is', 'is.id_image = i.id_image'); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getImages($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingImagesCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(i.id_image) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $imageIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getImagesIncremental($limit, $imageIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('i.id_image IN(' . implode(',', array_map('intval', $imageIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $productId - * @param int $shopId - * - * @return false|string|null - */ - public function getProductCoverImage($productId, $shopId) - { - $query = new \DbQuery(); - - $query->select('imgs.id_image') - ->from('image_shop', 'imgs') - ->where('imgs.cover = 1') - ->where('imgs.id_shop = ' . (int) $shopId) - ->where('imgs.id_product = ' . (int) $productId); - - return $this->db->getValue($query); - } - - /** - * @param int $productId - * @param int $attributeId - * @param int $shopId - * @param bool $includeCover - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getProductImages($productId, $attributeId, $shopId, $includeCover = null) - { - $query = new \DbQuery(); - - $query->select('imgs.id_image') - ->from('image_shop', 'imgs') - ->leftJoin('image', 'img', 'imgs.id_image = img.id_image') - ->where('imgs.id_shop = ' . (int) $shopId) - ->where('imgs.id_product = ' . (int) $productId) - ->orderBy('img.position ASC'); - - if ((int) $attributeId !== 0) { - $query->innerJoin( - 'product_attribute_image', - 'pai', - 'imgs.id_image = pai.id_image AND pai.id_product_attribute = ' . (int) $attributeId - ); - } - - if (!$includeCover) { - $query->where('(imgs.cover IS NULL OR imgs.cover = 0)'); - } - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('i.id_image'); - $query->select('i.id_product'); - $query->select('i.position'); - $query->select('i.cover'); - $query->select('il.id_lang'); - $query->select('il.legend'); - $query->select('is.id_shop'); - } -} diff --git a/src/Repository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php deleted file mode 100644 index 745a6314..00000000 --- a/src/Repository/ImageTypeRepository.php +++ /dev/null @@ -1,122 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - $query = new \DbQuery(); - - $query->from('image_type', 'it'); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getImageTypes($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingImageTypesCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(it.id_image_type) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $imageTypeIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getImageTypesIncremental($limit, $imageTypeIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('it.id_image_type IN(' . implode(',', array_map('intval', $imageTypeIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('it.id_image_type'); - $query->select('it.name'); - $query->select('it.width'); - $query->select('it.height'); - $query->select('it.products'); - $query->select('it.categories'); - $query->select('it.manufacturers'); - $query->select('it.suppliers'); - $query->select('it.stores'); - } -} diff --git a/src/Repository/NewRepository/CategoryRepository.php b/src/Repository/NewRepository/CategoryRepository.php index 45b6f241..7cfe2d16 100644 --- a/src/Repository/NewRepository/CategoryRepository.php +++ b/src/Repository/NewRepository/CategoryRepository.php @@ -81,7 +81,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d $this->generateFullQuery($langIso, true); $this->query - ->where('p.id_category IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('cs.id_category IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/NewRepository/EmployeeRepository.php b/src/Repository/NewRepository/EmployeeRepository.php index e6dfc4de..1bb9616d 100644 --- a/src/Repository/NewRepository/EmployeeRepository.php +++ b/src/Repository/NewRepository/EmployeeRepository.php @@ -87,7 +87,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d $this->generateFullQuery($langIso, true); $this->query - ->where('c.id_employee IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('e.id_employee IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/NewRepository/ImageRepository.php b/src/Repository/NewRepository/ImageRepository.php new file mode 100644 index 00000000..863688ef --- /dev/null +++ b/src/Repository/NewRepository/ImageRepository.php @@ -0,0 +1,101 @@ +generateMinimalQuery(self::TABLE_NAME, 'i'); + + $this->query + ->leftJoin('image_lang', 'il', 'il.id_image = i.id_image') + ->leftJoin('image_shop', 'is', 'is.id_image = i.id_image'); + + if ($withSelecParameters) { + $this->query + ->select('i.id_image') + ->select('i.id_product') + ->select('i.position') + ->select('i.cover') + ->select('il.id_lang') + ->select('il.legend') + ->select('is.id_shop') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('i.id_image IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/NewRepository/ImageTypeRepository.php b/src/Repository/NewRepository/ImageTypeRepository.php new file mode 100644 index 00000000..1ebfc258 --- /dev/null +++ b/src/Repository/NewRepository/ImageTypeRepository.php @@ -0,0 +1,99 @@ +generateMinimalQuery(self::TABLE_NAME, 'it'); + + if ($withSelecParameters) { + $this->query + ->select('it.id_image_type') + ->select('it.name') + ->select('it.width') + ->select('it.height') + ->select('it.products') + ->select('it.categories') + ->select('it.manufacturers') + ->select('it.suppliers') + ->select('it.stores') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('it.id_image_type IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/NewRepository/ProductBundleRepository.php b/src/Repository/NewRepository/ProductBundleRepository.php index 69037b61..413ffbbf 100644 --- a/src/Repository/NewRepository/ProductBundleRepository.php +++ b/src/Repository/NewRepository/ProductBundleRepository.php @@ -75,7 +75,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d $this->generateFullQuery($langIso, true); $this->query - ->where('p.id_bundle IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('pac.id_bundle IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php new file mode 100644 index 00000000..ddfb1224 --- /dev/null +++ b/src/Service/ShopContent/ImageTypesService.php @@ -0,0 +1,103 @@ +imageTypeRepository = $imageTypeRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->imageTypeRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castImageTypes($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_image_type'], + 'collection' => Config::COLLECTION_IMAGE_TYPES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->imageTypeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castImageTypes($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_image_type'], + 'collection' => Config::COLLECTION_IMAGE_TYPES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->imageTypeRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $imageTypes + * + * @return void + */ + private function castImageTypes(&$imageTypes) + { + foreach ($imageTypes as &$imageType) { + $imageType['id_image_type'] = (int) $imageType['id_image_type']; + $imageType['name'] = (string) $imageType['name']; + $imageType['width'] = (int) $imageType['width']; + $imageType['height'] = (int) $imageType['height']; + $imageType['products'] = (bool) $imageType['products']; + $imageType['categories'] = (bool) $imageType['categories']; + $imageType['manufacturers'] = (bool) $imageType['manufacturers']; + $imageType['suppliers'] = (bool) $imageType['suppliers']; + $imageType['stores'] = (bool) $imageType['stores']; + } + } +} diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php new file mode 100644 index 00000000..619a80a0 --- /dev/null +++ b/src/Service/ShopContent/ImagesService.php @@ -0,0 +1,101 @@ +imageRepository = $imageRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->imageRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castImages($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_image'], + 'collection' => Config::COLLECTION_IMAGES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->imageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castImages($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['id_image'], + 'collection' => Config::COLLECTION_IMAGES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->imageRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $images + * + * @return void + */ + private function castImages(&$images) + { + foreach ($images as &$image) { + $image['id_image'] = (int) $image['id_image']; + $image['id_product'] = (int) $image['id_product']; + $image['id_lang'] = (int) $image['id_lang']; + $image['id_shop'] = (int) $image['id_shop']; + $image['position'] = (int) $image['position']; + $image['cover'] = (bool) $image['cover']; + $image['legend'] = (string) $image['legend']; + } + } +} From e6f12592bb1c6ad4b058ae4fe41e35d561e7b447 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:24:36 +0200 Subject: [PATCH 083/162] feat: pseventbus v4 infos (#371) --- config/common/repository.yml | 15 -- config/front/services.yml | 15 ++ .../1.6/{shops.json => shop_information.json} | 2 +- .../1.7/{shops.json => shop_information.json} | 2 +- .../8/{shops.json => shop_information.json} | 12 +- .../9/{shops.json => shop_information.json} | 2 +- e2e/src/helpers/shop-contents.ts | 2 +- ps_eventbus.php | 9 - src/Config/Config.php | 5 +- .../ServerInformationRepository.php | 231 ------------------ src/Service/CommonService.php | 6 +- src/Service/FrontApiService.php | 21 +- src/Service/HealthCheckService.php | 122 ++++++++- .../ShopContent/ShopInformationService.php | 131 ++++++++++ 14 files changed, 287 insertions(+), 288 deletions(-) rename e2e/src/fixtures/1.6/{shops.json => shop_information.json} (95%) rename e2e/src/fixtures/1.7/{shops.json => shop_information.json} (95%) rename e2e/src/fixtures/8/{shops.json => shop_information.json} (70%) rename e2e/src/fixtures/9/{shops.json => shop_information.json} (95%) delete mode 100644 src/Repository/ServerInformationRepository.php create mode 100644 src/Service/ShopContent/ShopInformationService.php diff --git a/config/common/repository.yml b/config/common/repository.yml index f599a512..bc42a745 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -19,21 +19,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ModuleRepository public: true - PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository: - class: PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' - - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' - - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' - - '%ps_eventbus.sync_api_url%' - - '%ps_eventbus.live_sync_api_url%' - - '%ps_eventbus.proxy_api_url%' - PrestaShop\Module\PsEventbus\Repository\ThemeRepository: class: PrestaShop\Module\PsEventbus\Repository\ThemeRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 4ee036ff..f9e3f190 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -50,6 +50,11 @@ services: public: true arguments: - '@ps_eventbus' + - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' + - '%ps_eventbus.sync_api_url%' + - '%ps_eventbus.live_sync_api_url%' + - '%ps_eventbus.proxy_api_url%' # SHOP CONTENT SERVICES PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: @@ -177,3 +182,13 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ShopInformationService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopInformationService + public: true + arguments: + - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' diff --git a/e2e/src/fixtures/1.6/shops.json b/e2e/src/fixtures/1.6/shop_information.json similarity index 95% rename from e2e/src/fixtures/1.6/shops.json rename to e2e/src/fixtures/1.6/shop_information.json index 5ccb60ce..828e386a 100644 --- a/e2e/src/fixtures/1.6/shops.json +++ b/e2e/src/fixtures/1.6/shop_information.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shops", + "collection": "shop_information", "properties": { "created_at": "2024-07-16 15:33:52", "folder_created_at": "2024-07-16 15:34:17", diff --git a/e2e/src/fixtures/1.7/shops.json b/e2e/src/fixtures/1.7/shop_information.json similarity index 95% rename from e2e/src/fixtures/1.7/shops.json rename to e2e/src/fixtures/1.7/shop_information.json index b29741e3..29700e6a 100644 --- a/e2e/src/fixtures/1.7/shops.json +++ b/e2e/src/fixtures/1.7/shop_information.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shops", + "collection": "shop_information", "properties": { "created_at": "2023-12-20 22:56:03", "folder_created_at": "2024-03-05 12:59:12", diff --git a/e2e/src/fixtures/8/shops.json b/e2e/src/fixtures/8/shop_information.json similarity index 70% rename from e2e/src/fixtures/8/shops.json rename to e2e/src/fixtures/8/shop_information.json index d6980752..0c4a44f5 100644 --- a/e2e/src/fixtures/8/shops.json +++ b/e2e/src/fixtures/8/shop_information.json @@ -1,11 +1,11 @@ [ { "id": "1", - "collection": "shops", + "collection": "shop_information", "properties": { - "created_at": "2024-02-06 20:24:44", - "folder_created_at": "2024-02-09 16:24:55", - "cms_version": "8.1.3", + "created_at": "2024-08-22T12:27:09+0200", + "folder_created_at": "2024-08-27T10:07:19+0200", + "cms_version": "8.1.7", "url_is_simplified": true, "cart_is_persistent": false, "default_language": "en", @@ -19,8 +19,8 @@ "timezone": "Europe/Paris", "is_order_return_enabled": false, "order_return_nb_days": 14, - "php_version": "8.1.27", - "http_server": "nginx/1.24.0", + "php_version": "8.1.29", + "http_server": "nginx/1.26.2", "url": "http://localhost:8000/", "ssl": false, "multi_shop_count": 1, diff --git a/e2e/src/fixtures/9/shops.json b/e2e/src/fixtures/9/shop_information.json similarity index 95% rename from e2e/src/fixtures/9/shops.json rename to e2e/src/fixtures/9/shop_information.json index 49605475..cc940f66 100644 --- a/e2e/src/fixtures/9/shops.json +++ b/e2e/src/fixtures/9/shop_information.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shops", + "collection": "shop_information", "properties": { "created_at": "2024-06-10 02:27:21", "folder_created_at": "2024-06-10 18:01:29", diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 73676bc8..7dd1daff 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -6,7 +6,6 @@ import R from "ramda"; 'specific_prices': 'specific-prices', 'taxonomies': 'taxonomies', 'modules': 'modules', - 'shops': 'info', 'stores': 'stores', 'themes': 'themes', 'wishlists': 'wishlists', @@ -40,6 +39,7 @@ export const shopContentMapping = { employees: "employees", images: "images", image_types: "image-types", + shop_information: "shop-information", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/ps_eventbus.php b/ps_eventbus.php index b62f75d8..610ecdde 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -52,15 +52,6 @@ class Ps_eventbus extends Module const DEFAULT_ENV = ''; - /** - * @var array - */ - const REQUIRED_TABLES = [ - 'eventbus_type_sync', - 'eventbus_job', - 'eventbus_incremental_sync', - ]; - /** * @var string */ diff --git a/src/Config/Config.php b/src/Config/Config.php index 6121d566..3aa80ba5 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -59,7 +59,7 @@ class Config const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; const COLLECTION_PRODUCT_CARRIERS = 'product_carriers'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; - const COLLECTION_SHOPS = 'shops'; + const COLLECTION_SHOP_INFORMATION = 'shop_information'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; const COLLECTION_STOCKS = 'stocks'; const COLLECTION_STOCK_MVTS = 'stock_movements'; @@ -85,7 +85,6 @@ class Config self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, - self::COLLECTION_INFO, self::COLLECTION_LANGUAGES, self::COLLECTION_MANUFACTURERS, self::COLLECTION_MODULES, @@ -98,7 +97,7 @@ class Config self::COLLECTION_PRODUCT_BUNDLES, self::COLLECTION_PRODUCT_CARRIERS, self::COLLECTION_PRODUCT_SUPPLIERS, - self::COLLECTION_SHOPS, + self::COLLECTION_SHOP_INFORMATION, self::COLLECTION_SPECIFIC_PRICES, self::COLLECTION_STOCKS, self::COLLECTION_STOCK_MVTS, diff --git a/src/Repository/ServerInformationRepository.php b/src/Repository/ServerInformationRepository.php deleted file mode 100644 index 75403f0b..00000000 --- a/src/Repository/ServerInformationRepository.php +++ /dev/null @@ -1,231 +0,0 @@ - - */ - private $configuration; - /** - * @var ErrorHandlerInterface - */ - private $errorHandler; - - /** - * @param \Context $context - * @param PsAccountsAdapterService $psAccountsAdapterService - * @param LanguageRepository $languageRepository - * @param ConfigurationRepository $configurationRepository - * @param ShopRepository $shopRepository - * @param CurrenciesService $currenciesService - * @param ErrorHandlerInterface $errorHandler - * @param string $eventbusSyncApiUrl - * @param string $eventbusLiveSyncApiUrl - * @param string $eventbusProxyApiUrl - * - * @return void - */ - public function __construct( - \Context $context, - PsAccountsAdapterService $psAccountsAdapterService, - LanguageRepository $languageRepository, - ConfigurationRepository $configurationRepository, - ShopRepository $shopRepository, - CurrenciesService $currenciesService, - ErrorHandlerInterface $errorHandler, - $eventbusSyncApiUrl, - $eventbusLiveSyncApiUrl, - $eventbusProxyApiUrl - ) { - $this->currenciesService = $currenciesService; - $this->languageRepository = $languageRepository; - $this->configurationRepository = $configurationRepository; - $this->shopRepository = $shopRepository; - $this->context = $context; - $this->db = \Db::getInstance(); - $this->psAccountsAdapterService = $psAccountsAdapterService; - $this->configuration = [ - 'EVENT_BUS_SYNC_API_URL' => $eventbusSyncApiUrl, - 'EVENT_BUS_LIVE_SYNC_API_URL' => $eventbusLiveSyncApiUrl, - 'EVENT_BUS_PROXY_API_URL' => $eventbusProxyApiUrl, - ]; - $this->errorHandler = $errorHandler; - } - - /** - * @param string $langIso - * - * @return array[] - * - * @throws \PrestaShopException - */ - public function getServerInformation($langIso = '') - { - $langId = !empty($langIso) ? (int) \Language::getIdByIso($langIso) : null; - - /* This file is created on installation and never modified. - As php doesn't allow to retrieve the creation date of a file or folder, - we use the modification date of this file to get the installation date of the shop */ - $filename = './img/admin/enabled.gif'; - $folderCreatedAt = null; - if (file_exists($filename)) { - $folderCreatedAt = date('Y-m-d H:i:s', (int) filectime($filename)); - } - - if ($this->context->link === null) { - throw new \PrestaShopException('No link context'); - } - - return [ - [ - 'id' => '1', - 'collection' => Config::COLLECTION_SHOPS, - 'properties' => [ - 'created_at' => $this->shopRepository->getCreatedAt(), - 'folder_created_at' => $folderCreatedAt, - 'cms_version' => _PS_VERSION_, - 'url_is_simplified' => $this->configurationRepository->get('PS_REWRITING_SETTINGS') == '1', - 'cart_is_persistent' => $this->configurationRepository->get('PS_CART_FOLLOWING') == '1', - 'default_language' => $this->languageRepository->getDefaultLanguageIsoCode(), - 'languages' => implode(';', $this->languageRepository->getLanguagesIsoCodes()), - 'default_currency' => $this->currenciesService->getDefaultCurrencyIsoCode(), - 'currencies' => implode(';', $this->currenciesService->getCurrenciesIsoCodes()), - 'weight_unit' => $this->configurationRepository->get('PS_WEIGHT_UNIT'), - 'distance_unit' => $this->configurationRepository->get('PS_BASE_DISTANCE_UNIT'), - 'volume_unit' => $this->configurationRepository->get('PS_VOLUME_UNIT'), - 'dimension_unit' => $this->configurationRepository->get('PS_DIMENSION_UNIT'), - 'timezone' => $this->configurationRepository->get('PS_TIMEZONE'), - 'is_order_return_enabled' => $this->configurationRepository->get('PS_ORDER_RETURN') == '1', - 'order_return_nb_days' => (int) $this->configurationRepository->get('PS_ORDER_RETURN_NB_DAYS'), - 'php_version' => phpversion(), - 'http_server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '', - 'url' => $this->context->link->getPageLink('index', null, $langId), - 'ssl' => $this->configurationRepository->get('PS_SSL_ENABLED') == '1', - 'multi_shop_count' => $this->shopRepository->getMultiShopCount(), - 'country_code' => $this->shopRepository->getShopCountryCode(), - ], - ], - ]; - } - - /** - * @param bool $isAuthentifiedCall - * - * @return array - */ - public function getHealthCheckData($isAuthentifiedCall) - { - $tokenValid = false; - $tokenIsSet = false; - $allTablesInstalled = true; - - try { - $token = $this->psAccountsAdapterService->getOrRefreshToken(); - if ($token) { - $tokenIsSet = true; - $accountsClient = $this->getAccountsClient(); - /** @phpstan-ignore-next-line */ - $response = $accountsClient->verifyToken($token); - if ($response && true === $response['status']) { - $tokenValid = true; - } - } - } catch (\Exception $e) { - $this->errorHandler->handle($e); - $tokenIsSet = false; - } - - foreach (\Ps_eventbus::REQUIRED_TABLES as $requiredTable) { - $query = new \DbQuery(); - - $query->select('*') - ->from($requiredTable) - ->limit(1); - - try { - $this->db->executeS($query); - } catch (\PrestaShopDatabaseException $e) { - $allTablesInstalled = false; - break; - } - } - - if (defined('PHP_VERSION') && defined('PHP_EXTRA_VERSION')) { - $phpVersion = str_replace(PHP_EXTRA_VERSION, '', PHP_VERSION); - } else { - $phpVersion = (string) explode('-', (string) phpversion())[0]; - } - - $sensibleInformation = [ - 'prestashop_version' => _PS_VERSION_, - 'ps_eventbus_version' => \Ps_eventbus::VERSION, - 'ps_accounts_version' => defined('Ps_accounts::VERSION') ? \Ps_accounts::VERSION : false, /* @phpstan-ignore-line */ - 'php_version' => $phpVersion, - 'shop_id' => $this->psAccountsAdapterService->getShopUuid(), - ]; - - $serverInformation = [ - 'ps_account' => $tokenIsSet, - 'is_valid_jwt' => $tokenValid, - 'ps_eventbus' => $allTablesInstalled, - 'env' => [ - 'EVENT_BUS_PROXY_API_URL' => isset($this->configuration['EVENT_BUS_PROXY_API_URL']) ? $this->configuration['EVENT_BUS_PROXY_API_URL'] : null, - 'EVENT_BUS_SYNC_API_URL' => isset($this->configuration['EVENT_BUS_SYNC_API_URL']) ? $this->configuration['EVENT_BUS_SYNC_API_URL'] : null, - 'EVENT_BUS_LIVE_SYNC_API_URL' => isset($this->configuration['EVENT_BUS_LIVE_SYNC_API_URL']) ? $this->configuration['EVENT_BUS_LIVE_SYNC_API_URL'] : null, - ], - ]; - - if ($isAuthentifiedCall) { - $serverInformation = array_merge($sensibleInformation, $serverInformation); - } - - return $serverInformation; - } - - /** - * @return mixed - */ - private function getAccountsClient() - { - $module = \Module::getInstanceByName('ps_accounts'); - - /* @phpstan-ignore-next-line */ - return $module->getService(AccountsClient::class); - } -} diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 35756687..5047a341 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -10,12 +10,16 @@ class CommonService { /** - * @param array $response + * @param mixed $response * * @return void */ public static function exitWithResponse($response) { + if (!is_array($response)) { + $response = [$response]; + } + $httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200; self::dieWithResponse($response, $httpCode); diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index aa25ce95..f635329f 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -72,35 +72,32 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } + if ($limit < 0) { + CommonService::exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); + } + $isHealthCheck = $shopContent == Config::COLLECTION_HEALTHCHECK; $isAuthentified = $this->authorize($jobId, $isHealthCheck); + $response = []; + // If is healthcheck, return healthcheck response if ($isHealthCheck) { /** @var HealthCheckService $healthCheckService */ $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); + $response = $healthCheckService->getHealthCheck($isAuthentified); - $healthCheckService->getHealthCheck($isAuthentified); - - return; - } - - if ($limit < 0) { - CommonService::exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); + CommonService::exitWithResponse($response); } /** @var ConfigurationRepository $configurationRepository */ $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); /** @var LanguageRepository $languageRepository */ $languageRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\LanguageRepository'); - /** @var IncrementalSyncRepository $incrementalSyncRepository */ - $incrementalSyncRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); $langIso = $langIso ? $langIso : $languageRepository->getDefaultLanguageIsoCode(); - $response = []; - $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); // If no typesync exist, or if fullsync is requested by user @@ -110,6 +107,8 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $offset = 0; if ($typeSync) { + /** @var IncrementalSyncRepository $incrementalSyncRepository */ + $incrementalSyncRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository'); $incrementalSyncRepository->removeIncrementaSyncObjectByType($shopContent); } diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 19d0d8d9..f0da66e6 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -2,32 +2,138 @@ namespace PrestaShop\Module\PsEventbus\Service; -use PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository; +use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; class HealthCheckService { /** @var \Ps_eventbus */ private $module; - public function __construct(\Ps_eventbus $module) - { + /** @var \Db */ + private $db; + + /** @var PsAccountsAdapterService */ + private $psAccountsAdapterService; + + /** @var array */ + private $configuration; + + /** @var ErrorHandlerInterface */ + private $errorHandler; + + /** + * @var array + */ + const REQUIRED_TABLES = [ + 'eventbus_type_sync', + 'eventbus_job', + 'eventbus_incremental_sync', + ]; + + /** + * @param \Ps_eventbus $module + * @param PsAccountsAdapterService $psAccountsAdapterService + * @param ErrorHandlerInterface $errorHandler + * @param string $eventbusSyncApiUrl + * @param string $eventbusLiveSyncApiUrl + * @param string $eventbusProxyApiUrl + * + * @return void + */ + public function __construct( + \Ps_eventbus $module, + PsAccountsAdapterService $psAccountsAdapterService, + ErrorHandlerInterface $errorHandler, + $eventbusSyncApiUrl, + $eventbusLiveSyncApiUrl, + $eventbusProxyApiUrl + ) { $this->module = $module; + $this->db = \Db::getInstance(); + $this->psAccountsAdapterService = $psAccountsAdapterService; + $this->configuration = [ + 'EVENT_BUS_SYNC_API_URL' => $eventbusSyncApiUrl, + 'EVENT_BUS_LIVE_SYNC_API_URL' => $eventbusLiveSyncApiUrl, + 'EVENT_BUS_PROXY_API_URL' => $eventbusProxyApiUrl, + ]; + $this->errorHandler = $errorHandler; } /** * @param bool $isAuthentified * - * @return void + * @return array * * @throws \PrestaShopException */ public function getHealthCheck($isAuthentified) { - /** @var ServerInformationRepository $serverInformationRepository */ - $serverInformationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ServerInformationRepository'); + $tokenValid = false; + $tokenIsSet = false; + $allTablesInstalled = true; + + try { + $token = $this->psAccountsAdapterService->getOrRefreshToken(); + if ($token) { + $accountsClient = $this->module->getService('PrestaShop\Module\PsAccounts\Api\Client\AccountsClient'); + + $tokenIsSet = true; + + /** @phpstan-ignore-next-line */ + $response = $accountsClient->verifyToken($token); + if ($response && true === $response['status']) { + $tokenValid = true; + } + } + } catch (\Exception $e) { + $this->errorHandler->handle($e); + $tokenIsSet = false; + } + + foreach (self::REQUIRED_TABLES as $requiredTable) { + $query = new \DbQuery(); + + $query->select('*') + ->from($requiredTable) + ->limit(1); + + try { + $this->db->executeS($query); + } catch (\PrestaShopDatabaseException $e) { + $allTablesInstalled = false; + break; + } + } + + if (defined('PHP_VERSION') && defined('PHP_EXTRA_VERSION')) { + $phpVersion = str_replace(PHP_EXTRA_VERSION, '', PHP_VERSION); + } else { + $phpVersion = (string) explode('-', (string) phpversion())[0]; + } + + $sensibleInformation = [ + 'prestashop_version' => _PS_VERSION_, + 'ps_eventbus_version' => \Ps_eventbus::VERSION, + 'ps_accounts_version' => defined('Ps_accounts::VERSION') ? \Ps_accounts::VERSION : false, /* @phpstan-ignore-line */ + 'php_version' => $phpVersion, + 'shop_id' => $this->psAccountsAdapterService->getShopUuid(), + ]; + + $serverInformation = [ + 'ps_account' => $tokenIsSet, + 'is_valid_jwt' => $tokenValid, + 'ps_eventbus' => $allTablesInstalled, + 'env' => [ + 'EVENT_BUS_PROXY_API_URL' => isset($this->configuration['EVENT_BUS_PROXY_API_URL']) ? $this->configuration['EVENT_BUS_PROXY_API_URL'] : null, + 'EVENT_BUS_SYNC_API_URL' => isset($this->configuration['EVENT_BUS_SYNC_API_URL']) ? $this->configuration['EVENT_BUS_SYNC_API_URL'] : null, + 'EVENT_BUS_LIVE_SYNC_API_URL' => isset($this->configuration['EVENT_BUS_LIVE_SYNC_API_URL']) ? $this->configuration['EVENT_BUS_LIVE_SYNC_API_URL'] : null, + ], + ]; - $status = $serverInformationRepository->getHealthCheckData($isAuthentified); + if ($isAuthentified) { + $serverInformation = array_merge($sensibleInformation, $serverInformation); + } - CommonService::exitWithResponse($status); + return $serverInformation; } } diff --git a/src/Service/ShopContent/ShopInformationService.php b/src/Service/ShopContent/ShopInformationService.php new file mode 100644 index 00000000..9f28b7a1 --- /dev/null +++ b/src/Service/ShopContent/ShopInformationService.php @@ -0,0 +1,131 @@ +currenciesService = $currenciesService; + $this->languageRepository = $languageRepository; + $this->configurationRepository = $configurationRepository; + $this->shopRepository = $shopRepository; + $this->context = $context; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $langId = !empty($langIso) ? (int) \Language::getIdByIso($langIso) : null; + + /* This file is created on installation and never modified. + As php doesn't allow to retrieve the creation date of a file or folder, + we use the modification date of this file to get the installation date of the shop */ + $filename = './img/admin/enabled.gif'; + $folderCreatedAt = null; + if (file_exists($filename)) { + $folderCreatedAt = date('Y-m-d H:i:s', (int) filectime($filename)); + } + + if ($this->context->link === null) { + throw new \PrestaShopException('No link context'); + } + + return [ + [ + 'id' => '1', + 'collection' => Config::COLLECTION_SHOP_INFORMATION, + 'properties' => [ + 'created_at' => $this->shopRepository->getCreatedAt(), + 'folder_created_at' => $folderCreatedAt, + 'cms_version' => _PS_VERSION_, + 'url_is_simplified' => $this->configurationRepository->get('PS_REWRITING_SETTINGS') == '1', + 'cart_is_persistent' => $this->configurationRepository->get('PS_CART_FOLLOWING') == '1', + 'default_language' => $this->languageRepository->getDefaultLanguageIsoCode(), + 'languages' => implode(';', $this->languageRepository->getLanguagesIsoCodes()), + 'default_currency' => $this->currenciesService->getDefaultCurrencyIsoCode(), + 'currencies' => implode(';', $this->currenciesService->getCurrenciesIsoCodes()), + 'weight_unit' => $this->configurationRepository->get('PS_WEIGHT_UNIT'), + 'distance_unit' => $this->configurationRepository->get('PS_BASE_DISTANCE_UNIT'), + 'volume_unit' => $this->configurationRepository->get('PS_VOLUME_UNIT'), + 'dimension_unit' => $this->configurationRepository->get('PS_DIMENSION_UNIT'), + 'timezone' => $this->configurationRepository->get('PS_TIMEZONE'), + 'is_order_return_enabled' => $this->configurationRepository->get('PS_ORDER_RETURN') == '1', + 'order_return_nb_days' => (int) $this->configurationRepository->get('PS_ORDER_RETURN_NB_DAYS'), + 'php_version' => phpversion(), + 'http_server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '', + 'url' => $this->context->link->getPageLink('index', null, $langId), + 'ssl' => $this->configurationRepository->get('PS_SSL_ENABLED') == '1', + 'multi_shop_count' => $this->shopRepository->getMultiShopCount(), + 'country_code' => $this->shopRepository->getShopCountryCode(), + ], + ], + ]; + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + return []; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return 0; + } +} From 780a98025130a4182d8f37944fca792906c85f7d Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 24 Sep 2024 11:00:55 +0200 Subject: [PATCH 084/162] feat: add modules --- OLD/Provider/ModuleDataProvider.php | 90 -------------- config/common/new-repository.yml | 4 + config/common/repository.yml | 4 - config/front/services.yml | 7 ++ e2e/src/helpers/shop-contents.ts | 2 +- src/Repository/ModuleRepository.php | 109 ----------------- .../NewRepository/ModuleRepository.php | 112 ++++++++++++++++++ src/Service/ShopContent/ModulesService.php | 107 +++++++++++++++++ 8 files changed, 231 insertions(+), 204 deletions(-) delete mode 100644 OLD/Provider/ModuleDataProvider.php delete mode 100644 src/Repository/ModuleRepository.php create mode 100644 src/Repository/NewRepository/ModuleRepository.php create mode 100644 src/Service/ShopContent/ModulesService.php diff --git a/OLD/Provider/ModuleDataProvider.php b/OLD/Provider/ModuleDataProvider.php deleted file mode 100644 index df9fa2bc..00000000 --- a/OLD/Provider/ModuleDataProvider.php +++ /dev/null @@ -1,90 +0,0 @@ -moduleRepository = $moduleRepository; - $this->createdAt = $shopRepository->getCreatedAt(); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - */ - public function getFormattedData($offset, $limit, $langIso) - { - $modules = $this->moduleRepository->getModules($offset, $limit); - - if (!is_array($modules)) { - return []; - } - - return array_map(function ($module) { - $module['module_id'] = (string) $module['module_id']; - $module['active'] = $module['active'] == '1'; - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $module['created_at'] = $module['created_at'] ?: $this->createdAt; - $module['updated_at'] = $module['updated_at'] ?: $this->createdAt; - } else { - $module['created_at'] = $this->createdAt; - $module['updated_at'] = $this->createdAt; - } - - return [ - 'id' => $module['module_id'], - 'collection' => Config::COLLECTION_MODULES, - 'properties' => $module, - ]; - }, $modules); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->moduleRepository->getRemainingModules($offset); - } - - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - return []; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->moduleRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index a20793be..a242f1cb 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -70,3 +70,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index bc42a745..ace75cfb 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -15,10 +15,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\ModuleRepository: - class: PrestaShop\Module\PsEventbus\Repository\ModuleRepository - public: true - PrestaShop\Module\PsEventbus\Repository\ThemeRepository: class: PrestaShop\Module\PsEventbus\Repository\ThemeRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index f9e3f190..3920f603 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -192,3 +192,10 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 7dd1daff..6fe599bf 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -5,7 +5,6 @@ import R from "ramda"; /* export const shopContentMapping = { 'specific_prices': 'specific-prices', 'taxonomies': 'taxonomies', - 'modules': 'modules', 'stores': 'stores', 'themes': 'themes', 'wishlists': 'wishlists', @@ -40,6 +39,7 @@ export const shopContentMapping = { images: "images", image_types: "image-types", shop_information: "shop-information", + modules: "modules", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php deleted file mode 100644 index 5fdd606c..00000000 --- a/src/Repository/ModuleRepository.php +++ /dev/null @@ -1,109 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - $query = (new \DbQuery()) - ->from(self::MODULE_TABLE, 'm') - ->leftJoin(self::MODULE_SHOP, 'm_shop', 'm.id_module = m_shop.id_module'); - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $query = $query->leftJoin(self::MODULE_TABLE_HISTORY, 'h', 'm.id_module = h.id_module'); - } - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|false|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getModules($offset, $limit) - { - $query = $this->getBaseQuery(); - - /* - * The `active` field of the "ps_module" table has been deprecated, this is why we use the "ps_module_shop" table - * to check if a module is active or not - */ - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $query->select('m.id_module as module_id, name, version as module_version, IF(m_shop.enable_device, 1, 0) as active, date_add as created_at, date_upd as updated_at') - ->limit($limit, $offset); - } else { - $query->select('m.id_module as module_id, name, version as module_version, IF(m_shop.enable_device, 1, 0) as active') - ->limit($limit, $offset); - } - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingModules($offset) - { - $query = $this->getBaseQuery(); - - $query->select('(COUNT(m.id_module) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - /* - * The `active` field of the "ps_module" table has been deprecated, this is why we use the "ps_module_shop" table - * to check if a module is active or not - */ - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { - $query->select('m.id_module as module_id, name, version as module_version, IF(m_shop.enable_device, 1, 0) as active, date_add as created_at, date_upd as updated_at') - ->limit($limit, $offset); - } else { - $query->select('m.id_module as module_id, name, version as module_version, IF(m_shop.enable_device, 1, 0) as active') - ->limit($limit, $offset); - } - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } -} diff --git a/src/Repository/NewRepository/ModuleRepository.php b/src/Repository/NewRepository/ModuleRepository.php new file mode 100644 index 00000000..e16d6451 --- /dev/null +++ b/src/Repository/NewRepository/ModuleRepository.php @@ -0,0 +1,112 @@ +generateMinimalQuery(self::TABLE_NAME, 'm'); + + $this->query->leftJoin('module_shop', 'm_shop', 'm.id_module = m_shop.id_module'); + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { + $this->query->leftJoin('module_history', 'h', 'm.id_module = h.id_module'); + } + + if ($withSelecParameters) { + /* + * The `active` field of the "ps_module" table has been deprecated, + * this is why we use the "ps_module_shop" table to check if a module is active or not + */ + + $this->query + ->select('m.id_module as module_id') + ->select('name') + ->select('version as module_version') + ->select('IF(m_shop.enable_device, 1, 0) as active') + ; + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>=')) { + $this->query + ->select('date_add as created_at') + ->select('date_upd as updated_at') + ; + } + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('m.id_module IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php new file mode 100644 index 00000000..64ff38ba --- /dev/null +++ b/src/Service/ShopContent/ModulesService.php @@ -0,0 +1,107 @@ +moduleRepository = $moduleRepository; + $this->shopRepository = $shopRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->moduleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castModules($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['module_id'], + 'collection' => Config::COLLECTION_MODULES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->moduleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castModules($result); + + return array_map(function ($item) { + return [ + 'id' => (string) $item['module_id'], + 'collection' => Config::COLLECTION_MODULES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->moduleRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $modules + * + * @return void + */ + private function castModules(&$modules) + { + $shopCreatedAt = $this->shopRepository->getCreatedAt(); + + foreach ($modules as &$module) { + $module['module_id'] = (string) $module['module_id']; + $module['active'] = $module['active'] == '1'; + $module['created_at'] = $module['created_at'] ?: $shopCreatedAt; + $module['updated_at'] = $module['updated_at'] ?: $shopCreatedAt; + } + } +} From 76111aff2cb40acc80f3939784e4c99336c87521 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 24 Sep 2024 11:31:26 +0200 Subject: [PATCH 085/162] fix: shop_informations name --- e2e/src/fixtures/1.6/shop_information.json | 2 +- e2e/src/fixtures/1.7/shop_information.json | 2 +- e2e/src/fixtures/8/shop_information.json | 2 +- e2e/src/fixtures/9/shop_information.json | 2 +- e2e/src/helpers/shop-contents.ts | 2 +- src/Config/Config.php | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/src/fixtures/1.6/shop_information.json b/e2e/src/fixtures/1.6/shop_information.json index 828e386a..53da0dcb 100644 --- a/e2e/src/fixtures/1.6/shop_information.json +++ b/e2e/src/fixtures/1.6/shop_information.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_information", + "collection": "shop_informations", "properties": { "created_at": "2024-07-16 15:33:52", "folder_created_at": "2024-07-16 15:34:17", diff --git a/e2e/src/fixtures/1.7/shop_information.json b/e2e/src/fixtures/1.7/shop_information.json index 29700e6a..f2c3ae9a 100644 --- a/e2e/src/fixtures/1.7/shop_information.json +++ b/e2e/src/fixtures/1.7/shop_information.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_information", + "collection": "shop_informations", "properties": { "created_at": "2023-12-20 22:56:03", "folder_created_at": "2024-03-05 12:59:12", diff --git a/e2e/src/fixtures/8/shop_information.json b/e2e/src/fixtures/8/shop_information.json index 0c4a44f5..e09b49ca 100644 --- a/e2e/src/fixtures/8/shop_information.json +++ b/e2e/src/fixtures/8/shop_information.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_information", + "collection": "shop_informations", "properties": { "created_at": "2024-08-22T12:27:09+0200", "folder_created_at": "2024-08-27T10:07:19+0200", diff --git a/e2e/src/fixtures/9/shop_information.json b/e2e/src/fixtures/9/shop_information.json index cc940f66..fb978956 100644 --- a/e2e/src/fixtures/9/shop_information.json +++ b/e2e/src/fixtures/9/shop_information.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_information", + "collection": "shop_informations", "properties": { "created_at": "2024-06-10 02:27:21", "folder_created_at": "2024-06-10 18:01:29", diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 6fe599bf..aa52f374 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -38,7 +38,7 @@ export const shopContentMapping = { employees: "employees", images: "images", image_types: "image-types", - shop_information: "shop-information", + shop_informations: "shops-informations", modules: "modules", } as const; diff --git a/src/Config/Config.php b/src/Config/Config.php index 3aa80ba5..3617a880 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -59,7 +59,7 @@ class Config const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; const COLLECTION_PRODUCT_CARRIERS = 'product_carriers'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; - const COLLECTION_SHOP_INFORMATION = 'shop_information'; + const COLLECTION_SHOP_INFORMATIONS = 'shop_informations'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; const COLLECTION_STOCKS = 'stocks'; const COLLECTION_STOCK_MVTS = 'stock_movements'; @@ -97,7 +97,7 @@ class Config self::COLLECTION_PRODUCT_BUNDLES, self::COLLECTION_PRODUCT_CARRIERS, self::COLLECTION_PRODUCT_SUPPLIERS, - self::COLLECTION_SHOP_INFORMATION, + self::COLLECTION_SHOP_INFORMATIONS, self::COLLECTION_SPECIFIC_PRICES, self::COLLECTION_STOCKS, self::COLLECTION_STOCK_MVTS, From 0495b5a0aab42ee0c7ba64ffdc65847ac091c184 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:07:32 +0200 Subject: [PATCH 086/162] feat: fpseventbus v4 themes (#372) --- config/common/repository.yml | 6 - config/front/services.yml | 52 +++--- ...hop_information.json => shop_details.json} | 2 +- ...hop_information.json => shop_details.json} | 2 +- ...hop_information.json => shop_details.json} | 2 +- ...hop_information.json => shop_details.json} | 2 +- e2e/src/helpers/shop-contents.ts | 3 +- src/Config/Config.php | 5 +- src/Repository/ThemeRepository.php | 91 ---------- ...tionService.php => ShopDetailsService.php} | 4 +- src/Service/ShopContent/ThemesService.php | 158 ++++++++++++++++++ 11 files changed, 197 insertions(+), 130 deletions(-) rename e2e/src/fixtures/1.6/{shop_information.json => shop_details.json} (95%) rename e2e/src/fixtures/1.7/{shop_information.json => shop_details.json} (95%) rename e2e/src/fixtures/8/{shop_information.json => shop_details.json} (95%) rename e2e/src/fixtures/9/{shop_information.json => shop_details.json} (95%) delete mode 100644 src/Repository/ThemeRepository.php rename src/Service/ShopContent/{ShopInformationService.php => ShopDetailsService.php} (97%) create mode 100644 src/Service/ShopContent/ThemesService.php diff --git a/config/common/repository.yml b/config/common/repository.yml index ace75cfb..fc339933 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -15,12 +15,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\ThemeRepository: - class: PrestaShop\Module\PsEventbus\Repository\ThemeRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository: class: PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 3920f603..44de1093 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -58,7 +58,7 @@ services: # SHOP CONTENT SERVICES PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository' @@ -66,62 +66,62 @@ services: - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CartProductsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartProductsService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartProductsService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CartRulesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartRulesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartRulesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' @@ -130,61 +130,61 @@ services: - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\EmployeesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\EmployeesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\EmployeesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ImagesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImagesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImagesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ImageTypesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImageTypesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImageTypesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\ShopInformationService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopInformationService + PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' @@ -194,8 +194,14 @@ services: - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService + public: true + arguments: + - '@=service("prestashop.adapter.legacy.context").getContext()' diff --git a/e2e/src/fixtures/1.6/shop_information.json b/e2e/src/fixtures/1.6/shop_details.json similarity index 95% rename from e2e/src/fixtures/1.6/shop_information.json rename to e2e/src/fixtures/1.6/shop_details.json index 53da0dcb..9cd1e3b6 100644 --- a/e2e/src/fixtures/1.6/shop_information.json +++ b/e2e/src/fixtures/1.6/shop_details.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_informations", + "collection": "shop_details", "properties": { "created_at": "2024-07-16 15:33:52", "folder_created_at": "2024-07-16 15:34:17", diff --git a/e2e/src/fixtures/1.7/shop_information.json b/e2e/src/fixtures/1.7/shop_details.json similarity index 95% rename from e2e/src/fixtures/1.7/shop_information.json rename to e2e/src/fixtures/1.7/shop_details.json index f2c3ae9a..cd3a96b0 100644 --- a/e2e/src/fixtures/1.7/shop_information.json +++ b/e2e/src/fixtures/1.7/shop_details.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_informations", + "collection": "shop_details", "properties": { "created_at": "2023-12-20 22:56:03", "folder_created_at": "2024-03-05 12:59:12", diff --git a/e2e/src/fixtures/8/shop_information.json b/e2e/src/fixtures/8/shop_details.json similarity index 95% rename from e2e/src/fixtures/8/shop_information.json rename to e2e/src/fixtures/8/shop_details.json index e09b49ca..ad085f79 100644 --- a/e2e/src/fixtures/8/shop_information.json +++ b/e2e/src/fixtures/8/shop_details.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_informations", + "collection": "shop_details", "properties": { "created_at": "2024-08-22T12:27:09+0200", "folder_created_at": "2024-08-27T10:07:19+0200", diff --git a/e2e/src/fixtures/9/shop_information.json b/e2e/src/fixtures/9/shop_details.json similarity index 95% rename from e2e/src/fixtures/9/shop_information.json rename to e2e/src/fixtures/9/shop_details.json index fb978956..57254296 100644 --- a/e2e/src/fixtures/9/shop_information.json +++ b/e2e/src/fixtures/9/shop_details.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_informations", + "collection": "shop_details", "properties": { "created_at": "2024-06-10 02:27:21", "folder_created_at": "2024-06-10 18:01:29", diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index aa52f374..38900a4f 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -38,8 +38,9 @@ export const shopContentMapping = { employees: "employees", images: "images", image_types: "image-types", - shop_informations: "shops-informations", + shop_details: "shop-details", modules: "modules", + themes: "themes", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Config/Config.php b/src/Config/Config.php index 3617a880..f4c7f5db 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -46,7 +46,6 @@ class Config const COLLECTION_HEALTHCHECK = 'healthcheck'; const COLLECTION_IMAGES = 'images'; const COLLECTION_IMAGE_TYPES = 'image_types'; - const COLLECTION_INFO = 'info'; const COLLECTION_LANGUAGES = 'languages'; const COLLECTION_MANUFACTURERS = 'manufacturers'; const COLLECTION_MODULES = 'modules'; @@ -59,7 +58,7 @@ class Config const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; const COLLECTION_PRODUCT_CARRIERS = 'product_carriers'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; - const COLLECTION_SHOP_INFORMATIONS = 'shop_informations'; + const COLLECTION_SHOP_DETAILS = 'shop_details'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; const COLLECTION_STOCKS = 'stocks'; const COLLECTION_STOCK_MVTS = 'stock_movements'; @@ -97,7 +96,7 @@ class Config self::COLLECTION_PRODUCT_BUNDLES, self::COLLECTION_PRODUCT_CARRIERS, self::COLLECTION_PRODUCT_SUPPLIERS, - self::COLLECTION_SHOP_INFORMATIONS, + self::COLLECTION_SHOP_DETAILS, self::COLLECTION_SPECIFIC_PRICES, self::COLLECTION_STOCKS, self::COLLECTION_STOCK_MVTS, diff --git a/src/Repository/ThemeRepository.php b/src/Repository/ThemeRepository.php deleted file mode 100644 index d773ee3e..00000000 --- a/src/Repository/ThemeRepository.php +++ /dev/null @@ -1,91 +0,0 @@ -context = $context; - $this->db = \Db::getInstance(); - } - - /** - * @return array|mixed|null - */ - public function getThemes() - { - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>')) { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $themeRepository = (new ThemeManagerBuilder($this->context, $this->db)) - ->buildRepository($this->context->shop); - - $currentTheme = $this->context->shop->theme; - $themes = $themeRepository->getList(); - - return array_map(function ($key, $theme) use ($currentTheme) { - return [ - 'id' => md5((string) $key), - 'collection' => Config::COLLECTION_THEMES, - 'properties' => [ - 'theme_id' => md5((string) $key), - 'name' => (string) $theme->getName(), - 'theme_version' => (string) $theme->get('version'), - 'active' => $theme->getName() == $currentTheme->getName(), - ], - ]; - }, array_keys($themes), $themes); - } else { - /* @phpstan-ignore-next-line */ - $themes = \Theme::getAvailable(false); - - return array_map(function ($theme) { - /* @phpstan-ignore-next-line */ - $themeObj = \Theme::getByDirectory($theme); - - $themeData = [ - 'id' => md5($theme), - 'collection' => Config::COLLECTION_THEMES, - 'properties' => [], - ]; - - /* @phpstan-ignore-next-line */ - if ($themeObj instanceof \Theme) { - /* @phpstan-ignore-next-line */ - $themeInfo = \Theme::getThemeInfo($themeObj->id); - - $themeData['properties'] = [ - 'theme_id' => md5($theme), - 'name' => isset($themeInfo['theme_name']) ? $themeInfo['theme_name'] : '', - 'theme_version' => isset($themeInfo['theme_version']) ? $themeInfo['theme_version'] : '', - 'active' => isset($themeInfo['theme_version']) ? false : (string) $this->context->theme->id == (string) $themeInfo['theme_id'], - ]; - } else { - $themeData['properties'] = [ - 'theme_id' => md5($theme), - 'name' => $theme, - 'theme_version' => '', - 'active' => false, - ]; - } - - return $themeData; - }, $themes); - } - } -} diff --git a/src/Service/ShopContent/ShopInformationService.php b/src/Service/ShopContent/ShopDetailsService.php similarity index 97% rename from src/Service/ShopContent/ShopInformationService.php rename to src/Service/ShopContent/ShopDetailsService.php index 9f28b7a1..6cfa8d09 100644 --- a/src/Service/ShopContent/ShopInformationService.php +++ b/src/Service/ShopContent/ShopDetailsService.php @@ -7,7 +7,7 @@ use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\ShopRepository; -class ShopInformationService implements ShopContentServiceInterface +class ShopDetailsService implements ShopContentServiceInterface { /** @var CurrenciesService */ private $currenciesService; @@ -75,7 +75,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return [ [ 'id' => '1', - 'collection' => Config::COLLECTION_SHOP_INFORMATION, + 'collection' => Config::COLLECTION_SHOP_DETAILS, 'properties' => [ 'created_at' => $this->shopRepository->getCreatedAt(), 'folder_created_at' => $folderCreatedAt, diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php new file mode 100644 index 00000000..3ec42ee8 --- /dev/null +++ b/src/Service/ShopContent/ThemesService.php @@ -0,0 +1,158 @@ +context = $context; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->getAllThemes(); + + if (empty($result)) { + return []; + } + + $themes = $this->formatThemes($result); + + return array_map(function ($item) { + return [ + 'id' => $item['theme_id'], + 'collection' => Config::COLLECTION_THEMES, + 'properties' => $item, + ]; + }, $themes); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->getAllThemes(); + + if (empty($result)) { + return []; + } + + $themes = $this->formatThemes($result); + + return array_map(function ($item) { + return [ + 'id' => $item['theme_id'], + 'collection' => Config::COLLECTION_THEMES, + 'properties' => $item, + ]; + }, $themes); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return 0; + } + + /** + * Get all Themes + * + * @return mixed + * + * @throws \PrestaShopException + */ + private function getAllThemes() + { + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>')) { + if ($this->context->shop === null) { + throw new \PrestaShopException('No shop context'); + } + + $themeRepository = (new ThemeManagerBuilder($this->context, \Db::getInstance()))->buildRepository($this->context->shop); + + return $themeRepository->getList(); + } else { + /* @phpstan-ignore-next-line */ + return \Theme::getAvailable(false); + } + } + + /** + * @param array $themes + * + * @return array + * + * @throws \PrestaShopException + */ + private function formatThemes($themes) + { + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '>')) { + if ($this->context->shop === null) { + throw new \PrestaShopException('No shop context'); + } + + $currentTheme = $this->context->shop->theme; + + return array_map(function ($key, $theme) use ($currentTheme) { + return [ + 'theme_id' => md5((string) $key), + 'name' => (string) $theme->getName(), + 'theme_version' => (string) $theme->get('version'), + 'active' => $theme->getName() == $currentTheme->getName(), + ]; + }, array_keys($themes), $themes); + } else { + return array_map(function ($theme) { + /* @phpstan-ignore-next-line */ + $themeObj = \Theme::getByDirectory($theme); + + /* @phpstan-ignore-next-line */ + if ($themeObj instanceof \Theme) { + /* @phpstan-ignore-next-line */ + $themeInfo = \Theme::getThemeInfo($themeObj->id); + + return [ + 'theme_id' => md5($theme), + 'name' => isset($themeInfo['theme_name']) ? $themeInfo['theme_name'] : '', + 'theme_version' => isset($themeInfo['theme_version']) ? $themeInfo['theme_version'] : '', + 'active' => isset($themeInfo['theme_version']) ? false : (string) $this->context->theme->id == (string) $themeInfo['theme_id'], + ]; + } else { + return [ + 'theme_id' => md5($theme), + 'name' => $theme, + 'theme_version' => '', + 'active' => false, + ]; + } + }, $themes); + } + } +} From 749df28aa56de40012e6f4ad3e96606a33316016 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:30:24 +0200 Subject: [PATCH 087/162] feat: pseventbus v4 wishlists and wishlist products (#373) --- OLD/Provider/WishlistDataProvider.php | 25 --- config/common/new-repository.yml | 8 + config/common/repository.yml | 10 -- config/front/services.yml | 12 ++ e2e/src/fixtures/1.6/wishlist_products.json | 1 + e2e/src/fixtures/1.6/wishlists.json | 1 + e2e/src/fixtures/1.7/wishlist_products.json | 1 + e2e/src/fixtures/1.7/wishlists.json | 1 + e2e/src/fixtures/8/wishlist_products.json | 1 + e2e/src/fixtures/8/wishlists.json | 1 + e2e/src/fixtures/9/wishlist_products.json | 1 + e2e/src/fixtures/9/wishlists.json | 1 + e2e/src/helpers/shop-contents.ts | 2 + src/Decorator/WishlistDecorator.php | 60 ------- .../NewRepository/AbstractRepository.php | 2 +- .../WishlistProductRepository.php | 119 ++++++++++++++ .../NewRepository/WishlistRepository.php | 125 +++++++++++++++ src/Repository/WishlistProductRepository.php | 75 --------- src/Repository/WishlistRepository.php | 150 ------------------ src/Service/HealthCheckService.php | 39 +++-- .../ShopContent/WishlistProductsService.php | 101 ++++++++++++ src/Service/ShopContent/WishlistsService.php | 101 ++++++++++++ 22 files changed, 503 insertions(+), 334 deletions(-) create mode 100644 e2e/src/fixtures/1.6/wishlist_products.json create mode 100644 e2e/src/fixtures/1.6/wishlists.json create mode 100644 e2e/src/fixtures/1.7/wishlist_products.json create mode 100644 e2e/src/fixtures/1.7/wishlists.json create mode 100644 e2e/src/fixtures/8/wishlist_products.json create mode 100644 e2e/src/fixtures/8/wishlists.json create mode 100644 e2e/src/fixtures/9/wishlist_products.json create mode 100644 e2e/src/fixtures/9/wishlists.json delete mode 100644 src/Decorator/WishlistDecorator.php create mode 100644 src/Repository/NewRepository/WishlistProductRepository.php create mode 100644 src/Repository/NewRepository/WishlistRepository.php delete mode 100644 src/Repository/WishlistProductRepository.php delete mode 100644 src/Repository/WishlistRepository.php create mode 100644 src/Service/ShopContent/WishlistProductsService.php create mode 100644 src/Service/ShopContent/WishlistsService.php diff --git a/OLD/Provider/WishlistDataProvider.php b/OLD/Provider/WishlistDataProvider.php index 8eef8710..28306fc2 100644 --- a/OLD/Provider/WishlistDataProvider.php +++ b/OLD/Provider/WishlistDataProvider.php @@ -71,17 +71,6 @@ public function getFormattedData($offset, $limit, $langIso) return array_merge($wishlists, $wishlistProducts); } - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->wishlistRepository->getRemainingWishlistsCount($offset); - } - /** * @param int $limit * @param string $langIso @@ -113,20 +102,6 @@ public function getFormattedDataIncremental($limit, $langIso, $objectIds) return array_merge($wishlists, $wishlistProducts); } - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->wishlistRepository->getQueryForDebug($offset, $limit); - } - /** * @param array $wishlists * diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index a242f1cb..9e175092 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -74,3 +74,11 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index fc339933..f0a69cf5 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -52,16 +52,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\WishlistRepository: - class: PrestaShop\Module\PsEventbus\Repository\WishlistRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository - public: true - PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository: class: PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 44de1093..d2263898 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -205,3 +205,15 @@ services: public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' + + PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository' diff --git a/e2e/src/fixtures/1.6/wishlist_products.json b/e2e/src/fixtures/1.6/wishlist_products.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/wishlist_products.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.6/wishlists.json b/e2e/src/fixtures/1.6/wishlists.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/wishlists.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/wishlist_products.json b/e2e/src/fixtures/1.7/wishlist_products.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/wishlist_products.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/wishlists.json b/e2e/src/fixtures/1.7/wishlists.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/wishlists.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/wishlist_products.json b/e2e/src/fixtures/8/wishlist_products.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/wishlist_products.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/wishlists.json b/e2e/src/fixtures/8/wishlists.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/wishlists.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/9/wishlist_products.json b/e2e/src/fixtures/9/wishlist_products.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/wishlist_products.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/9/wishlists.json b/e2e/src/fixtures/9/wishlists.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/wishlists.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 38900a4f..b03b5bf9 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -41,6 +41,8 @@ export const shopContentMapping = { shop_details: "shop-details", modules: "modules", themes: "themes", + wishlists: "wishlists", + wishlist_products: "wishlist-products", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Decorator/WishlistDecorator.php b/src/Decorator/WishlistDecorator.php deleted file mode 100644 index cf49f9ad..00000000 --- a/src/Decorator/WishlistDecorator.php +++ /dev/null @@ -1,60 +0,0 @@ - $wishlists - * - * @return void - */ - public function decorateWishlists(&$wishlists) - { - foreach ($wishlists as &$wishlist) { - $this->castWishlistPropertyValues($wishlist); - } - } - - /** - * @param array $wishlistProducts - * - * @return void - */ - public function decorateWishlistProducts(&$wishlistProducts) - { - foreach ($wishlistProducts as &$wishlistProduct) { - $this->castWishlistProductPropertyValues($wishlistProduct); - } - } - - /** - * @param array $wishlist - * - * @return void - */ - private function castWishlistPropertyValues(&$wishlist) - { - $wishlist['id_wishlist'] = (int) $wishlist['id_wishlist']; - $wishlist['id_customer'] = (int) $wishlist['id_customer']; - $wishlist['id_shop'] = (int) $wishlist['id_shop']; - $wishlist['id_shop_group'] = (int) $wishlist['id_shop_group']; - $wishlist['counter'] = (int) $wishlist['counter']; - $wishlist['default'] = (bool) $wishlist['default']; - } - - /** - * @param array $wishlistProduct - * - * @return void - */ - private function castWishlistProductPropertyValues(&$wishlistProduct) - { - $wishlistProduct['id_wishlist_product'] = (int) $wishlistProduct['id_wishlist_product']; - $wishlistProduct['id_wishlist'] = (int) $wishlistProduct['id_wishlist']; - $wishlistProduct['id_product'] = (int) $wishlistProduct['id_product']; - $wishlistProduct['id_product_attribute'] = (int) $wishlistProduct['id_product_attribute']; - $wishlistProduct['quantity'] = (int) $wishlistProduct['quantity']; - $wishlistProduct['priority'] = (int) $wishlistProduct['priority']; - } -} diff --git a/src/Repository/NewRepository/AbstractRepository.php b/src/Repository/NewRepository/AbstractRepository.php index bf4d1fb7..9502038f 100644 --- a/src/Repository/NewRepository/AbstractRepository.php +++ b/src/Repository/NewRepository/AbstractRepository.php @@ -14,7 +14,7 @@ abstract class AbstractRepository /** * @var \Db */ - private $db; + protected $db; /** * @var \DbQuery diff --git a/src/Repository/NewRepository/WishlistProductRepository.php b/src/Repository/NewRepository/WishlistProductRepository.php new file mode 100644 index 00000000..5369e223 --- /dev/null +++ b/src/Repository/NewRepository/WishlistProductRepository.php @@ -0,0 +1,119 @@ +generateMinimalQuery(self::TABLE_NAME, 'wp'); + + if ($withSelecParameters) { + $this->query + ->select('wp.id_wishlist_product') + ->select('wp.id_wishlist') + ->select('wp.id_product') + ->select('wp.id_product_attribute') + ->select('wp.quantity') + ->select('wp.priority') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html + if (empty($this->checkIfPsWishlistIsInstalled())) { + return []; + } + + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('ps.id_wishlist IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html + if (empty($this->checkIfPsWishlistIsInstalled())) { + return 0; + } + + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } + + /** + * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + private function checkIfPsWishlistIsInstalled() + { + $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%wishlist\' LIMIT 1;'; + + return $this->db->executeS($moduleisInstalledQuery, false); + } +} diff --git a/src/Repository/NewRepository/WishlistRepository.php b/src/Repository/NewRepository/WishlistRepository.php new file mode 100644 index 00000000..7c673e8d --- /dev/null +++ b/src/Repository/NewRepository/WishlistRepository.php @@ -0,0 +1,125 @@ +generateMinimalQuery(self::TABLE_NAME, 'w'); + + $this->query->where('w.id_shop = ' . parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('w.id_wishlist') + ->select('w.id_customer') + ->select('w.id_shop') + ->select('w.id_shop_group') + ->select('w.token') + ->select('w.name') + ->select('w.counter') + ->select('w.date_add AS created_at') + ->select('w.date_upd as updated_at') + ->select('w.default') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html + if (empty($this->checkIfPsWishlistIsInstalled())) { + return []; + } + + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('ps.id_wishlist IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html + if (empty($this->checkIfPsWishlistIsInstalled())) { + return 0; + } + + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } + + /** + * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + private function checkIfPsWishlistIsInstalled() + { + $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%wishlist\' LIMIT 1;'; + + return $this->db->executeS($moduleisInstalledQuery, false); + } +} diff --git a/src/Repository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php deleted file mode 100644 index f206bb1e..00000000 --- a/src/Repository/WishlistProductRepository.php +++ /dev/null @@ -1,75 +0,0 @@ -db = \Db::getInstance(); - } - - /** - * @param array $wishlistIds - * - * @return \DbQuery - */ - public function getBaseQuery(&$wishlistIds) - { - $query = new \DbQuery(); - - $query->from('wishlist_product', 'wp'); - $query->where('wp.id_wishlist IN(' . implode(',', array_map('intval', $wishlistIds)) . ')'); - - return $query; - } - - /** - * @param array $wishlistIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getWishlistProducts(&$wishlistIds) - { - // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html - if (empty($this->checkIfPsWishlistIsInstalled())) { - return []; - } - - $query = $this->getBaseQuery($wishlistIds); - - $this->addSelectParameters($query); - - return $this->db->executeS($query); - } - - /** - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - private function checkIfPsWishlistIsInstalled() - { - $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%wishlist\' LIMIT 1;'; - - return $this->db->executeS($moduleisInstalledQuery); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('wp.id_wishlist_product, wp.id_wishlist, wp.id_product, wp.id_product_attribute'); - $query->select('wp.quantity, wp.priority'); - } -} diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php deleted file mode 100644 index eeb8c1fd..00000000 --- a/src/Repository/WishlistRepository.php +++ /dev/null @@ -1,150 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - $query->from('wishlist', 'w') - ->where('w.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getWishlists($offset, $limit) - { - // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html - if (empty($this->checkIfPsWishlistIsInstalled())) { - return []; - } - - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingWishlistsCount($offset) - { - // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html - if (empty($this->checkIfPsWishlistIsInstalled())) { - return 0; - } - - $query = $this->getBaseQuery() - ->select('(COUNT(w.id_wishlist) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $wishlistIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getWishlistsIncremental($limit, $wishlistIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('w.id_wishlist IN(' . implode(',', array_map('intval', $wishlistIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('w.id_wishlist, w.id_customer, w.id_shop, w.id_shop_group, w.token, w.name, w.counter'); - $query->select('w.date_add AS created_at, w.date_upd as updated_at, w.default'); - } - - /** - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopException - * @throws \PrestaShopDatabaseException - */ - private function checkIfPsWishlistIsInstalled() - { - $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%wishlist\' LIMIT 1;'; - - return $this->db->executeS($moduleisInstalledQuery); - } -} diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index f0da66e6..8a4bfe6d 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -70,7 +70,7 @@ public function getHealthCheck($isAuthentified) { $tokenValid = false; $tokenIsSet = false; - $allTablesInstalled = true; + $allTablesInstalled = false; try { $token = $this->psAccountsAdapterService->getOrRefreshToken(); @@ -90,19 +90,10 @@ public function getHealthCheck($isAuthentified) $tokenIsSet = false; } - foreach (self::REQUIRED_TABLES as $requiredTable) { - $query = new \DbQuery(); + $missingTables = $this->getMissingRequiredTables(); - $query->select('*') - ->from($requiredTable) - ->limit(1); - - try { - $this->db->executeS($query); - } catch (\PrestaShopDatabaseException $e) { - $allTablesInstalled = false; - break; - } + if (count($missingTables) == 0) { + $allTablesInstalled = true; } if (defined('PHP_VERSION') && defined('PHP_EXTRA_VERSION')) { @@ -136,4 +127,26 @@ public function getHealthCheck($isAuthentified) return $serverInformation; } + + /** + * @return array + * + * @throws \PrestaShopDatabaseException + */ + private function getMissingRequiredTables() + { + $requiredTablesQuery = 'SELECT TABLE_NAME FROM information_schema.tables WHERE table_name LIKE \'%eventbus%\';'; + $requiredTablesResponse = (array) $this->db->executeS($requiredTablesQuery); + + // Transform 2D array into array + $requiredTables = array_column($requiredTablesResponse, 'TABLE_NAME'); + + // Remove the prefix of the tables (ex: ps_) + $filteredRequiredTables = array_map(function ($item) { + return substr($item, strpos($item, '_') + 1); + }, $requiredTables); + + // return array, with list of missing required table + return array_diff(self::REQUIRED_TABLES, $filteredRequiredTables); + } } diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php new file mode 100644 index 00000000..e2b47cdc --- /dev/null +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -0,0 +1,101 @@ +wishlistProductRepository = $wishlistProductRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->wishlistProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castWishlistProducts($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_wishlist_product'], + 'collection' => Config::COLLECTION_WISHLIST_PRODUCTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->wishlistProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castWishlistProducts($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['COLLECTION_WISHLIST_PRODUCTS'], + 'collection' => Config::COLLECTION_WISHLIST_PRODUCTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->wishlistProductRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $wishlistProducts + * @param string $langIso + * + * @return void + */ + private function castWishlistProducts(&$wishlistProducts, $langIso) + { + foreach ($wishlistProducts as &$wishlistProduct) { + $wishlistProduct['id_wishlist_product'] = (int) $wishlistProduct['id_wishlist_product']; + $wishlistProduct['id_wishlist'] = (int) $wishlistProduct['id_wishlist']; + $wishlistProduct['id_product'] = (int) $wishlistProduct['id_product']; + $wishlistProduct['id_product_attribute'] = (int) $wishlistProduct['id_product_attribute']; + $wishlistProduct['quantity'] = (int) $wishlistProduct['quantity']; + $wishlistProduct['priority'] = (int) $wishlistProduct['priority']; + } + } +} diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php new file mode 100644 index 00000000..3d1b8f57 --- /dev/null +++ b/src/Service/ShopContent/WishlistsService.php @@ -0,0 +1,101 @@ +wishlistRepository = $wishlistRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->wishlistRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castWishlists($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_wishlist'], + 'collection' => Config::COLLECTION_WISHLISTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castWishlists($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_wishlist'], + 'collection' => Config::COLLECTION_WISHLISTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->wishlistRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $wishlists + * @param string $langIso + * + * @return void + */ + private function castWishlists(&$wishlists, $langIso) + { + foreach ($wishlists as &$wishlist) { + $wishlist['id_wishlist'] = (int) $wishlist['id_wishlist']; + $wishlist['id_customer'] = (int) $wishlist['id_customer']; + $wishlist['id_shop'] = (int) $wishlist['id_shop']; + $wishlist['id_shop_group'] = (int) $wishlist['id_shop_group']; + $wishlist['counter'] = (int) $wishlist['counter']; + $wishlist['default'] = (bool) $wishlist['default']; + } + } +} From cc021d83054283cb975e118aadee0d59644eb60a Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:01:06 +0200 Subject: [PATCH 088/162] feat: add languages (#374) --- .github/workflows/quality-check.yml | 3 + OLD/Provider/LanguageDataProvider.php | 105 ----------- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 12 +- e2e/src/helpers/shop-contents.ts | 20 +- src/Decorator/LanguageDecorator.php | 31 --- src/Repository/LanguageRepository.php | 176 ------------------ .../NewRepository/LanguageRepository.php | 106 +++++++++++ src/Service/FrontApiService.php | 8 +- src/Service/ShopContent/CurrenciesService.php | 40 ++-- src/Service/ShopContent/LanguagesService.php | 143 ++++++++++++++ src/Service/ShopContent/ProductsService.php | 13 +- .../ShopContent/ShopDetailsService.php | 15 +- src/Service/SynchronizationService.php | 16 +- 15 files changed, 319 insertions(+), 379 deletions(-) delete mode 100644 OLD/Provider/LanguageDataProvider.php delete mode 100644 src/Decorator/LanguageDecorator.php delete mode 100644 src/Repository/LanguageRepository.php create mode 100644 src/Repository/NewRepository/LanguageRepository.php create mode 100644 src/Service/ShopContent/LanguagesService.php diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index e25e20a5..9ba25e91 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -114,6 +114,9 @@ jobs: path: vendor key: php-${{ hashFiles('composer.lock') }} + - name: install php dependencies + run: composer install + - name: Install dependencies and setup e2e run: pnpm install --no-optional --force working-directory: e2e diff --git a/OLD/Provider/LanguageDataProvider.php b/OLD/Provider/LanguageDataProvider.php deleted file mode 100644 index 79a9b575..00000000 --- a/OLD/Provider/LanguageDataProvider.php +++ /dev/null @@ -1,105 +0,0 @@ -languageRepository = $languageRepository; - $this->languageDecorator = $languageDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $languages = $this->languageRepository->getLanguagesSync($offset, $limit); - - if (!is_array($languages)) { - return []; - } - $this->languageDecorator->decorateLanguages($languages); - - return array_map(function ($language) { - return [ - 'id' => $language['id_lang'], - 'collection' => Config::COLLECTION_LANGUAGES, - 'properties' => $language, - ]; - }, $languages); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->languageRepository->getRemainingLanguagesCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $languages = $this->languageRepository->getLanguagesIncremental($limit, $objectIds); - - if (!is_array($languages)) { - return []; - } - $this->languageDecorator->decorateLanguages($languages); - - return array_map(function ($language) { - return [ - 'id' => $language['id_lang'], - 'collection' => Config::COLLECTION_LANGUAGES, - 'properties' => $language, - ]; - }, $languages); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->languageRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 9e175092..80a69c48 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -82,3 +82,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index f0a69cf5..56fcaefc 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -1,10 +1,4 @@ services: - PrestaShop\Module\PsEventbus\Repository\LanguageRepository: - class: PrestaShop\Module\PsEventbus\Repository\LanguageRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository: class: PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index d2263898..4791b13f 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -20,7 +20,7 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - '@PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator' @@ -125,7 +125,7 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' @@ -188,9 +188,9 @@ services: public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService: @@ -217,3 +217,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index b03b5bf9..a690e0d5 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -6,9 +6,6 @@ import R from "ramda"; 'specific_prices': 'specific-prices', 'taxonomies': 'taxonomies', 'stores': 'stores', - 'themes': 'themes', - 'wishlists': 'wishlists', - 'wishlist_products': 'wishlist-products', 'stocks': 'stocks', 'stock_movements': 'stock-movements', 'manufacturers': 'manufacturers', @@ -24,22 +21,23 @@ export const shopContentMapping = { carts: "carts", cart_products: "cart-products", cart_rules: "cart-rules", + categories: "categories", + currencies: "currencies", + customers: "customers", + employees: "employees", + images: "images", + image_types: "image-types", + languages: "languages", + modules: "modules", orders: "orders", order_cart_rules: "order-cart-rules", order_details: "order-details", order_histories: "order-histories", products: "products", product_bundles: "product-bundles", - product_suppliers: "product-suppliers", product_carriers: "product-carriers", - categories: "categories", - customers: "customers", - currencies: "currencies", - employees: "employees", - images: "images", - image_types: "image-types", + product_suppliers: "product-suppliers", shop_details: "shop-details", - modules: "modules", themes: "themes", wishlists: "wishlists", wishlist_products: "wishlist-products", diff --git a/src/Decorator/LanguageDecorator.php b/src/Decorator/LanguageDecorator.php deleted file mode 100644 index cef89282..00000000 --- a/src/Decorator/LanguageDecorator.php +++ /dev/null @@ -1,31 +0,0 @@ - $languages - * - * @return void - */ - public function decorateLanguages(&$languages) - { - foreach ($languages as &$language) { - $this->castPropertyValues($language); - } - } - - /** - * @param array $language - * - * @return void - */ - private function castPropertyValues(&$language) - { - $language['id_lang'] = (int) $language['id_lang']; - $language['active'] = (bool) $language['active']; - $language['is_rtl'] = (bool) $language['is_rtl']; - $language['id_shop'] = (int) $language['id_shop']; - } -} diff --git a/src/Repository/LanguageRepository.php b/src/Repository/LanguageRepository.php deleted file mode 100644 index 4a4c84d0..00000000 --- a/src/Repository/LanguageRepository.php +++ /dev/null @@ -1,176 +0,0 @@ -db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getLanguagesSync($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingLanguagesCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(la.id_lang) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $languageIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getLanguagesIncremental($limit, $languageIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('la.id_lang IN(' . implode(',', array_map('intval', $languageIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - $query = new \DbQuery(); - $query->from('lang', 'la') - ->innerJoin('lang_shop', 'las', 'la.id_lang = las.id_lang AND las.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - // https://github.com/PrestaShop/PrestaShop/commit/481111b8274ed005e1c4a8ce2cf2b3ebbeb9a270#diff-c123d3d30d9c9e012a826a21887fccce6600a2f2a848a58d5910e55f0f8f5093R41 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.0.0', '>=')) { - $query->select('la.locale'); - } - - $query->select('la.id_lang, la.name, la.active, la.iso_code, la.language_code, la.date_format_lite'); - $query->select('la.date_format_full, la.is_rtl, las.id_shop'); - } - - /** - * @return array - */ - public function getLanguagesIsoCodes() - { - /** @var array $languages */ - $languages = \Language::getLanguages(); - - return array_map(function ($language) { - return $language['iso_code']; - }, $languages); - } - - /** - * @return string - */ - public function getDefaultLanguageIsoCode() - { - $language = \Language::getLanguage((int) \Configuration::get('PS_LANG_DEFAULT')); - - if (is_array($language)) { - return $language['iso_code']; - } - - return ''; - } - - /** - * @param string $isoCode - * - * @return int - */ - public function getLanguageIdByIsoCode($isoCode) - { - return (int) \Language::getIdByIso($isoCode); - } - - /** - * @return array - */ - public function getLanguages() - { - return \Language::getLanguages(); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } -} diff --git a/src/Repository/NewRepository/LanguageRepository.php b/src/Repository/NewRepository/LanguageRepository.php new file mode 100644 index 00000000..f3e4382b --- /dev/null +++ b/src/Repository/NewRepository/LanguageRepository.php @@ -0,0 +1,106 @@ +generateMinimalQuery(self::TABLE_NAME, 'la'); + + $this->query->innerJoin('lang_shop', 'las', 'la.id_lang = las.id_lang AND las.id_shop = ' . parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('la.id_lang') + ->select('la.name') + ->select('la.active') + ->select('la.iso_code') + ->select('la.language_code') + ->select('la.date_format_lite') + ->select('la.date_format_full') + ->select('la.is_rtl') + ->select('las.id_shop') + ; + + // https://github.com/PrestaShop/PrestaShop/commit/481111b8274ed005e1c4a8ce2cf2b3ebbeb9a270#diff-c123d3d30d9c9e012a826a21887fccce6600a2f2a848a58d5910e55f0f8f5093R41 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.0.0', '>=')) { + $this->query->select('la.locale'); + } + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('la.id_lang IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index f635329f..8e20c116 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -10,7 +10,7 @@ use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; -use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; +use PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; class FrontApiService @@ -91,12 +91,12 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync /** @var ConfigurationRepository $configurationRepository */ $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); - /** @var LanguageRepository $languageRepository */ - $languageRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\LanguageRepository'); + /** @var LanguagesService $languagesService */ + $languagesService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService'); $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); - $langIso = $langIso ? $langIso : $languageRepository->getDefaultLanguageIsoCode(); + $langIso = $langIso ? $langIso : $languagesService->getDefaultLanguageIsoCode(); $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index 01e1582d..1b2ff191 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -81,26 +81,6 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) return $this->currencyRepository->countFullSyncContentLeft($offset, $limit, $langIso); } - /** - * @param array $currencies - * - * @return void - */ - private function castCurrencies(&$currencies) - { - foreach ($currencies as &$currency) { - $currency['id_currency'] = (int) $currency['id_currency']; - $currency['conversion_rate'] = (float) $currency['conversion_rate']; - $currency['deleted'] = (bool) $currency['deleted']; - $currency['active'] = (bool) $currency['active']; - - // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { - $currency['precision'] = (int) $currency['precision']; - } - } - } - /** * @return array */ @@ -122,4 +102,24 @@ public function getDefaultCurrencyIsoCode() return $currency instanceof \Currency ? $currency->iso_code : ''; } + + /** + * @param array $currencies + * + * @return void + */ + private function castCurrencies(&$currencies) + { + foreach ($currencies as &$currency) { + $currency['id_currency'] = (int) $currency['id_currency']; + $currency['conversion_rate'] = (float) $currency['conversion_rate']; + $currency['deleted'] = (bool) $currency['deleted']; + $currency['active'] = (bool) $currency['active']; + + // https://github.com/PrestaShop/PrestaShop/commit/37807f66b40b0cebb365ef952e919be15e9d6b2f#diff-3f41d3529ffdbfd1b994927eb91826a32a0560697025a734cf128a2c8e092a45R124 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.6.0', '>=')) { + $currency['precision'] = (int) $currency['precision']; + } + } + } } diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php new file mode 100644 index 00000000..8735158e --- /dev/null +++ b/src/Service/ShopContent/LanguagesService.php @@ -0,0 +1,143 @@ +languageRepository = $languageRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->languageRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castLanguages($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_lang'], + 'collection' => Config::COLLECTION_LANGUAGES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->languageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castLanguages($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_lang'], + 'collection' => Config::COLLECTION_LANGUAGES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->languageRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @return array + */ + public function getLanguagesIsoCodes() + { + /** @var array $languages */ + $languages = \Language::getLanguages(); + + return array_map(function ($language) { + return $language['iso_code']; + }, $languages); + } + + /** + * @return string + */ + public function getDefaultLanguageIsoCode() + { + $language = \Language::getLanguage((int) \Configuration::get('PS_LANG_DEFAULT')); + + if (is_array($language)) { + return $language['iso_code']; + } + + return ''; + } + + /** + * @param string $isoCode + * + * @return int + */ + public function getLanguageIdByIsoCode($isoCode) + { + return (int) \Language::getIdByIso($isoCode); + } + + /** + * @return array + */ + public function getLanguages() + { + return \Language::getLanguages(); + } + + /** + * @param array $languages + * + * @return void + */ + private function castLanguages(&$languages) + { + foreach ($languages as &$language) { + $language['id_lang'] = (int) $language['id_lang']; + $language['active'] = (bool) $language['active']; + $language['is_rtl'] = (bool) $language['is_rtl']; + $language['id_shop'] = (int) $language['id_shop']; + } + } +} diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index ae2258ba..be2d4105 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -4,7 +4,6 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository; class ProductsService implements ShopContentServiceInterface @@ -12,8 +11,8 @@ class ProductsService implements ShopContentServiceInterface /** @var ProductRepository */ private $productRepository; - /** @var LanguageRepository */ - private $languageRepository; + /** @var LanguagesService */ + private $languagesService; /** @var CategoriesService */ private $categoriesService; @@ -29,12 +28,12 @@ class ProductsService implements ShopContentServiceInterface public function __construct( ProductRepository $productRepository, - LanguageRepository $languageRepository, + LanguagesService $languagesService, CategoriesService $categoriesService, ArrayFormatter $arrayFormatter ) { $this->productRepository = $productRepository; - $this->languageRepository = $languageRepository; + $this->languagesService = $languagesService; $this->categoriesService = $categoriesService; $this->arrayFormatter = $arrayFormatter; @@ -202,7 +201,7 @@ private function addLink(&$product) null, null, null, - $this->languageRepository->getLanguageIdByIsoCode($product['iso_code']), + $this->languagesService->getLanguageIdByIsoCode($product['iso_code']), $this->shopId, $product['id_attribute'] ); @@ -250,7 +249,7 @@ private function addCategoryTree(&$product) { $categoryPaths = $this->categoriesService->getCategoryPaths( $product['id_category_default'], - $this->languageRepository->getLanguageIdByIsoCode($product['iso_code']), + $this->languagesService->getLanguageIdByIsoCode($product['iso_code']), $this->shopId ); diff --git a/src/Service/ShopContent/ShopDetailsService.php b/src/Service/ShopContent/ShopDetailsService.php index 6cfa8d09..42feca1b 100644 --- a/src/Service/ShopContent/ShopDetailsService.php +++ b/src/Service/ShopContent/ShopDetailsService.php @@ -4,7 +4,6 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; -use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\ShopRepository; class ShopDetailsService implements ShopContentServiceInterface @@ -12,8 +11,8 @@ class ShopDetailsService implements ShopContentServiceInterface /** @var CurrenciesService */ private $currenciesService; - /** @var LanguageRepository */ - private $languageRepository; + /** @var LanguagesService */ + private $languagesService; /** @var ConfigurationRepository */ private $configurationRepository; @@ -26,22 +25,22 @@ class ShopDetailsService implements ShopContentServiceInterface /** * @param \Context $context - * @param LanguageRepository $languageRepository * @param ConfigurationRepository $configurationRepository * @param ShopRepository $shopRepository + * @param LanguagesService $languagesService * @param CurrenciesService $currenciesService * * @return void */ public function __construct( \Context $context, - LanguageRepository $languageRepository, ConfigurationRepository $configurationRepository, ShopRepository $shopRepository, + LanguagesService $languagesService, CurrenciesService $currenciesService ) { $this->currenciesService = $currenciesService; - $this->languageRepository = $languageRepository; + $this->languagesService = $languagesService; $this->configurationRepository = $configurationRepository; $this->shopRepository = $shopRepository; $this->context = $context; @@ -82,8 +81,8 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) 'cms_version' => _PS_VERSION_, 'url_is_simplified' => $this->configurationRepository->get('PS_REWRITING_SETTINGS') == '1', 'cart_is_persistent' => $this->configurationRepository->get('PS_CART_FOLLOWING') == '1', - 'default_language' => $this->languageRepository->getDefaultLanguageIsoCode(), - 'languages' => implode(';', $this->languageRepository->getLanguagesIsoCodes()), + 'default_language' => $this->languagesService->getDefaultLanguageIsoCode(), + 'languages' => implode(';', $this->languagesService->getLanguagesIsoCodes()), 'default_currency' => $this->currenciesService->getDefaultCurrencyIsoCode(), 'currencies' => implode(';', $this->currenciesService->getCurrenciesIsoCodes()), 'weight_unit' => $this->configurationRepository->get('PS_WEIGHT_UNIT'), diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 2c9724f5..fef54594 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -7,8 +7,8 @@ use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; -use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; use PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository; +use PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService; use PrestaShop\Module\PsEventbus\Service\ShopContent\ShopContentServiceInterface; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; @@ -30,9 +30,9 @@ class SynchronizationService private $liveSyncRepository; /** - * @var LanguageRepository + * @var LanguagesService */ - private $languageRepository; + private $languagesService; /** * @var PayloadDecorator @@ -48,14 +48,14 @@ public function __construct( EventbusSyncRepository $eventbusSyncRepository, IncrementalSyncRepository $incrementalSyncRepository, LiveSyncRepository $liveSyncRepository, - LanguageRepository $languageRepository, + LanguagesService $languagesService, ProxyServiceInterface $proxyService, PayloadDecorator $payloadDecorator ) { $this->eventbusSyncRepository = $eventbusSyncRepository; $this->incrementalSyncRepository = $incrementalSyncRepository; $this->liveSyncRepository = $liveSyncRepository; - $this->languageRepository = $languageRepository; + $this->languagesService = $languagesService; $this->proxyService = $proxyService; $this->payloadDecorator = $payloadDecorator; } @@ -242,7 +242,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, 0, $createdAt, false, - $this->languageRepository->getDefaultLanguageIsoCode() + $this->languagesService->getDefaultLanguageIsoCode() ); } } @@ -254,7 +254,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $contentToInsert = []; if ($hasMultiLang) { - $allIsoCodes = $this->languageRepository->getLanguagesIsoCodes(); + $allIsoCodes = $this->languagesService->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { foreach ($contentTypesWithIds as $contentType => $contentId) { @@ -273,7 +273,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } } } else { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + $defaultIsoCode = $this->languagesService->getDefaultLanguageIsoCode(); foreach ($contentTypesWithIds as $contentType => $contentId) { if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { From 3603539abcadad89478dcdc3ba15e3816e973b68 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 26 Sep 2024 18:23:56 +0200 Subject: [PATCH 089/162] fix: add header stamps --- Makefile | 5 ++++ OLD/Provider/CustomPriceDataProvider.php | 18 ++++++++++++ OLD/Provider/GoogleTaxonomyDataProvider.php | 18 ++++++++++++ OLD/Provider/ManufacturerDataProvider.php | 18 ++++++++++++ .../PaginatedApiDataProviderInterface.php | 18 ++++++++++++ OLD/Provider/StockDataProvider.php | 18 ++++++++++++ OLD/Provider/StoreDataProvider.php | 18 ++++++++++++ OLD/Provider/SupplierDataProvider.php | 18 ++++++++++++ OLD/Provider/TranslationDataProvider.php | 18 ++++++++++++ OLD/Provider/WishlistDataProvider.php | 18 ++++++++++++ controllers/front/apiFront.php | 18 ++++++++++++ ps_eventbus.php | 28 ++++++++----------- src/Api/CollectorApiClient.php | 18 ++++++++++++ src/Api/LiveSyncApiClient.php | 18 ++++++++++++ src/Api/Post/MultipartBody.php | 18 ++++++++++++ src/Api/Post/PostFileApi.php | 18 ++++++++++++ src/Api/Post/PostFileInterface.php | 18 ++++++++++++ src/Api/Post/Stream.php | 18 ++++++++++++ src/Api/SyncApiClient.php | 18 ++++++++++++ src/Config/Config.php | 18 ++++++++++++ src/Decorator/CustomPriceDecorator.php | 18 ++++++++++++ src/Decorator/ManufacturerDecorator.php | 18 ++++++++++++ src/Decorator/PayloadDecorator.php | 18 ++++++++++++ src/Decorator/StockDecorator.php | 18 ++++++++++++ src/Decorator/StoreDecorator.php | 18 ++++++++++++ src/Decorator/SupplierDecorator.php | 18 ++++++++++++ src/Decorator/TranslationDecorator.php | 18 ++++++++++++ src/Exception/ApiException.php | 14 +++++----- src/Exception/EnvVarException.php | 14 +++++----- src/Exception/FirebaseException.php | 14 +++++----- src/Exception/HmacException.php | 14 +++++----- .../PsAccountsRsaSignDataEmptyException.php | 14 +++++----- src/Exception/QueryParamsException.php | 14 +++++----- src/Exception/UnauthorizedException.php | 18 ++++++++++++ src/Exception/WebhookException.php | 14 +++++----- src/Factory/ContextFactory.php | 18 ++++++++++++ src/Formatter/ArrayFormatter.php | 18 ++++++++++++ src/Formatter/JsonFormatter.php | 18 ++++++++++++ .../ErrorHandler/ErrorHandlerInterface.php | 18 ++++++++++++ src/Helper/CarrierHelper.php | 18 ++++++++++++ src/Helper/ModuleHelper.php | 18 ++++++++++++ src/Module/Install.php | 14 +++++----- src/Module/Uninstall.php | 14 +++++----- src/Repository/ConfigurationRepository.php | 18 ++++++++++++ src/Repository/CountryRepository.php | 18 ++++++++++++ src/Repository/CustomPriceRepository.php | 18 ++++++++++++ src/Repository/EventbusSyncRepository.php | 18 ++++++++++++ src/Repository/GoogleTaxonomyRepository.php | 18 ++++++++++++ src/Repository/IncrementalSyncRepository.php | 18 ++++++++++++ src/Repository/LiveSyncRepository.php | 18 ++++++++++++ src/Repository/ManufacturerRepository.php | 18 ++++++++++++ .../NewRepository/AbstractRepository.php | 18 ++++++++++++ .../NewRepository/CarrierRepository.php | 18 ++++++++++++ .../NewRepository/CartProductRepository.php | 18 ++++++++++++ .../NewRepository/CartRepository.php | 18 ++++++++++++ .../NewRepository/CartRuleRepository.php | 18 ++++++++++++ .../NewRepository/CategoryRepository.php | 18 ++++++++++++ .../NewRepository/CurrencyRepository.php | 18 ++++++++++++ .../NewRepository/CustomerRepository.php | 18 ++++++++++++ .../NewRepository/EmployeeRepository.php | 18 ++++++++++++ .../NewRepository/ImageRepository.php | 18 ++++++++++++ .../NewRepository/ImageTypeRepository.php | 18 ++++++++++++ .../NewRepository/LanguageRepository.php | 18 ++++++++++++ .../NewRepository/ModuleRepository.php | 18 ++++++++++++ .../NewRepository/OrderCartRuleRepository.php | 18 ++++++++++++ .../NewRepository/OrderDetailRepository.php | 18 ++++++++++++ .../NewRepository/OrderHistoryRepository.php | 18 ++++++++++++ .../NewRepository/OrderRepository.php | 18 ++++++++++++ .../NewRepository/ProductBundleRepository.php | 18 ++++++++++++ .../ProductCarrierRepository.php | 18 ++++++++++++ .../NewRepository/ProductRepository.php | 18 ++++++++++++ .../ProductSupplierRepository.php | 18 ++++++++++++ .../NewRepository/RepositoryInterface.php | 18 ++++++++++++ .../WishlistProductRepository.php | 18 ++++++++++++ .../NewRepository/WishlistRepository.php | 18 ++++++++++++ src/Repository/ShopRepository.php | 18 ++++++++++++ src/Repository/SpecificPriceRepository.php | 18 ++++++++++++ src/Repository/StateRepository.php | 18 ++++++++++++ src/Repository/StockMvtRepository.php | 18 ++++++++++++ src/Repository/StockRepository.php | 18 ++++++++++++ src/Repository/StoreRepository.php | 18 ++++++++++++ src/Repository/SupplierRepository.php | 18 ++++++++++++ src/Repository/TaxeRepository.php | 18 ++++++++++++ src/Repository/TranslationRepository.php | 18 ++++++++++++ src/Service/ApiAuthorizationService.php | 18 ++++++++++++ src/Service/CommonService.php | 18 ++++++++++++ src/Service/FrontApiService.php | 18 ++++++++++++ src/Service/HealthCheckService.php | 18 ++++++++++++ src/Service/PresenterService.php | 18 ++++++++++++ src/Service/ProxyService.php | 18 ++++++++++++ src/Service/ProxyServiceInterface.php | 18 ++++++++++++ src/Service/PsAccountsAdapterService.php | 18 ++++++++++++ .../ShopContent/CarrierDetailsService.php | 18 ++++++++++++ .../ShopContent/CarrierTaxesService.php | 18 ++++++++++++ src/Service/ShopContent/CarriersService.php | 18 ++++++++++++ .../ShopContent/CartProductsService.php | 18 ++++++++++++ src/Service/ShopContent/CartRulesService.php | 18 ++++++++++++ src/Service/ShopContent/CartsService.php | 18 ++++++++++++ src/Service/ShopContent/CategoriesService.php | 18 ++++++++++++ src/Service/ShopContent/CurrenciesService.php | 18 ++++++++++++ src/Service/ShopContent/CustomersService.php | 18 ++++++++++++ src/Service/ShopContent/EmployeesService.php | 18 ++++++++++++ src/Service/ShopContent/ImageTypesService.php | 18 ++++++++++++ src/Service/ShopContent/ImagesService.php | 18 ++++++++++++ src/Service/ShopContent/LanguagesService.php | 18 ++++++++++++ src/Service/ShopContent/ModulesService.php | 18 ++++++++++++ .../ShopContent/OrderCartRulesService.php | 18 ++++++++++++ .../ShopContent/OrderDetailsService.php | 18 ++++++++++++ .../ShopContent/OrderHistoriesService.php | 18 ++++++++++++ src/Service/ShopContent/OrdersService.php | 18 ++++++++++++ .../ShopContent/ProductBundlesService.php | 18 ++++++++++++ .../ShopContent/ProductCarriersService.php | 18 ++++++++++++ .../ShopContent/ProductSuppliersService.php | 18 ++++++++++++ src/Service/ShopContent/ProductsService.php | 18 ++++++++++++ .../ShopContentServiceInterface.php | 18 ++++++++++++ .../ShopContent/ShopDetailsService.php | 18 ++++++++++++ src/Service/ShopContent/ThemesService.php | 18 ++++++++++++ .../ShopContent/WishlistProductsService.php | 18 ++++++++++++ src/Service/ShopContent/WishlistsService.php | 18 ++++++++++++ src/Service/SpecificPriceService.php | 18 ++++++++++++ src/Service/SynchronizationService.php | 18 ++++++++++++ src/Traits/UseHooks.php | 18 ++++++++++++ translations/en.php | 19 +++++++++++++ translations/es.php | 19 +++++++++++++ translations/fr.php | 19 +++++++++++++ translations/it.php | 19 +++++++++++++ upgrade/Upgrade-1.7.2.php | 18 ++++++++++++ upgrade/Upgrade-3.0.13.php | 18 ++++++++++++ 128 files changed, 2189 insertions(+), 80 deletions(-) diff --git a/Makefile b/Makefile index eb937fa7..bae8e55c 100644 --- a/Makefile +++ b/Makefile @@ -154,6 +154,11 @@ phpstan: tools/vendor prestashop/prestashop-${PS_VERSION} docker-phpstan: tools/vendor @$(call in_docker,/usr/bin/phpstan,analyse --memory-limit=-1 --configuration=./tests/phpstan/phpstan-docker.neon) +# target: header-stamp - check Headers of PHP files +.PHONY:header-stamp +header-stamp: + tools/vendor/bin/header-stamp --license=tools/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,tools,e2e,e2e-env,tests,composer.json,scoper.inc.php + define COMMENT Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this. Currently failing to resolve devDeps: diff --git a/OLD/Provider/CustomPriceDataProvider.php b/OLD/Provider/CustomPriceDataProvider.php index e7f330ab..b04c6100 100644 --- a/OLD/Provider/CustomPriceDataProvider.php +++ b/OLD/Provider/CustomPriceDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/GoogleTaxonomyDataProvider.php b/OLD/Provider/GoogleTaxonomyDataProvider.php index 0cc59dcd..bf1a3c39 100644 --- a/OLD/Provider/GoogleTaxonomyDataProvider.php +++ b/OLD/Provider/GoogleTaxonomyDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/ManufacturerDataProvider.php b/OLD/Provider/ManufacturerDataProvider.php index f6add459..097c8646 100644 --- a/OLD/Provider/ManufacturerDataProvider.php +++ b/OLD/Provider/ManufacturerDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/PaginatedApiDataProviderInterface.php b/OLD/Provider/PaginatedApiDataProviderInterface.php index 646ea950..d16b5558 100644 --- a/OLD/Provider/PaginatedApiDataProviderInterface.php +++ b/OLD/Provider/PaginatedApiDataProviderInterface.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/StockDataProvider.php b/OLD/Provider/StockDataProvider.php index 1f17b456..2756d7ff 100644 --- a/OLD/Provider/StockDataProvider.php +++ b/OLD/Provider/StockDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/StoreDataProvider.php b/OLD/Provider/StoreDataProvider.php index 7b4226fa..a50346d5 100644 --- a/OLD/Provider/StoreDataProvider.php +++ b/OLD/Provider/StoreDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/SupplierDataProvider.php b/OLD/Provider/SupplierDataProvider.php index 2b044996..a94fcd56 100644 --- a/OLD/Provider/SupplierDataProvider.php +++ b/OLD/Provider/SupplierDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/TranslationDataProvider.php b/OLD/Provider/TranslationDataProvider.php index 2494e557..d695ae3a 100644 --- a/OLD/Provider/TranslationDataProvider.php +++ b/OLD/Provider/TranslationDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/WishlistDataProvider.php b/OLD/Provider/WishlistDataProvider.php index 28306fc2..2a81a4e5 100644 --- a/OLD/Provider/WishlistDataProvider.php +++ b/OLD/Provider/WishlistDataProvider.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 16aa24e5..03e368ee 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ use PrestaShop\Module\PsEventbus\Service\FrontApiService; diff --git a/ps_eventbus.php b/ps_eventbus.php index 610ecdde..46ec0a01 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -1,27 +1,21 @@ - * @copyright 2007-2023 PrestaShop SA and Contributors - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; diff --git a/src/Api/CollectorApiClient.php b/src/Api/CollectorApiClient.php index 7d818e7e..8dfb849f 100644 --- a/src/Api/CollectorApiClient.php +++ b/src/Api/CollectorApiClient.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Api; diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index 2e89027d..fb207510 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Api; diff --git a/src/Api/Post/MultipartBody.php b/src/Api/Post/MultipartBody.php index 898dd0e0..b7c0e272 100755 --- a/src/Api/Post/MultipartBody.php +++ b/src/Api/Post/MultipartBody.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/PostFileApi.php b/src/Api/Post/PostFileApi.php index bb9f4a84..fdcde617 100644 --- a/src/Api/Post/PostFileApi.php +++ b/src/Api/Post/PostFileApi.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/PostFileInterface.php b/src/Api/Post/PostFileInterface.php index 8d90bb5c..6352523f 100755 --- a/src/Api/Post/PostFileInterface.php +++ b/src/Api/Post/PostFileInterface.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/Stream.php b/src/Api/Post/Stream.php index aae58bfd..c6f49466 100644 --- a/src/Api/Post/Stream.php +++ b/src/Api/Post/Stream.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/SyncApiClient.php b/src/Api/SyncApiClient.php index 75536d97..4a66ad85 100644 --- a/src/Api/SyncApiClient.php +++ b/src/Api/SyncApiClient.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Api; diff --git a/src/Config/Config.php b/src/Config/Config.php index f4c7f5db..c7854cfd 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Config; diff --git a/src/Decorator/CustomPriceDecorator.php b/src/Decorator/CustomPriceDecorator.php index 0f91454a..d5d34451 100644 --- a/src/Decorator/CustomPriceDecorator.php +++ b/src/Decorator/CustomPriceDecorator.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Decorator; diff --git a/src/Decorator/ManufacturerDecorator.php b/src/Decorator/ManufacturerDecorator.php index 878dee70..d1d9305c 100644 --- a/src/Decorator/ManufacturerDecorator.php +++ b/src/Decorator/ManufacturerDecorator.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Decorator; diff --git a/src/Decorator/PayloadDecorator.php b/src/Decorator/PayloadDecorator.php index c67f5135..ccaaf63f 100644 --- a/src/Decorator/PayloadDecorator.php +++ b/src/Decorator/PayloadDecorator.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Decorator; diff --git a/src/Decorator/StockDecorator.php b/src/Decorator/StockDecorator.php index 4666cfa5..dc51de8f 100644 --- a/src/Decorator/StockDecorator.php +++ b/src/Decorator/StockDecorator.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Decorator; diff --git a/src/Decorator/StoreDecorator.php b/src/Decorator/StoreDecorator.php index 7a41da0a..3001a55e 100644 --- a/src/Decorator/StoreDecorator.php +++ b/src/Decorator/StoreDecorator.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Decorator; diff --git a/src/Decorator/SupplierDecorator.php b/src/Decorator/SupplierDecorator.php index fc0e87c7..513e999e 100644 --- a/src/Decorator/SupplierDecorator.php +++ b/src/Decorator/SupplierDecorator.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Decorator; diff --git a/src/Decorator/TranslationDecorator.php b/src/Decorator/TranslationDecorator.php index 7fbbd5e5..b6bca74f 100644 --- a/src/Decorator/TranslationDecorator.php +++ b/src/Decorator/TranslationDecorator.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Decorator; diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index 1ce8b3cd..6f3989be 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/EnvVarException.php b/src/Exception/EnvVarException.php index dcc5300d..141d2e1b 100644 --- a/src/Exception/EnvVarException.php +++ b/src/Exception/EnvVarException.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/FirebaseException.php b/src/Exception/FirebaseException.php index 689a296e..4827c671 100644 --- a/src/Exception/FirebaseException.php +++ b/src/Exception/FirebaseException.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/HmacException.php b/src/Exception/HmacException.php index 3792a400..3549a8fc 100644 --- a/src/Exception/HmacException.php +++ b/src/Exception/HmacException.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/PsAccountsRsaSignDataEmptyException.php b/src/Exception/PsAccountsRsaSignDataEmptyException.php index d7df4349..cee6afd0 100644 --- a/src/Exception/PsAccountsRsaSignDataEmptyException.php +++ b/src/Exception/PsAccountsRsaSignDataEmptyException.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/QueryParamsException.php b/src/Exception/QueryParamsException.php index 6602b9a1..3a11df9b 100644 --- a/src/Exception/QueryParamsException.php +++ b/src/Exception/QueryParamsException.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/UnauthorizedException.php b/src/Exception/UnauthorizedException.php index 151954d1..3b056acd 100644 --- a/src/Exception/UnauthorizedException.php +++ b/src/Exception/UnauthorizedException.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/WebhookException.php b/src/Exception/WebhookException.php index b3f25884..104f3856 100644 --- a/src/Exception/WebhookException.php +++ b/src/Exception/WebhookException.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Factory/ContextFactory.php b/src/Factory/ContextFactory.php index 013ace1a..00ad0a7c 100644 --- a/src/Factory/ContextFactory.php +++ b/src/Factory/ContextFactory.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Factory; diff --git a/src/Formatter/ArrayFormatter.php b/src/Formatter/ArrayFormatter.php index 248958de..498eabbd 100644 --- a/src/Formatter/ArrayFormatter.php +++ b/src/Formatter/ArrayFormatter.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Formatter; diff --git a/src/Formatter/JsonFormatter.php b/src/Formatter/JsonFormatter.php index 39fe4c85..41c88e4e 100644 --- a/src/Formatter/JsonFormatter.php +++ b/src/Formatter/JsonFormatter.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Formatter; diff --git a/src/Handler/ErrorHandler/ErrorHandlerInterface.php b/src/Handler/ErrorHandler/ErrorHandlerInterface.php index 1ce0b05f..3d7b933b 100644 --- a/src/Handler/ErrorHandler/ErrorHandlerInterface.php +++ b/src/Handler/ErrorHandler/ErrorHandlerInterface.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; diff --git a/src/Helper/CarrierHelper.php b/src/Helper/CarrierHelper.php index 74042afa..155dee21 100644 --- a/src/Helper/CarrierHelper.php +++ b/src/Helper/CarrierHelper.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Helper; diff --git a/src/Helper/ModuleHelper.php b/src/Helper/ModuleHelper.php index 800e20a4..8b31b36f 100644 --- a/src/Helper/ModuleHelper.php +++ b/src/Helper/ModuleHelper.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Helper; diff --git a/src/Module/Install.php b/src/Module/Install.php index b6360ff2..b1dbc0b4 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Module; diff --git a/src/Module/Uninstall.php b/src/Module/Uninstall.php index 023ff290..b79b6527 100644 --- a/src/Module/Uninstall.php +++ b/src/Module/Uninstall.php @@ -1,21 +1,21 @@ - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA + * @author PrestaShop SA and Contributors + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsEventbus\Module; diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index a2086802..395dec00 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index 1c34582d..413cbfe1 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CustomPriceRepository.php b/src/Repository/CustomPriceRepository.php index fc2eec9b..dec75474 100644 --- a/src/Repository/CustomPriceRepository.php +++ b/src/Repository/CustomPriceRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/EventbusSyncRepository.php b/src/Repository/EventbusSyncRepository.php index e262b8c5..127c6920 100644 --- a/src/Repository/EventbusSyncRepository.php +++ b/src/Repository/EventbusSyncRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/GoogleTaxonomyRepository.php b/src/Repository/GoogleTaxonomyRepository.php index 8f32ad48..c5d75a61 100644 --- a/src/Repository/GoogleTaxonomyRepository.php +++ b/src/Repository/GoogleTaxonomyRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 93bc5f2d..4d2076d4 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/LiveSyncRepository.php b/src/Repository/LiveSyncRepository.php index 808cfd9d..ff735808 100644 --- a/src/Repository/LiveSyncRepository.php +++ b/src/Repository/LiveSyncRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 9a9ed0e2..25926a3a 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/NewRepository/AbstractRepository.php b/src/Repository/NewRepository/AbstractRepository.php index 9502038f..2fba1a7d 100644 --- a/src/Repository/NewRepository/AbstractRepository.php +++ b/src/Repository/NewRepository/AbstractRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index ab68ef85..e80b9e94 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CartProductRepository.php b/src/Repository/NewRepository/CartProductRepository.php index 203e9a29..304e655c 100644 --- a/src/Repository/NewRepository/CartProductRepository.php +++ b/src/Repository/NewRepository/CartProductRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CartRepository.php b/src/Repository/NewRepository/CartRepository.php index c364c91a..e53c7273 100644 --- a/src/Repository/NewRepository/CartRepository.php +++ b/src/Repository/NewRepository/CartRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CartRuleRepository.php b/src/Repository/NewRepository/CartRuleRepository.php index 76f0208b..614a6193 100644 --- a/src/Repository/NewRepository/CartRuleRepository.php +++ b/src/Repository/NewRepository/CartRuleRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CategoryRepository.php b/src/Repository/NewRepository/CategoryRepository.php index 7cfe2d16..464e04ee 100644 --- a/src/Repository/NewRepository/CategoryRepository.php +++ b/src/Repository/NewRepository/CategoryRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CurrencyRepository.php b/src/Repository/NewRepository/CurrencyRepository.php index 0e20ace7..4ff56349 100644 --- a/src/Repository/NewRepository/CurrencyRepository.php +++ b/src/Repository/NewRepository/CurrencyRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CustomerRepository.php b/src/Repository/NewRepository/CustomerRepository.php index 604334cd..81b289d9 100644 --- a/src/Repository/NewRepository/CustomerRepository.php +++ b/src/Repository/NewRepository/CustomerRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/EmployeeRepository.php b/src/Repository/NewRepository/EmployeeRepository.php index 1bb9616d..2385c149 100644 --- a/src/Repository/NewRepository/EmployeeRepository.php +++ b/src/Repository/NewRepository/EmployeeRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/ImageRepository.php b/src/Repository/NewRepository/ImageRepository.php index 863688ef..3973f24d 100644 --- a/src/Repository/NewRepository/ImageRepository.php +++ b/src/Repository/NewRepository/ImageRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/ImageTypeRepository.php b/src/Repository/NewRepository/ImageTypeRepository.php index 1ebfc258..5a20a359 100644 --- a/src/Repository/NewRepository/ImageTypeRepository.php +++ b/src/Repository/NewRepository/ImageTypeRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/LanguageRepository.php b/src/Repository/NewRepository/LanguageRepository.php index f3e4382b..f9a88189 100644 --- a/src/Repository/NewRepository/LanguageRepository.php +++ b/src/Repository/NewRepository/LanguageRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/ModuleRepository.php b/src/Repository/NewRepository/ModuleRepository.php index e16d6451..1519142b 100644 --- a/src/Repository/NewRepository/ModuleRepository.php +++ b/src/Repository/NewRepository/ModuleRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/NewRepository/OrderCartRuleRepository.php index c51a81de..0d713245 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/NewRepository/OrderCartRuleRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php index 09a35694..ae5794a4 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php index ae753929..d0c05625 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php index c0967bc7..01ec31b4 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/ProductBundleRepository.php b/src/Repository/NewRepository/ProductBundleRepository.php index 413ffbbf..aef47646 100644 --- a/src/Repository/NewRepository/ProductBundleRepository.php +++ b/src/Repository/NewRepository/ProductBundleRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/ProductCarrierRepository.php b/src/Repository/NewRepository/ProductCarrierRepository.php index 9e4960e8..cd1d3ca1 100644 --- a/src/Repository/NewRepository/ProductCarrierRepository.php +++ b/src/Repository/NewRepository/ProductCarrierRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/NewRepository/ProductRepository.php index 9f4476c1..f8f97cc2 100644 --- a/src/Repository/NewRepository/ProductRepository.php +++ b/src/Repository/NewRepository/ProductRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/ProductSupplierRepository.php b/src/Repository/NewRepository/ProductSupplierRepository.php index f22f114c..fc86784a 100644 --- a/src/Repository/NewRepository/ProductSupplierRepository.php +++ b/src/Repository/NewRepository/ProductSupplierRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php index f0c0061f..f01a6f69 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/WishlistProductRepository.php b/src/Repository/NewRepository/WishlistProductRepository.php index 5369e223..8003cec1 100644 --- a/src/Repository/NewRepository/WishlistProductRepository.php +++ b/src/Repository/NewRepository/WishlistProductRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/WishlistRepository.php b/src/Repository/NewRepository/WishlistRepository.php index 7c673e8d..72ab85c9 100644 --- a/src/Repository/NewRepository/WishlistRepository.php +++ b/src/Repository/NewRepository/WishlistRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/ShopRepository.php b/src/Repository/ShopRepository.php index 1e523f5c..bbe7da4a 100644 --- a/src/Repository/ShopRepository.php +++ b/src/Repository/ShopRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index 27e16717..fb8e499c 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index 372cc239..6eee0ae2 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StockMvtRepository.php b/src/Repository/StockMvtRepository.php index 6c3141f5..c54ff56f 100644 --- a/src/Repository/StockMvtRepository.php +++ b/src/Repository/StockMvtRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index 93b1e534..51c4f8e4 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index d6b6807f..2e47af7a 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index 269f6279..5c7587d0 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php index 5bcf0e90..b0101e6c 100644 --- a/src/Repository/TaxeRepository.php +++ b/src/Repository/TaxeRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 2043247b..74346ffc 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index 28243a37..641be893 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 5047a341..4bf43098 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 8e20c116..44d7d19e 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 8a4bfe6d..49cce189 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/PresenterService.php b/src/Service/PresenterService.php index 3c8f5bcb..8d1d4b2b 100644 --- a/src/Service/PresenterService.php +++ b/src/Service/PresenterService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index e804aa50..440aebe2 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/ProxyServiceInterface.php b/src/Service/ProxyServiceInterface.php index bcf1bc95..ed5f987c 100644 --- a/src/Service/ProxyServiceInterface.php +++ b/src/Service/ProxyServiceInterface.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/PsAccountsAdapterService.php b/src/Service/PsAccountsAdapterService.php index d928c747..e5e662a9 100644 --- a/src/Service/PsAccountsAdapterService.php +++ b/src/Service/PsAccountsAdapterService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index f0d808fe..7cd22315 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 455e9826..75f03fa0 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index e9a69a25..56702b28 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index 5740e404..f3d6a34a 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index 8acb0fcb..4f1ad315 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 742c369a..71cfb451 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index 27e6b229..0b964d0b 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index 1b2ff191..a0d8944a 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index c703fa53..78ebce85 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index 50e67742..22770412 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index ddfb1224..2f860579 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index 619a80a0..0c349f84 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index 8735158e..38bd0a34 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 64ff38ba..c61d732a 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index d9b7d5da..3da03ae4 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index 2ffee9e0..c0f6b1f1 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index e020ddf5..611c6f79 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index a1eb4038..883ef019 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index 2983a012..3665782d 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/ProductCarriersService.php index da3742a7..f858cfcc 100644 --- a/src/Service/ShopContent/ProductCarriersService.php +++ b/src/Service/ShopContent/ProductCarriersService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index b7447b86..6c7ff75a 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index be2d4105..79320be2 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index 193c3f1e..ee732237 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ShopDetailsService.php b/src/Service/ShopContent/ShopDetailsService.php index 42feca1b..afba7848 100644 --- a/src/Service/ShopContent/ShopDetailsService.php +++ b/src/Service/ShopContent/ShopDetailsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php index 3ec42ee8..6a7427a4 100644 --- a/src/Service/ShopContent/ThemesService.php +++ b/src/Service/ShopContent/ThemesService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index e2b47cdc..49d45ae3 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index 3d1b8f57..d903a200 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/SpecificPriceService.php b/src/Service/SpecificPriceService.php index bf029e80..03939dda 100644 --- a/src/Service/SpecificPriceService.php +++ b/src/Service/SpecificPriceService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index fef54594..9050d145 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index db0d0572..cb051eae 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsEventbus\Traits; diff --git a/translations/en.php b/translations/en.php index 3f27b6db..59bebffa 100644 --- a/translations/en.php +++ b/translations/en.php @@ -1,4 +1,23 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/es.php b/translations/es.php index 314ad396..099f790e 100644 --- a/translations/es.php +++ b/translations/es.php @@ -1,4 +1,23 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/fr.php b/translations/fr.php index 8126e1f5..3b321736 100644 --- a/translations/fr.php +++ b/translations/fr.php @@ -1,4 +1,23 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/it.php b/translations/it.php index 91fd9fc0..b72aa739 100644 --- a/translations/it.php +++ b/translations/it.php @@ -1,4 +1,23 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/upgrade/Upgrade-1.7.2.php b/upgrade/Upgrade-1.7.2.php index 804405cb..2366b8d4 100644 --- a/upgrade/Upgrade-1.7.2.php +++ b/upgrade/Upgrade-1.7.2.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/upgrade/Upgrade-3.0.13.php b/upgrade/Upgrade-3.0.13.php index 339c0cd4..b4b6b189 100644 --- a/upgrade/Upgrade-3.0.13.php +++ b/upgrade/Upgrade-3.0.13.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ use PrestaShop\Module\PsEventbus\Config\Config; From c88470fb812fed8e7ac261f2d5ebec1971be5212 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 26 Sep 2024 18:27:42 +0200 Subject: [PATCH 090/162] fix: add check for define version --- OLD/Provider/CustomPriceDataProvider.php | 4 ++++ OLD/Provider/GoogleTaxonomyDataProvider.php | 4 ++++ OLD/Provider/ManufacturerDataProvider.php | 4 ++++ .../PaginatedApiDataProviderInterface.php | 4 ++++ OLD/Provider/StockDataProvider.php | 4 ++++ OLD/Provider/StoreDataProvider.php | 4 ++++ OLD/Provider/SupplierDataProvider.php | 4 ++++ OLD/Provider/TranslationDataProvider.php | 4 ++++ OLD/Provider/WishlistDataProvider.php | 4 ++++ controllers/front/apiFront.php | 4 ++++ ps_eventbus.php | 7 ++++--- src/Api/CollectorApiClient.php | 4 ++++ src/Api/LiveSyncApiClient.php | 4 ++++ src/Api/Post/MultipartBody.php | 4 ++++ src/Api/Post/PostFileApi.php | 4 ++++ src/Api/Post/PostFileInterface.php | 4 ++++ src/Api/Post/Stream.php | 4 ++++ src/Api/SyncApiClient.php | 4 ++++ src/Config/Config.php | 4 ++++ src/Decorator/CustomPriceDecorator.php | 4 ++++ src/Decorator/ManufacturerDecorator.php | 4 ++++ src/Decorator/PayloadDecorator.php | 4 ++++ src/Decorator/StockDecorator.php | 4 ++++ src/Decorator/StoreDecorator.php | 4 ++++ src/Decorator/SupplierDecorator.php | 4 ++++ src/Decorator/TranslationDecorator.php | 4 ++++ src/DependencyInjection/ContainerProvider.php | 4 ++++ src/DependencyInjection/ServiceContainer.php | 4 ++++ src/Exception/ApiException.php | 4 ++++ src/Exception/EnvVarException.php | 4 ++++ src/Exception/FirebaseException.php | 4 ++++ src/Exception/HmacException.php | 4 ++++ .../PsAccountsRsaSignDataEmptyException.php | 4 ++++ src/Exception/QueryParamsException.php | 4 ++++ src/Exception/UnauthorizedException.php | 4 ++++ src/Exception/WebhookException.php | 4 ++++ src/Factory/ContextFactory.php | 4 ++++ src/Formatter/ArrayFormatter.php | 4 ++++ src/Formatter/JsonFormatter.php | 4 ++++ src/Handler/ErrorHandler/ErrorHandler.php | 4 ++++ .../ErrorHandler/ErrorHandlerInterface.php | 4 ++++ src/Helper/CarrierHelper.php | 4 ++++ src/Helper/ModuleHelper.php | 4 ++++ src/Module/Install.php | 4 ++++ src/Module/Uninstall.php | 4 ++++ src/Repository/ConfigurationRepository.php | 4 ++++ src/Repository/CountryRepository.php | 4 ++++ src/Repository/CustomPriceRepository.php | 4 ++++ src/Repository/EventbusSyncRepository.php | 4 ++++ src/Repository/GoogleTaxonomyRepository.php | 4 ++++ src/Repository/IncrementalSyncRepository.php | 4 ++++ src/Repository/LiveSyncRepository.php | 4 ++++ src/Repository/ManufacturerRepository.php | 4 ++++ .../NewRepository/AbstractRepository.php | 4 ++++ .../NewRepository/CarrierRepository.php | 4 ++++ .../NewRepository/CartProductRepository.php | 4 ++++ .../NewRepository/CartRepository.php | 4 ++++ .../NewRepository/CartRuleRepository.php | 4 ++++ .../NewRepository/CategoryRepository.php | 4 ++++ .../NewRepository/CurrencyRepository.php | 4 ++++ .../NewRepository/CustomerRepository.php | 4 ++++ .../NewRepository/EmployeeRepository.php | 4 ++++ .../NewRepository/ImageRepository.php | 4 ++++ .../NewRepository/ImageTypeRepository.php | 4 ++++ .../NewRepository/LanguageRepository.php | 4 ++++ .../NewRepository/ModuleRepository.php | 4 ++++ .../NewRepository/OrderCartRuleRepository.php | 4 ++++ .../NewRepository/OrderDetailRepository.php | 4 ++++ .../NewRepository/OrderHistoryRepository.php | 4 ++++ .../NewRepository/OrderRepository.php | 4 ++++ .../NewRepository/ProductBundleRepository.php | 4 ++++ .../NewRepository/ProductCarrierRepository.php | 4 ++++ .../NewRepository/ProductRepository.php | 4 ++++ .../ProductSupplierRepository.php | 4 ++++ .../NewRepository/RepositoryInterface.php | 4 ++++ .../WishlistProductRepository.php | 4 ++++ .../NewRepository/WishlistRepository.php | 4 ++++ src/Repository/ShopRepository.php | 4 ++++ src/Repository/SpecificPriceRepository.php | 4 ++++ src/Repository/StateRepository.php | 4 ++++ src/Repository/StockMvtRepository.php | 4 ++++ src/Repository/StockRepository.php | 4 ++++ src/Repository/StoreRepository.php | 4 ++++ src/Repository/SupplierRepository.php | 4 ++++ src/Repository/TaxeRepository.php | 4 ++++ src/Repository/TranslationRepository.php | 4 ++++ src/Service/ApiAuthorizationService.php | 4 ++++ src/Service/CommonService.php | 4 ++++ src/Service/FrontApiService.php | 4 ++++ src/Service/HealthCheckService.php | 4 ++++ src/Service/PresenterService.php | 4 ++++ src/Service/ProxyService.php | 4 ++++ src/Service/ProxyServiceInterface.php | 4 ++++ src/Service/PsAccountsAdapterService.php | 4 ++++ .../ShopContent/CarrierDetailsService.php | 4 ++++ .../ShopContent/CarrierTaxesService.php | 4 ++++ src/Service/ShopContent/CarriersService.php | 4 ++++ .../ShopContent/CartProductsService.php | 4 ++++ src/Service/ShopContent/CartRulesService.php | 4 ++++ src/Service/ShopContent/CartsService.php | 4 ++++ src/Service/ShopContent/CategoriesService.php | 4 ++++ src/Service/ShopContent/CurrenciesService.php | 4 ++++ src/Service/ShopContent/CustomersService.php | 4 ++++ src/Service/ShopContent/EmployeesService.php | 4 ++++ src/Service/ShopContent/ImageTypesService.php | 4 ++++ src/Service/ShopContent/ImagesService.php | 4 ++++ src/Service/ShopContent/LanguagesService.php | 4 ++++ src/Service/ShopContent/ModulesService.php | 4 ++++ .../ShopContent/OrderCartRulesService.php | 4 ++++ .../ShopContent/OrderDetailsService.php | 4 ++++ .../ShopContent/OrderHistoriesService.php | 4 ++++ src/Service/ShopContent/OrdersService.php | 4 ++++ .../ShopContent/ProductBundlesService.php | 4 ++++ .../ShopContent/ProductCarriersService.php | 4 ++++ .../ShopContent/ProductSuppliersService.php | 4 ++++ src/Service/ShopContent/ProductsService.php | 4 ++++ .../ShopContentServiceInterface.php | 4 ++++ src/Service/ShopContent/ShopDetailsService.php | 4 ++++ src/Service/ShopContent/ThemesService.php | 4 ++++ .../ShopContent/WishlistProductsService.php | 4 ++++ src/Service/ShopContent/WishlistsService.php | 4 ++++ src/Service/SpecificPriceService.php | 4 ++++ src/Service/SynchronizationService.php | 4 ++++ src/Traits/UseHooks.php | 4 ++++ translations/en.php | 4 ++++ translations/es.php | 4 ++++ translations/fr.php | 4 ++++ translations/it.php | 4 ++++ upgrade/Upgrade-1.10.0.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.10.3.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.10.7.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.10.8.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.3.7.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.5.1.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.5.2.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.6.9.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.7.1.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.7.11.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.7.15.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.7.2.php | 4 ++++ upgrade/Upgrade-1.8.1.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.9.3.php | 18 ++++++++++++++++++ upgrade/Upgrade-1.9.7.php | 18 ++++++++++++++++++ upgrade/Upgrade-2.1.0.php | 18 ++++++++++++++++++ upgrade/Upgrade-2.3.0.php | 18 ++++++++++++++++++ upgrade/Upgrade-2.3.2.php | 18 ++++++++++++++++++ upgrade/Upgrade-3.0.0.php | 18 ++++++++++++++++++ upgrade/Upgrade-3.0.12.php | 18 ++++++++++++++++++ upgrade/Upgrade-3.0.13.php | 4 ++++ upgrade/Upgrade-3.0.5.php | 18 ++++++++++++++++++ upgrade/Upgrade-4.0.0.php | 18 ++++++++++++++++++ 151 files changed, 898 insertions(+), 3 deletions(-) diff --git a/OLD/Provider/CustomPriceDataProvider.php b/OLD/Provider/CustomPriceDataProvider.php index b04c6100..afd8395e 100644 --- a/OLD/Provider/CustomPriceDataProvider.php +++ b/OLD/Provider/CustomPriceDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/GoogleTaxonomyDataProvider.php b/OLD/Provider/GoogleTaxonomyDataProvider.php index bf1a3c39..125ecf4a 100644 --- a/OLD/Provider/GoogleTaxonomyDataProvider.php +++ b/OLD/Provider/GoogleTaxonomyDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/ManufacturerDataProvider.php b/OLD/Provider/ManufacturerDataProvider.php index 097c8646..1a7ef701 100644 --- a/OLD/Provider/ManufacturerDataProvider.php +++ b/OLD/Provider/ManufacturerDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/PaginatedApiDataProviderInterface.php b/OLD/Provider/PaginatedApiDataProviderInterface.php index d16b5558..dfe1de3b 100644 --- a/OLD/Provider/PaginatedApiDataProviderInterface.php +++ b/OLD/Provider/PaginatedApiDataProviderInterface.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; interface PaginatedApiDataProviderInterface diff --git a/OLD/Provider/StockDataProvider.php b/OLD/Provider/StockDataProvider.php index 2756d7ff..07b49bdc 100644 --- a/OLD/Provider/StockDataProvider.php +++ b/OLD/Provider/StockDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/StoreDataProvider.php b/OLD/Provider/StoreDataProvider.php index a50346d5..a719b64a 100644 --- a/OLD/Provider/StoreDataProvider.php +++ b/OLD/Provider/StoreDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/SupplierDataProvider.php b/OLD/Provider/SupplierDataProvider.php index a94fcd56..0d61be3e 100644 --- a/OLD/Provider/SupplierDataProvider.php +++ b/OLD/Provider/SupplierDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/TranslationDataProvider.php b/OLD/Provider/TranslationDataProvider.php index d695ae3a..0d3e7738 100644 --- a/OLD/Provider/TranslationDataProvider.php +++ b/OLD/Provider/TranslationDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/WishlistDataProvider.php b/OLD/Provider/WishlistDataProvider.php index 2a81a4e5..8e9e07c2 100644 --- a/OLD/Provider/WishlistDataProvider.php +++ b/OLD/Provider/WishlistDataProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 03e368ee..c8d2cd66 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + use PrestaShop\Module\PsEventbus\Service\FrontApiService; class ps_EventbusApiFrontModuleFrontController extends ModuleFrontController diff --git a/ps_eventbus.php b/ps_eventbus.php index 46ec0a01..e62f86a9 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -18,14 +18,15 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; -if (!defined('_PS_VERSION_')) { - exit; -} require_once __DIR__ . '/vendor/autoload.php'; diff --git a/src/Api/CollectorApiClient.php b/src/Api/CollectorApiClient.php index 8dfb849f..33ec2830 100644 --- a/src/Api/CollectorApiClient.php +++ b/src/Api/CollectorApiClient.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Api; use GuzzleHttp\Psr7\Request; diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index fb207510..d8a22767 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Api; use GuzzleHttp\Psr7\Request; diff --git a/src/Api/Post/MultipartBody.php b/src/Api/Post/MultipartBody.php index b7c0e272..4ef74ad7 100755 --- a/src/Api/Post/MultipartBody.php +++ b/src/Api/Post/MultipartBody.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Api\Post; use GuzzleHttp\Psr7\AppendStream; diff --git a/src/Api/Post/PostFileApi.php b/src/Api/Post/PostFileApi.php index fdcde617..9ef53371 100644 --- a/src/Api/Post/PostFileApi.php +++ b/src/Api/Post/PostFileApi.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Api\Post; use Psr\Http\Message\StreamInterface; diff --git a/src/Api/Post/PostFileInterface.php b/src/Api/Post/PostFileInterface.php index 6352523f..b89aac29 100755 --- a/src/Api/Post/PostFileInterface.php +++ b/src/Api/Post/PostFileInterface.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Api\Post; use Psr\Http\Message\StreamInterface; diff --git a/src/Api/Post/Stream.php b/src/Api/Post/Stream.php index c6f49466..210fa9ef 100644 --- a/src/Api/Post/Stream.php +++ b/src/Api/Post/Stream.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Api\Post; use GuzzleHttp\Psr7\PumpStream; diff --git a/src/Api/SyncApiClient.php b/src/Api/SyncApiClient.php index 4a66ad85..9904b5b2 100644 --- a/src/Api/SyncApiClient.php +++ b/src/Api/SyncApiClient.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Api; use GuzzleHttp\Psr7\Request; diff --git a/src/Config/Config.php b/src/Config/Config.php index c7854cfd..ba8268cf 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Config; class Config diff --git a/src/Decorator/CustomPriceDecorator.php b/src/Decorator/CustomPriceDecorator.php index d5d34451..87b6e6bd 100644 --- a/src/Decorator/CustomPriceDecorator.php +++ b/src/Decorator/CustomPriceDecorator.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Decorator; use PrestaShop\Module\PsEventbus\Service\SpecificPriceService; diff --git a/src/Decorator/ManufacturerDecorator.php b/src/Decorator/ManufacturerDecorator.php index d1d9305c..edf3797e 100644 --- a/src/Decorator/ManufacturerDecorator.php +++ b/src/Decorator/ManufacturerDecorator.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Decorator; class ManufacturerDecorator diff --git a/src/Decorator/PayloadDecorator.php b/src/Decorator/PayloadDecorator.php index ccaaf63f..dd5e73d3 100644 --- a/src/Decorator/PayloadDecorator.php +++ b/src/Decorator/PayloadDecorator.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Decorator; use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; diff --git a/src/Decorator/StockDecorator.php b/src/Decorator/StockDecorator.php index dc51de8f..57688e7a 100644 --- a/src/Decorator/StockDecorator.php +++ b/src/Decorator/StockDecorator.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Decorator; class StockDecorator diff --git a/src/Decorator/StoreDecorator.php b/src/Decorator/StoreDecorator.php index 3001a55e..8712609f 100644 --- a/src/Decorator/StoreDecorator.php +++ b/src/Decorator/StoreDecorator.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Decorator; class StoreDecorator diff --git a/src/Decorator/SupplierDecorator.php b/src/Decorator/SupplierDecorator.php index 513e999e..bdad2af7 100644 --- a/src/Decorator/SupplierDecorator.php +++ b/src/Decorator/SupplierDecorator.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Decorator; class SupplierDecorator diff --git a/src/Decorator/TranslationDecorator.php b/src/Decorator/TranslationDecorator.php index b6bca74f..ce2ec693 100644 --- a/src/Decorator/TranslationDecorator.php +++ b/src/Decorator/TranslationDecorator.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Decorator; class TranslationDecorator diff --git a/src/DependencyInjection/ContainerProvider.php b/src/DependencyInjection/ContainerProvider.php index 7f24fb78..9744c04f 100644 --- a/src/DependencyInjection/ContainerProvider.php +++ b/src/DependencyInjection/ContainerProvider.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\DependencyInjection; use PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider; diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php index 40fffb94..01beefb9 100644 --- a/src/DependencyInjection/ServiceContainer.php +++ b/src/DependencyInjection/ServiceContainer.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\DependencyInjection; use PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider; diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index 6f3989be..7dc2137e 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class ApiException extends \Exception diff --git a/src/Exception/EnvVarException.php b/src/Exception/EnvVarException.php index 141d2e1b..9b5ca930 100644 --- a/src/Exception/EnvVarException.php +++ b/src/Exception/EnvVarException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class EnvVarException extends \Exception diff --git a/src/Exception/FirebaseException.php b/src/Exception/FirebaseException.php index 4827c671..f73e3079 100644 --- a/src/Exception/FirebaseException.php +++ b/src/Exception/FirebaseException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class FirebaseException extends \Exception diff --git a/src/Exception/HmacException.php b/src/Exception/HmacException.php index 3549a8fc..32508873 100644 --- a/src/Exception/HmacException.php +++ b/src/Exception/HmacException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class HmacException extends \Exception diff --git a/src/Exception/PsAccountsRsaSignDataEmptyException.php b/src/Exception/PsAccountsRsaSignDataEmptyException.php index cee6afd0..c1b3c544 100644 --- a/src/Exception/PsAccountsRsaSignDataEmptyException.php +++ b/src/Exception/PsAccountsRsaSignDataEmptyException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class PsAccountsRsaSignDataEmptyException extends \Exception diff --git a/src/Exception/QueryParamsException.php b/src/Exception/QueryParamsException.php index 3a11df9b..3f683c4d 100644 --- a/src/Exception/QueryParamsException.php +++ b/src/Exception/QueryParamsException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class QueryParamsException extends \Exception diff --git a/src/Exception/UnauthorizedException.php b/src/Exception/UnauthorizedException.php index 3b056acd..21933b37 100644 --- a/src/Exception/UnauthorizedException.php +++ b/src/Exception/UnauthorizedException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class UnauthorizedException extends \Exception diff --git a/src/Exception/WebhookException.php b/src/Exception/WebhookException.php index 104f3856..3e1d98d2 100644 --- a/src/Exception/WebhookException.php +++ b/src/Exception/WebhookException.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Exception; class WebhookException extends \Exception diff --git a/src/Factory/ContextFactory.php b/src/Factory/ContextFactory.php index 00ad0a7c..b0b58ee4 100644 --- a/src/Factory/ContextFactory.php +++ b/src/Factory/ContextFactory.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Factory; class ContextFactory diff --git a/src/Formatter/ArrayFormatter.php b/src/Formatter/ArrayFormatter.php index 498eabbd..b08fda96 100644 --- a/src/Formatter/ArrayFormatter.php +++ b/src/Formatter/ArrayFormatter.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Formatter; class ArrayFormatter diff --git a/src/Formatter/JsonFormatter.php b/src/Formatter/JsonFormatter.php index 41c88e4e..df7f1269 100644 --- a/src/Formatter/JsonFormatter.php +++ b/src/Formatter/JsonFormatter.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Formatter; class JsonFormatter diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index f6d83e7e..a0887c10 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -19,6 +19,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; use Exception; diff --git a/src/Handler/ErrorHandler/ErrorHandlerInterface.php b/src/Handler/ErrorHandler/ErrorHandlerInterface.php index 3d7b933b..a0d46fd4 100644 --- a/src/Handler/ErrorHandler/ErrorHandlerInterface.php +++ b/src/Handler/ErrorHandler/ErrorHandlerInterface.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; interface ErrorHandlerInterface diff --git a/src/Helper/CarrierHelper.php b/src/Helper/CarrierHelper.php index 155dee21..4e0d6903 100644 --- a/src/Helper/CarrierHelper.php +++ b/src/Helper/CarrierHelper.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Helper; use Carrier; diff --git a/src/Helper/ModuleHelper.php b/src/Helper/ModuleHelper.php index 8b31b36f..94be5805 100644 --- a/src/Helper/ModuleHelper.php +++ b/src/Helper/ModuleHelper.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Helper; use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; diff --git a/src/Module/Install.php b/src/Module/Install.php index b1dbc0b4..fd41ade3 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Module; class Install diff --git a/src/Module/Uninstall.php b/src/Module/Uninstall.php index b79b6527..0a720274 100644 --- a/src/Module/Uninstall.php +++ b/src/Module/Uninstall.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Module; class Uninstall diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index 395dec00..e959eccf 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; use Configuration; diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index 413cbfe1..3c7a1442 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class CountryRepository diff --git a/src/Repository/CustomPriceRepository.php b/src/Repository/CustomPriceRepository.php index dec75474..5f635338 100644 --- a/src/Repository/CustomPriceRepository.php +++ b/src/Repository/CustomPriceRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class CustomPriceRepository diff --git a/src/Repository/EventbusSyncRepository.php b/src/Repository/EventbusSyncRepository.php index 127c6920..3daf6fbe 100644 --- a/src/Repository/EventbusSyncRepository.php +++ b/src/Repository/EventbusSyncRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class EventbusSyncRepository diff --git a/src/Repository/GoogleTaxonomyRepository.php b/src/Repository/GoogleTaxonomyRepository.php index c5d75a61..0fe2a2e0 100644 --- a/src/Repository/GoogleTaxonomyRepository.php +++ b/src/Repository/GoogleTaxonomyRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class GoogleTaxonomyRepository diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 4d2076d4..70c1f96d 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; diff --git a/src/Repository/LiveSyncRepository.php b/src/Repository/LiveSyncRepository.php index ff735808..82bfc3a6 100644 --- a/src/Repository/LiveSyncRepository.php +++ b/src/Repository/LiveSyncRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class LiveSyncRepository diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 25926a3a..8739e91d 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class ManufacturerRepository diff --git a/src/Repository/NewRepository/AbstractRepository.php b/src/Repository/NewRepository/AbstractRepository.php index 2fba1a7d..cb948c76 100644 --- a/src/Repository/NewRepository/AbstractRepository.php +++ b/src/Repository/NewRepository/AbstractRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; use PrestaShop\Module\PsEventbus\Service\CommonService; diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index e80b9e94..3415ab34 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class CarrierRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/CartProductRepository.php b/src/Repository/NewRepository/CartProductRepository.php index 304e655c..5c4810a0 100644 --- a/src/Repository/NewRepository/CartProductRepository.php +++ b/src/Repository/NewRepository/CartProductRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class CartProductRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/CartRepository.php b/src/Repository/NewRepository/CartRepository.php index e53c7273..9d0a3ba4 100644 --- a/src/Repository/NewRepository/CartRepository.php +++ b/src/Repository/NewRepository/CartRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class CartRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/CartRuleRepository.php b/src/Repository/NewRepository/CartRuleRepository.php index 614a6193..6d8bfcc3 100644 --- a/src/Repository/NewRepository/CartRuleRepository.php +++ b/src/Repository/NewRepository/CartRuleRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class CartRuleRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/CategoryRepository.php b/src/Repository/NewRepository/CategoryRepository.php index 464e04ee..ba6a8349 100644 --- a/src/Repository/NewRepository/CategoryRepository.php +++ b/src/Repository/NewRepository/CategoryRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class CategoryRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/CurrencyRepository.php b/src/Repository/NewRepository/CurrencyRepository.php index 4ff56349..b4dc0262 100644 --- a/src/Repository/NewRepository/CurrencyRepository.php +++ b/src/Repository/NewRepository/CurrencyRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class CurrencyRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/CustomerRepository.php b/src/Repository/NewRepository/CustomerRepository.php index 81b289d9..f2a9188a 100644 --- a/src/Repository/NewRepository/CustomerRepository.php +++ b/src/Repository/NewRepository/CustomerRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class CustomerRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/EmployeeRepository.php b/src/Repository/NewRepository/EmployeeRepository.php index 2385c149..8dd6592e 100644 --- a/src/Repository/NewRepository/EmployeeRepository.php +++ b/src/Repository/NewRepository/EmployeeRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class EmployeeRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/ImageRepository.php b/src/Repository/NewRepository/ImageRepository.php index 3973f24d..23a7396d 100644 --- a/src/Repository/NewRepository/ImageRepository.php +++ b/src/Repository/NewRepository/ImageRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class ImageRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/ImageTypeRepository.php b/src/Repository/NewRepository/ImageTypeRepository.php index 5a20a359..7456aa00 100644 --- a/src/Repository/NewRepository/ImageTypeRepository.php +++ b/src/Repository/NewRepository/ImageTypeRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class ImageTypeRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/LanguageRepository.php b/src/Repository/NewRepository/LanguageRepository.php index f9a88189..f974d93f 100644 --- a/src/Repository/NewRepository/LanguageRepository.php +++ b/src/Repository/NewRepository/LanguageRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class LanguageRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/ModuleRepository.php b/src/Repository/NewRepository/ModuleRepository.php index 1519142b..a30c1e93 100644 --- a/src/Repository/NewRepository/ModuleRepository.php +++ b/src/Repository/NewRepository/ModuleRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class ModuleRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/NewRepository/OrderCartRuleRepository.php index 0d713245..c42494a9 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/NewRepository/OrderCartRuleRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class OrderCartRuleRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php index ae5794a4..ad623b20 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class OrderDetailRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php index d0c05625..433ec6b4 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class OrderHistoryRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php index 01ec31b4..3f8132f5 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class OrderRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/ProductBundleRepository.php b/src/Repository/NewRepository/ProductBundleRepository.php index aef47646..56489635 100644 --- a/src/Repository/NewRepository/ProductBundleRepository.php +++ b/src/Repository/NewRepository/ProductBundleRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class ProductBundleRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/ProductCarrierRepository.php b/src/Repository/NewRepository/ProductCarrierRepository.php index cd1d3ca1..09b87a39 100644 --- a/src/Repository/NewRepository/ProductCarrierRepository.php +++ b/src/Repository/NewRepository/ProductCarrierRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class ProductCarrierRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/NewRepository/ProductRepository.php index f8f97cc2..45a49183 100644 --- a/src/Repository/NewRepository/ProductRepository.php +++ b/src/Repository/NewRepository/ProductRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class ProductRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/ProductSupplierRepository.php b/src/Repository/NewRepository/ProductSupplierRepository.php index fc86784a..a550ba3f 100644 --- a/src/Repository/NewRepository/ProductSupplierRepository.php +++ b/src/Repository/NewRepository/ProductSupplierRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class ProductSupplierRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php index f01a6f69..886a9e10 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; /** diff --git a/src/Repository/NewRepository/WishlistProductRepository.php b/src/Repository/NewRepository/WishlistProductRepository.php index 8003cec1..a0614265 100644 --- a/src/Repository/NewRepository/WishlistProductRepository.php +++ b/src/Repository/NewRepository/WishlistProductRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class WishlistProductRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/NewRepository/WishlistRepository.php b/src/Repository/NewRepository/WishlistRepository.php index 72ab85c9..159dc404 100644 --- a/src/Repository/NewRepository/WishlistRepository.php +++ b/src/Repository/NewRepository/WishlistRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; class WishlistRepository extends AbstractRepository implements RepositoryInterface diff --git a/src/Repository/ShopRepository.php b/src/Repository/ShopRepository.php index bbe7da4a..8f9472bd 100644 --- a/src/Repository/ShopRepository.php +++ b/src/Repository/ShopRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class ShopRepository diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index fb8e499c..3aba9159 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class SpecificPriceRepository diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index 6eee0ae2..aeb06bb4 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class StateRepository diff --git a/src/Repository/StockMvtRepository.php b/src/Repository/StockMvtRepository.php index c54ff56f..9ebd616b 100644 --- a/src/Repository/StockMvtRepository.php +++ b/src/Repository/StockMvtRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class StockMvtRepository diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index 51c4f8e4..f4c64517 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class StockRepository diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index 2e47af7a..b65f2bf2 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class StoreRepository diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index 5c7587d0..cbf43a5a 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class SupplierRepository diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php index b0101e6c..4b942a83 100644 --- a/src/Repository/TaxeRepository.php +++ b/src/Repository/TaxeRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class TaxeRepository diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 74346ffc..da689fc1 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Repository; class TranslationRepository diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index 641be893..89faa447 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Api\SyncApiClient; diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 4bf43098..ca961c8f 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 44d7d19e..980a3ae4 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 49cce189..b5d12961 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; diff --git a/src/Service/PresenterService.php b/src/Service/PresenterService.php index 8d1d4b2b..9e7db3f7 100644 --- a/src/Service/PresenterService.php +++ b/src/Service/PresenterService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; class PresenterService diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index 440aebe2..fce1b13f 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use GuzzleHttp\Exception\ClientException; diff --git a/src/Service/ProxyServiceInterface.php b/src/Service/ProxyServiceInterface.php index ed5f987c..1f486701 100644 --- a/src/Service/ProxyServiceInterface.php +++ b/src/Service/ProxyServiceInterface.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; interface ProxyServiceInterface diff --git a/src/Service/PsAccountsAdapterService.php b/src/Service/PsAccountsAdapterService.php index e5e662a9..76ad04b4 100644 --- a/src/Service/PsAccountsAdapterService.php +++ b/src/Service/PsAccountsAdapterService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Helper\ModuleHelper; diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index 7cd22315..93ad9259 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 75f03fa0..92781504 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 56702b28..2ea7ed1b 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index f3d6a34a..8b27286e 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index 4f1ad315..fdeae555 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 71cfb451..a4ba7016 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index 0b964d0b..f315be4e 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index a0d8944a..fde2216f 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index 78ebce85..7e507ec2 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index 22770412..44fc0bcc 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index 2f860579..1913cfde 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index 0c349f84..115b70a8 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index 38bd0a34..5b404bfc 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index c61d732a..5e35c286 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index 3da03ae4..d97ad519 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index c0f6b1f1..3747f451 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index 611c6f79..0ec6cfae 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 883ef019..c8d65327 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index 3665782d..37141462 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/ProductCarriersService.php index f858cfcc..b0bbf151 100644 --- a/src/Service/ShopContent/ProductCarriersService.php +++ b/src/Service/ShopContent/ProductCarriersService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index 6c7ff75a..8d8d138b 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index 79320be2..04d7b4aa 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index ee732237..5137f2e9 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; interface ShopContentServiceInterface diff --git a/src/Service/ShopContent/ShopDetailsService.php b/src/Service/ShopContent/ShopDetailsService.php index afba7848..d8db2e57 100644 --- a/src/Service/ShopContent/ShopDetailsService.php +++ b/src/Service/ShopContent/ShopDetailsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php index 6a7427a4..6ee09ec9 100644 --- a/src/Service/ShopContent/ThemesService.php +++ b/src/Service/ShopContent/ThemesService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index 49d45ae3..9a7c427f 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index d903a200..8ce1afa9 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Service/SpecificPriceService.php b/src/Service/SpecificPriceService.php index 03939dda..59ffc067 100644 --- a/src/Service/SpecificPriceService.php +++ b/src/Service/SpecificPriceService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 9050d145..41ce8dcf 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index cb051eae..c2e6cdd5 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + namespace PrestaShop\Module\PsEventbus\Traits; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/translations/en.php b/translations/en.php index 59bebffa..ce87b98a 100644 --- a/translations/en.php +++ b/translations/en.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/es.php b/translations/es.php index 099f790e..ece6efe4 100644 --- a/translations/es.php +++ b/translations/es.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/fr.php b/translations/fr.php index 3b321736..53c0f73b 100644 --- a/translations/fr.php +++ b/translations/fr.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/it.php b/translations/it.php index b72aa739..ce57df3f 100644 --- a/translations/it.php +++ b/translations/it.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/upgrade/Upgrade-1.10.0.php b/upgrade/Upgrade-1.10.0.php index 0610a1fe..be158c1d 100644 --- a/upgrade/Upgrade-1.10.0.php +++ b/upgrade/Upgrade-1.10.0.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.10.3.php b/upgrade/Upgrade-1.10.3.php index 662a0e30..837f0940 100644 --- a/upgrade/Upgrade-1.10.3.php +++ b/upgrade/Upgrade-1.10.3.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.10.7.php b/upgrade/Upgrade-1.10.7.php index 806e7fa0..a18c380e 100644 --- a/upgrade/Upgrade-1.10.7.php +++ b/upgrade/Upgrade-1.10.7.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.10.8.php b/upgrade/Upgrade-1.10.8.php index 03fae974..da02746e 100644 --- a/upgrade/Upgrade-1.10.8.php +++ b/upgrade/Upgrade-1.10.8.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.3.7.php b/upgrade/Upgrade-1.3.7.php index 7e0fa605..ee80dc91 100644 --- a/upgrade/Upgrade-1.3.7.php +++ b/upgrade/Upgrade-1.3.7.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.5.1.php b/upgrade/Upgrade-1.5.1.php index 50e06306..4daccc00 100644 --- a/upgrade/Upgrade-1.5.1.php +++ b/upgrade/Upgrade-1.5.1.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.5.2.php b/upgrade/Upgrade-1.5.2.php index 111eac3b..31dd48e7 100644 --- a/upgrade/Upgrade-1.5.2.php +++ b/upgrade/Upgrade-1.5.2.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.6.9.php b/upgrade/Upgrade-1.6.9.php index 7319f00b..e2e38e69 100644 --- a/upgrade/Upgrade-1.6.9.php +++ b/upgrade/Upgrade-1.6.9.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.7.1.php b/upgrade/Upgrade-1.7.1.php index 11270927..49cb7fff 100644 --- a/upgrade/Upgrade-1.7.1.php +++ b/upgrade/Upgrade-1.7.1.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.7.11.php b/upgrade/Upgrade-1.7.11.php index 340a5f31..985e5c4d 100644 --- a/upgrade/Upgrade-1.7.11.php +++ b/upgrade/Upgrade-1.7.11.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.7.15.php b/upgrade/Upgrade-1.7.15.php index b9123b69..d37118bf 100644 --- a/upgrade/Upgrade-1.7.15.php +++ b/upgrade/Upgrade-1.7.15.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.7.2.php b/upgrade/Upgrade-1.7.2.php index 2366b8d4..71afa544 100644 --- a/upgrade/Upgrade-1.7.2.php +++ b/upgrade/Upgrade-1.7.2.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + use PrestaShop\Module\PsEventbus\Config\Config; /** diff --git a/upgrade/Upgrade-1.8.1.php b/upgrade/Upgrade-1.8.1.php index 536a053f..11767f80 100644 --- a/upgrade/Upgrade-1.8.1.php +++ b/upgrade/Upgrade-1.8.1.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-1.9.3.php b/upgrade/Upgrade-1.9.3.php index 86110ba0..58285c02 100644 --- a/upgrade/Upgrade-1.9.3.php +++ b/upgrade/Upgrade-1.9.3.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.9.7.php b/upgrade/Upgrade-1.9.7.php index 1a5fe6f6..df0bdef0 100644 --- a/upgrade/Upgrade-1.9.7.php +++ b/upgrade/Upgrade-1.9.7.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-2.1.0.php b/upgrade/Upgrade-2.1.0.php index 3fd7136f..de03248f 100644 --- a/upgrade/Upgrade-2.1.0.php +++ b/upgrade/Upgrade-2.1.0.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-2.3.0.php b/upgrade/Upgrade-2.3.0.php index 4950c157..5458f900 100644 --- a/upgrade/Upgrade-2.3.0.php +++ b/upgrade/Upgrade-2.3.0.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-2.3.2.php b/upgrade/Upgrade-2.3.2.php index 16b9c5b6..5734e9f2 100644 --- a/upgrade/Upgrade-2.3.2.php +++ b/upgrade/Upgrade-2.3.2.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-3.0.0.php b/upgrade/Upgrade-3.0.0.php index 381166aa..bd2b483f 100644 --- a/upgrade/Upgrade-3.0.0.php +++ b/upgrade/Upgrade-3.0.0.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-3.0.12.php b/upgrade/Upgrade-3.0.12.php index cb99be1f..40dcc2e4 100644 --- a/upgrade/Upgrade-3.0.12.php +++ b/upgrade/Upgrade-3.0.12.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-3.0.13.php b/upgrade/Upgrade-3.0.13.php index b4b6b189..50daf7a5 100644 --- a/upgrade/Upgrade-3.0.13.php +++ b/upgrade/Upgrade-3.0.13.php @@ -18,6 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + use PrestaShop\Module\PsEventbus\Config\Config; /** diff --git a/upgrade/Upgrade-3.0.5.php b/upgrade/Upgrade-3.0.5.php index 8f7b8488..8456449c 100644 --- a/upgrade/Upgrade-3.0.5.php +++ b/upgrade/Upgrade-3.0.5.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index 7785ff4c..63cbe509 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ /** * @return bool From 113237a45ed99669b7ec0a7f1b9415db948bec95 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 26 Sep 2024 18:36:41 +0200 Subject: [PATCH 091/162] fix: problem with header stamp --- OLD/Provider/CustomPriceDataProvider.php | 8 +++++--- OLD/Provider/GoogleTaxonomyDataProvider.php | 8 +++++--- OLD/Provider/ManufacturerDataProvider.php | 8 +++++--- OLD/Provider/PaginatedApiDataProviderInterface.php | 4 +--- OLD/Provider/StockDataProvider.php | 8 +++++--- OLD/Provider/StoreDataProvider.php | 8 +++++--- OLD/Provider/SupplierDataProvider.php | 8 +++++--- OLD/Provider/TranslationDataProvider.php | 8 +++++--- OLD/Provider/WishlistDataProvider.php | 8 +++++--- controllers/front/apiFront.php | 6 ++++-- ps_eventbus.php | 8 +++++--- src/Api/CollectorApiClient.php | 8 +++++--- src/Api/LiveSyncApiClient.php | 8 +++++--- src/Api/Post/MultipartBody.php | 4 +--- src/Api/Post/PostFileApi.php | 4 +--- src/Api/Post/PostFileInterface.php | 4 +--- src/Api/Post/Stream.php | 4 +--- src/Api/SyncApiClient.php | 8 +++++--- src/Config/Config.php | 6 ++++-- src/Decorator/CustomPriceDecorator.php | 8 +++++--- src/Decorator/ManufacturerDecorator.php | 6 ++++-- src/Decorator/PayloadDecorator.php | 8 +++++--- src/Decorator/StockDecorator.php | 6 ++++-- src/Decorator/StoreDecorator.php | 6 ++++-- src/Decorator/SupplierDecorator.php | 6 ++++-- src/Decorator/TranslationDecorator.php | 6 ++++-- src/DependencyInjection/ContainerProvider.php | 8 +++++--- src/DependencyInjection/ServiceContainer.php | 8 +++++--- src/Exception/ApiException.php | 6 ++++-- src/Exception/EnvVarException.php | 6 ++++-- src/Exception/FirebaseException.php | 6 ++++-- src/Exception/HmacException.php | 6 ++++-- src/Exception/PsAccountsRsaSignDataEmptyException.php | 6 ++++-- src/Exception/QueryParamsException.php | 6 ++++-- src/Exception/UnauthorizedException.php | 6 ++++-- src/Exception/WebhookException.php | 6 ++++-- src/Factory/ContextFactory.php | 6 ++++-- src/Formatter/ArrayFormatter.php | 6 ++++-- src/Formatter/JsonFormatter.php | 6 ++++-- src/Handler/ErrorHandler/ErrorHandler.php | 4 +--- src/Handler/ErrorHandler/ErrorHandlerInterface.php | 4 +--- src/Helper/CarrierHelper.php | 8 +++++--- src/Helper/ModuleHelper.php | 8 +++++--- src/Module/Install.php | 6 ++++-- src/Module/Uninstall.php | 6 ++++-- src/Repository/ConfigurationRepository.php | 8 +++++--- src/Repository/CountryRepository.php | 6 ++++-- src/Repository/CustomPriceRepository.php | 6 ++++-- src/Repository/EventbusSyncRepository.php | 6 ++++-- src/Repository/GoogleTaxonomyRepository.php | 6 ++++-- src/Repository/IncrementalSyncRepository.php | 8 +++++--- src/Repository/LiveSyncRepository.php | 4 ++-- src/Repository/ManufacturerRepository.php | 4 ++-- src/Repository/NewRepository/AbstractRepository.php | 4 +--- src/Repository/NewRepository/CarrierRepository.php | 6 ++++-- src/Repository/NewRepository/CartProductRepository.php | 6 ++++-- src/Repository/NewRepository/CartRepository.php | 6 ++++-- src/Repository/NewRepository/CartRuleRepository.php | 6 ++++-- src/Repository/NewRepository/CategoryRepository.php | 6 ++++-- src/Repository/NewRepository/CurrencyRepository.php | 6 ++++-- src/Repository/NewRepository/CustomerRepository.php | 6 ++++-- src/Repository/NewRepository/EmployeeRepository.php | 6 ++++-- src/Repository/NewRepository/ImageRepository.php | 6 ++++-- src/Repository/NewRepository/ImageTypeRepository.php | 6 ++++-- src/Repository/NewRepository/LanguageRepository.php | 6 ++++-- src/Repository/NewRepository/ModuleRepository.php | 6 ++++-- src/Repository/NewRepository/OrderCartRuleRepository.php | 6 ++++-- src/Repository/NewRepository/OrderDetailRepository.php | 6 ++++-- src/Repository/NewRepository/OrderHistoryRepository.php | 6 ++++-- src/Repository/NewRepository/OrderRepository.php | 6 ++++-- src/Repository/NewRepository/ProductBundleRepository.php | 6 ++++-- src/Repository/NewRepository/ProductCarrierRepository.php | 6 ++++-- src/Repository/NewRepository/ProductRepository.php | 6 ++++-- .../NewRepository/ProductSupplierRepository.php | 6 ++++-- src/Repository/NewRepository/RepositoryInterface.php | 4 +--- .../NewRepository/WishlistProductRepository.php | 6 ++++-- src/Repository/NewRepository/WishlistRepository.php | 6 ++++-- src/Repository/ShopRepository.php | 6 ++++-- src/Repository/SpecificPriceRepository.php | 6 ++++-- src/Repository/StateRepository.php | 6 ++++-- src/Repository/StockMvtRepository.php | 6 ++++-- src/Repository/StockRepository.php | 6 ++++-- src/Repository/StoreRepository.php | 6 ++++-- src/Repository/SupplierRepository.php | 6 ++++-- src/Repository/TaxeRepository.php | 6 ++++-- src/Repository/TranslationRepository.php | 6 ++++-- src/Service/ApiAuthorizationService.php | 8 +++++--- src/Service/CommonService.php | 8 +++++--- src/Service/FrontApiService.php | 8 +++++--- src/Service/HealthCheckService.php | 8 +++++--- src/Service/PresenterService.php | 6 ++++-- src/Service/ProxyService.php | 8 +++++--- src/Service/ProxyServiceInterface.php | 4 +--- src/Service/PsAccountsAdapterService.php | 8 +++++--- src/Service/ShopContent/CarrierDetailsService.php | 8 +++++--- src/Service/ShopContent/CarrierTaxesService.php | 8 +++++--- src/Service/ShopContent/CarriersService.php | 8 +++++--- src/Service/ShopContent/CartProductsService.php | 8 +++++--- src/Service/ShopContent/CartRulesService.php | 8 +++++--- src/Service/ShopContent/CartsService.php | 8 +++++--- src/Service/ShopContent/CategoriesService.php | 8 +++++--- src/Service/ShopContent/CurrenciesService.php | 8 +++++--- src/Service/ShopContent/CustomersService.php | 8 +++++--- src/Service/ShopContent/EmployeesService.php | 8 +++++--- src/Service/ShopContent/ImageTypesService.php | 8 +++++--- src/Service/ShopContent/ImagesService.php | 8 +++++--- src/Service/ShopContent/LanguagesService.php | 8 +++++--- src/Service/ShopContent/ModulesService.php | 8 +++++--- src/Service/ShopContent/OrderCartRulesService.php | 8 +++++--- src/Service/ShopContent/OrderDetailsService.php | 8 +++++--- src/Service/ShopContent/OrderHistoriesService.php | 8 +++++--- src/Service/ShopContent/OrdersService.php | 8 +++++--- src/Service/ShopContent/ProductBundlesService.php | 8 +++++--- src/Service/ShopContent/ProductCarriersService.php | 8 +++++--- src/Service/ShopContent/ProductSuppliersService.php | 8 +++++--- src/Service/ShopContent/ProductsService.php | 8 +++++--- src/Service/ShopContent/ShopContentServiceInterface.php | 4 +--- src/Service/ShopContent/ShopDetailsService.php | 8 +++++--- src/Service/ShopContent/ThemesService.php | 8 +++++--- src/Service/ShopContent/WishlistProductsService.php | 8 +++++--- src/Service/ShopContent/WishlistsService.php | 8 +++++--- src/Service/SpecificPriceService.php | 8 +++++--- src/Service/SynchronizationService.php | 8 +++++--- src/Traits/UseHooks.php | 4 +--- translations/en.php | 4 +--- translations/es.php | 4 +--- translations/fr.php | 4 +--- translations/it.php | 4 +--- upgrade/Upgrade-1.7.2.php | 4 +--- upgrade/Upgrade-3.0.13.php | 4 +--- 130 files changed, 516 insertions(+), 332 deletions(-) diff --git a/OLD/Provider/CustomPriceDataProvider.php b/OLD/Provider/CustomPriceDataProvider.php index afd8395e..ede6fcbe 100644 --- a/OLD/Provider/CustomPriceDataProvider.php +++ b/OLD/Provider/CustomPriceDataProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Decorator\CustomPriceDecorator; use PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomPriceDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/OLD/Provider/GoogleTaxonomyDataProvider.php b/OLD/Provider/GoogleTaxonomyDataProvider.php index 125ecf4a..d0e94756 100644 --- a/OLD/Provider/GoogleTaxonomyDataProvider.php +++ b/OLD/Provider/GoogleTaxonomyDataProvider.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class GoogleTaxonomyDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/OLD/Provider/ManufacturerDataProvider.php b/OLD/Provider/ManufacturerDataProvider.php index 1a7ef701..7c93bada 100644 --- a/OLD/Provider/ManufacturerDataProvider.php +++ b/OLD/Provider/ManufacturerDataProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Decorator\ManufacturerDecorator; use PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ManufacturerDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/OLD/Provider/PaginatedApiDataProviderInterface.php b/OLD/Provider/PaginatedApiDataProviderInterface.php index dfe1de3b..0f51ad4c 100644 --- a/OLD/Provider/PaginatedApiDataProviderInterface.php +++ b/OLD/Provider/PaginatedApiDataProviderInterface.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; diff --git a/OLD/Provider/StockDataProvider.php b/OLD/Provider/StockDataProvider.php index 07b49bdc..b95a20f4 100644 --- a/OLD/Provider/StockDataProvider.php +++ b/OLD/Provider/StockDataProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; @@ -30,6 +28,10 @@ use PrestaShop\Module\PsEventbus\Repository\StockMvtRepository; use PrestaShop\Module\PsEventbus\Repository\StockRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class StockDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/OLD/Provider/StoreDataProvider.php b/OLD/Provider/StoreDataProvider.php index a719b64a..d354dc2f 100644 --- a/OLD/Provider/StoreDataProvider.php +++ b/OLD/Provider/StoreDataProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Decorator\StoreDecorator; use PrestaShop\Module\PsEventbus\Repository\StoreRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class StoreDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/OLD/Provider/SupplierDataProvider.php b/OLD/Provider/SupplierDataProvider.php index 0d61be3e..4563b5fe 100644 --- a/OLD/Provider/SupplierDataProvider.php +++ b/OLD/Provider/SupplierDataProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator; use PrestaShop\Module\PsEventbus\Repository\SupplierRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class SupplierDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/OLD/Provider/TranslationDataProvider.php b/OLD/Provider/TranslationDataProvider.php index 0d3e7738..82581430 100644 --- a/OLD/Provider/TranslationDataProvider.php +++ b/OLD/Provider/TranslationDataProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Decorator\TranslationDecorator; use PrestaShop\Module\PsEventbus\Repository\TranslationRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class TranslationDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/OLD/Provider/WishlistDataProvider.php b/OLD/Provider/WishlistDataProvider.php index 8e9e07c2..e481ab70 100644 --- a/OLD/Provider/WishlistDataProvider.php +++ b/OLD/Provider/WishlistDataProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Provider; @@ -30,6 +28,10 @@ use PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository; use PrestaShop\Module\PsEventbus\Repository\WishlistRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class WishlistDataProvider implements PaginatedApiDataProviderInterface { /** diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index c8d2cd66..80abc31c 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +use PrestaShop\Module\PsEventbus\Service\FrontApiService; + if (!defined('_PS_VERSION_')) { exit; } -use PrestaShop\Module\PsEventbus\Service\FrontApiService; - class ps_EventbusApiFrontModuleFrontController extends ModuleFrontController { /** diff --git a/ps_eventbus.php b/ps_eventbus.php index e62f86a9..b170dcec 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; use PrestaShop\Module\PsEventbus\Module\Install; @@ -30,6 +28,10 @@ require_once __DIR__ . '/vendor/autoload.php'; +if (!defined('_PS_VERSION_')) { + exit; +} + class Ps_eventbus extends Module { // All hooks is here diff --git a/src/Api/CollectorApiClient.php b/src/Api/CollectorApiClient.php index 33ec2830..9157f4e7 100644 --- a/src/Api/CollectorApiClient.php +++ b/src/Api/CollectorApiClient.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Api; @@ -32,6 +30,10 @@ use Prestashop\ModuleLibGuzzleAdapter\ClientFactory; use Prestashop\ModuleLibGuzzleAdapter\Interfaces\HttpClientInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class CollectorApiClient { /** diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index d8a22767..efbc9858 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Api; @@ -30,6 +28,10 @@ use Prestashop\ModuleLibGuzzleAdapter\ClientFactory; use Prestashop\ModuleLibGuzzleAdapter\Interfaces\HttpClientInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class LiveSyncApiClient { /** diff --git a/src/Api/Post/MultipartBody.php b/src/Api/Post/MultipartBody.php index 4ef74ad7..8381f375 100755 --- a/src/Api/Post/MultipartBody.php +++ b/src/Api/Post/MultipartBody.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/PostFileApi.php b/src/Api/Post/PostFileApi.php index 9ef53371..9831a3a5 100644 --- a/src/Api/Post/PostFileApi.php +++ b/src/Api/Post/PostFileApi.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/PostFileInterface.php b/src/Api/Post/PostFileInterface.php index b89aac29..178eee11 100755 --- a/src/Api/Post/PostFileInterface.php +++ b/src/Api/Post/PostFileInterface.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/Stream.php b/src/Api/Post/Stream.php index 210fa9ef..b1a505d3 100644 --- a/src/Api/Post/Stream.php +++ b/src/Api/Post/Stream.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/SyncApiClient.php b/src/Api/SyncApiClient.php index 9904b5b2..554fda6b 100644 --- a/src/Api/SyncApiClient.php +++ b/src/Api/SyncApiClient.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Api; @@ -30,6 +28,10 @@ use Prestashop\ModuleLibGuzzleAdapter\ClientFactory; use Prestashop\ModuleLibGuzzleAdapter\Interfaces\HttpClientInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class SyncApiClient { /** diff --git a/src/Config/Config.php b/src/Config/Config.php index ba8268cf..4f600127 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Config; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Config; - class Config { const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s'; diff --git a/src/Decorator/CustomPriceDecorator.php b/src/Decorator/CustomPriceDecorator.php index 87b6e6bd..7c015b54 100644 --- a/src/Decorator/CustomPriceDecorator.php +++ b/src/Decorator/CustomPriceDecorator.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Decorator; use PrestaShop\Module\PsEventbus\Service\SpecificPriceService; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomPriceDecorator { /** diff --git a/src/Decorator/ManufacturerDecorator.php b/src/Decorator/ManufacturerDecorator.php index edf3797e..ebe095f3 100644 --- a/src/Decorator/ManufacturerDecorator.php +++ b/src/Decorator/ManufacturerDecorator.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Decorator; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Decorator; - class ManufacturerDecorator { /** diff --git a/src/Decorator/PayloadDecorator.php b/src/Decorator/PayloadDecorator.php index dd5e73d3..54adcdfe 100644 --- a/src/Decorator/PayloadDecorator.php +++ b/src/Decorator/PayloadDecorator.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Decorator; @@ -39,6 +37,10 @@ 'to', ]; +if (!defined('_PS_VERSION_')) { + exit; +} + class PayloadDecorator { /** diff --git a/src/Decorator/StockDecorator.php b/src/Decorator/StockDecorator.php index 57688e7a..fec83a1f 100644 --- a/src/Decorator/StockDecorator.php +++ b/src/Decorator/StockDecorator.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Decorator; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Decorator; - class StockDecorator { /** diff --git a/src/Decorator/StoreDecorator.php b/src/Decorator/StoreDecorator.php index 8712609f..e9fa2a89 100644 --- a/src/Decorator/StoreDecorator.php +++ b/src/Decorator/StoreDecorator.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Decorator; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Decorator; - class StoreDecorator { /** diff --git a/src/Decorator/SupplierDecorator.php b/src/Decorator/SupplierDecorator.php index bdad2af7..afdca6e7 100644 --- a/src/Decorator/SupplierDecorator.php +++ b/src/Decorator/SupplierDecorator.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Decorator; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Decorator; - class SupplierDecorator { /** diff --git a/src/Decorator/TranslationDecorator.php b/src/Decorator/TranslationDecorator.php index ce2ec693..35bdfccd 100644 --- a/src/Decorator/TranslationDecorator.php +++ b/src/Decorator/TranslationDecorator.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Decorator; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Decorator; - class TranslationDecorator { /** diff --git a/src/DependencyInjection/ContainerProvider.php b/src/DependencyInjection/ContainerProvider.php index 9744c04f..9e0fc8e7 100644 --- a/src/DependencyInjection/ContainerProvider.php +++ b/src/DependencyInjection/ContainerProvider.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\DependencyInjection; @@ -32,6 +30,10 @@ use Symfony\Component\DependencyInjection\Dumper\PhpDumper; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +if (!defined('_PS_VERSION_')) { + exit; +} + class ContainerProvider { /** diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php index 01beefb9..571bb868 100644 --- a/src/DependencyInjection/ServiceContainer.php +++ b/src/DependencyInjection/ServiceContainer.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\DependencyInjection; use PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider; use Symfony\Component\DependencyInjection\ContainerInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class ServiceContainer { /** diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index 7dc2137e..54535608 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class ApiException extends \Exception { } diff --git a/src/Exception/EnvVarException.php b/src/Exception/EnvVarException.php index 9b5ca930..810f3bbf 100644 --- a/src/Exception/EnvVarException.php +++ b/src/Exception/EnvVarException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class EnvVarException extends \Exception { } diff --git a/src/Exception/FirebaseException.php b/src/Exception/FirebaseException.php index f73e3079..b462e678 100644 --- a/src/Exception/FirebaseException.php +++ b/src/Exception/FirebaseException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class FirebaseException extends \Exception { } diff --git a/src/Exception/HmacException.php b/src/Exception/HmacException.php index 32508873..7a3fd859 100644 --- a/src/Exception/HmacException.php +++ b/src/Exception/HmacException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class HmacException extends \Exception { } diff --git a/src/Exception/PsAccountsRsaSignDataEmptyException.php b/src/Exception/PsAccountsRsaSignDataEmptyException.php index c1b3c544..d6a689c8 100644 --- a/src/Exception/PsAccountsRsaSignDataEmptyException.php +++ b/src/Exception/PsAccountsRsaSignDataEmptyException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class PsAccountsRsaSignDataEmptyException extends \Exception { } diff --git a/src/Exception/QueryParamsException.php b/src/Exception/QueryParamsException.php index 3f683c4d..85208244 100644 --- a/src/Exception/QueryParamsException.php +++ b/src/Exception/QueryParamsException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class QueryParamsException extends \Exception { } diff --git a/src/Exception/UnauthorizedException.php b/src/Exception/UnauthorizedException.php index 21933b37..dfd86a08 100644 --- a/src/Exception/UnauthorizedException.php +++ b/src/Exception/UnauthorizedException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class UnauthorizedException extends \Exception { } diff --git a/src/Exception/WebhookException.php b/src/Exception/WebhookException.php index 3e1d98d2..f5b3282f 100644 --- a/src/Exception/WebhookException.php +++ b/src/Exception/WebhookException.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Exception; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Exception; - class WebhookException extends \Exception { } diff --git a/src/Factory/ContextFactory.php b/src/Factory/ContextFactory.php index b0b58ee4..f667774d 100644 --- a/src/Factory/ContextFactory.php +++ b/src/Factory/ContextFactory.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Factory; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Factory; - class ContextFactory { /** diff --git a/src/Formatter/ArrayFormatter.php b/src/Formatter/ArrayFormatter.php index b08fda96..0e47cd99 100644 --- a/src/Formatter/ArrayFormatter.php +++ b/src/Formatter/ArrayFormatter.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Formatter; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Formatter; - class ArrayFormatter { /** diff --git a/src/Formatter/JsonFormatter.php b/src/Formatter/JsonFormatter.php index df7f1269..28f6e7dd 100644 --- a/src/Formatter/JsonFormatter.php +++ b/src/Formatter/JsonFormatter.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Formatter; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Formatter; - class JsonFormatter { /** diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index a0887c10..cb7b5813 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -19,9 +19,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; diff --git a/src/Handler/ErrorHandler/ErrorHandlerInterface.php b/src/Handler/ErrorHandler/ErrorHandlerInterface.php index a0d46fd4..9831332c 100644 --- a/src/Handler/ErrorHandler/ErrorHandlerInterface.php +++ b/src/Handler/ErrorHandler/ErrorHandlerInterface.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; diff --git a/src/Helper/CarrierHelper.php b/src/Helper/CarrierHelper.php index 4e0d6903..d72d28c7 100644 --- a/src/Helper/CarrierHelper.php +++ b/src/Helper/CarrierHelper.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Helper; @@ -29,6 +27,10 @@ use PrestaShop\Module\PsEventbus\Repository\StateRepository; use PrestaShop\Module\PsEventbus\Repository\TaxeRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CarrierHelper { /** diff --git a/src/Helper/ModuleHelper.php b/src/Helper/ModuleHelper.php index 94be5805..7eb72c3f 100644 --- a/src/Helper/ModuleHelper.php +++ b/src/Helper/ModuleHelper.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Helper; use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; +if (!defined('_PS_VERSION_')) { + exit; +} + class ModuleHelper { /** diff --git a/src/Module/Install.php b/src/Module/Install.php index fd41ade3..6559e2eb 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Module; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Module; - class Install { const PARENT_TAB_NAME = -1; diff --git a/src/Module/Uninstall.php b/src/Module/Uninstall.php index 0a720274..ede58334 100644 --- a/src/Module/Uninstall.php +++ b/src/Module/Uninstall.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Module; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Module; - class Uninstall { /** diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index e959eccf..62184170 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Repository; use Configuration; +if (!defined('_PS_VERSION_')) { + exit; +} + class ConfigurationRepository { /** diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index 3c7a1442..ff3b6b1c 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class CountryRepository { /** diff --git a/src/Repository/CustomPriceRepository.php b/src/Repository/CustomPriceRepository.php index 5f635338..97f839fa 100644 --- a/src/Repository/CustomPriceRepository.php +++ b/src/Repository/CustomPriceRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class CustomPriceRepository { /** diff --git a/src/Repository/EventbusSyncRepository.php b/src/Repository/EventbusSyncRepository.php index 3daf6fbe..dd35c2ba 100644 --- a/src/Repository/EventbusSyncRepository.php +++ b/src/Repository/EventbusSyncRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class EventbusSyncRepository { const TYPE_SYNC_TABLE_NAME = 'eventbus_type_sync'; diff --git a/src/Repository/GoogleTaxonomyRepository.php b/src/Repository/GoogleTaxonomyRepository.php index 0fe2a2e0..6c6c0d46 100644 --- a/src/Repository/GoogleTaxonomyRepository.php +++ b/src/Repository/GoogleTaxonomyRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class GoogleTaxonomyRepository { /** diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 70c1f96d..30ab79bb 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Repository; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class IncrementalSyncRepository { const INCREMENTAL_SYNC_TABLE = 'eventbus_incremental_sync'; diff --git a/src/Repository/LiveSyncRepository.php b/src/Repository/LiveSyncRepository.php index 82bfc3a6..0d3e7565 100644 --- a/src/Repository/LiveSyncRepository.php +++ b/src/Repository/LiveSyncRepository.php @@ -18,12 +18,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class LiveSyncRepository { /** diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 8739e91d..ad70c2e4 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -18,12 +18,12 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class ManufacturerRepository { /** diff --git a/src/Repository/NewRepository/AbstractRepository.php b/src/Repository/NewRepository/AbstractRepository.php index cb948c76..765e8cb8 100644 --- a/src/Repository/NewRepository/AbstractRepository.php +++ b/src/Repository/NewRepository/AbstractRepository.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/NewRepository/CarrierRepository.php index 3415ab34..b9902116 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/NewRepository/CarrierRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class CarrierRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'carrier'; diff --git a/src/Repository/NewRepository/CartProductRepository.php b/src/Repository/NewRepository/CartProductRepository.php index 5c4810a0..c3331d4b 100644 --- a/src/Repository/NewRepository/CartProductRepository.php +++ b/src/Repository/NewRepository/CartProductRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class CartProductRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'cart_product'; diff --git a/src/Repository/NewRepository/CartRepository.php b/src/Repository/NewRepository/CartRepository.php index 9d0a3ba4..1d007250 100644 --- a/src/Repository/NewRepository/CartRepository.php +++ b/src/Repository/NewRepository/CartRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class CartRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'cart'; diff --git a/src/Repository/NewRepository/CartRuleRepository.php b/src/Repository/NewRepository/CartRuleRepository.php index 6d8bfcc3..5aaaa1d0 100644 --- a/src/Repository/NewRepository/CartRuleRepository.php +++ b/src/Repository/NewRepository/CartRuleRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class CartRuleRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'cart_rule'; diff --git a/src/Repository/NewRepository/CategoryRepository.php b/src/Repository/NewRepository/CategoryRepository.php index ba6a8349..65488b2e 100644 --- a/src/Repository/NewRepository/CategoryRepository.php +++ b/src/Repository/NewRepository/CategoryRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class CategoryRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'category_shop'; diff --git a/src/Repository/NewRepository/CurrencyRepository.php b/src/Repository/NewRepository/CurrencyRepository.php index b4dc0262..d6e34bc5 100644 --- a/src/Repository/NewRepository/CurrencyRepository.php +++ b/src/Repository/NewRepository/CurrencyRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class CurrencyRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'currency'; diff --git a/src/Repository/NewRepository/CustomerRepository.php b/src/Repository/NewRepository/CustomerRepository.php index f2a9188a..03c81e79 100644 --- a/src/Repository/NewRepository/CustomerRepository.php +++ b/src/Repository/NewRepository/CustomerRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class CustomerRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'customer'; diff --git a/src/Repository/NewRepository/EmployeeRepository.php b/src/Repository/NewRepository/EmployeeRepository.php index 8dd6592e..adfc9eab 100644 --- a/src/Repository/NewRepository/EmployeeRepository.php +++ b/src/Repository/NewRepository/EmployeeRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class EmployeeRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'employee'; diff --git a/src/Repository/NewRepository/ImageRepository.php b/src/Repository/NewRepository/ImageRepository.php index 23a7396d..eb2c6e64 100644 --- a/src/Repository/NewRepository/ImageRepository.php +++ b/src/Repository/NewRepository/ImageRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class ImageRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'image'; diff --git a/src/Repository/NewRepository/ImageTypeRepository.php b/src/Repository/NewRepository/ImageTypeRepository.php index 7456aa00..80b9f349 100644 --- a/src/Repository/NewRepository/ImageTypeRepository.php +++ b/src/Repository/NewRepository/ImageTypeRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class ImageTypeRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'image_type'; diff --git a/src/Repository/NewRepository/LanguageRepository.php b/src/Repository/NewRepository/LanguageRepository.php index f974d93f..10b4d66f 100644 --- a/src/Repository/NewRepository/LanguageRepository.php +++ b/src/Repository/NewRepository/LanguageRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class LanguageRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'lang'; diff --git a/src/Repository/NewRepository/ModuleRepository.php b/src/Repository/NewRepository/ModuleRepository.php index a30c1e93..61794018 100644 --- a/src/Repository/NewRepository/ModuleRepository.php +++ b/src/Repository/NewRepository/ModuleRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class ModuleRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'module'; diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/NewRepository/OrderCartRuleRepository.php index c42494a9..96544120 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/NewRepository/OrderCartRuleRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class OrderCartRuleRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'order_cart_rule'; diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/NewRepository/OrderDetailRepository.php index ad623b20..ec04a9a2 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/NewRepository/OrderDetailRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class OrderDetailRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'order_detail'; diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/NewRepository/OrderHistoryRepository.php index 433ec6b4..a50f5eda 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/NewRepository/OrderHistoryRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class OrderHistoryRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'order_history'; diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/NewRepository/OrderRepository.php index 3f8132f5..d11efadf 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/NewRepository/OrderRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class OrderRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'orders'; diff --git a/src/Repository/NewRepository/ProductBundleRepository.php b/src/Repository/NewRepository/ProductBundleRepository.php index 56489635..0d1661f1 100644 --- a/src/Repository/NewRepository/ProductBundleRepository.php +++ b/src/Repository/NewRepository/ProductBundleRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class ProductBundleRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'pack'; diff --git a/src/Repository/NewRepository/ProductCarrierRepository.php b/src/Repository/NewRepository/ProductCarrierRepository.php index 09b87a39..f4fe3fcc 100644 --- a/src/Repository/NewRepository/ProductCarrierRepository.php +++ b/src/Repository/NewRepository/ProductCarrierRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class ProductCarrierRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'product_carrier'; diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/NewRepository/ProductRepository.php index 45a49183..42dad865 100644 --- a/src/Repository/NewRepository/ProductRepository.php +++ b/src/Repository/NewRepository/ProductRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class ProductRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'product'; diff --git a/src/Repository/NewRepository/ProductSupplierRepository.php b/src/Repository/NewRepository/ProductSupplierRepository.php index a550ba3f..08ccef0f 100644 --- a/src/Repository/NewRepository/ProductSupplierRepository.php +++ b/src/Repository/NewRepository/ProductSupplierRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class ProductSupplierRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'product_supplier'; diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/NewRepository/RepositoryInterface.php index 886a9e10..b24de588 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/NewRepository/RepositoryInterface.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; diff --git a/src/Repository/NewRepository/WishlistProductRepository.php b/src/Repository/NewRepository/WishlistProductRepository.php index a0614265..abe918e2 100644 --- a/src/Repository/NewRepository/WishlistProductRepository.php +++ b/src/Repository/NewRepository/WishlistProductRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class WishlistProductRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'wishlist_product'; diff --git a/src/Repository/NewRepository/WishlistRepository.php b/src/Repository/NewRepository/WishlistRepository.php index 159dc404..00133545 100644 --- a/src/Repository/NewRepository/WishlistRepository.php +++ b/src/Repository/NewRepository/WishlistRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; - class WishlistRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'wishlist'; diff --git a/src/Repository/ShopRepository.php b/src/Repository/ShopRepository.php index 8f9472bd..452722c9 100644 --- a/src/Repository/ShopRepository.php +++ b/src/Repository/ShopRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class ShopRepository { /** diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index 3aba9159..4e1f0a78 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class SpecificPriceRepository { const TABLE_NAME = 'specific_price'; diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index aeb06bb4..b0ca940d 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class StateRepository { /** diff --git a/src/Repository/StockMvtRepository.php b/src/Repository/StockMvtRepository.php index 9ebd616b..c8aa0410 100644 --- a/src/Repository/StockMvtRepository.php +++ b/src/Repository/StockMvtRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class StockMvtRepository { /** diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index f4c64517..4d304d13 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class StockRepository { /** diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index b65f2bf2..d9fb6dec 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class StoreRepository { const STORES_TABLE = 'store'; diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index cbf43a5a..f45cc746 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class SupplierRepository { /** diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php index 4b942a83..8f9b3379 100644 --- a/src/Repository/TaxeRepository.php +++ b/src/Repository/TaxeRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class TaxeRepository { /** diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index da689fc1..ba2ba3ca 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Repository; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Repository; - class TranslationRepository { /** diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index 89faa447..08df41d5 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Api\SyncApiClient; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ApiAuthorizationService { /** diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index ca961c8f..da88a8f7 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; @@ -29,6 +27,10 @@ use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; +if (!defined('_PS_VERSION_')) { + exit; +} + class CommonService { /** diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 980a3ae4..faa2bdcf 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; @@ -35,6 +33,10 @@ use PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; +if (!defined('_PS_VERSION_')) { + exit; +} + class FrontApiService { /** @var int */ diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index b5d12961..ac208f57 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class HealthCheckService { /** @var \Ps_eventbus */ diff --git a/src/Service/PresenterService.php b/src/Service/PresenterService.php index 9e7db3f7..7c76bf50 100644 --- a/src/Service/PresenterService.php +++ b/src/Service/PresenterService.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ + + +namespace PrestaShop\Module\PsEventbus\Service; + if (!defined('_PS_VERSION_')) { exit; } -namespace PrestaShop\Module\PsEventbus\Service; - class PresenterService { /** diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index fce1b13f..5294b627 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; @@ -31,6 +29,10 @@ use PrestaShop\Module\PsEventbus\Formatter\JsonFormatter; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProxyService implements ProxyServiceInterface { /** diff --git a/src/Service/ProxyServiceInterface.php b/src/Service/ProxyServiceInterface.php index 1f486701..9ce22a05 100644 --- a/src/Service/ProxyServiceInterface.php +++ b/src/Service/ProxyServiceInterface.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/PsAccountsAdapterService.php b/src/Service/PsAccountsAdapterService.php index 76ad04b4..f8a6081c 100644 --- a/src/Service/PsAccountsAdapterService.php +++ b/src/Service/PsAccountsAdapterService.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Helper\ModuleHelper; +if (!defined('_PS_VERSION_')) { + exit; +} + class PsAccountsAdapterService { /** diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index 93ad9259..169e01b8 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Helper\CarrierHelper; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CarrierDetailsService implements ShopContentServiceInterface { /** @var CarrierRepository */ diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 92781504..085231d2 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Helper\CarrierHelper; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CarrierTaxesService implements ShopContentServiceInterface { /** @var CarrierRepository */ diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 2ea7ed1b..bf6e9ee1 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CarriersService implements ShopContentServiceInterface { /** @var CarrierRepository */ diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index 8b27286e..fed01439 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartProductsService implements ShopContentServiceInterface { /** @var CartProductRepository */ diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index fdeae555..8dfd359b 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartRulesService implements ShopContentServiceInterface { /** @var CartRuleRepository */ diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index a4ba7016..dd112e1b 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartsService implements ShopContentServiceInterface { /** @var CartRepository */ diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index f315be4e..4129e33b 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CategoriesService implements ShopContentServiceInterface { /** @var CategoryRepository */ diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index fde2216f..66fae739 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CurrenciesService implements ShopContentServiceInterface { /** @var CurrencyRepository */ diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index 7e507ec2..2d058acb 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomersService implements ShopContentServiceInterface { /** @var CustomerRepository */ diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index 44fc0bcc..82c546bc 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class EmployeesService implements ShopContentServiceInterface { /** @var EmployeeRepository */ diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index 1913cfde..4865d53c 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ImageTypesService implements ShopContentServiceInterface { /** @var ImageTypeRepository */ diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index 115b70a8..eb59e42c 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ImagesService implements ShopContentServiceInterface { /** @var ImageRepository */ diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index 5b404bfc..339d3630 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class LanguagesService implements ShopContentServiceInterface { /** @var LanguageRepository */ diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 5e35c286..3ec9977e 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository; use PrestaShop\Module\PsEventbus\Repository\ShopRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ModulesService implements ShopContentServiceInterface { /** @var ModuleRepository */ diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index d97ad519..0327c5ed 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderCartRulesService implements ShopContentServiceInterface { /** @var OrderCartRuleRepository */ diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index 3747f451..51d63508 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderDetailsService implements ShopContentServiceInterface { /** @var OrderDetailRepository */ diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index 0ec6cfae..bc51c266 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderHistoriesService implements ShopContentServiceInterface { /** @var OrderHistoryRepository */ diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index c8d65327..265c6508 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; @@ -29,6 +27,10 @@ use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository; use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrdersService implements ShopContentServiceInterface { /** @var OrderRepository */ diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index 37141462..9f2ed8ef 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProductBundlesService implements ShopContentServiceInterface { /** @var ProductBundleRepository */ diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/ProductCarriersService.php index b0bbf151..2ffb358b 100644 --- a/src/Service/ShopContent/ProductCarriersService.php +++ b/src/Service/ShopContent/ProductCarriersService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProductCarriersService implements ShopContentServiceInterface { /** @var ProductCarrierRepository */ diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index 8d8d138b..1a203280 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProductSuppliersService implements ShopContentServiceInterface { /** @var ProductSupplierRepository */ diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index 04d7b4aa..3c5fbc5c 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProductsService implements ShopContentServiceInterface { /** @var ProductRepository */ diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index 5137f2e9..529d7317 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ShopDetailsService.php b/src/Service/ShopContent/ShopDetailsService.php index d8db2e57..4b4e4a6c 100644 --- a/src/Service/ShopContent/ShopDetailsService.php +++ b/src/Service/ShopContent/ShopDetailsService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; @@ -28,6 +26,10 @@ use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\ShopRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ShopDetailsService implements ShopContentServiceInterface { /** @var CurrenciesService */ diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php index 6ee09ec9..b8e55bb0 100644 --- a/src/Service/ShopContent/ThemesService.php +++ b/src/Service/ShopContent/ThemesService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManagerBuilder; +if (!defined('_PS_VERSION_')) { + exit; +} + class ThemesService implements ShopContentServiceInterface { /** @var \Context */ diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index 9a7c427f..f286e19d 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class WishlistProductsService implements ShopContentServiceInterface { /** @var WishlistProductRepository */ diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index 8ce1afa9..7db6c9fe 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -18,15 +18,17 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class WishlistsService implements ShopContentServiceInterface { /** @var WishlistRepository */ diff --git a/src/Service/SpecificPriceService.php b/src/Service/SpecificPriceService.php index 59ffc067..328849b4 100644 --- a/src/Service/SpecificPriceService.php +++ b/src/Service/SpecificPriceService.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class SpecificPriceService { /** @var array */ diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 41ce8dcf..be69c5d8 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Service; @@ -34,6 +32,10 @@ use PrestaShop\Module\PsEventbus\Service\ShopContent\ShopContentServiceInterface; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; +if (!defined('_PS_VERSION_')) { + exit; +} + class SynchronizationService { /** diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index c2e6cdd5..b4cc2271 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + namespace PrestaShop\Module\PsEventbus\Traits; diff --git a/translations/en.php b/translations/en.php index ce87b98a..cce97f2e 100644 --- a/translations/en.php +++ b/translations/en.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + global $_MODULE; $_MODULE = array(); diff --git a/translations/es.php b/translations/es.php index ece6efe4..a120e51c 100644 --- a/translations/es.php +++ b/translations/es.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + global $_MODULE; $_MODULE = array(); diff --git a/translations/fr.php b/translations/fr.php index 53c0f73b..6c389252 100644 --- a/translations/fr.php +++ b/translations/fr.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + global $_MODULE; $_MODULE = array(); diff --git a/translations/it.php b/translations/it.php index ce57df3f..482efa94 100644 --- a/translations/it.php +++ b/translations/it.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + global $_MODULE; $_MODULE = array(); diff --git a/upgrade/Upgrade-1.7.2.php b/upgrade/Upgrade-1.7.2.php index 71afa544..e60e8850 100644 --- a/upgrade/Upgrade-1.7.2.php +++ b/upgrade/Upgrade-1.7.2.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/upgrade/Upgrade-3.0.13.php b/upgrade/Upgrade-3.0.13.php index 50daf7a5..9085ccc6 100644 --- a/upgrade/Upgrade-3.0.13.php +++ b/upgrade/Upgrade-3.0.13.php @@ -18,9 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -if (!defined('_PS_VERSION_')) { - exit; -} + use PrestaShop\Module\PsEventbus\Config\Config; From 940538e08ea7973b33f487abfa80433706b41dd1 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 26 Sep 2024 19:01:03 +0200 Subject: [PATCH 092/162] fix: last problems --- .htaccess | 14 ++++++++++++++ .zip-contents | 1 + Makefile | 3 ++- OLD/Provider/CustomPriceDataProvider.php | 2 -- OLD/Provider/GoogleTaxonomyDataProvider.php | 2 -- OLD/Provider/ManufacturerDataProvider.php | 2 -- OLD/Provider/PaginatedApiDataProviderInterface.php | 2 -- OLD/Provider/StockDataProvider.php | 2 -- OLD/Provider/StoreDataProvider.php | 2 -- OLD/Provider/SupplierDataProvider.php | 2 -- OLD/Provider/TranslationDataProvider.php | 2 -- OLD/Provider/WishlistDataProvider.php | 2 -- controllers/front/apiFront.php | 2 -- ps_eventbus.php | 3 --- src/Api/CollectorApiClient.php | 2 -- src/Api/LiveSyncApiClient.php | 2 -- src/Api/Post/MultipartBody.php | 6 ++++-- src/Api/Post/PostFileApi.php | 6 ++++-- src/Api/Post/PostFileInterface.php | 6 ++++-- src/Api/Post/Stream.php | 6 ++++-- src/Api/SyncApiClient.php | 2 -- src/Config/Config.php | 2 -- src/Decorator/CustomPriceDecorator.php | 2 -- src/Decorator/ManufacturerDecorator.php | 2 -- src/Decorator/PayloadDecorator.php | 2 -- src/Decorator/StockDecorator.php | 2 -- src/Decorator/StoreDecorator.php | 2 -- src/Decorator/SupplierDecorator.php | 2 -- src/Decorator/TranslationDecorator.php | 2 -- src/DependencyInjection/ContainerProvider.php | 2 -- src/DependencyInjection/ServiceContainer.php | 2 -- src/Exception/ApiException.php | 2 -- src/Exception/EnvVarException.php | 2 -- src/Exception/FirebaseException.php | 2 -- src/Exception/HmacException.php | 2 -- .../PsAccountsRsaSignDataEmptyException.php | 2 -- src/Exception/QueryParamsException.php | 2 -- src/Exception/UnauthorizedException.php | 2 -- src/Exception/WebhookException.php | 2 -- src/Factory/ContextFactory.php | 2 -- src/Formatter/ArrayFormatter.php | 2 -- src/Formatter/JsonFormatter.php | 2 -- src/Handler/ErrorHandler/ErrorHandler.php | 7 ++++--- src/Handler/ErrorHandler/ErrorHandlerInterface.php | 6 ++++-- src/Helper/CarrierHelper.php | 2 -- src/Helper/ModuleHelper.php | 2 -- src/Module/Install.php | 2 -- src/Module/Uninstall.php | 2 -- src/Repository/ConfigurationRepository.php | 2 -- src/Repository/CountryRepository.php | 2 -- src/Repository/CustomPriceRepository.php | 2 -- src/Repository/EventbusSyncRepository.php | 2 -- src/Repository/GoogleTaxonomyRepository.php | 2 -- src/Repository/IncrementalSyncRepository.php | 2 -- .../NewRepository/AbstractRepository.php | 6 ++++-- src/Repository/NewRepository/CarrierRepository.php | 2 -- .../NewRepository/CartProductRepository.php | 2 -- src/Repository/NewRepository/CartRepository.php | 2 -- .../NewRepository/CartRuleRepository.php | 2 -- .../NewRepository/CategoryRepository.php | 2 -- .../NewRepository/CurrencyRepository.php | 2 -- .../NewRepository/CustomerRepository.php | 2 -- .../NewRepository/EmployeeRepository.php | 2 -- src/Repository/NewRepository/ImageRepository.php | 2 -- .../NewRepository/ImageTypeRepository.php | 2 -- .../NewRepository/LanguageRepository.php | 2 -- src/Repository/NewRepository/ModuleRepository.php | 2 -- .../NewRepository/OrderCartRuleRepository.php | 2 -- .../NewRepository/OrderDetailRepository.php | 2 -- .../NewRepository/OrderHistoryRepository.php | 2 -- src/Repository/NewRepository/OrderRepository.php | 2 -- .../NewRepository/ProductBundleRepository.php | 2 -- .../NewRepository/ProductCarrierRepository.php | 2 -- src/Repository/NewRepository/ProductRepository.php | 2 -- .../NewRepository/ProductSupplierRepository.php | 2 -- .../NewRepository/RepositoryInterface.php | 6 ++++-- .../NewRepository/WishlistProductRepository.php | 2 -- .../NewRepository/WishlistRepository.php | 2 -- src/Repository/ShopRepository.php | 2 -- src/Repository/SpecificPriceRepository.php | 2 -- src/Repository/StateRepository.php | 2 -- src/Repository/StockMvtRepository.php | 2 -- src/Repository/StockRepository.php | 2 -- src/Repository/StoreRepository.php | 2 -- src/Repository/SupplierRepository.php | 2 -- src/Repository/TaxeRepository.php | 2 -- src/Repository/TranslationRepository.php | 2 -- src/Service/ApiAuthorizationService.php | 2 -- src/Service/CommonService.php | 2 -- src/Service/FrontApiService.php | 2 -- src/Service/HealthCheckService.php | 2 -- src/Service/PresenterService.php | 2 -- src/Service/ProxyService.php | 2 -- src/Service/ProxyServiceInterface.php | 6 ++++-- src/Service/PsAccountsAdapterService.php | 2 -- src/Service/ShopContent/CarrierDetailsService.php | 2 -- src/Service/ShopContent/CarrierTaxesService.php | 2 -- src/Service/ShopContent/CarriersService.php | 2 -- src/Service/ShopContent/CartProductsService.php | 2 -- src/Service/ShopContent/CartRulesService.php | 2 -- src/Service/ShopContent/CartsService.php | 2 -- src/Service/ShopContent/CategoriesService.php | 2 -- src/Service/ShopContent/CurrenciesService.php | 2 -- src/Service/ShopContent/CustomersService.php | 2 -- src/Service/ShopContent/EmployeesService.php | 2 -- src/Service/ShopContent/ImageTypesService.php | 2 -- src/Service/ShopContent/ImagesService.php | 2 -- src/Service/ShopContent/LanguagesService.php | 2 -- src/Service/ShopContent/ModulesService.php | 2 -- src/Service/ShopContent/OrderCartRulesService.php | 2 -- src/Service/ShopContent/OrderDetailsService.php | 2 -- src/Service/ShopContent/OrderHistoriesService.php | 2 -- src/Service/ShopContent/OrdersService.php | 2 -- src/Service/ShopContent/ProductBundlesService.php | 2 -- src/Service/ShopContent/ProductCarriersService.php | 2 -- .../ShopContent/ProductSuppliersService.php | 2 -- src/Service/ShopContent/ProductsService.php | 2 -- .../ShopContent/ShopContentServiceInterface.php | 6 ++++-- src/Service/ShopContent/ShopDetailsService.php | 2 -- src/Service/ShopContent/ThemesService.php | 2 -- .../ShopContent/WishlistProductsService.php | 2 -- src/Service/ShopContent/WishlistsService.php | 2 -- src/Service/SpecificPriceService.php | 2 -- src/Service/SynchronizationService.php | 2 -- src/Traits/UseHooks.php | 6 ++++-- translations/en.php | 2 -- translations/es.php | 2 -- translations/fr.php | 2 -- translations/it.php | 2 -- upgrade/Upgrade-1.10.0.php | 3 +++ upgrade/Upgrade-1.10.3.php | 3 +++ upgrade/Upgrade-1.10.7.php | 3 +++ upgrade/Upgrade-1.10.8.php | 3 +++ upgrade/Upgrade-1.3.7.php | 3 +++ upgrade/Upgrade-1.5.1.php | 3 +++ upgrade/Upgrade-1.5.2.php | 3 +++ upgrade/Upgrade-1.6.9.php | 3 +++ upgrade/Upgrade-1.7.1.php | 3 +++ upgrade/Upgrade-1.7.11.php | 3 +++ upgrade/Upgrade-1.7.15.php | 3 +++ upgrade/Upgrade-1.7.2.php | 5 +++-- upgrade/Upgrade-1.8.1.php | 3 +++ upgrade/Upgrade-1.9.3.php | 3 +++ upgrade/Upgrade-1.9.7.php | 3 +++ upgrade/Upgrade-2.1.0.php | 3 +++ upgrade/Upgrade-2.3.0.php | 3 +++ upgrade/Upgrade-2.3.2.php | 3 +++ upgrade/Upgrade-3.0.0.php | 3 +++ upgrade/Upgrade-3.0.12.php | 3 +++ upgrade/Upgrade-3.0.13.php | 5 +++-- upgrade/Upgrade-3.0.5.php | 3 +++ upgrade/Upgrade-4.0.0.php | 3 +++ 152 files changed, 130 insertions(+), 259 deletions(-) create mode 100644 .htaccess diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000..3576e0c8 --- /dev/null +++ b/.htaccess @@ -0,0 +1,14 @@ +# Apache 2.2 + + + order allow,deny + deny from all + + + +# Apache 2.4 + + + Require all denied + + diff --git a/.zip-contents b/.zip-contents index 5d957751..49275582 100644 --- a/.zip-contents +++ b/.zip-contents @@ -11,3 +11,4 @@ LICENSE README.md composer.json composer.lock +.htaccess diff --git a/Makefile b/Makefile index bae8e55c..fcf9b246 100644 --- a/Makefile +++ b/Makefile @@ -157,7 +157,7 @@ docker-phpstan: tools/vendor # target: header-stamp - check Headers of PHP files .PHONY:header-stamp header-stamp: - tools/vendor/bin/header-stamp --license=tools/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,tools,e2e,e2e-env,tests,composer.json,scoper.inc.php + tools/vendor/bin/header-stamp --license=tools/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,tools,e2e,e2e-env,tests,composer.json,scoper.inc.php --dry-run define COMMENT Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this. @@ -183,6 +183,7 @@ define create_module cp -r $(shell cat .zip-contents) ${TMP_DIR}/${MODULE_NAME}; $(call replace_version,${TMP_DIR}/${MODULE_NAME},${SEM_VERSION}) ./tools/vendor/bin/autoindex prestashop:add:index ${TMP_DIR} + tools/vendor/bin/header-stamp --target=${TMP_DIR}/${MODULE_NAME} --license=tools/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,e2e,e2e-env,tests,composer.json,scoper.inc.php cp $1 ${TMP_DIR}/${MODULE_NAME}/config/parameters.yml cd ${TMP_DIR}/${MODULE_NAME} && composer dump-autoload endef diff --git a/OLD/Provider/CustomPriceDataProvider.php b/OLD/Provider/CustomPriceDataProvider.php index ede6fcbe..d3bc81ec 100644 --- a/OLD/Provider/CustomPriceDataProvider.php +++ b/OLD/Provider/CustomPriceDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/GoogleTaxonomyDataProvider.php b/OLD/Provider/GoogleTaxonomyDataProvider.php index d0e94756..e946257b 100644 --- a/OLD/Provider/GoogleTaxonomyDataProvider.php +++ b/OLD/Provider/GoogleTaxonomyDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/ManufacturerDataProvider.php b/OLD/Provider/ManufacturerDataProvider.php index 7c93bada..a5aba22f 100644 --- a/OLD/Provider/ManufacturerDataProvider.php +++ b/OLD/Provider/ManufacturerDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/PaginatedApiDataProviderInterface.php b/OLD/Provider/PaginatedApiDataProviderInterface.php index 0f51ad4c..d16b5558 100644 --- a/OLD/Provider/PaginatedApiDataProviderInterface.php +++ b/OLD/Provider/PaginatedApiDataProviderInterface.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; interface PaginatedApiDataProviderInterface diff --git a/OLD/Provider/StockDataProvider.php b/OLD/Provider/StockDataProvider.php index b95a20f4..3332c1c4 100644 --- a/OLD/Provider/StockDataProvider.php +++ b/OLD/Provider/StockDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/StoreDataProvider.php b/OLD/Provider/StoreDataProvider.php index d354dc2f..50b916cc 100644 --- a/OLD/Provider/StoreDataProvider.php +++ b/OLD/Provider/StoreDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/SupplierDataProvider.php b/OLD/Provider/SupplierDataProvider.php index 4563b5fe..bd4db1ef 100644 --- a/OLD/Provider/SupplierDataProvider.php +++ b/OLD/Provider/SupplierDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/TranslationDataProvider.php b/OLD/Provider/TranslationDataProvider.php index 82581430..25b0305b 100644 --- a/OLD/Provider/TranslationDataProvider.php +++ b/OLD/Provider/TranslationDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/OLD/Provider/WishlistDataProvider.php b/OLD/Provider/WishlistDataProvider.php index e481ab70..942fdb24 100644 --- a/OLD/Provider/WishlistDataProvider.php +++ b/OLD/Provider/WishlistDataProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Provider; use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 80abc31c..7a00c238 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - use PrestaShop\Module\PsEventbus\Service\FrontApiService; if (!defined('_PS_VERSION_')) { diff --git a/ps_eventbus.php b/ps_eventbus.php index b170dcec..5728289f 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -18,14 +18,11 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; use PrestaShop\Module\PsEventbus\Module\Install; use PrestaShop\Module\PsEventbus\Module\Uninstall; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; - require_once __DIR__ . '/vendor/autoload.php'; if (!defined('_PS_VERSION_')) { diff --git a/src/Api/CollectorApiClient.php b/src/Api/CollectorApiClient.php index 9157f4e7..13ec776a 100644 --- a/src/Api/CollectorApiClient.php +++ b/src/Api/CollectorApiClient.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Api; use GuzzleHttp\Psr7\Request; diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index efbc9858..5d3e3dfb 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Api; use GuzzleHttp\Psr7\Request; diff --git a/src/Api/Post/MultipartBody.php b/src/Api/Post/MultipartBody.php index 8381f375..9cc771e2 100755 --- a/src/Api/Post/MultipartBody.php +++ b/src/Api/Post/MultipartBody.php @@ -18,14 +18,16 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Api\Post; use GuzzleHttp\Psr7\AppendStream; use GuzzleHttp\Psr7\StreamDecoratorTrait; use Psr\Http\Message\StreamInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Stream that when read returns bytes for a streaming multipart/form-data body */ diff --git a/src/Api/Post/PostFileApi.php b/src/Api/Post/PostFileApi.php index 9831a3a5..0de358ac 100644 --- a/src/Api/Post/PostFileApi.php +++ b/src/Api/Post/PostFileApi.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Api\Post; use Psr\Http\Message\StreamInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Post file upload */ diff --git a/src/Api/Post/PostFileInterface.php b/src/Api/Post/PostFileInterface.php index 178eee11..661aeccb 100755 --- a/src/Api/Post/PostFileInterface.php +++ b/src/Api/Post/PostFileInterface.php @@ -18,12 +18,14 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Api\Post; use Psr\Http\Message\StreamInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * Post file upload interface */ diff --git a/src/Api/Post/Stream.php b/src/Api/Post/Stream.php index b1a505d3..faf58868 100644 --- a/src/Api/Post/Stream.php +++ b/src/Api/Post/Stream.php @@ -18,13 +18,15 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Api\Post; use GuzzleHttp\Psr7\PumpStream; use Psr\Http\Message\StreamInterface; +if (!defined('_PS_VERSION_')) { + exit; +} + /** * PHP stream implementation */ diff --git a/src/Api/SyncApiClient.php b/src/Api/SyncApiClient.php index 554fda6b..43b00b69 100644 --- a/src/Api/SyncApiClient.php +++ b/src/Api/SyncApiClient.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Api; use GuzzleHttp\Psr7\Request; diff --git a/src/Config/Config.php b/src/Config/Config.php index 4f600127..25ce7eec 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Config; if (!defined('_PS_VERSION_')) { diff --git a/src/Decorator/CustomPriceDecorator.php b/src/Decorator/CustomPriceDecorator.php index 7c015b54..95e0a7e2 100644 --- a/src/Decorator/CustomPriceDecorator.php +++ b/src/Decorator/CustomPriceDecorator.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Decorator; use PrestaShop\Module\PsEventbus\Service\SpecificPriceService; diff --git a/src/Decorator/ManufacturerDecorator.php b/src/Decorator/ManufacturerDecorator.php index ebe095f3..e5a13f99 100644 --- a/src/Decorator/ManufacturerDecorator.php +++ b/src/Decorator/ManufacturerDecorator.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Decorator; if (!defined('_PS_VERSION_')) { diff --git a/src/Decorator/PayloadDecorator.php b/src/Decorator/PayloadDecorator.php index 54adcdfe..fa74ca0d 100644 --- a/src/Decorator/PayloadDecorator.php +++ b/src/Decorator/PayloadDecorator.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Decorator; use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; diff --git a/src/Decorator/StockDecorator.php b/src/Decorator/StockDecorator.php index fec83a1f..20457e6b 100644 --- a/src/Decorator/StockDecorator.php +++ b/src/Decorator/StockDecorator.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Decorator; if (!defined('_PS_VERSION_')) { diff --git a/src/Decorator/StoreDecorator.php b/src/Decorator/StoreDecorator.php index e9fa2a89..66db4d77 100644 --- a/src/Decorator/StoreDecorator.php +++ b/src/Decorator/StoreDecorator.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Decorator; if (!defined('_PS_VERSION_')) { diff --git a/src/Decorator/SupplierDecorator.php b/src/Decorator/SupplierDecorator.php index afdca6e7..647880fd 100644 --- a/src/Decorator/SupplierDecorator.php +++ b/src/Decorator/SupplierDecorator.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Decorator; if (!defined('_PS_VERSION_')) { diff --git a/src/Decorator/TranslationDecorator.php b/src/Decorator/TranslationDecorator.php index 35bdfccd..7a34be10 100644 --- a/src/Decorator/TranslationDecorator.php +++ b/src/Decorator/TranslationDecorator.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Decorator; if (!defined('_PS_VERSION_')) { diff --git a/src/DependencyInjection/ContainerProvider.php b/src/DependencyInjection/ContainerProvider.php index 9e0fc8e7..12e17230 100644 --- a/src/DependencyInjection/ContainerProvider.php +++ b/src/DependencyInjection/ContainerProvider.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\DependencyInjection; use PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider; diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php index 571bb868..3b610d87 100644 --- a/src/DependencyInjection/ServiceContainer.php +++ b/src/DependencyInjection/ServiceContainer.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\DependencyInjection; use PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider; diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index 54535608..f9da2ef9 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Exception/EnvVarException.php b/src/Exception/EnvVarException.php index 810f3bbf..b3839b4b 100644 --- a/src/Exception/EnvVarException.php +++ b/src/Exception/EnvVarException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Exception/FirebaseException.php b/src/Exception/FirebaseException.php index b462e678..2a138a6a 100644 --- a/src/Exception/FirebaseException.php +++ b/src/Exception/FirebaseException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Exception/HmacException.php b/src/Exception/HmacException.php index 7a3fd859..35b2359f 100644 --- a/src/Exception/HmacException.php +++ b/src/Exception/HmacException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Exception/PsAccountsRsaSignDataEmptyException.php b/src/Exception/PsAccountsRsaSignDataEmptyException.php index d6a689c8..96b42a58 100644 --- a/src/Exception/PsAccountsRsaSignDataEmptyException.php +++ b/src/Exception/PsAccountsRsaSignDataEmptyException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Exception/QueryParamsException.php b/src/Exception/QueryParamsException.php index 85208244..e39c31ef 100644 --- a/src/Exception/QueryParamsException.php +++ b/src/Exception/QueryParamsException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Exception/UnauthorizedException.php b/src/Exception/UnauthorizedException.php index dfd86a08..48350f33 100644 --- a/src/Exception/UnauthorizedException.php +++ b/src/Exception/UnauthorizedException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Exception/WebhookException.php b/src/Exception/WebhookException.php index f5b3282f..b1c17f01 100644 --- a/src/Exception/WebhookException.php +++ b/src/Exception/WebhookException.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Exception; if (!defined('_PS_VERSION_')) { diff --git a/src/Factory/ContextFactory.php b/src/Factory/ContextFactory.php index f667774d..8a83ffb9 100644 --- a/src/Factory/ContextFactory.php +++ b/src/Factory/ContextFactory.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Factory; if (!defined('_PS_VERSION_')) { diff --git a/src/Formatter/ArrayFormatter.php b/src/Formatter/ArrayFormatter.php index 0e47cd99..5e8bdcdc 100644 --- a/src/Formatter/ArrayFormatter.php +++ b/src/Formatter/ArrayFormatter.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Formatter; if (!defined('_PS_VERSION_')) { diff --git a/src/Formatter/JsonFormatter.php b/src/Formatter/JsonFormatter.php index 28f6e7dd..4da26b0c 100644 --- a/src/Formatter/JsonFormatter.php +++ b/src/Formatter/JsonFormatter.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - namespace PrestaShop\Module\PsEventbus\Formatter; if (!defined('_PS_VERSION_')) { diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index cb7b5813..b977c0ae 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -1,5 +1,4 @@ ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/es.php b/translations/es.php index a120e51c..099f790e 100644 --- a/translations/es.php +++ b/translations/es.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/fr.php b/translations/fr.php index 6c389252..3b321736 100644 --- a/translations/fr.php +++ b/translations/fr.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/translations/it.php b/translations/it.php index 482efa94..b72aa739 100644 --- a/translations/it.php +++ b/translations/it.php @@ -18,8 +18,6 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - global $_MODULE; $_MODULE = array(); $_MODULE['<{ps_eventbus}prestashop>ps_eventbus_5aa8d80fbd2c1cd4eb908ed27db0e4f2'] = 'PrestaShop EventBus'; diff --git a/upgrade/Upgrade-1.10.0.php b/upgrade/Upgrade-1.10.0.php index be158c1d..cf9e4216 100644 --- a/upgrade/Upgrade-1.10.0.php +++ b/upgrade/Upgrade-1.10.0.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.10.3.php b/upgrade/Upgrade-1.10.3.php index 837f0940..dc8741be 100644 --- a/upgrade/Upgrade-1.10.3.php +++ b/upgrade/Upgrade-1.10.3.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.10.7.php b/upgrade/Upgrade-1.10.7.php index a18c380e..c4cd2710 100644 --- a/upgrade/Upgrade-1.10.7.php +++ b/upgrade/Upgrade-1.10.7.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.10.8.php b/upgrade/Upgrade-1.10.8.php index da02746e..c4e0cce6 100644 --- a/upgrade/Upgrade-1.10.8.php +++ b/upgrade/Upgrade-1.10.8.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.3.7.php b/upgrade/Upgrade-1.3.7.php index ee80dc91..38a2cd64 100644 --- a/upgrade/Upgrade-1.3.7.php +++ b/upgrade/Upgrade-1.3.7.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.5.1.php b/upgrade/Upgrade-1.5.1.php index 4daccc00..312bd4e3 100644 --- a/upgrade/Upgrade-1.5.1.php +++ b/upgrade/Upgrade-1.5.1.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.5.2.php b/upgrade/Upgrade-1.5.2.php index 31dd48e7..cc761d37 100644 --- a/upgrade/Upgrade-1.5.2.php +++ b/upgrade/Upgrade-1.5.2.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.6.9.php b/upgrade/Upgrade-1.6.9.php index e2e38e69..c5e9c749 100644 --- a/upgrade/Upgrade-1.6.9.php +++ b/upgrade/Upgrade-1.6.9.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.7.1.php b/upgrade/Upgrade-1.7.1.php index 49cb7fff..36a7b664 100644 --- a/upgrade/Upgrade-1.7.1.php +++ b/upgrade/Upgrade-1.7.1.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.7.11.php b/upgrade/Upgrade-1.7.11.php index 985e5c4d..898c34ac 100644 --- a/upgrade/Upgrade-1.7.11.php +++ b/upgrade/Upgrade-1.7.11.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.7.15.php b/upgrade/Upgrade-1.7.15.php index d37118bf..e8cc4d03 100644 --- a/upgrade/Upgrade-1.7.15.php +++ b/upgrade/Upgrade-1.7.15.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.7.2.php b/upgrade/Upgrade-1.7.2.php index e60e8850..77c6bd7a 100644 --- a/upgrade/Upgrade-1.7.2.php +++ b/upgrade/Upgrade-1.7.2.php @@ -17,8 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - +if (!defined('_PS_VERSION_')) { + exit; +} use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/upgrade/Upgrade-1.8.1.php b/upgrade/Upgrade-1.8.1.php index 11767f80..4005a56a 100644 --- a/upgrade/Upgrade-1.8.1.php +++ b/upgrade/Upgrade-1.8.1.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-1.9.3.php b/upgrade/Upgrade-1.9.3.php index 58285c02..4c26dbb7 100644 --- a/upgrade/Upgrade-1.9.3.php +++ b/upgrade/Upgrade-1.9.3.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @param Ps_eventbus $module diff --git a/upgrade/Upgrade-1.9.7.php b/upgrade/Upgrade-1.9.7.php index df0bdef0..5bf2ea51 100644 --- a/upgrade/Upgrade-1.9.7.php +++ b/upgrade/Upgrade-1.9.7.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-2.1.0.php b/upgrade/Upgrade-2.1.0.php index de03248f..3a1a2583 100644 --- a/upgrade/Upgrade-2.1.0.php +++ b/upgrade/Upgrade-2.1.0.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-2.3.0.php b/upgrade/Upgrade-2.3.0.php index 5458f900..b354f786 100644 --- a/upgrade/Upgrade-2.3.0.php +++ b/upgrade/Upgrade-2.3.0.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-2.3.2.php b/upgrade/Upgrade-2.3.2.php index 5734e9f2..975dc718 100644 --- a/upgrade/Upgrade-2.3.2.php +++ b/upgrade/Upgrade-2.3.2.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-3.0.0.php b/upgrade/Upgrade-3.0.0.php index bd2b483f..fa7f8b5b 100644 --- a/upgrade/Upgrade-3.0.0.php +++ b/upgrade/Upgrade-3.0.0.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-3.0.12.php b/upgrade/Upgrade-3.0.12.php index 40dcc2e4..e8a84a76 100644 --- a/upgrade/Upgrade-3.0.12.php +++ b/upgrade/Upgrade-3.0.12.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-3.0.13.php b/upgrade/Upgrade-3.0.13.php index 9085ccc6..ab5bb061 100644 --- a/upgrade/Upgrade-3.0.13.php +++ b/upgrade/Upgrade-3.0.13.php @@ -17,8 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ - - +if (!defined('_PS_VERSION_')) { + exit; +} use PrestaShop\Module\PsEventbus\Config\Config; diff --git a/upgrade/Upgrade-3.0.5.php b/upgrade/Upgrade-3.0.5.php index 8456449c..1f09d410 100644 --- a/upgrade/Upgrade-3.0.5.php +++ b/upgrade/Upgrade-3.0.5.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index 63cbe509..38a48e36 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -17,6 +17,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool From 7d285a1fef59fb848449c3c35122c98e53d49fe4 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Fri, 27 Sep 2024 18:36:19 +0200 Subject: [PATCH 093/162] feat: add manufacturers (#375) --- OLD/Provider/ManufacturerDataProvider.php | 127 -------------- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 6 + e2e/src/helpers/shop-contents.ts | 3 +- src/Decorator/ManufacturerDecorator.php | 55 ------ src/Repository/ManufacturerRepository.php | 158 ------------------ .../NewRepository/ManufacturerRepository.php | 128 ++++++++++++++ .../ShopContent/ManufacturersService.php | 122 ++++++++++++++ 9 files changed, 261 insertions(+), 348 deletions(-) delete mode 100644 OLD/Provider/ManufacturerDataProvider.php delete mode 100644 src/Decorator/ManufacturerDecorator.php delete mode 100644 src/Repository/ManufacturerRepository.php create mode 100644 src/Repository/NewRepository/ManufacturerRepository.php create mode 100644 src/Service/ShopContent/ManufacturersService.php diff --git a/OLD/Provider/ManufacturerDataProvider.php b/OLD/Provider/ManufacturerDataProvider.php deleted file mode 100644 index a5aba22f..00000000 --- a/OLD/Provider/ManufacturerDataProvider.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\ManufacturerDecorator; -use PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class ManufacturerDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var ManufacturerRepository - */ - private $manufacturerRepository; - - /** - * @var ManufacturerDecorator - */ - private $manufacturerDecorator; - - public function __construct(ManufacturerRepository $manufacturerRepository, ManufacturerDecorator $manufacturerDecorator) - { - $this->manufacturerRepository = $manufacturerRepository; - $this->manufacturerDecorator = $manufacturerDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $manufacturers = $this->manufacturerRepository->getManufacturers($offset, $limit, $langIso); - - if (!is_array($manufacturers)) { - return []; - } - $this->manufacturerDecorator->decorateManufacturers($manufacturers); - - return array_map(function ($manufacturer) { - return [ - 'id' => $manufacturer['id_manufacturer'], - 'collection' => Config::COLLECTION_MANUFACTURERS, - 'properties' => $manufacturer, - ]; - }, $manufacturers); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->manufacturerRepository->getRemainingManufacturersCount($offset, $langIso); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $manufacturers = $this->manufacturerRepository->getManufacturersIncremental($limit, $langIso, $objectIds); - - if (!is_array($manufacturers)) { - return []; - } - $this->manufacturerDecorator->decorateManufacturers($manufacturers); - - return array_map(function ($manufacturer) { - return [ - 'id' => $manufacturer['id_manufacturer'], - 'collection' => Config::COLLECTION_MANUFACTURERS, - 'properties' => $manufacturer, - ]; - }, $manufacturers); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->manufacturerRepository->getQueryForDebug($offset, $limit, $langIso); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 80a69c48..7c993a2f 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -86,3 +86,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 56fcaefc..a77ac38f 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -66,12 +66,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\StockMvtRepository public: true - PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository: - class: PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\SupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\SupplierRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 4791b13f..cd77e2d3 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -223,3 +223,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index a690e0d5..92c21e56 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -8,9 +8,7 @@ import R from "ramda"; 'stores': 'stores', 'stocks': 'stocks', 'stock_movements': 'stock-movements', - 'manufacturers': 'manufacturers', 'suppliers': 'suppliers', - 'languages': 'languages', 'translations': 'translations', } as const; */ @@ -28,6 +26,7 @@ export const shopContentMapping = { images: "images", image_types: "image-types", languages: "languages", + manufacturers: "manufacturers", modules: "modules", orders: "orders", order_cart_rules: "order-cart-rules", diff --git a/src/Decorator/ManufacturerDecorator.php b/src/Decorator/ManufacturerDecorator.php deleted file mode 100644 index e5a13f99..00000000 --- a/src/Decorator/ManufacturerDecorator.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Decorator; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class ManufacturerDecorator -{ - /** - * @param array $manufacturers - * - * @return void - */ - public function decorateManufacturers(&$manufacturers) - { - foreach ($manufacturers as &$manufacturer) { - $this->castPropertyValues($manufacturer); - } - } - - /** - * @param array $manufacturer - * - * @return void - */ - private function castPropertyValues(&$manufacturer) - { - $manufacturer['id_manufacturer'] = (int) $manufacturer['id_manufacturer']; - $manufacturer['active'] = (bool) $manufacturer['active']; - $manufacturer['id_lang'] = (int) $manufacturer['id_lang']; - $manufacturer['id_shop'] = (int) $manufacturer['id_shop']; - $manufacturer['created_at'] = (string) $manufacturer['created_at']; - $manufacturer['updated_at'] = (string) $manufacturer['updated_at']; - } -} diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php deleted file mode 100644 index ad70c2e4..00000000 --- a/src/Repository/ManufacturerRepository.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class ManufacturerRepository -{ - /** - * @var \Db - */ - private $db; - - /** - * @var \Context - */ - private $context; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getManufacturers($offset, $limit, $langIso) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingManufacturersCount($offset, $langIso) - { - $query = $this->getBaseQuery($langIso) - ->select('(COUNT(ma.id_manufacturer) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $manufacturerIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getManufacturersIncremental($limit, $langIso, $manufacturerIds) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->where('ma.id_manufacturer IN(' . implode(',', array_map('intval', $manufacturerIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param string $langIso - * - * @return \DbQuery - */ - public function getBaseQuery($langIso) - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - /** @var int $langId */ - $langId = (int) \Language::getIdByIso($langIso); - $query = new \DbQuery(); - $query->from('manufacturer', 'ma') - ->innerJoin('manufacturer_lang', 'mal', 'ma.id_manufacturer = mal.id_manufacturer AND mal.id_lang = ' . (int) $langId) - ->innerJoin('manufacturer_shop', 'mas', 'ma.id_manufacturer = mas.id_manufacturer AND mas.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('ma.id_manufacturer, ma.name, ma.date_add as created_at, ma.date_upd as updated_at, ma.active, mal.id_lang'); - $query->select('mal.description, mal.short_description, mal.meta_title, mal.meta_keywords, mal.meta_description, mas.id_shop'); - } -} diff --git a/src/Repository/NewRepository/ManufacturerRepository.php b/src/Repository/NewRepository/ManufacturerRepository.php new file mode 100644 index 00000000..f39cd2e5 --- /dev/null +++ b/src/Repository/NewRepository/ManufacturerRepository.php @@ -0,0 +1,128 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class ManufacturerRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'manufacturer'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'ma'); + + $this->query + ->innerJoin('manufacturer_lang', 'mal', 'ma.id_manufacturer = mal.id_manufacturer AND mal.id_lang = ' . (int) parent::getShopContext()->id) + ->innerJoin('manufacturer_shop', 'mas', 'ma.id_manufacturer = mas.id_manufacturer AND mas.id_shop = ' . (int) parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('ma.id_manufacturer') + ->select('ma.name') + ->select('ma.date_add as created_at') + ->select('ma.date_upd as updated_at') + ->select('ma.active') + ->select('mal.id_lang') + ->select('mal.description') + ->select('mal.short_description') + ->select('mal.meta_title') + ->select('mal.meta_keywords') + ->select('mal.meta_description') + ->select('mas.id_shop') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('la.id_manufacturer IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Service/ShopContent/ManufacturersService.php b/src/Service/ShopContent/ManufacturersService.php new file mode 100644 index 00000000..27274444 --- /dev/null +++ b/src/Service/ShopContent/ManufacturersService.php @@ -0,0 +1,122 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class ManufacturersService implements ShopContentServiceInterface +{ + /** @var ManufacturerRepository */ + private $manufacturerRepository; + + public function __construct(ManufacturerRepository $manufacturerRepository) + { + $this->manufacturerRepository = $manufacturerRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->manufacturerRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castManufacturers($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_manufacturer'], + 'collection' => Config::COLLECTION_MANUFACTURERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->manufacturerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castManufacturers($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_manufacturer'], + 'collection' => Config::COLLECTION_MANUFACTURERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->manufacturerRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $manufacturers + * + * @return void + */ + private function castManufacturers(&$manufacturers) + { + foreach ($manufacturers as &$manufacturer) { + $manufacturer['id_manufacturer'] = (int) $manufacturer['id_manufacturer']; + $manufacturer['active'] = (bool) $manufacturer['active']; + $manufacturer['id_lang'] = (int) $manufacturer['id_lang']; + $manufacturer['id_shop'] = (int) $manufacturer['id_shop']; + $manufacturer['created_at'] = (string) $manufacturer['created_at']; + $manufacturer['updated_at'] = (string) $manufacturer['updated_at']; + } + } +} From d2f63f5d5651f347b79eee90e8b70fe6d466de41 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:24:53 +0200 Subject: [PATCH 094/162] feat: pseventbus v4 translations (#376) --- OLD/Provider/TranslationDataProvider.php | 142 ----------------- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 6 + e2e/src/fixtures/1.6/translations.json | 1 + e2e/src/fixtures/1.7/translations.json | 1 + e2e/src/fixtures/8/translations.json | 1 + e2e/src/fixtures/9/translations.json | 1 + e2e/src/helpers/shop-contents.ts | 2 +- src/Decorator/TranslationDecorator.php | 55 ------- .../NewRepository/ManufacturerRepository.php | 2 +- .../NewRepository/TranslationRepository.php | 118 ++++++++++++++ .../WishlistProductRepository.php | 2 +- .../NewRepository/WishlistRepository.php | 2 +- src/Repository/TranslationRepository.php | 145 ------------------ .../ShopContent/TranslationsService.php | 123 +++++++++++++++ 16 files changed, 259 insertions(+), 352 deletions(-) delete mode 100644 OLD/Provider/TranslationDataProvider.php create mode 100644 e2e/src/fixtures/1.6/translations.json create mode 100644 e2e/src/fixtures/1.7/translations.json create mode 100644 e2e/src/fixtures/8/translations.json create mode 100644 e2e/src/fixtures/9/translations.json delete mode 100644 src/Decorator/TranslationDecorator.php create mode 100644 src/Repository/NewRepository/TranslationRepository.php delete mode 100644 src/Repository/TranslationRepository.php create mode 100644 src/Service/ShopContent/TranslationsService.php diff --git a/OLD/Provider/TranslationDataProvider.php b/OLD/Provider/TranslationDataProvider.php deleted file mode 100644 index 25b0305b..00000000 --- a/OLD/Provider/TranslationDataProvider.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\TranslationDecorator; -use PrestaShop\Module\PsEventbus\Repository\TranslationRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class TranslationDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var TranslationRepository - */ - private $translationRepository; - - /** - * @var TranslationDecorator - */ - private $translationDecorator; - - public function __construct(TranslationRepository $translationRepository, TranslationDecorator $translationDecorator) - { - $this->translationRepository = $translationRepository; - $this->translationDecorator = $translationDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - // translations are stored as xml files before version 1.7 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '<')) { - return []; - } - - $translations = $this->translationRepository->getTranslations($offset, $limit); - - if (!is_array($translations)) { - return []; - } - $this->translationDecorator->decorateTranslations($translations); - - return array_map(function ($translation) { - return [ - 'id' => $translation['id_lang'], - 'collection' => Config::COLLECTION_TRANSLATIONS, - 'properties' => $translation, - ]; - }, $translations); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - // translations are stored as xml files before version 1.7 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '<')) { - return 0; - } - - return (int) $this->translationRepository->getRemainingTranslationsCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - // translations are stored as xml files before version 1.7 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7', '<')) { - return []; - } - - $translations = $this->translationRepository->getTranslationsIncremental($limit, $objectIds); - - if (!is_array($translations)) { - return []; - } - $this->translationDecorator->decorateTranslations($translations); - - return array_map(function ($translation) { - return [ - 'id' => $translation['id_lang'], - 'collection' => Config::COLLECTION_TRANSLATIONS, - 'properties' => $translation, - ]; - }, $translations); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->translationRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 7c993a2f..5a9f99eb 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -90,3 +90,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index a77ac38f..02e860cd 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -72,12 +72,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\TranslationRepository: - class: PrestaShop\Module\PsEventbus\Repository\TranslationRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index cd77e2d3..11618f10 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -229,3 +229,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository' diff --git a/e2e/src/fixtures/1.6/translations.json b/e2e/src/fixtures/1.6/translations.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/translations.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/translations.json b/e2e/src/fixtures/1.7/translations.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/translations.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/translations.json b/e2e/src/fixtures/8/translations.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/translations.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/9/translations.json b/e2e/src/fixtures/9/translations.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/translations.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 92c21e56..96d80132 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -9,7 +9,6 @@ import R from "ramda"; 'stocks': 'stocks', 'stock_movements': 'stock-movements', 'suppliers': 'suppliers', - 'translations': 'translations', } as const; */ export const shopContentMapping = { @@ -38,6 +37,7 @@ export const shopContentMapping = { product_suppliers: "product-suppliers", shop_details: "shop-details", themes: "themes", + translations: "translations", wishlists: "wishlists", wishlist_products: "wishlist-products", } as const; diff --git a/src/Decorator/TranslationDecorator.php b/src/Decorator/TranslationDecorator.php deleted file mode 100644 index 7a34be10..00000000 --- a/src/Decorator/TranslationDecorator.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Decorator; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class TranslationDecorator -{ - /** - * @param array $translations - * - * @return void - */ - public function decorateTranslations(&$translations) - { - foreach ($translations as &$translation) { - $this->castPropertyValues($translation); - } - } - - /** - * @param array $translation - * - * @return void - */ - private function castPropertyValues(&$translation) - { - $translation['id_translation'] = (int) $translation['id_translation']; - $translation['id_lang'] = (int) $translation['id_lang']; - $translation['key'] = (string) $translation['key']; - $translation['translation'] = (string) $translation['translation']; - $translation['domain'] = (string) $translation['domain']; - $translation['theme'] = (string) $translation['theme']; - } -} diff --git a/src/Repository/NewRepository/ManufacturerRepository.php b/src/Repository/NewRepository/ManufacturerRepository.php index f39cd2e5..d21c6c01 100644 --- a/src/Repository/NewRepository/ManufacturerRepository.php +++ b/src/Repository/NewRepository/ManufacturerRepository.php @@ -98,7 +98,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d $this->generateFullQuery($langIso, true); $this->query - ->where('la.id_manufacturer IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('ma.id_manufacturer IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/NewRepository/TranslationRepository.php b/src/Repository/NewRepository/TranslationRepository.php new file mode 100644 index 00000000..523f2e89 --- /dev/null +++ b/src/Repository/NewRepository/TranslationRepository.php @@ -0,0 +1,118 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class TranslationRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'translation'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 't'); + + if ($withSelecParameters) { + $this->query + ->select('t.id_translation') + ->select('t.id_lang') + ->select('t.key') + ->select('t.translation') + ->select('t.domain') + ->select('t.theme') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('t.id_translation IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/NewRepository/WishlistProductRepository.php b/src/Repository/NewRepository/WishlistProductRepository.php index 8aa46f60..124082ff 100644 --- a/src/Repository/NewRepository/WishlistProductRepository.php +++ b/src/Repository/NewRepository/WishlistProductRepository.php @@ -93,7 +93,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d $this->generateFullQuery($langIso, true); $this->query - ->where('ps.id_wishlist IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('wp.id_wishlist IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/NewRepository/WishlistRepository.php b/src/Repository/NewRepository/WishlistRepository.php index 5ea1cd7a..4924b50d 100644 --- a/src/Repository/NewRepository/WishlistRepository.php +++ b/src/Repository/NewRepository/WishlistRepository.php @@ -99,7 +99,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d $this->generateFullQuery($langIso, true); $this->query - ->where('ps.id_wishlist IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('w.id_wishlist IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php deleted file mode 100644 index b7c48ff5..00000000 --- a/src/Repository/TranslationRepository.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class TranslationRepository -{ - /** - * @var \Db - */ - private $db; - - /** - * @var \Context - */ - private $context; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $query = new \DbQuery(); - $query->from('translation', 't'); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getTranslations($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingTranslationsCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(t.id_translation) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $translationIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getTranslationsIncremental($limit, $translationIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('t.id_translation IN(' . implode(',', array_map('intval', $translationIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('t.id_translation, t.id_lang, t.key, t.translation, t.domain, t.theme'); - } -} diff --git a/src/Service/ShopContent/TranslationsService.php b/src/Service/ShopContent/TranslationsService.php new file mode 100644 index 00000000..ccd473da --- /dev/null +++ b/src/Service/ShopContent/TranslationsService.php @@ -0,0 +1,123 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class TranslationsService implements ShopContentServiceInterface +{ + /** @var TranslationRepository */ + private $translationRepository; + + public function __construct(TranslationRepository $translationRepository) + { + $this->translationRepository = $translationRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->translationRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castTranslations($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_lang'], + 'collection' => Config::COLLECTION_TRANSLATIONS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->translationRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castTranslations($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_lang'], + 'collection' => Config::COLLECTION_TRANSLATIONS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->translationRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $translations + * @param string $langIso + * + * @return void + */ + private function castTranslations(&$translations, $langIso) + { + foreach ($translations as &$translation) { + $translation['id_translation'] = (int) $translation['id_translation']; + $translation['id_lang'] = (int) $translation['id_lang']; + $translation['key'] = (string) $translation['key']; + $translation['translation'] = (string) $translation['translation']; + $translation['domain'] = (string) $translation['domain']; + $translation['theme'] = (string) $translation['theme']; + } + } +} From b5cf102e65af6d9d0af09fa4d1e9d245092157ea Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:26:09 +0200 Subject: [PATCH 095/162] feat: add stock and stock mvmts (#377) --- OLD/Provider/StockDataProvider.php | 186 ------------------ config/common/new-repository.yml | 9 + config/common/repository.yml | 10 - config/front/services.yml | 12 ++ .../{stock_movements.json => stock_mvts.json} | 0 .../{stock_movements.json => stock_mvts.json} | 0 .../{stock_movements.json => stock_mvts.json} | 0 .../{stock_movements.json => stock_mvts.json} | 0 e2e/src/helpers/shop-contents.ts | 4 +- src/Config/Config.php | 2 +- src/Decorator/StockDecorator.php | 103 ---------- .../NewRepository/StockMvtRepository.php | 134 +++++++++++++ .../NewRepository/StockRepository.php | 135 +++++++++++++ src/Repository/StockMvtRepository.php | 86 -------- src/Repository/StockRepository.php | 181 ----------------- src/Service/ShopContent/StockMvtsService.php | 135 +++++++++++++ src/Service/ShopContent/StocksService.php | 132 +++++++++++++ 17 files changed, 560 insertions(+), 569 deletions(-) delete mode 100644 OLD/Provider/StockDataProvider.php rename e2e/src/fixtures/1.6/{stock_movements.json => stock_mvts.json} (100%) rename e2e/src/fixtures/1.7/{stock_movements.json => stock_mvts.json} (100%) rename e2e/src/fixtures/8/{stock_movements.json => stock_mvts.json} (100%) rename e2e/src/fixtures/9/{stock_movements.json => stock_mvts.json} (100%) delete mode 100644 src/Decorator/StockDecorator.php create mode 100644 src/Repository/NewRepository/StockMvtRepository.php create mode 100644 src/Repository/NewRepository/StockRepository.php delete mode 100644 src/Repository/StockMvtRepository.php delete mode 100644 src/Repository/StockRepository.php create mode 100644 src/Service/ShopContent/StockMvtsService.php create mode 100644 src/Service/ShopContent/StocksService.php diff --git a/OLD/Provider/StockDataProvider.php b/OLD/Provider/StockDataProvider.php deleted file mode 100644 index 3332c1c4..00000000 --- a/OLD/Provider/StockDataProvider.php +++ /dev/null @@ -1,186 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\StockDecorator; -use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Repository\StockMvtRepository; -use PrestaShop\Module\PsEventbus\Repository\StockRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StockDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var StockRepository - */ - private $stockRepository; - /** - * @var StockMvtRepository - */ - private $stockMvtRepository; - /** - * @var StockDecorator - */ - private $stockDecorator; - /** - * @var ArrayFormatter - */ - private $arrayFormatter; - - public function __construct( - StockRepository $stockRepository, - StockMvtRepository $stockMvtRepository, - StockDecorator $stockDecorator, - ArrayFormatter $arrayFormatter - ) { - $this->stockRepository = $stockRepository; - $this->stockMvtRepository = $stockMvtRepository; - $this->stockDecorator = $stockDecorator; - $this->arrayFormatter = $arrayFormatter; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $stocks = $this->stockRepository->getStocks($offset, $limit); - - if (empty($stocks)) { - return []; - } - $this->stockDecorator->decorateStocks($stocks); - - $stockMvts = $this->getStockMvts($langIso, $stocks); - - $stocks = array_map(function ($stock) { - return [ - 'id' => $stock['id_stock_available'], - 'collection' => Config::COLLECTION_STOCKS, - 'properties' => $stock, - ]; - }, $stocks); - - return array_merge($stocks, $stockMvts); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->stockRepository->getRemainingStocksCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $stocks = $this->stockRepository->getStocksIncremental($limit, $objectIds); - - if (!is_array($stocks) || empty($stocks)) { - return []; - } - - $this->stockDecorator->decorateStocks($stocks); - - $stockMvts = $this->getStockMvts($langIso, $stocks); - - $stocks = array_map(function ($stock) { - return [ - 'id' => $stock['id_stock_available'], - 'collection' => Config::COLLECTION_STOCKS, - 'properties' => $stock, - ]; - }, $stocks); - - return array_merge($stocks, $stockMvts); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->stockRepository->getQueryForDebug($offset, $limit); - } - - /** - * @param string $langIso - * @param array $stocks - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getStockMvts($langIso, $stocks) - { - if (empty($stocks)) { - return []; - } - - $stockIds = $this->arrayFormatter->formatValueArray($stocks, 'id_stock_available'); - - $stockMvts = $this->stockMvtRepository->getStockMvts($langIso, $stockIds); - - if (!is_array($stockMvts) || empty($stockMvts)) { - return []; - } - - $this->stockDecorator->decorateStockMvts($stockMvts); - - $stockMvts = array_map(function ($stockMvt) { - return [ - 'id' => $stockMvt['id_stock_mvt'], - 'collection' => Config::COLLECTION_STOCK_MVTS, - 'properties' => $stockMvt, - ]; - }, $stockMvts); - - return $stockMvts; - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 5a9f99eb..69b2f0f1 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -94,3 +94,12 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository + public: true + diff --git a/config/common/repository.yml b/config/common/repository.yml index 02e860cd..d9f9324a 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -56,16 +56,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\StockRepository: - class: PrestaShop\Module\PsEventbus\Repository\StockRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Repository\StockMvtRepository: - class: PrestaShop\Module\PsEventbus\Repository\StockMvtRepository - public: true - PrestaShop\Module\PsEventbus\Repository\SupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\SupplierRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 11618f10..d667c8b9 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -235,3 +235,15 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\StocksService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\StocksService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\StockMvtsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\StockMvtsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository' diff --git a/e2e/src/fixtures/1.6/stock_movements.json b/e2e/src/fixtures/1.6/stock_mvts.json similarity index 100% rename from e2e/src/fixtures/1.6/stock_movements.json rename to e2e/src/fixtures/1.6/stock_mvts.json diff --git a/e2e/src/fixtures/1.7/stock_movements.json b/e2e/src/fixtures/1.7/stock_mvts.json similarity index 100% rename from e2e/src/fixtures/1.7/stock_movements.json rename to e2e/src/fixtures/1.7/stock_mvts.json diff --git a/e2e/src/fixtures/8/stock_movements.json b/e2e/src/fixtures/8/stock_mvts.json similarity index 100% rename from e2e/src/fixtures/8/stock_movements.json rename to e2e/src/fixtures/8/stock_mvts.json diff --git a/e2e/src/fixtures/9/stock_movements.json b/e2e/src/fixtures/9/stock_mvts.json similarity index 100% rename from e2e/src/fixtures/9/stock_movements.json rename to e2e/src/fixtures/9/stock_mvts.json diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 96d80132..abb1f7c9 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -6,8 +6,6 @@ import R from "ramda"; 'specific_prices': 'specific-prices', 'taxonomies': 'taxonomies', 'stores': 'stores', - 'stocks': 'stocks', - 'stock_movements': 'stock-movements', 'suppliers': 'suppliers', } as const; */ @@ -36,6 +34,8 @@ export const shopContentMapping = { product_carriers: "product-carriers", product_suppliers: "product-suppliers", shop_details: "shop-details", + stocks: "stocks", + stock_mvts: "stock-mvts", themes: "themes", translations: "translations", wishlists: "wishlists", diff --git a/src/Config/Config.php b/src/Config/Config.php index 25ce7eec..4ed3a3ec 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -83,7 +83,7 @@ class Config const COLLECTION_SHOP_DETAILS = 'shop_details'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; const COLLECTION_STOCKS = 'stocks'; - const COLLECTION_STOCK_MVTS = 'stock_movements'; + const COLLECTION_STOCK_MVTS = 'stock_mvts'; const COLLECTION_STORES = 'stores'; const COLLECTION_SUPPLIERS = 'suppliers'; const COLLECTION_TAXONOMIES = 'taxonomies'; diff --git a/src/Decorator/StockDecorator.php b/src/Decorator/StockDecorator.php deleted file mode 100644 index 20457e6b..00000000 --- a/src/Decorator/StockDecorator.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Decorator; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StockDecorator -{ - /** - * @param array $stocks - * - * @return void - */ - public function decorateStocks(&$stocks) - { - foreach ($stocks as &$stock) { - $this->castStockPropertyValues($stock); - } - } - - /** - * @param array $stock - * - * @return void - */ - private function castStockPropertyValues(&$stock) - { - $stock['id_stock_available'] = (int) $stock['id_stock_available']; - $stock['id_product'] = (int) $stock['id_product']; - $stock['id_product_attribute'] = (int) $stock['id_product_attribute']; - $stock['id_shop'] = (int) $stock['id_shop']; - $stock['id_shop_group'] = (int) $stock['id_shop_group']; - $stock['quantity'] = (int) $stock['quantity']; - - $stock['depends_on_stock'] = (bool) $stock['depends_on_stock']; - $stock['out_of_stock'] = (bool) $stock['out_of_stock']; - - // https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.2.0', '>=')) { - $stock['physical_quantity'] = (int) $stock['physical_quantity']; - $stock['reserved_quantity'] = (int) $stock['reserved_quantity']; - } - } - - /** - * @param array $stockMvts - * - * @return void - */ - public function decorateStockMvts(&$stockMvts) - { - foreach ($stockMvts as &$stockMvt) { - $this->castStockMvtPropertyValues($stockMvt); - } - } - - /** - * @param array $stockMvt - * - * @return void - */ - private function castStockMvtPropertyValues(&$stockMvt) - { - $date = $stockMvt['date_add']; - - $stockMvt['id_stock_mvt'] = (int) $stockMvt['id_stock_mvt']; - $stockMvt['id_stock'] = (int) $stockMvt['id_stock']; - $stockMvt['id_order'] = (int) $stockMvt['id_order']; - $stockMvt['id_supply_order'] = (int) $stockMvt['id_supply_order']; - $stockMvt['id_stock_mvt_reason'] = (int) $stockMvt['id_stock_mvt_reason']; - $stockMvt['id_lang'] = (int) $stockMvt['id_lang']; - $stockMvt['id_employee'] = (int) $stockMvt['id_employee']; - $stockMvt['physical_quantity'] = (int) $stockMvt['physical_quantity']; - $stockMvt['date_add'] = $date; - $stockMvt['sign'] = (int) $stockMvt['sign']; - $stockMvt['price_te'] = (float) $stockMvt['price_te']; - $stockMvt['last_wa'] = (float) $stockMvt['last_wa']; - $stockMvt['current_wa'] = (float) $stockMvt['current_wa']; - $stockMvt['referer'] = (int) $stockMvt['referer']; - $stockMvt['deleted'] = (bool) $stockMvt['deleted']; - $stockMvt['created_at'] = $date; - } -} diff --git a/src/Repository/NewRepository/StockMvtRepository.php b/src/Repository/NewRepository/StockMvtRepository.php new file mode 100644 index 00000000..8150dd66 --- /dev/null +++ b/src/Repository/NewRepository/StockMvtRepository.php @@ -0,0 +1,134 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class StockMvtRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'stock_mvt'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'sm'); + + $this->query + ->innerJoin('stock_mvt_reason', 'smr', 'sm.id_stock_mvt_reason = smr.id_stock_mvt_reason') + ->innerJoin('stock_mvt_reason_lang', 'smrl', 'sm.id_stock_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang = ' . (int) parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('sm.id_stock_mvt') + ->select('sm.id_stock') + ->select('sm.id_order') + ->select('sm.id_supply_order') + ->select('sm.id_stock_mvt_reason') + ->select('smrl.name') + ->select('smrl.id_lang') + ->select('sm.id_employee') + ->select('sm.employee_lastname') + ->select('sm.employee_firstname') + ->select('sm.physical_quantity') + ->select('sm.date_add') + ->select('sm.sign') + ->select('sm.price_te') + ->select('sm.last_wa') + ->select('sm.current_wa') + ->select('sm.referer') + ->select('smr.deleted') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('sm.id_stock_mvt IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/NewRepository/StockRepository.php b/src/Repository/NewRepository/StockRepository.php new file mode 100644 index 00000000..f12386d5 --- /dev/null +++ b/src/Repository/NewRepository/StockRepository.php @@ -0,0 +1,135 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class StockRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'stock_available'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'sa'); + + $this->query->where('sa.id_shop = ' . (int) parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('sa.id_stock_available') + ->select('sa.id_product') + ->select('sa.id_product_attribute') + ->select('sa.id_shop') + ->select('sa.id_shop_group') + ->select('sa.quantity') + ->select('sa.depends_on_stock') + ->select('sa.out_of_stock') + ; + + // https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.2.0', '>=')) { + $this->query + ->select('sa.physical_quantity') + ->select('sa.reserved_quantity') + ; + } + + // https://github.com/PrestaShop/PrestaShop/commit/4c7d58a905dfb61c7fb2ef4a1f9b4fab2a8d8ecb#diff-e57fb1deeaab9e9079505333394d58f0bf7bb40280b4382aad1278c08c73e2e8R58 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.5.0', '>=')) { + $this->query->select('sa.location'); + } + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('s.id_stock_available IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/StockMvtRepository.php b/src/Repository/StockMvtRepository.php deleted file mode 100644 index 890bef66..00000000 --- a/src/Repository/StockMvtRepository.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StockMvtRepository -{ - /** - * @var \Db - */ - private $db; - - public function __construct() - { - $this->db = \Db::getInstance(); - } - - /** - * @param string $langIso - * - * @return \DbQuery - */ - public function getBaseQuery($langIso) - { - /** @var int $langId */ - $langId = (int) \Language::getIdByIso($langIso); - $query = new \DbQuery(); - $query->from('stock_mvt', 'sm') - ->innerJoin('stock_mvt_reason', 'smr', 'sm.id_stock_mvt_reason = smr.id_stock_mvt_reason') - ->innerJoin('stock_mvt_reason_lang', 'smrl', 'sm.id_stock_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang = ' . (int) $langId); - - return $query; - } - - /** - * @param string $langIso - * @param array $stockIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getStockMvts($langIso, $stockIds) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->where('sm.id_stock IN(' . implode(',', array_map('intval', $stockIds)) . ')'); - - return $this->db->executeS($query); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('sm.id_stock_mvt, sm.id_stock, sm.id_order, sm.id_supply_order, sm.id_stock_mvt_reason, smrl.name, smrl.id_lang'); - $query->select('sm.id_employee, sm.employee_lastname, sm.employee_firstname, sm.physical_quantity, sm.date_add, sm.sign, sm.price_te'); - $query->select('sm.last_wa, sm.current_wa, sm.referer, smr.deleted'); - } -} diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php deleted file mode 100644 index f5bb4b44..00000000 --- a/src/Repository/StockRepository.php +++ /dev/null @@ -1,181 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StockRepository -{ - /** - * @var \Db - */ - private $db; - - /** - * @var \Context - */ - private $context; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - $query->from('stock_available', 'sa') - ->where('sa.id_shop = ' . (int) $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getStocks($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * - * @return int - */ - public function getRemainingStocksCount($offset) - { - $query = $this->getBaseQuery() - ->select('(COUNT(sa.id_stock_available) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param array $productIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getStocksIncremental($limit, $productIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('sa.id_product IN(' . implode(',', array_map('intval', $productIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param array $productIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getStocksIdsByProductIds($productIds) - { - if (!$productIds) { - return []; - } - - $query = $this->getBaseQuery(); - - $query->select('sa.id_stock_available as id'); - $query->where('sa.id_product IN (' . implode(',', array_map('intval', $productIds)) . ')'); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('sa.id_stock_available, sa.id_product, sa.id_product_attribute, sa.id_shop, sa.id_shop_group'); - $query->select('sa.quantity, sa.depends_on_stock, sa.out_of_stock'); - - // https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.2.0', '>=')) { - $query->select('sa.physical_quantity, sa.reserved_quantity'); - } - // https://github.com/PrestaShop/PrestaShop/commit/4c7d58a905dfb61c7fb2ef4a1f9b4fab2a8d8ecb#diff-e57fb1deeaab9e9079505333394d58f0bf7bb40280b4382aad1278c08c73e2e8R58 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.5.0', '>=')) { - $query->select('sa.location'); - } - } -} diff --git a/src/Service/ShopContent/StockMvtsService.php b/src/Service/ShopContent/StockMvtsService.php new file mode 100644 index 00000000..2573c762 --- /dev/null +++ b/src/Service/ShopContent/StockMvtsService.php @@ -0,0 +1,135 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class StockMvtsService implements ShopContentServiceInterface +{ + /** @var StockMvtRepository */ + private $stockMvtRepository; + + public function __construct(StockMvtRepository $stockMvtRepository) + { + $this->stockMvtRepository = $stockMvtRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->stockMvtRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castStockMvts($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_stock_mvt'], + 'collection' => Config::COLLECTION_STOCK_MVTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->stockMvtRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castStockMvts($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_stock_mvt'], + 'collection' => Config::COLLECTION_STOCK_MVTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->stockMvtRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $stockMvts + * @param string $langIso + * + * @return void + */ + private function castStockMvts(&$stockMvts, $langIso) + { + foreach ($stockMvts as &$stockMvt) { + $date = $stockMvt['date_add']; + + $stockMvt['id_stock_mvt'] = (int) $stockMvt['id_stock_mvt']; + $stockMvt['id_stock'] = (int) $stockMvt['id_stock']; + $stockMvt['id_order'] = (int) $stockMvt['id_order']; + $stockMvt['id_supply_order'] = (int) $stockMvt['id_supply_order']; + $stockMvt['id_stock_mvt_reason'] = (int) $stockMvt['id_stock_mvt_reason']; + $stockMvt['id_lang'] = (int) $stockMvt['id_lang']; + $stockMvt['id_employee'] = (int) $stockMvt['id_employee']; + $stockMvt['physical_quantity'] = (int) $stockMvt['physical_quantity']; + $stockMvt['date_add'] = $date; + $stockMvt['sign'] = (int) $stockMvt['sign']; + $stockMvt['price_te'] = (float) $stockMvt['price_te']; + $stockMvt['last_wa'] = (float) $stockMvt['last_wa']; + $stockMvt['current_wa'] = (float) $stockMvt['current_wa']; + $stockMvt['referer'] = (int) $stockMvt['referer']; + $stockMvt['deleted'] = (bool) $stockMvt['deleted']; + $stockMvt['created_at'] = $date; + } + } +} diff --git a/src/Service/ShopContent/StocksService.php b/src/Service/ShopContent/StocksService.php new file mode 100644 index 00000000..51f8be60 --- /dev/null +++ b/src/Service/ShopContent/StocksService.php @@ -0,0 +1,132 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class StocksService implements ShopContentServiceInterface +{ + /** @var StockRepository */ + private $stockRepository; + + public function __construct(StockRepository $stockRepository) + { + $this->stockRepository = $stockRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->stockRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castStocks($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_stock_available'], + 'collection' => Config::COLLECTION_STOCKS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->stockRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castStocks($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_stock_available'], + 'collection' => Config::COLLECTION_STOCKS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->stockRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $stocks + * @param string $langIso + * + * @return void + */ + private function castStocks(&$stocks, $langIso) + { + foreach ($stocks as &$stock) { + $stock['id_stock_available'] = (int) $stock['id_stock_available']; + $stock['id_product'] = (int) $stock['id_product']; + $stock['id_product_attribute'] = (int) $stock['id_product_attribute']; + $stock['id_shop'] = (int) $stock['id_shop']; + $stock['id_shop_group'] = (int) $stock['id_shop_group']; + $stock['quantity'] = (int) $stock['quantity']; + + $stock['depends_on_stock'] = (bool) $stock['depends_on_stock']; + $stock['out_of_stock'] = (bool) $stock['out_of_stock']; + + // https://github.com/PrestaShop/PrestaShop/commit/2a3269ad93b1985f2615d6604458061d4989f0ea#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2186 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.2.0', '>=')) { + $stock['physical_quantity'] = (int) $stock['physical_quantity']; + $stock['reserved_quantity'] = (int) $stock['reserved_quantity']; + } + } + } +} From 92db6fc969e5448ead601f88e9c26fe60fbc7522 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:30:37 +0200 Subject: [PATCH 096/162] feat: pseventbus v4 specific prices (#378) --- OLD/Provider/CustomPriceDataProvider.php | 128 ---- config/common/decorator.yml | 27 - config/common/new-repository.yml | 3 + config/common/repository.yml | 10 - config/front/services.yml | 13 +- e2e/src/helpers/shop-contents.ts | 2 +- src/Decorator/CustomPriceDecorator.php | 160 ----- src/Repository/CustomPriceRepository.php | 168 ------ .../NewRepository/CustomerRepository.php | 3 +- .../NewRepository/ProductRepository.php | 38 ++ .../NewRepository/SpecificPriceRepository.php | 177 ++++++ src/Repository/SpecificPriceRepository.php | 82 --- .../ShopContent/SpecificPricesService.php | 547 ++++++++++++++++++ src/Service/SpecificPriceService.php | 413 ------------- tests/phpstan/phpstan.neon | 4 +- 15 files changed, 777 insertions(+), 998 deletions(-) delete mode 100644 OLD/Provider/CustomPriceDataProvider.php delete mode 100644 src/Decorator/CustomPriceDecorator.php delete mode 100644 src/Repository/CustomPriceRepository.php create mode 100644 src/Repository/NewRepository/SpecificPriceRepository.php delete mode 100644 src/Repository/SpecificPriceRepository.php create mode 100644 src/Service/ShopContent/SpecificPricesService.php delete mode 100644 src/Service/SpecificPriceService.php diff --git a/OLD/Provider/CustomPriceDataProvider.php b/OLD/Provider/CustomPriceDataProvider.php deleted file mode 100644 index d3bc81ec..00000000 --- a/OLD/Provider/CustomPriceDataProvider.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\CustomPriceDecorator; -use PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class CustomPriceDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var CustomPriceRepository - */ - private $customPriceRepository; - /** - * @var CustomPriceDecorator - */ - private $customPriceDecorator; - - public function __construct( - CustomPriceRepository $customPriceRepository, - CustomPriceDecorator $customPriceDecorator - ) { - $this->customPriceRepository = $customPriceRepository; - $this->customPriceDecorator = $customPriceDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $specificPrices = $this->customPriceRepository->getSpecificPrices($offset, $limit); - - $this->customPriceDecorator->decorateSpecificPrices($specificPrices); - - return array_map(function ($specificPrice) { - return [ - 'id' => $specificPrice['id_specific_price'], - 'collection' => Config::COLLECTION_SPECIFIC_PRICES, - 'properties' => $specificPrice, - ]; - }, $specificPrices); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - * - * @@throws \PrestaShopDatabaseException - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->customPriceRepository->getRemainingSpecificPricesCount($offset); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $specificPrices = $this->customPriceRepository->getSpecificPricesIncremental($limit, $objectIds); - - if (!empty($specificPrices)) { - $this->customPriceDecorator->decorateSpecificPrices($specificPrices); - } else { - return []; - } - - return array_map(function ($specificPrice) { - return [ - 'id' => $specificPrice['id_specific_price'], - 'collection' => Config::COLLECTION_SPECIFIC_PRICES, - 'properties' => $specificPrice, - ]; - }, $specificPrices); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->customPriceRepository->getQueryForDebug($offset, $limit); - } -} diff --git a/config/common/decorator.yml b/config/common/decorator.yml index 1879f558..9166e823 100644 --- a/config/common/decorator.yml +++ b/config/common/decorator.yml @@ -5,37 +5,10 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - PrestaShop\Module\PsEventbus\Decorator\CustomPriceDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\CustomPriceDecorator - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Service\SpecificPriceService' - - PrestaShop\Module\PsEventbus\Decorator\WishlistDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\WishlistDecorator - public: true - PrestaShop\Module\PsEventbus\Decorator\StoreDecorator: class: PrestaShop\Module\PsEventbus\Decorator\StoreDecorator public: true - PrestaShop\Module\PsEventbus\Decorator\StockDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\StockDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\ManufacturerDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\ManufacturerDecorator - public: true - PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator: class: PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator public: true - - PrestaShop\Module\PsEventbus\Decorator\LanguageDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\LanguageDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\TranslationDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\TranslationDecorator - public: true diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 69b2f0f1..f8fe8ed1 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -103,3 +103,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository public: true + PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index d9f9324a..dd409c13 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -40,16 +40,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository: - class: PrestaShop\Module\PsEventbus\Repository\CustomPriceRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository: - class: PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository - public: true - PrestaShop\Module\PsEventbus\Repository\StoreRepository: class: PrestaShop\Module\PsEventbus\Repository\StoreRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index d667c8b9..695842e9 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -24,12 +24,6 @@ services: - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - '@PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator' - PrestaShop\Module\PsEventbus\Service\SpecificPriceService: - class: PrestaShop\Module\PsEventbus\Service\SpecificPriceService - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository' - public: true - PrestaShop\Module\PsEventbus\Service\PresenterService: class: PrestaShop\Module\PsEventbus\Service\PresenterService public: true @@ -247,3 +241,10 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository' + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index abb1f7c9..dede594c 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -3,7 +3,6 @@ import R from "ramda"; // TEMPORARY DISABLED, WAIT ADD ALL SHOP CONTENT // AFTER UNCOMMENT THIS, CHANGE ALL "as ShopContent"CAST IN FULLSYNC TEST /* export const shopContentMapping = { - 'specific_prices': 'specific-prices', 'taxonomies': 'taxonomies', 'stores': 'stores', 'suppliers': 'suppliers', @@ -34,6 +33,7 @@ export const shopContentMapping = { product_carriers: "product-carriers", product_suppliers: "product-suppliers", shop_details: "shop-details", + specific_prices: "specific-prices", stocks: "stocks", stock_mvts: "stock-mvts", themes: "themes", diff --git a/src/Decorator/CustomPriceDecorator.php b/src/Decorator/CustomPriceDecorator.php deleted file mode 100644 index 95e0a7e2..00000000 --- a/src/Decorator/CustomPriceDecorator.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Decorator; - -use PrestaShop\Module\PsEventbus\Service\SpecificPriceService; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class CustomPriceDecorator -{ - /** - * @var \Context - */ - private $context; - /** - * @var SpecificPriceService - */ - private $priceService; - - public function __construct( - \Context $context, - SpecificPriceService $priceService - ) { - $this->context = $context; - $this->priceService = $priceService; - } - - /** - * @param array $specificPrices - * - * @return void - */ - public function decorateSpecificPrices(&$specificPrices) - { - foreach ($specificPrices as &$specificPrice) { - $this->addTotalPrice($specificPrice); - $this->setShopId($specificPrice); - $this->castPropertyValues($specificPrice); - } - } - - /** - * @param array $specificPrice - * - * @return void - */ - private function addTotalPrice(&$specificPrice) - { - $this->context->country = new \Country($specificPrice['id_country']); - $this->context->currency = new \Currency($specificPrice['id_currency']); - - $specificPrice['price_tax_included'] = $this->priceService->getSpecificProductPrice( - $specificPrice['id_product'], - $specificPrice['id_product_attribute'], - $specificPrice['id_specific_price'], - true, - false, - $this->context - ); - - $specificPrice['price_tax_excluded'] = $this->priceService->getSpecificProductPrice( - $specificPrice['id_product'], - $specificPrice['id_product_attribute'], - $specificPrice['id_specific_price'], - false, - false, - $this->context - ); - $specificPrice['sale_price_tax_incl'] = $this->priceService->getSpecificProductPrice( - $specificPrice['id_product'], - $specificPrice['id_product_attribute'], - $specificPrice['id_specific_price'], - true, - true, - $this->context - ); - $specificPrice['sale_price_tax_excl'] = $this->priceService->getSpecificProductPrice( - $specificPrice['id_product'], - $specificPrice['id_product_attribute'], - $specificPrice['id_specific_price'], - false, - true, - $this->context - ); - } - - /** - * @param array $specificPrice - * - * @return void - */ - private function castPropertyValues(&$specificPrice) - { - $specificPrice['id_specific_price'] = (int) $specificPrice['id_specific_price']; - $specificPrice['id_product'] = (int) $specificPrice['id_product']; - $specificPrice['id_shop'] = (int) $specificPrice['id_shop']; - $specificPrice['id_group'] = (int) $specificPrice['id_group']; - $specificPrice['id_shop_group'] = (int) $specificPrice['id_shop_group']; - $specificPrice['id_product_attribute'] = (int) $specificPrice['id_product_attribute']; - $specificPrice['price'] = (float) $specificPrice['price']; - $specificPrice['from_quantity'] = (int) $specificPrice['from_quantity']; - $specificPrice['reduction'] = (float) $specificPrice['reduction']; - $specificPrice['reduction_tax'] = (int) $specificPrice['reduction_tax']; - $specificPrice['id_currency'] = (int) $specificPrice['id_currency']; - $specificPrice['id_country'] = (int) $specificPrice['id_country']; - $specificPrice['id_customer'] = (int) $specificPrice['id_customer']; - $specificPrice['currency'] = $specificPrice['currency'] ?: 'ALL'; - $specificPrice['country'] = $specificPrice['country'] ?: 'ALL'; - $specificPrice['price_tax_included'] = (float) $specificPrice['price_tax_included']; - $specificPrice['price_tax_excluded'] = (float) $specificPrice['price_tax_excluded']; - $specificPrice['sale_price_tax_incl'] = (float) $specificPrice['sale_price_tax_incl']; - $specificPrice['sale_price_tax_excl'] = (float) $specificPrice['sale_price_tax_excl']; - - if ($specificPrice['reduction_type'] === 'percentage') { - $specificPrice['discount_percentage'] = $specificPrice['reduction'] * 100; - $specificPrice['discount_value_tax_incl'] = 0.0; - $specificPrice['discount_value_tax_excl'] = 0.0; - } else { - $specificPrice['discount_percentage'] = 0; - $specificPrice['discount_value_tax_incl'] = $specificPrice['price_tax_included'] - $specificPrice['sale_price_tax_incl']; - $specificPrice['discount_value_tax_excl'] = $specificPrice['price_tax_excluded'] - $specificPrice['sale_price_tax_excl']; - } - } - - /** - * @param array $specificPrice - * - * @return void - */ - private function setShopId(&$specificPrice) - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - if ($specificPrice['id_shop']) { - $specificPrice['id_shop'] = $this->context->shop->id; - } - } -} diff --git a/src/Repository/CustomPriceRepository.php b/src/Repository/CustomPriceRepository.php deleted file mode 100644 index 72cccca3..00000000 --- a/src/Repository/CustomPriceRepository.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class CustomPriceRepository -{ - /** - * @var \Context - */ - private $context; - /** - * @var \Db - */ - private $db; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - - if (!$this->context->employee instanceof \Employee) { - if (($employees = \Employee::getEmployees()) !== false) { - $this->context->employee = new \Employee($employees[0]['id_employee']); - } - } - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - $query = new \DbQuery(); - - $query->from('specific_price', 'sp') - ->leftJoin('country', 'c', 'c.id_country = sp.id_country') - ->leftJoin('currency', 'cur', 'cur.id_currency = sp.id_currency'); - - $query->where('sp.id_shop = 0 OR sp.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getSpecificPrices($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * - * @return int - * - * @throws \PrestaShopDatabaseException - */ - public function getRemainingSpecificPricesCount($offset) - { - $query = $this->getBaseQuery(); - - $query->select('(COUNT(sp.id_specific_price) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('sp.id_specific_price, sp.id_product, sp.id_shop, sp.id_shop_group, sp.id_currency'); - $query->select('sp.id_country, sp.id_group, sp.id_customer, sp.id_product_attribute, sp.price, sp.from_quantity'); - $query->select('sp.reduction, sp.reduction_tax, sp.from, sp.to, sp.reduction_type'); - $query->select('c.iso_code as country'); - $query->select('cur.iso_code as currency'); - } - - /** - * @param int $limit - * @param array $specificPriceIds - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getSpecificPricesIncremental($limit, $specificPriceIds) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->where('sp.id_specific_price IN(' . implode(',', array_map('intval', $specificPriceIds)) . ')') - ->limit($limit); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; - } - - /** - * @param int $offset - * @param int $limit - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit) - { - $query = $this->getBaseQuery(); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } -} diff --git a/src/Repository/NewRepository/CustomerRepository.php b/src/Repository/NewRepository/CustomerRepository.php index d0362276..c8a31a35 100644 --- a/src/Repository/NewRepository/CustomerRepository.php +++ b/src/Repository/NewRepository/CustomerRepository.php @@ -43,7 +43,8 @@ public function generateFullQuery($langIso, $withSelecParameters) $this->query->where('c.id_shop = ' . parent::getShopContext()->id); if ($withSelecParameters) { - $this->query->select('c.id_customer') + $this->query + ->select('c.id_customer') ->select('c.id_lang') ->select('c.email') ->select('c.newsletter') diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/NewRepository/ProductRepository.php index 304a2fb3..8201796f 100644 --- a/src/Repository/NewRepository/ProductRepository.php +++ b/src/Repository/NewRepository/ProductRepository.php @@ -321,4 +321,42 @@ public function getAttributeImages($attributeIds) return $this->runQuery(false); } + + /** + * @param int $productId + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function getProductPriceAndDeclinations($productId) + { + $this->generateMinimalQuery('product', 'p'); + + $this->query->where('p.`id_product` = ' . (int) $productId); + + $this->query->innerJoin( + 'product_shop', 'ps', '(ps.id_product=p.id_product AND ps.id_shop = ' . (int) parent::getShopContext()->id . ')'); + + $this->query + ->select('ps.price') + ->select('ps.ecotax') + ; + + if (\Combination::isFeatureActive()) { + $this->query->leftJoin( + 'product_attribute_shop', 'pas', '(pas.id_product = p.id_product AND pas.id_shop = ' . (int) parent::getShopContext()->id . ')'); + + $this->query + ->select('IFNULL(pas.id_product_attribute,0) id_product_attribute') + ->select('pas.`price` AS attribute_price') + ->select('pas.default_on') + ; + } else { + $this->query->select('0 as id_product_attribute'); + } + + return $this->runQuery(false); + } } diff --git a/src/Repository/NewRepository/SpecificPriceRepository.php b/src/Repository/NewRepository/SpecificPriceRepository.php new file mode 100644 index 00000000..4bc95b0c --- /dev/null +++ b/src/Repository/NewRepository/SpecificPriceRepository.php @@ -0,0 +1,177 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class SpecificPriceRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'specific_price'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'sp'); + + $this->query + ->leftJoin('country', 'c', 'c.id_country = sp.id_country') + ->leftJoin('currency', 'cur', 'cur.id_currency = sp.id_currency') + ; + + $this->query->where('sp.id_shop = 0 OR sp.id_shop = ' . (int) parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('sp.id_specific_price') + ->select('sp.id_product') + ->select('sp.id_shop') + ->select('sp.id_shop_group') + ->select('sp.id_currency') + ->select('sp.id_country') + ->select('sp.id_group') // different + ->select('sp.id_customer') + ->select('sp.id_product_attribute') + ->select('sp.price') + ->select('sp.from_quantity') + ->select('sp.reduction') + ->select('sp.reduction_tax') + ->select('sp.from') + ->select('sp.to') + ->select('sp.reduction_type') + ->select('c.iso_code as country') // different + ->select('cur.iso_code as currency') // different + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('sp.id_specific_price IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } + + /** + * @param int $specificPriceId + * + * @return array + * + * @throws \PrestaShopDatabaseException + */ + public function getSpecificPriceById($specificPriceId) + { + if (!$specificPriceId) { + return []; + } + + $this->generateMinimalQuery(self::TABLE_NAME, 'sp'); + + $this->query->where('sp.id_specific_price= ' . (int) $specificPriceId); + + $this->query + ->select('sp.id_specific_price') + ->select('sp.id_product') + ->select('sp.id_shop') + ->select('sp.id_shop_group') + ->select('sp.id_currency') + ->select('sp.id_country') + ->select('sp.id_customer') + ->select('sp.id_product_attribute') + ->select('sp.price') + ->select('sp.from_quantity') + ->select('sp.reduction') + ->select('sp.reduction_tax') + ->select('sp.from') + ->select('sp.to') + ->select('sp.reduction_type') + ->select('sp.id_specific_price_rule') // different + ->select('sp.id_cart') // different + ; + + return $this->runQuery(false); + } +} diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php deleted file mode 100644 index d696aee3..00000000 --- a/src/Repository/SpecificPriceRepository.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class SpecificPriceRepository -{ - const TABLE_NAME = 'specific_price'; - - /** - * @var \Db - */ - private $db; - - public function __construct() - { - $this->db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - public function getBaseQuery() - { - $query = new \DbQuery(); - $query->from(self::TABLE_NAME, 'sp'); - - return $query; - } - - /** - * @param int $specificPriceId - * - * @return array|bool|false|object|null - * - * @throws \PrestaShopDatabaseException - */ - public function getSpecificPrice($specificPriceId) - { - if (!$specificPriceId) { - return []; - } - - $query = $this->getBaseQuery(); - $this->addSelectParameters($query); - $query->where('sp.id_specific_price= ' . (int) $specificPriceId); - - return $this->db->getRow($query); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('sp.id_specific_price, sp.id_specific_price_rule, sp.id_cart, sp.id_product, sp.id_shop, sp.id_shop_group, sp.id_currency, sp.id_country'); - $query->select('sp.id_country, sp.id_customer, sp.id_product_attribute, sp.price, sp.from_quantity, sp.reduction, sp.reduction_tax, sp.reduction_type, sp.from, sp.to'); - } -} diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php new file mode 100644 index 00000000..5aa06ab3 --- /dev/null +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -0,0 +1,547 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class SpecificPricesService implements ShopContentServiceInterface +{ + /** @var SpecificPriceRepository */ + private $specificPriceRepository; + + /** @var ProductRepository */ + private $productRepository; + + public function __construct( + SpecificPriceRepository $specificPriceRepository, + ProductRepository $productRepository + ) { + $this->specificPriceRepository = $specificPriceRepository; + $this->productRepository = $productRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->specificPriceRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCustomPrices($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_specific_price'], + 'collection' => Config::COLLECTION_SPECIFIC_PRICES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->specificPriceRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castCustomPrices($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_specific_price'], + 'collection' => Config::COLLECTION_SPECIFIC_PRICES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->specificPriceRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $customPrices + * + * @return void + */ + private function castCustomPrices(&$customPrices) + { + foreach ($customPrices as &$customPrice) { + $context = \Context::getContext(); + + if ($context == null) { + throw new \PrestaShopException('Context not found'); + } + + if ($context->shop === null) { + throw new \PrestaShopException('No shop context'); + } + + $context->country = new \Country($customPrice['id_country']); + $context->currency = new \Currency($customPrice['id_currency']); + + $customPrice['price_tax_included'] = $this->getPriceStatic( + $customPrice['id_product'], + $customPrice['id_product_attribute'], + $customPrice['id_specific_price'], + true, + false, + $context + ); + + $customPrice['price_tax_excluded'] = $this->getPriceStatic( + $customPrice['id_product'], + $customPrice['id_product_attribute'], + $customPrice['id_specific_price'], + false, + false, + $context + ); + $customPrice['sale_price_tax_incl'] = $this->getPriceStatic( + $customPrice['id_product'], + $customPrice['id_product_attribute'], + $customPrice['id_specific_price'], + true, + true, + $context + ); + $customPrice['sale_price_tax_excl'] = $this->getPriceStatic( + $customPrice['id_product'], + $customPrice['id_product_attribute'], + $customPrice['id_specific_price'], + false, + true, + $context + ); + + if ($customPrice['id_shop']) { + $customPrice['id_shop'] = $context->shop->id; + } + + $customPrice['id_specific_price'] = (int) $customPrice['id_specific_price']; + $customPrice['id_product'] = (int) $customPrice['id_product']; + $customPrice['id_shop'] = (int) $customPrice['id_shop']; + $customPrice['id_group'] = (int) $customPrice['id_group']; + $customPrice['id_shop_group'] = (int) $customPrice['id_shop_group']; + $customPrice['id_product_attribute'] = (int) $customPrice['id_product_attribute']; + $customPrice['price'] = (float) $customPrice['price']; + $customPrice['from_quantity'] = (int) $customPrice['from_quantity']; + $customPrice['reduction'] = (float) $customPrice['reduction']; + $customPrice['reduction_tax'] = (int) $customPrice['reduction_tax']; + $customPrice['id_currency'] = (int) $customPrice['id_currency']; + $customPrice['id_country'] = (int) $customPrice['id_country']; + $customPrice['id_customer'] = (int) $customPrice['id_customer']; + $customPrice['currency'] = $customPrice['currency'] ?: 'ALL'; + $customPrice['country'] = $customPrice['country'] ?: 'ALL'; + $customPrice['price_tax_included'] = (float) $customPrice['price_tax_included']; + $customPrice['price_tax_excluded'] = (float) $customPrice['price_tax_excluded']; + $customPrice['sale_price_tax_incl'] = (float) $customPrice['sale_price_tax_incl']; + $customPrice['sale_price_tax_excl'] = (float) $customPrice['sale_price_tax_excl']; + + if ($customPrice['reduction_type'] === 'percentage') { + $customPrice['discount_percentage'] = $customPrice['reduction'] * 100; + $customPrice['discount_value_tax_incl'] = 0.0; + $customPrice['discount_value_tax_excl'] = 0.0; + } else { + $customPrice['discount_percentage'] = 0; + $customPrice['discount_value_tax_incl'] = $customPrice['price_tax_included'] - $customPrice['sale_price_tax_incl']; + $customPrice['discount_value_tax_excl'] = $customPrice['price_tax_excluded'] - $customPrice['sale_price_tax_excl']; + } + } + } + + /** + * @param int $idProduct + * @param int $idProductAttribute + * @param int $specificPriceId + * @param bool $usetax + * @param bool $usereduc + * @param \Context|null $context + * @param int $decimals + * @param null $divisor + * @param bool $onlyReduc + * @param null $idCustomer + * @param null $idCart + * @param null $idAddress + * @param null $specificPriceOutput + * @param bool $useGroupReduction + * + * @return float|int|void + * + * @@throws \PrestaShopException + */ + private function getPriceStatic( + $idProduct, + $idProductAttribute, + $specificPriceId, + $usetax = true, + $usereduc = true, + $context = null, + $decimals = 6, + $divisor = null, + $onlyReduc = false, + $idCustomer = null, + $idCart = null, + $idAddress = null, + &$specificPriceOutput = null, + $useGroupReduction = true + ) { + if (!$context) { + /** @var \Context $context */ + $context = \Context::getContext(); + } + + \Tools::displayParameterAsDeprecated('divisor'); + + if (!\Validate::isBool($usetax) || !\Validate::isUnsignedId($idProduct)) { + exit(\Tools::displayError()); + } + + // Initializations + $idGroup = (int) \Group::getCurrent()->id; + + /** @var \Currency $currency */ + $currency = $context->currency; + $idCurrency = \Validate::isLoadedObject($currency) ? (int) $currency->id : (int) \Configuration::get('PS_CURRENCY_DEFAULT'); + + $currentCart = $context->cart; + if ($currentCart != null && \Validate::isLoadedObject($currentCart)) { + $idAddress = $currentCart->{\Configuration::get('PS_TAX_ADDRESS_TYPE')}; + } + + // retrieve address informations + $address = \Address::initialize($idAddress, true); + $idCountry = (int) $address->id_country; + $idState = (int) $address->id_state; + $zipcode = $address->postcode; + + if (\Tax::excludeTaxeOption()) { + $usetax = false; + } + + if ( + $usetax != false + && !empty($address->vat_number) + && $address->id_country != \Configuration::get('VATNUMBER_COUNTRY') + && \Configuration::get('VATNUMBER_MANAGEMENT') + ) { + $usetax = false; + } + + if ($context->shop == null) { + throw new \PrestaShopException('No shop context'); + } + + $shopId = (int) $context->shop->id; + + return $this->priceCalculation( + $shopId, + $idProduct, + $idProductAttribute, + $specificPriceId, + $idCountry, + $idState, + $zipcode, + $idCurrency, + $idGroup, + $usetax, + $decimals, + $onlyReduc, + $usereduc, + $specificPriceOutput, + $useGroupReduction + ); + } + + /** + * @param int $idShop + * @param int $idProduct + * @param int $idProductAttribute + * @param int $specificPriceId + * @param int $idCountry + * @param int $idState + * @param string $zipcode + * @param int $idCurrency + * @param int $idGroup + * @param bool $useTax + * @param int $decimals + * @param bool $onlyReduc + * @param bool $useReduc + * @param null $specificPrice + * @param bool $useGroupReduction + * @param int $idCustomization + * + * @return float|int|void + * + * @@throws \PrestaShopDatabaseException + */ + private function priceCalculation( + $idShop, + $idProduct, + $idProductAttribute, + $specificPriceId, + $idCountry, + $idState, + $zipcode, + $idCurrency, + $idGroup, + $useTax, + $decimals, + $onlyReduc, + $useReduc, + &$specificPrice, + $useGroupReduction, + $idCustomization = 0 + ) { + static $address = null; + static $context = null; + + /** @var array */ + static $pricesLevel2; + + if ($context == null) { + /** @var \Context $context */ + $context = \Context::getContext(); + $context = $context->cloneContext(); + } + + if ($address === null) { + if (is_object($context->cart) && $context->cart->{\Configuration::get('PS_TAX_ADDRESS_TYPE')} != null) { + $idAddress = $context->cart->{\Configuration::get('PS_TAX_ADDRESS_TYPE')}; + $address = new \Address($idAddress); + } else { + $address = new \Address(); + } + } + + if ($idShop !== null && $context->shop->id != (int) $idShop) { + $context->shop = new \Shop((int) $idShop); + } + + if ($idProductAttribute == null) { + $idProductAttribute = \Product::getDefaultAttribute($idProduct); + } + + // reference parameter is filled before any returns + /** @var array $specificPrice */ + $specificPrice = $this->getSpecificPrice($specificPriceId); + + // fetch price & attribute price + $cacheId2 = $idProduct . '-' . $idShop . '-' . $specificPriceId; + if (!isset($pricesLevel2[$cacheId2])) { + $result = $this->productRepository->getProductPriceAndDeclinations($idProduct); + + if (is_array($result) && count($result)) { + foreach ($result as $row) { + $array_tmp = [ + 'price' => $row['price'], + 'ecotax' => $row['ecotax'], + 'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null), + ]; + $pricesLevel2[$cacheId2][(int) $row['id_product_attribute']] = $array_tmp; + + if (isset($row['default_on']) && $row['default_on'] == 1) { + $pricesLevel2[$cacheId2][0] = $array_tmp; + } + } + } + } + + if (!isset($pricesLevel2[$cacheId2][(int) $idProductAttribute])) { + return; + } + + $result = $pricesLevel2[$cacheId2][(int) $idProductAttribute]; + + if (!$specificPrice || $specificPrice['price'] < 0) { + $price = (float) $result['price']; + } else { + $price = (float) $specificPrice['price']; + } + // convert only if the specific price is in the default currency (id_currency = 0) + if (!$specificPrice || !($specificPrice['price'] >= 0 && $specificPrice['id_currency'])) { + $price = \Tools::convertPrice($price, $idCurrency); + + if (isset($specificPrice['price']) && $specificPrice['price'] >= 0) { + $specificPrice['price'] = $price; + } + } + + // Attribute price + if (is_array($result) && (!$specificPrice || !$specificPrice['id_product_attribute'] || $specificPrice['price'] < 0)) { + $attributePrice = \Tools::convertPrice($result['attribute_price'] !== null ? (float) $result['attribute_price'] : 0, $idCurrency); + // If you want the default combination, please use NULL value instead + if ($idProductAttribute !== false) { + $price += $attributePrice; + } + } + + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.0.0', '>=')) { + // Customization price + if ((int) $idCustomization) { + /* @phpstan-ignore-next-line */ + $price += \Tools::convertPrice(\Customization::getCustomizationPrice($idCustomization), $idCurrency); + } + } + + // Tax + $address->id_country = $idCountry; + $address->id_state = $idState; + $address->postcode = $zipcode; + + $tax_manager = \TaxManagerFactory::getManager($address, \Product::getIdTaxRulesGroupByIdProduct((int) $idProduct, $context)); + $productTaxCalculator = $tax_manager->getTaxCalculator(); + + // Add Tax + if ($useTax) { + $price = $productTaxCalculator->addTaxes((float) $price); + } + + // Eco Tax + if ($result['ecotax'] || isset($result['attribute_ecotax'])) { + $ecotax = $result['ecotax']; + if (isset($result['attribute_ecotax']) && $result['attribute_ecotax'] > 0) { + $ecotax = $result['attribute_ecotax']; + } + + if ($idCurrency) { + $ecotax = \Tools::convertPrice($ecotax, $idCurrency); + } + if ($useTax) { + static $psEcotaxTaxRulesGroupId = null; + if ($psEcotaxTaxRulesGroupId === null) { + $psEcotaxTaxRulesGroupId = (int) \Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID'); + } + // reinit the tax manager for ecotax handling + $tax_manager = \TaxManagerFactory::getManager( + $address, + $psEcotaxTaxRulesGroupId + ); + $ecotaxTaxCalculator = $tax_manager->getTaxCalculator(); + $price += $ecotaxTaxCalculator->addTaxes($ecotax); + } else { + $price += $ecotax; + } + } + + // Reduction + $specificPriceReduction = 0; + if (($onlyReduc || $useReduc) && $specificPrice) { + if ($specificPrice['reduction_type'] == 'amount') { + $reductionAmount = $specificPrice['reduction']; + + if (!$specificPrice['id_currency']) { + $reductionAmount = \Tools::convertPrice($reductionAmount, $idCurrency); + } + + $specificPriceReduction = $reductionAmount; + + // Adjust taxes if required + + if (!$useTax && $specificPrice['reduction_tax']) { + $specificPriceReduction = $productTaxCalculator->removeTaxes($specificPriceReduction); + } + if ($useTax && !$specificPrice['reduction_tax']) { + $specificPriceReduction = $productTaxCalculator->addTaxes($specificPriceReduction); + } + } else { + $specificPriceReduction = $price * $specificPrice['reduction']; + } + } + + if ($useReduc) { + $price -= $specificPriceReduction; + } + + // Group reduction + if ($useGroupReduction) { + $reductionFromCategory = \GroupReduction::getValueForProduct($idProduct, $idGroup); + if ($reductionFromCategory !== false) { + $groupReduction = $price * (float) $reductionFromCategory; + } else { // apply group reduction if there is no group reduction for this category + $groupReduction = (($reduc = \Group::getReductionByIdGroup($idGroup)) != 0) ? ($price * $reduc / 100) : 0; + } + + $price -= $groupReduction; + } + + if ($onlyReduc) { + return \Tools::ps_round($specificPriceReduction, $decimals); + } + + $price = \Tools::ps_round((float) $price, $decimals); + + if ($price < 0) { + $price = 0; + } + + return $price; + } + + /** + * Returns the specificPrice information related to a given productId and context. + * + * @param int $specificPriceId + * + * @return array + */ + private function getSpecificPrice($specificPriceId) + { + if (!\SpecificPrice::isFeatureActive()) { + return []; + } + + return $this->specificPriceRepository->getSpecificPriceById($specificPriceId)[0]; + } +} diff --git a/src/Service/SpecificPriceService.php b/src/Service/SpecificPriceService.php deleted file mode 100644 index 9f96f69b..00000000 --- a/src/Service/SpecificPriceService.php +++ /dev/null @@ -1,413 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Service; - -use PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class SpecificPriceService -{ - /** @var array */ - private static $_pricesLevel2; - - /** - * @var SpecificPriceRepository - */ - private $specificPriceRepository; - - public function __construct(SpecificPriceRepository $specificPriceRepository) - { - $this->specificPriceRepository = $specificPriceRepository; - } - - /** - * @param int $productId - * @param int $attributeId - * @param int $specificPriceId - * @param bool $useTax - * @param bool $usereduc - * @param \Context|null $context - * - * @return float|int|void - * - * @@throws \PrestaShopException - */ - public function getSpecificProductPrice($productId, $attributeId, $specificPriceId, $useTax, $usereduc, $context) - { - return $this->getPriceStatic($productId, $attributeId, $specificPriceId, $useTax, $usereduc, $context); - } - - /** - * @param int $id_product - * @param int $id_product_attribute - * @param int $specificPriceId - * @param bool $usetax - * @param bool $usereduc - * @param \Context|null $context - * @param int $decimals - * @param null $divisor - * @param bool $only_reduc - * @param null $id_customer - * @param null $id_cart - * @param null $id_address - * @param null $specific_price_output - * @param bool $use_group_reduction - * - * @return float|int|void - * - * @@throws \PrestaShopException - */ - private function getPriceStatic( - $id_product, - $id_product_attribute, - $specificPriceId, - $usetax = true, - $usereduc = true, - $context = null, - $decimals = 6, - $divisor = null, - $only_reduc = false, - $id_customer = null, - $id_cart = null, - $id_address = null, - &$specific_price_output = null, - $use_group_reduction = true - ) { - if (!$context) { - /** @var \Context $context */ - $context = \Context::getContext(); - } - - \Tools::displayParameterAsDeprecated('divisor'); - - if (!\Validate::isBool($usetax) || !\Validate::isUnsignedId($id_product)) { - exit(\Tools::displayError()); - } - - // Initializations - $id_group = (int) \Group::getCurrent()->id; - - /** @var \Currency $currency */ - $currency = $context->currency; - $id_currency = \Validate::isLoadedObject($currency) ? (int) $currency->id : (int) \Configuration::get('PS_CURRENCY_DEFAULT'); - - $current_cart = $context->cart; - if ($current_cart != null && \Validate::isLoadedObject($current_cart)) { - $id_address = $current_cart->{\Configuration::get('PS_TAX_ADDRESS_TYPE')}; - } - - // retrieve address informations - $address = \Address::initialize($id_address, true); - $id_country = (int) $address->id_country; - $id_state = (int) $address->id_state; - $zipcode = $address->postcode; - - if (\Tax::excludeTaxeOption()) { - $usetax = false; - } - - if ( - $usetax != false - && !empty($address->vat_number) - && $address->id_country != \Configuration::get('VATNUMBER_COUNTRY') - && \Configuration::get('VATNUMBER_MANAGEMENT') - ) { - $usetax = false; - } - - if ($context->shop == null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $context->shop->id; - - return $this->priceCalculation( - $shopId, - $id_product, - $id_product_attribute, - $specificPriceId, - $id_country, - $id_state, - $zipcode, - $id_currency, - $id_group, - $usetax, - $decimals, - $only_reduc, - $usereduc, - $specific_price_output, - $use_group_reduction - ); - } - - /** - * @param int $id_shop - * @param int $id_product - * @param int $id_product_attribute - * @param int $specificPriceId - * @param int $id_country - * @param int $id_state - * @param string $zipcode - * @param int $id_currency - * @param int $id_group - * @param bool $use_tax - * @param int $decimals - * @param bool $only_reduc - * @param bool $use_reduc - * @param null $specific_price - * @param bool $use_group_reduction - * @param int $id_customization - * - * @return float|int|void - * - * @@throws \PrestaShopDatabaseException - */ - private function priceCalculation( - $id_shop, - $id_product, - $id_product_attribute, - $specificPriceId, - $id_country, - $id_state, - $zipcode, - $id_currency, - $id_group, - $use_tax, - $decimals, - $only_reduc, - $use_reduc, - &$specific_price, - $use_group_reduction, - $id_customization = 0 - ) { - static $address = null; - static $context = null; - - if ($context == null) { - /** @var \Context $context */ - $context = \Context::getContext(); - $context = $context->cloneContext(); - } - - if ($address === null) { - if (is_object($context->cart) && $context->cart->{\Configuration::get('PS_TAX_ADDRESS_TYPE')} != null) { - $id_address = $context->cart->{\Configuration::get('PS_TAX_ADDRESS_TYPE')}; - $address = new \Address($id_address); - } else { - $address = new \Address(); - } - } - - if ($id_shop !== null && $context->shop->id != (int) $id_shop) { - $context->shop = new \Shop((int) $id_shop); - } - - if ($id_product_attribute == null) { - $id_product_attribute = \Product::getDefaultAttribute($id_product); - } - - // reference parameter is filled before any returns - /** @var array $specific_price */ - $specific_price = $this->getSpecificPrice($specificPriceId); - - // fetch price & attribute price - $cache_id_2 = $id_product . '-' . $id_shop . '-' . $specificPriceId; - if (!isset(self::$_pricesLevel2[$cache_id_2])) { - $sql = new \DbQuery(); - $sql->select('product_shop.`price`, product_shop.`ecotax`'); - $sql->from('product', 'p'); - $sql->innerJoin('product_shop', 'product_shop', '(product_shop.id_product=p.id_product AND product_shop.id_shop = ' . (int) $id_shop . ')'); - $sql->where('p.`id_product` = ' . (int) $id_product); - if (\Combination::isFeatureActive()) { - $sql->select('IFNULL(product_attribute_shop.id_product_attribute,0) id_product_attribute, product_attribute_shop.`price` AS attribute_price, product_attribute_shop.default_on'); - $sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.id_product = p.id_product AND product_attribute_shop.id_shop = ' . (int) $id_shop . ')'); - } else { - $sql->select('0 as id_product_attribute'); - } - - $res = \Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($sql); - - if (is_array($res) && count($res)) { - foreach ($res as $row) { - $array_tmp = [ - 'price' => $row['price'], - 'ecotax' => $row['ecotax'], - 'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null), - ]; - self::$_pricesLevel2[$cache_id_2][(int) $row['id_product_attribute']] = $array_tmp; - - if (isset($row['default_on']) && $row['default_on'] == 1) { - self::$_pricesLevel2[$cache_id_2][0] = $array_tmp; - } - } - } - } - - if (!isset(self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute])) { - return; - } - - $result = self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute]; - - if (!$specific_price || $specific_price['price'] < 0) { - $price = (float) $result['price']; - } else { - $price = (float) $specific_price['price']; - } - // convert only if the specific price is in the default currency (id_currency = 0) - if (!$specific_price || !($specific_price['price'] >= 0 && $specific_price['id_currency'])) { - $price = \Tools::convertPrice($price, $id_currency); - - if (isset($specific_price['price']) && $specific_price['price'] >= 0) { - $specific_price['price'] = $price; - } - } - - // Attribute price - if (is_array($result) && (!$specific_price || !$specific_price['id_product_attribute'] || $specific_price['price'] < 0)) { - $attribute_price = \Tools::convertPrice($result['attribute_price'] !== null ? (float) $result['attribute_price'] : 0, $id_currency); - // If you want the default combination, please use NULL value instead - if ($id_product_attribute !== false) { - $price += $attribute_price; - } - } - - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.0.0', '>=')) { - // Customization price - if ((int) $id_customization) { - /* @phpstan-ignore-next-line */ - $price += \Tools::convertPrice(\Customization::getCustomizationPrice($id_customization), $id_currency); - } - } - - // Tax - $address->id_country = $id_country; - $address->id_state = $id_state; - $address->postcode = $zipcode; - - $tax_manager = \TaxManagerFactory::getManager($address, \Product::getIdTaxRulesGroupByIdProduct((int) $id_product, $context)); - $product_tax_calculator = $tax_manager->getTaxCalculator(); - - // Add Tax - if ($use_tax) { - $price = $product_tax_calculator->addTaxes((float) $price); - } - - // Eco Tax - if ($result['ecotax'] || isset($result['attribute_ecotax'])) { - $ecotax = $result['ecotax']; - if (isset($result['attribute_ecotax']) && $result['attribute_ecotax'] > 0) { - $ecotax = $result['attribute_ecotax']; - } - - if ($id_currency) { - $ecotax = \Tools::convertPrice($ecotax, $id_currency); - } - if ($use_tax) { - static $psEcotaxTaxRulesGroupId = null; - if ($psEcotaxTaxRulesGroupId === null) { - $psEcotaxTaxRulesGroupId = (int) \Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID'); - } - // reinit the tax manager for ecotax handling - $tax_manager = \TaxManagerFactory::getManager( - $address, - $psEcotaxTaxRulesGroupId - ); - $ecotax_tax_calculator = $tax_manager->getTaxCalculator(); - $price += $ecotax_tax_calculator->addTaxes($ecotax); - } else { - $price += $ecotax; - } - } - - // Reduction - $specific_price_reduction = 0; - if (($only_reduc || $use_reduc) && $specific_price) { - if ($specific_price['reduction_type'] == 'amount') { - $reduction_amount = $specific_price['reduction']; - - if (!$specific_price['id_currency']) { - $reduction_amount = \Tools::convertPrice($reduction_amount, $id_currency); - } - - $specific_price_reduction = $reduction_amount; - - // Adjust taxes if required - - if (!$use_tax && $specific_price['reduction_tax']) { - $specific_price_reduction = $product_tax_calculator->removeTaxes($specific_price_reduction); - } - if ($use_tax && !$specific_price['reduction_tax']) { - $specific_price_reduction = $product_tax_calculator->addTaxes($specific_price_reduction); - } - } else { - $specific_price_reduction = $price * $specific_price['reduction']; - } - } - - if ($use_reduc) { - $price -= $specific_price_reduction; - } - - // Group reduction - if ($use_group_reduction) { - $reduction_from_category = \GroupReduction::getValueForProduct($id_product, $id_group); - if ($reduction_from_category !== false) { - $group_reduction = $price * (float) $reduction_from_category; - } else { // apply group reduction if there is no group reduction for this category - $group_reduction = (($reduc = \Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0; - } - - $price -= $group_reduction; - } - - if ($only_reduc) { - return \Tools::ps_round($specific_price_reduction, $decimals); - } - - $price = \Tools::ps_round((float) $price, $decimals); - - if ($price < 0) { - $price = 0; - } - - return $price; - } - - /** - * Returns the specificPrice information related to a given productId and context. - * - * @param int $specificPriceId - * - * @return array|bool|false|object|null - */ - private function getSpecificPrice($specificPriceId) - { - if (!\SpecificPrice::isFeatureActive()) { - return []; - } - - return $this->specificPriceRepository->getSpecificPrice($specificPriceId); - } -} diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index c6958554..4ceb5bc6 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -22,7 +22,7 @@ parameters: - '#Cannot call method handle\(\) on mixed.#' - '#Cannot access property [a-z\$]+ on Context\|null.#' - '#Parameter \#2 \$currency of static method ToolsCore::convertPrice\(\) expects array\|object\|null, [a-z0-9<>,-\| ]+ given.#' - - '#Method PrestaShop\\Module\\PsEventbus\\Service\\SpecificPriceService::priceCalculation\(\) never returns void so it can be removed from the return type.#' + - '#Method PrestaShop\\Module\\PsEventbus\\Service\\ShopContent\\SpecificPricesService::priceCalculation\(\) never returns void so it can be removed from the return type.#' - '#Property PrestaShop\\Module\\PsEventbus\\Api\\Post\\Stream::\$stream \(resource\) does not accept null.#' - '#Cannot call method prepare\(\) on mysqli\|PDO\|resource.#' - '#Cannot call method bindParam\(\) on mysqli_stmt\|PDOStatement\|false.#' @@ -35,7 +35,7 @@ parameters: - '#Parameter \#2 \$type of static method TaxManagerFactoryCore::getManager\(\) expects string, int given.#' - '#Method PrestaShop\\Module\\PsEventbus\\Factory\\ContextFactory::getController\(\) has invalid return type PrestaShopBundle\\Bridge\\AdminController\\LegacyControllerBridgeInterface.#' - '#Cannot call method getService\(\) on ModuleCore\|false.#' - - '#Method PrestaShop\\Module\\PsEventbus\\Service\\SpecificPriceService::getPriceStatic\(\) never returns void so it can be removed from the return type.#' + - '#Method PrestaShop\\Module\\PsEventbus\\Service\\ShopContent\\SpecificPricesService::getPriceStatic\(\) never returns void so it can be removed from the return type.#' - '#Call to an undefined method object::findForUpdates\(\).#' - '#Property PrestaShop\\Module\\PsEventbus\\Helper\\ModuleHelper::\$moduleManager has unknown class PrestaShop\\PrestaShop\\Core\\Module\\ModuleManager as its type.#' From 803dd32d64b60fa5b9d6fdf0aa1a652703e9b447 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:52:53 +0200 Subject: [PATCH 097/162] feat: add taxonomies (#379) --- OLD/Provider/GoogleTaxonomyDataProvider.php | 101 ------------- config/common/new-repository.yml | 4 + config/common/repository.yml | 4 - config/front/services.yml | 6 + e2e/src/fixtures/1.6/taxonomies.json | 1 + e2e/src/fixtures/1.7/taxonomies.json | 1 + e2e/src/fixtures/8/taxonomies.json | 1 + e2e/src/fixtures/9/taxonomies.json | 1 + e2e/src/full-sync.spec.ts | 45 +----- e2e/src/helpers/shop-contents.ts | 1 + src/Repository/GoogleTaxonomyRepository.php | 111 -------------- .../NewRepository/TaxonomyRepository.php | 139 ++++++++++++++++++ .../WishlistProductRepository.php | 2 +- src/Service/ShopContent/CategoriesService.php | 7 +- src/Service/ShopContent/OrdersService.php | 9 +- .../ShopContent/ProductSuppliersService.php | 7 +- src/Service/ShopContent/StockMvtsService.php | 7 +- src/Service/ShopContent/TaxonomiesService.php | 117 +++++++++++++++ .../ShopContent/TranslationsService.php | 7 +- .../ShopContent/WishlistProductsService.php | 7 +- 20 files changed, 293 insertions(+), 285 deletions(-) delete mode 100644 OLD/Provider/GoogleTaxonomyDataProvider.php create mode 100644 e2e/src/fixtures/1.6/taxonomies.json create mode 100644 e2e/src/fixtures/1.7/taxonomies.json create mode 100644 e2e/src/fixtures/8/taxonomies.json create mode 100644 e2e/src/fixtures/9/taxonomies.json delete mode 100644 src/Repository/GoogleTaxonomyRepository.php create mode 100644 src/Repository/NewRepository/TaxonomyRepository.php create mode 100644 src/Service/ShopContent/TaxonomiesService.php diff --git a/OLD/Provider/GoogleTaxonomyDataProvider.php b/OLD/Provider/GoogleTaxonomyDataProvider.php deleted file mode 100644 index e946257b..00000000 --- a/OLD/Provider/GoogleTaxonomyDataProvider.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class GoogleTaxonomyDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var GoogleTaxonomyRepository - */ - private $googleTaxonomyRepository; - /** - * @var \Context - */ - private $context; - - /** - * @var int - */ - private $shopId; - - public function __construct(GoogleTaxonomyRepository $googleTaxonomyRepository, \Context $context) - { - $this->googleTaxonomyRepository = $googleTaxonomyRepository; - $this->context = $context; - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - - public function getFormattedData($offset, $limit, $langIso) - { - $data = $this->googleTaxonomyRepository->getTaxonomyCategories($offset, $limit, $this->shopId); - - if (!is_array($data)) { - return []; - } - - return array_map(function ($googleTaxonomy) { - $uniqueId = "{$googleTaxonomy['id_category']}-{$googleTaxonomy['id_category']}"; - $googleTaxonomy['taxonomy_id'] = $uniqueId; - - return [ - 'id' => $uniqueId, - 'collection' => Config::COLLECTION_TAXONOMIES, - 'properties' => $googleTaxonomy, - ]; - }, $data); - } - - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->googleTaxonomyRepository->getRemainingTaxonomyRepositories($offset, $this->shopId); - } - - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - return []; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->googleTaxonomyRepository->getQueryForDebug($offset, $limit, $this->shopId); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index f8fe8ed1..671de058 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -106,3 +106,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index dd409c13..346e4a82 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -9,10 +9,6 @@ services: arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository: - class: PrestaShop\Module\PsEventbus\Repository\GoogleTaxonomyRepository - public: true - PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 695842e9..199eece9 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -248,3 +248,9 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository' - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\TaxonomiesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\TaxonomiesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository' diff --git a/e2e/src/fixtures/1.6/taxonomies.json b/e2e/src/fixtures/1.6/taxonomies.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/taxonomies.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.7/taxonomies.json b/e2e/src/fixtures/1.7/taxonomies.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/taxonomies.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/taxonomies.json b/e2e/src/fixtures/8/taxonomies.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/taxonomies.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/9/taxonomies.json b/e2e/src/fixtures/9/taxonomies.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/taxonomies.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 655718db..675ffd8e 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -1,7 +1,7 @@ import testConfig from "./helpers/test.config"; import * as matchers from "jest-extended"; import { dumpUploadData, logAxiosError } from "./helpers/log-helper"; -import axios, { AxiosError } from "axios"; +import axios from "axios"; import { doFullSync, probe, PsEventbusSyncUpload } from "./helpers/mock-probe"; import { lastValueFrom, toArray, withLatestFrom } from "rxjs"; import { @@ -14,9 +14,6 @@ import { ShopContent, shopContentList } from "./helpers/shop-contents"; expect.extend(matchers); -// these ShopContent will be excluded from the following test suite -const EXCLUDED_API: ShopContent[] = ["taxonomies" as ShopContent]; - // these fields change from test run to test run, so we replace them with a matcher to only ensure the type and format are correct const isDateString = (val) => val ? expect(val).toBeDateString() : expect(val).toBeNull(); @@ -44,11 +41,6 @@ const specialFieldAssert: { [index: string]: (val) => void } = { describe("Full Sync", () => { let generatedNumber = 0; - // gérer les cas ou un shopContent n'existe pas (pas de fixture du coup) - const shopContents: ShopContent[] = shopContentList.filter( - (it) => !EXCLUDED_API.includes(it), - ); - let jobId: string; beforeEach(() => { @@ -56,40 +48,7 @@ describe("Full Sync", () => { jobId = `valid-job-full-${generatedNumber}`; }); - // TODO : some versions of prestashop include ps_facebook out of the box, this test can't reliably be run for all versions - describe.skip("taxonomies", () => { - const shoContent = "taxonomies"; - - // TODO : apiGoogleTaxonomies requires an additional module to be present : devise a specific test setup for this endpoint - it.skip(`${shoContent} should accept full sync`, async () => {}); - - it(`${shoContent} should reject full sync when ps_facebook is not installed`, async () => { - // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shoContent}&limit=5&full=1&job_id=${jobId}`; - - const callId = { call_id: Math.random().toString(36).substring(2, 11) }; - - // act - const response = await axios - .post(url, callId, { - headers: { - Host: testConfig.prestaShopHostHeader, - "Content-Type": "application/x-www-form-urlencoded", // for compat PHP 5.6 - }, - }) - .catch((err) => { - expect(err).toBeInstanceOf(AxiosError); - return err.response; - }); - - // assert - expect(response.status).toEqual(456); - // expect some explanation to be given to the user - expect(response.statusText).toMatch(/[Ff]acebook/); - }); - }); - - describe.each(shopContents)("%s", (shopContent) => { + describe.each(shopContentList)("%s", (shopContent) => { it(`${shopContent} should accept full sync`, async () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index dede594c..fb82563d 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -40,6 +40,7 @@ export const shopContentMapping = { translations: "translations", wishlists: "wishlists", wishlist_products: "wishlist-products", + taxonomies: "taxonomies", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Repository/GoogleTaxonomyRepository.php b/src/Repository/GoogleTaxonomyRepository.php deleted file mode 100644 index 680e0618..00000000 --- a/src/Repository/GoogleTaxonomyRepository.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class GoogleTaxonomyRepository -{ - /** - * @var \Db - */ - private $db; - - public function __construct() - { - $this->db = \Db::getInstance(); - } - - /** - * @param int $shopId - * - * @return \DbQuery - */ - public function getBaseQuery($shopId) - { - $query = new \DbQuery(); - - $query->from('fb_category_match', 'cm') - ->where('cm.id_shop = ' . (int) $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * @param int $shopId - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getTaxonomyCategories($offset, $limit, $shopId) - { - $query = $this->getBaseQuery($shopId); - - $query->select('cm.id_category, cm.google_category_id') - ->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param int $shopId - * - * @return int - */ - public function getRemainingTaxonomyRepositories($offset, $shopId) - { - $query = $this->getBaseQuery($shopId); - - $query->select('(COUNT(cm.id_category) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $offset - * @param int $limit - * @param int $shopId - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $shopId) - { - $query = $this->getBaseQuery($shopId); - - $query->select('cm.id_category, cm.google_category_id') - ->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } -} diff --git a/src/Repository/NewRepository/TaxonomyRepository.php b/src/Repository/NewRepository/TaxonomyRepository.php new file mode 100644 index 00000000..51e1e67d --- /dev/null +++ b/src/Repository/NewRepository/TaxonomyRepository.php @@ -0,0 +1,139 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class TaxonomyRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'fb_category_match'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'fbcm'); + + $this->query->where('fbcm.id_shop = ' . (int) parent::getShopContext()->id); + + if ($withSelecParameters) { + $this->query + ->select('fbcm.id_category') + ->select('fbcm.google_category_id') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + // need this module for this table : https://addons.prestashop.com/en/products-on-facebook-social-networks/50291-prestashop-social-with-facebook-instagram.html + if (empty($this->checkIfPsFacebookIsInstalled())) { + return []; + } + + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('fbcm.id_category IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + // need this module for this table : https://addons.prestashop.com/en/products-on-facebook-social-networks/50291-prestashop-social-with-facebook-instagram.html + if (empty($this->checkIfPsFacebookIsInstalled())) { + return 0; + } + + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } + + /** + * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + private function checkIfPsFacebookIsInstalled() + { + $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%fb_category_match\' LIMIT 1;'; + + return $this->db->executeS($moduleisInstalledQuery); + } +} diff --git a/src/Repository/NewRepository/WishlistProductRepository.php b/src/Repository/NewRepository/WishlistProductRepository.php index 124082ff..f6d3e70e 100644 --- a/src/Repository/NewRepository/WishlistProductRepository.php +++ b/src/Repository/NewRepository/WishlistProductRepository.php @@ -136,6 +136,6 @@ private function checkIfPsWishlistIsInstalled() { $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%wishlist\' LIMIT 1;'; - return $this->db->executeS($moduleisInstalledQuery, false); + return $this->db->executeS($moduleisInstalledQuery); } } diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index de10d674..94dff845 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -53,7 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castCategories($result, $langIso); + $this->castCategories($result); return array_map(function ($item) { return [ @@ -80,7 +80,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castCategories($result, $langIso); + $this->castCategories($result); return array_map(function ($item) { return [ @@ -163,11 +163,10 @@ private function buildCategoryPaths($categoriesWithParentsInfo, $currentCategory /** * @param array $categories - * @param string $langIso * * @return void */ - private function castCategories(&$categories, $langIso) + private function castCategories(&$categories) { foreach ($categories as &$category) { $category['id_category'] = (int) $category['id_category']; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 018e08c5..40f83b16 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -66,7 +66,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castOrders($result, $langIso, $debug); + $this->castOrders($result, $langIso); return array_map(function ($item) { return [ @@ -93,7 +93,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castOrders($result, $langIso, $debug); + $this->castOrders($result, $langIso); return array_map(function ($item) { return [ @@ -119,11 +119,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $orders * @param string $langIso - * @param bool $debug * * @return void */ - private function castOrders(&$orders, $langIso, $debug) + private function castOrders(&$orders, $langIso) { foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; @@ -135,7 +134,7 @@ private function castOrders(&$orders, $langIso, $debug) $order['refund'] = (float) $order['refund']; $order['refund_tax_excl'] = (float) $order['refund_tax_excl']; $order['new_customer'] = $order['new_customer'] == 1; - $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langIso, $debug); + $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langIso, false); $order['shipping_cost'] = (float) $order['shipping_cost']; $order['total_paid_tax'] = $order['total_paid_tax_incl'] - $order['total_paid_tax_excl']; $order['id_carrier'] = (int) $order['id_carrier']; diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index 004a4313..3840eeef 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -53,7 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castProductsSuppliers($result, $langIso); + $this->castProductsSuppliers($result); return array_map(function ($item) { return [ @@ -80,7 +80,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castProductsSuppliers($result, $langIso); + $this->castProductsSuppliers($result); return array_map(function ($item) { return [ @@ -105,11 +105,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $productSuppliers - * @param string $langIso * * @return void */ - private function castProductsSuppliers(&$productSuppliers, $langIso) + private function castProductsSuppliers(&$productSuppliers) { foreach ($productSuppliers as &$productSupplier) { $productSupplier['id_product_supplier'] = (int) $productSupplier['id_product_supplier']; diff --git a/src/Service/ShopContent/StockMvtsService.php b/src/Service/ShopContent/StockMvtsService.php index 2573c762..078cbc5a 100644 --- a/src/Service/ShopContent/StockMvtsService.php +++ b/src/Service/ShopContent/StockMvtsService.php @@ -53,7 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castStockMvts($result, $langIso); + $this->castStockMvts($result); return array_map(function ($item) { return [ @@ -80,7 +80,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castStockMvts($result, $langIso); + $this->castStockMvts($result); return array_map(function ($item) { return [ @@ -105,11 +105,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $stockMvts - * @param string $langIso * * @return void */ - private function castStockMvts(&$stockMvts, $langIso) + private function castStockMvts(&$stockMvts) { foreach ($stockMvts as &$stockMvt) { $date = $stockMvt['date_add']; diff --git a/src/Service/ShopContent/TaxonomiesService.php b/src/Service/ShopContent/TaxonomiesService.php new file mode 100644 index 00000000..f2ebeef5 --- /dev/null +++ b/src/Service/ShopContent/TaxonomiesService.php @@ -0,0 +1,117 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class TaxonomiesService implements ShopContentServiceInterface +{ + /** @var TaxonomyRepository */ + private $taxonomyRepository; + + public function __construct(TaxonomyRepository $taxonomyRepository) + { + $this->taxonomyRepository = $taxonomyRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->taxonomyRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castTaxonomies($result); + + return array_map(function ($item) { + return [ + 'id' => $item['taxonomy_id'], + 'collection' => Config::COLLECTION_TAXONOMIES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->taxonomyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castTaxonomies($result); + + return array_map(function ($item) { + return [ + 'id' => $item['taxonomy_id'], + 'collection' => Config::COLLECTION_TAXONOMIES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->taxonomyRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $taxonomies + * + * @return void + */ + private function castTaxonomies(&$taxonomies) + { + foreach ($taxonomies as &$taxonomy) { + $googleTaxonomy['taxonomy_id'] = "{$taxonomy['id_category']}-{$taxonomy['id_category']}"; + } + } +} diff --git a/src/Service/ShopContent/TranslationsService.php b/src/Service/ShopContent/TranslationsService.php index ccd473da..312f3f91 100644 --- a/src/Service/ShopContent/TranslationsService.php +++ b/src/Service/ShopContent/TranslationsService.php @@ -53,7 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castTranslations($result, $langIso); + $this->castTranslations($result); return array_map(function ($item) { return [ @@ -80,7 +80,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castTranslations($result, $langIso); + $this->castTranslations($result); return array_map(function ($item) { return [ @@ -105,11 +105,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $translations - * @param string $langIso * * @return void */ - private function castTranslations(&$translations, $langIso) + private function castTranslations(&$translations) { foreach ($translations as &$translation) { $translation['id_translation'] = (int) $translation['id_translation']; diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index 6e67c0e0..f7d2fab4 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -53,7 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castWishlistProducts($result, $langIso); + $this->castWishlistProducts($result); return array_map(function ($item) { return [ @@ -80,7 +80,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castWishlistProducts($result, $langIso); + $this->castWishlistProducts($result); return array_map(function ($item) { return [ @@ -105,11 +105,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $wishlistProducts - * @param string $langIso * * @return void */ - private function castWishlistProducts(&$wishlistProducts, $langIso) + private function castWishlistProducts(&$wishlistProducts) { foreach ($wishlistProducts as &$wishlistProduct) { $wishlistProduct['id_wishlist_product'] = (int) $wishlistProduct['id_wishlist_product']; From a91dd2b44fc3d72d72cb1d2033d886b955f8c2d7 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:37:21 +0200 Subject: [PATCH 098/162] feat: add suppliers (#380) --- OLD/Provider/SupplierDataProvider.php | 127 -------------- config/common/new-repository.yml | 4 + config/common/repository.yml | 6 - config/front/services.yml | 6 + e2e/src/helpers/shop-contents.ts | 5 +- src/Decorator/SupplierDecorator.php | 55 ------ src/Helper/CarrierHelper.php | 1 + .../NewRepository/SupplierRepository.php | 130 ++++++++++++++ src/Repository/SupplierRepository.php | 158 ------------------ src/Service/ShopContent/SuppliersService.php | 123 ++++++++++++++ 10 files changed, 266 insertions(+), 349 deletions(-) delete mode 100644 OLD/Provider/SupplierDataProvider.php delete mode 100644 src/Decorator/SupplierDecorator.php create mode 100644 src/Repository/NewRepository/SupplierRepository.php delete mode 100644 src/Repository/SupplierRepository.php create mode 100644 src/Service/ShopContent/SuppliersService.php diff --git a/OLD/Provider/SupplierDataProvider.php b/OLD/Provider/SupplierDataProvider.php deleted file mode 100644 index bd4db1ef..00000000 --- a/OLD/Provider/SupplierDataProvider.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator; -use PrestaShop\Module\PsEventbus\Repository\SupplierRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class SupplierDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var SupplierRepository - */ - private $supplierRepository; - - /** - * @var SupplierDecorator - */ - private $supplierDecorator; - - public function __construct(SupplierRepository $supplierRepository, SupplierDecorator $supplierDecorator) - { - $this->supplierRepository = $supplierRepository; - $this->supplierDecorator = $supplierDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $suppliers = $this->supplierRepository->getSuppliers($offset, $limit, $langIso); - - if (!is_array($suppliers)) { - return []; - } - $this->supplierDecorator->decorateSuppliers($suppliers); - - return array_map(function ($supplier) { - return [ - 'id' => $supplier['id_supplier'], - 'collection' => Config::COLLECTION_SUPPLIERS, - 'properties' => $supplier, - ]; - }, $suppliers); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->supplierRepository->getRemainingSuppliersCount($offset, $langIso); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $suppliers = $this->supplierRepository->getSuppliersIncremental($limit, $langIso, $objectIds); - - if (!is_array($suppliers)) { - return []; - } - $this->supplierDecorator->decorateSuppliers($suppliers); - - return array_map(function ($supplier) { - return [ - 'id' => $supplier['id_supplier'], - 'collection' => Config::COLLECTION_SUPPLIERS, - 'properties' => $supplier, - ]; - }, $suppliers); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->supplierRepository->getQueryForDebug($offset, $limit, $langIso); - } -} diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml index 671de058..a5042ec9 100644 --- a/config/common/new-repository.yml +++ b/config/common/new-repository.yml @@ -110,3 +110,7 @@ services: PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository: class: PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository public: true + + PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository: + class: PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository + public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 346e4a82..04779ffa 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -41,12 +41,6 @@ services: public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Repository\SupplierRepository: - class: PrestaShop\Module\PsEventbus\Repository\SupplierRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository diff --git a/config/front/services.yml b/config/front/services.yml index 199eece9..2bfd1190 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -254,3 +254,9 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index fb82563d..1373bb55 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -3,9 +3,7 @@ import R from "ramda"; // TEMPORARY DISABLED, WAIT ADD ALL SHOP CONTENT // AFTER UNCOMMENT THIS, CHANGE ALL "as ShopContent"CAST IN FULLSYNC TEST /* export const shopContentMapping = { - 'taxonomies': 'taxonomies', 'stores': 'stores', - 'suppliers': 'suppliers', } as const; */ export const shopContentMapping = { @@ -36,11 +34,12 @@ export const shopContentMapping = { specific_prices: "specific-prices", stocks: "stocks", stock_mvts: "stock-mvts", + suppliers: "suppliers", + taxonomies: "taxonomies", themes: "themes", translations: "translations", wishlists: "wishlists", wishlist_products: "wishlist-products", - taxonomies: "taxonomies", } as const; type ShopContentMapping = typeof shopContentMapping; diff --git a/src/Decorator/SupplierDecorator.php b/src/Decorator/SupplierDecorator.php deleted file mode 100644 index 647880fd..00000000 --- a/src/Decorator/SupplierDecorator.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Decorator; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class SupplierDecorator -{ - /** - * @param array $suppliers - * - * @return void - */ - public function decorateSuppliers(&$suppliers) - { - foreach ($suppliers as &$supplier) { - $this->castPropertyValues($supplier); - } - } - - /** - * @param array $supplier - * - * @return void - */ - private function castPropertyValues(&$supplier) - { - $supplier['id_supplier'] = (int) $supplier['id_supplier']; - $supplier['active'] = (bool) $supplier['active']; - $supplier['id_lang'] = (int) $supplier['id_lang']; - $supplier['id_shop'] = (int) $supplier['id_shop']; - $supplier['created_at'] = (string) $supplier['created_at']; - $supplier['updated_at'] = (string) $supplier['updated_at']; - } -} diff --git a/src/Helper/CarrierHelper.php b/src/Helper/CarrierHelper.php index a71728b1..e2505de6 100644 --- a/src/Helper/CarrierHelper.php +++ b/src/Helper/CarrierHelper.php @@ -29,6 +29,7 @@ exit; } +// TODO: reorganise this code to services class CarrierHelper { /** diff --git a/src/Repository/NewRepository/SupplierRepository.php b/src/Repository/NewRepository/SupplierRepository.php new file mode 100644 index 00000000..16f43260 --- /dev/null +++ b/src/Repository/NewRepository/SupplierRepository.php @@ -0,0 +1,130 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class SupplierRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'supplier'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'su'); + + $langId = (int) \Language::getIdByIso($langIso); + + $this->query + ->innerJoin('supplier_lang', 'sul', 'su.id_supplier = sul.id_supplier AND sul.id_lang = ' . (int) $langId) + ->innerJoin('supplier_shop', 'sus', 'su.id_supplier = sus.id_supplier AND sus.id_shop = ' . parent::getShopContext()->id) + ; + + if ($withSelecParameters) { + $this->query + ->select('su.id_supplier') + ->select('su.name') + ->select('su.date_add as created_at') + ->select('su.date_upd as updated_at') + ->select('su.active') + ->select('sul.id_lang') + ->select('sul.description') + ->select('sul.meta_title') + ->select('sul.meta_keywords') + ->select('sul.meta_description') + ->select('sus.id_shop') + ; + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery($debug); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $this->generateFullQuery($langIso, true); + + $this->query + ->where('su.id_supplier IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; + + return $this->runQuery($debug); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, false); + + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); + + $result = $this->runQuery(false); + + return $result[0]['count']; + } +} diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php deleted file mode 100644 index 27d0af79..00000000 --- a/src/Repository/SupplierRepository.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class SupplierRepository -{ - /** - * @var \Db - */ - private $db; - - /** - * @var \Context - */ - private $context; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getSuppliers($offset, $limit, $langIso) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingSuppliersCount($offset, $langIso) - { - $query = $this->getBaseQuery($langIso) - ->select('(COUNT(su.id_supplier) - ' . (int) $offset . ') as count'); - - return (int) $this->db->getValue($query); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $supplierIds - * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopDatabaseException - */ - public function getSuppliersIncremental($limit, $langIso, $supplierIds) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->where('su.id_supplier IN(' . implode(',', array_map('intval', $supplierIds)) . ')') - ->limit($limit); - - return $this->db->executeS($query); - } - - /** - * @param string $langIso - * - * @return \DbQuery - */ - public function getBaseQuery($langIso) - { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - /** @var int $langId */ - $langId = (int) \Language::getIdByIso($langIso); - $query = new \DbQuery(); - $query->from('supplier', 'su') - ->innerJoin('supplier_lang', 'sul', 'su.id_supplier = sul.id_supplier AND sul.id_lang = ' . (int) $langId) - ->innerJoin('supplier_shop', 'sus', 'su.id_supplier = sus.id_supplier AND sus.id_shop = ' . $shopId); - - return $query; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->limit($limit, $offset); - - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); - - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('su.id_supplier, su.name, su.date_add as created_at, su.date_upd as updated_at, su.active, sul.id_lang'); - $query->select('sul.description, sul.meta_title, sul.meta_keywords, sul.meta_description, sus.id_shop'); - } -} diff --git a/src/Service/ShopContent/SuppliersService.php b/src/Service/ShopContent/SuppliersService.php new file mode 100644 index 00000000..93b72068 --- /dev/null +++ b/src/Service/ShopContent/SuppliersService.php @@ -0,0 +1,123 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class SuppliersService implements ShopContentServiceInterface +{ + /** @var SupplierRepository */ + private $supplierRepository; + + public function __construct(SupplierRepository $supplierRepository) + { + $this->supplierRepository = $supplierRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->supplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castSuppliers($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_supplier'], + 'collection' => Config::COLLECTION_SUPPLIERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->supplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castSuppliers($result, $langIso); + + return array_map(function ($item) { + return [ + 'id' => $item['id_supplier'], + 'collection' => Config::COLLECTION_SUPPLIERS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->supplierRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $suppliers + * @param string $langIso + * + * @return void + */ + private function castSuppliers(&$suppliers, $langIso) + { + foreach ($suppliers as &$supplier) { + $supplier['id_supplier'] = (int) $supplier['id_supplier']; + $supplier['active'] = (bool) $supplier['active']; + $supplier['id_lang'] = (int) $supplier['id_lang']; + $supplier['id_shop'] = (int) $supplier['id_shop']; + $supplier['created_at'] = (string) $supplier['created_at']; + $supplier['updated_at'] = (string) $supplier['updated_at']; + } + } +} From 42181ac9cbe526675a54823e5ebaf905028321bf Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:01:50 +0200 Subject: [PATCH 099/162] feat: last edits for v4 (#381) --- OLD/Provider/StoreDataProvider.php | 128 --------- config/admin/services.yml | 1 - config/common/decorator.yml | 2 - config/common/new-repository.yml | 116 --------- config/common/repository.yml | 135 +++++++++- config/front/services.yml | 80 +++--- e2e/src/helpers/shop-contents.ts | 7 +- src/Decorator/PayloadDecorator.php | 11 +- src/Decorator/StoreDecorator.php | 62 ----- src/Helper/CarrierHelper.php | 245 ------------------ .../AbstractRepository.php | 16 +- .../{NewRepository => }/CarrierRepository.php | 2 +- .../CartProductRepository.php | 2 +- .../{NewRepository => }/CartRepository.php | 2 +- .../CartRuleRepository.php | 2 +- .../CategoryRepository.php | 2 +- src/Repository/ConfigurationRepository.php | 42 --- src/Repository/CountryRepository.php | 71 ++--- .../CurrencyRepository.php | 2 +- .../CustomerRepository.php | 2 +- .../EmployeeRepository.php | 2 +- src/Repository/EventbusSyncRepository.php | 75 ++---- .../{NewRepository => }/ImageRepository.php | 2 +- .../ImageTypeRepository.php | 2 +- src/Repository/IncrementalSyncRepository.php | 84 +++--- .../LanguageRepository.php | 2 +- src/Repository/LiveSyncRepository.php | 2 + .../ManufacturerRepository.php | 2 +- .../{NewRepository => }/ModuleRepository.php | 2 +- .../OrderCartRuleRepository.php | 2 +- .../OrderDetailRepository.php | 2 +- .../OrderHistoryRepository.php | 2 +- .../{NewRepository => }/OrderRepository.php | 2 +- .../ProductBundleRepository.php | 2 +- .../ProductCarrierRepository.php | 24 +- .../{NewRepository => }/ProductRepository.php | 10 +- .../ProductSupplierRepository.php | 2 +- .../RepositoryInterface.php | 2 +- src/Repository/ShopRepository.php | 39 +-- .../SpecificPriceRepository.php | 2 +- src/Repository/StateRepository.php | 51 ++-- .../StockMvtRepository.php | 2 +- .../{NewRepository => }/StockRepository.php | 27 +- src/Repository/StoreRepository.php | 176 +++++-------- .../SupplierRepository.php | 4 +- src/Repository/TaxeRepository.php | 89 +++---- .../TaxonomyRepository.php | 2 +- .../TranslationRepository.php | 2 +- .../WishlistProductRepository.php | 2 +- .../WishlistRepository.php | 2 +- src/Service/FrontApiService.php | 5 +- .../ShopContent/CarrierDetailsService.php | 73 +++++- .../ShopContent/CarrierTaxesService.php | 72 ++++- src/Service/ShopContent/CarriersService.php | 106 ++++++-- .../ShopContent/CartProductsService.php | 2 +- src/Service/ShopContent/CartRulesService.php | 2 +- src/Service/ShopContent/CartsService.php | 2 +- src/Service/ShopContent/CategoriesService.php | 2 +- src/Service/ShopContent/CurrenciesService.php | 2 +- src/Service/ShopContent/CustomersService.php | 2 +- src/Service/ShopContent/EmployeesService.php | 2 +- src/Service/ShopContent/ImageTypesService.php | 2 +- src/Service/ShopContent/ImagesService.php | 2 +- src/Service/ShopContent/LanguagesService.php | 2 +- .../ShopContent/ManufacturersService.php | 2 +- src/Service/ShopContent/ModulesService.php | 2 +- .../ShopContent/OrderCartRulesService.php | 2 +- .../ShopContent/OrderDetailsService.php | 2 +- .../ShopContent/OrderHistoriesService.php | 2 +- src/Service/ShopContent/OrdersService.php | 4 +- .../ShopContent/ProductBundlesService.php | 2 +- .../ShopContent/ProductCarriersService.php | 2 +- .../ShopContent/ProductSuppliersService.php | 2 +- src/Service/ShopContent/ProductsService.php | 2 +- .../ShopContent/ShopDetailsService.php | 27 +- .../ShopContent/SpecificPricesService.php | 4 +- src/Service/ShopContent/StockMvtsService.php | 2 +- src/Service/ShopContent/StocksService.php | 2 +- src/Service/ShopContent/StoresService.php | 128 +++++++++ src/Service/ShopContent/SuppliersService.php | 9 +- src/Service/ShopContent/TaxonomiesService.php | 2 +- .../ShopContent/TranslationsService.php | 2 +- .../ShopContent/WishlistProductsService.php | 2 +- src/Service/ShopContent/WishlistsService.php | 2 +- src/Service/SynchronizationService.php | 10 +- src/Traits/UseHooks.php | 124 ++++++--- 86 files changed, 956 insertions(+), 1205 deletions(-) delete mode 100644 OLD/Provider/StoreDataProvider.php delete mode 100644 config/common/new-repository.yml delete mode 100644 src/Decorator/StoreDecorator.php delete mode 100644 src/Helper/CarrierHelper.php rename src/Repository/{NewRepository => }/AbstractRepository.php (88%) rename src/Repository/{NewRepository => }/CarrierRepository.php (98%) rename src/Repository/{NewRepository => }/CartProductRepository.php (98%) rename src/Repository/{NewRepository => }/CartRepository.php (98%) rename src/Repository/{NewRepository => }/CartRuleRepository.php (98%) rename src/Repository/{NewRepository => }/CategoryRepository.php (98%) delete mode 100644 src/Repository/ConfigurationRepository.php rename src/Repository/{NewRepository => }/CurrencyRepository.php (98%) rename src/Repository/{NewRepository => }/CustomerRepository.php (98%) rename src/Repository/{NewRepository => }/EmployeeRepository.php (98%) rename src/Repository/{NewRepository => }/ImageRepository.php (98%) rename src/Repository/{NewRepository => }/ImageTypeRepository.php (98%) rename src/Repository/{NewRepository => }/LanguageRepository.php (98%) rename src/Repository/{NewRepository => }/ManufacturerRepository.php (98%) rename src/Repository/{NewRepository => }/ModuleRepository.php (98%) rename src/Repository/{NewRepository => }/OrderCartRuleRepository.php (98%) rename src/Repository/{NewRepository => }/OrderDetailRepository.php (98%) rename src/Repository/{NewRepository => }/OrderHistoryRepository.php (98%) rename src/Repository/{NewRepository => }/OrderRepository.php (99%) rename src/Repository/{NewRepository => }/ProductBundleRepository.php (98%) rename src/Repository/{NewRepository => }/ProductCarrierRepository.php (83%) rename src/Repository/{NewRepository => }/ProductRepository.php (96%) rename src/Repository/{NewRepository => }/ProductSupplierRepository.php (98%) rename src/Repository/{NewRepository => }/RepositoryInterface.php (96%) rename src/Repository/{NewRepository => }/SpecificPriceRepository.php (98%) rename src/Repository/{NewRepository => }/StockMvtRepository.php (98%) rename src/Repository/{NewRepository => }/StockRepository.php (85%) rename src/Repository/{NewRepository => }/SupplierRepository.php (98%) rename src/Repository/{NewRepository => }/TaxonomyRepository.php (98%) rename src/Repository/{NewRepository => }/TranslationRepository.php (98%) rename src/Repository/{NewRepository => }/WishlistProductRepository.php (98%) rename src/Repository/{NewRepository => }/WishlistRepository.php (98%) create mode 100644 src/Service/ShopContent/StoresService.php diff --git a/OLD/Provider/StoreDataProvider.php b/OLD/Provider/StoreDataProvider.php deleted file mode 100644 index 50b916cc..00000000 --- a/OLD/Provider/StoreDataProvider.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\StoreDecorator; -use PrestaShop\Module\PsEventbus\Repository\StoreRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StoreDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var StoreRepository - */ - private $storeRepository; - /** - * @var StoreDecorator - */ - private $storeDecorator; - - public function __construct(StoreRepository $storeRepository, StoreDecorator $storeDecorator) - { - $this->storeRepository = $storeRepository; - $this->storeDecorator = $storeDecorator; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $stores = $this->storeRepository->getStores($offset, $limit, $langIso); - - if (!is_array($stores)) { - return []; - } - - $this->storeDecorator->decorateStores($stores); - - return array_map(function ($store) { - return [ - 'id' => $store['id_store'], - 'collection' => Config::COLLECTION_STORES, - 'properties' => $store, - ]; - }, $stores); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingObjectsCount($offset, $langIso) - { - return (int) $this->storeRepository->getRemainingStoreCount($offset, $langIso); - } - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $stores = $this->storeRepository->getStoresIncremental($limit, $langIso, $objectIds); - - if (!is_array($stores)) { - return []; - } - - $this->storeDecorator->decorateStores($stores); - - return array_map(function ($store) { - return [ - 'id' => $store['id_store'], - 'collection' => Config::COLLECTION_STORES, - 'properties' => $store, - ]; - }, $stores); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso) - { - return $this->storeRepository->getQueryForDebug($offset, $limit, $langIso); - } -} diff --git a/config/admin/services.yml b/config/admin/services.yml index 0489a1c6..521fb78a 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1,7 +1,6 @@ imports: - { resource: ../common/common.yml } - { resource: ../common/repository.yml } - - { resource: ../common/new-repository.yml } - { resource: ../front/services.yml } services: diff --git a/config/common/decorator.yml b/config/common/decorator.yml index 9166e823..1f9307f4 100644 --- a/config/common/decorator.yml +++ b/config/common/decorator.yml @@ -2,8 +2,6 @@ services: PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator: class: PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' PrestaShop\Module\PsEventbus\Decorator\StoreDecorator: class: PrestaShop\Module\PsEventbus\Decorator\StoreDecorator diff --git a/config/common/new-repository.yml b/config/common/new-repository.yml deleted file mode 100644 index a5042ec9..00000000 --- a/config/common/new-repository.yml +++ /dev/null @@ -1,116 +0,0 @@ -services: - PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository: - class: PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository - public: true diff --git a/config/common/repository.yml b/config/common/repository.yml index 04779ffa..87cf2c4c 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -1,8 +1,4 @@ services: - PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository: - class: PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository - public: true - PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository public: true @@ -13,7 +9,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' PrestaShop\Module\PsEventbus\Repository\ShopRepository: @@ -35,13 +30,131 @@ services: public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - - PrestaShop\Module\PsEventbus\Repository\StoreRepository: - class: PrestaShop\Module\PsEventbus\Repository\StoreRepository - public: true - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository public: true + +############################################################################################################ +###################################### SHOP CONTENT REPOSITORIES ########################################### +############################################################################################################ + + PrestaShop\Module\PsEventbus\Repository\OrderRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CarrierRepository: + class: PrestaShop\Module\PsEventbus\Repository\CarrierRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CartRepository: + class: PrestaShop\Module\PsEventbus\Repository\CartRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CartProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\CartProductRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CartRuleRepository: + class: PrestaShop\Module\PsEventbus\Repository\CartRuleRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\ProductRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository: + class: PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository: + class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository: + class: PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CategoryRepository: + class: PrestaShop\Module\PsEventbus\Repository\CategoryRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CustomerRepository: + class: PrestaShop\Module\PsEventbus\Repository\CustomerRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CurrencyRepository: + class: PrestaShop\Module\PsEventbus\Repository\CurrencyRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\EmployeeRepository: + class: PrestaShop\Module\PsEventbus\Repository\EmployeeRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ImageRepository: + class: PrestaShop\Module\PsEventbus\Repository\ImageRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository: + class: PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ModuleRepository: + class: PrestaShop\Module\PsEventbus\Repository\ModuleRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\WishlistRepository: + class: PrestaShop\Module\PsEventbus\Repository\WishlistRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\LanguageRepository: + class: PrestaShop\Module\PsEventbus\Repository\LanguageRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository: + class: PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\TranslationRepository: + class: PrestaShop\Module\PsEventbus\Repository\TranslationRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\StockRepository: + class: PrestaShop\Module\PsEventbus\Repository\StockRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\StockMvtRepository: + class: PrestaShop\Module\PsEventbus\Repository\StockMvtRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository: + class: PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository: + class: PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\SupplierRepository: + class: PrestaShop\Module\PsEventbus\Repository\SupplierRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\StoreRepository: + class: PrestaShop\Module\PsEventbus\Repository\StoreRepository + public: true diff --git a/config/front/services.yml b/config/front/services.yml index 2bfd1190..34b498a9 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -3,7 +3,6 @@ imports: - { resource: ../common/common.yml } - { resource: ../common/decorator.yml } - { resource: ../common/repository.yml } - - { resource: ../common/new-repository.yml } services: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService: @@ -50,75 +49,77 @@ services: - '%ps_eventbus.live_sync_api_url%' - '%ps_eventbus.proxy_api_url%' - # SHOP CONTENT SERVICES +############################################################################################################ +###################################### SHOP CONTENT SERVICES ############################################### +############################################################################################################ + PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository' - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' - - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CarrierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CarrierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CarrierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CartRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CartProductsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartProductsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CartProductRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CartRulesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartRulesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CartRuleRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' @@ -127,62 +128,61 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CustomerRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CurrencyRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\EmployeesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\EmployeesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository' + - '@PrestaShop\Module\PsEventbus\Repository\EmployeeRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ImagesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImagesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ImageRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ImageTypesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ImageTypesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' @@ -191,7 +191,7 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ModuleRepository' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService: @@ -204,59 +204,65 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository' + - '@PrestaShop\Module\PsEventbus\Repository\WishlistRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository' + - '@PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository' + - '@PrestaShop\Module\PsEventbus\Repository\TranslationRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\StocksService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\StocksService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository' + - '@PrestaShop\Module\PsEventbus\Repository\StockRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\StockMvtsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\StockMvtsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository' + - '@PrestaShop\Module\PsEventbus\Repository\StockMvtRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository' - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository' + - '@PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\TaxonomiesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\TaxonomiesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository' + - '@PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\SupplierRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\StoreRepository' diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 1373bb55..2e969c5a 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -1,11 +1,5 @@ import R from "ramda"; -// TEMPORARY DISABLED, WAIT ADD ALL SHOP CONTENT -// AFTER UNCOMMENT THIS, CHANGE ALL "as ShopContent"CAST IN FULLSYNC TEST -/* export const shopContentMapping = { - 'stores': 'stores', -} as const; */ - export const shopContentMapping = { carriers: "carriers", carrier_details: "carrier-details", @@ -34,6 +28,7 @@ export const shopContentMapping = { specific_prices: "specific-prices", stocks: "stocks", stock_mvts: "stock-mvts", + stores: "stores", suppliers: "suppliers", taxonomies: "taxonomies", themes: "themes", diff --git a/src/Decorator/PayloadDecorator.php b/src/Decorator/PayloadDecorator.php index fa74ca0d..6cf5fead 100644 --- a/src/Decorator/PayloadDecorator.php +++ b/src/Decorator/PayloadDecorator.php @@ -20,8 +20,6 @@ namespace PrestaShop\Module\PsEventbus\Decorator; -use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; - // use hardcoded format to avoid problems with interface change in PHP 7.2 const ISO8601 = 'Y-m-d\TH:i:sO'; const DATE_FIELDS = [ @@ -41,19 +39,14 @@ class PayloadDecorator { - /** - * @var ConfigurationRepository - */ - private $configurationRepository; /** * @var string */ private $timezone; - public function __construct(ConfigurationRepository $configurationRepository) + public function __construct() { - $this->configurationRepository = $configurationRepository; - $this->timezone = (string) $this->configurationRepository->get('PS_TIMEZONE'); + $this->timezone = (string) \Configuration::get('PS_TIMEZONE'); } /** diff --git a/src/Decorator/StoreDecorator.php b/src/Decorator/StoreDecorator.php deleted file mode 100644 index 66db4d77..00000000 --- a/src/Decorator/StoreDecorator.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Decorator; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StoreDecorator -{ - /** - * @param array $stores - * - * @return void - */ - public function decorateStores(&$stores) - { - foreach ($stores as &$store) { - $this->castPropertyValues($store); - } - } - - /** - * @param array $store - * - * @return void - */ - private function castPropertyValues(&$store) - { - $store['id_store'] = (int) $store['id_store']; - $store['id_country'] = (int) $store['id_country']; - $store['id_state'] = (int) $store['id_state']; - $store['active'] = (bool) $store['active']; - - // https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.3.0', '>=')) { - $store['id_lang'] = (int) $store['id_lang']; - $store['id_shop'] = (int) $store['id_shop']; - } - - $store['created_at'] = (string) $store['created_at']; - $store['updated_at'] = (string) $store['updated_at']; - } -} diff --git a/src/Helper/CarrierHelper.php b/src/Helper/CarrierHelper.php deleted file mode 100644 index e2505de6..00000000 --- a/src/Helper/CarrierHelper.php +++ /dev/null @@ -1,245 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Helper; - -use Carrier; -use PrestaShop\Module\PsEventbus\Repository\CountryRepository; -use PrestaShop\Module\PsEventbus\Repository\StateRepository; -use PrestaShop\Module\PsEventbus\Repository\TaxeRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -// TODO: reorganise this code to services -class CarrierHelper -{ - /** - * Build a CarrierDetail from Carrier data - * - * @param array $carrierData - * - * @return array - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public static function buildCarrierDetails($carrierData) - { - /** @var \Ps_eventbus $module */ - $module = \Module::getInstanceByName('ps_eventbus'); - - /** @var CountryRepository $countryRepository */ - $countryRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\CountryRepository'); - - /** @var StateRepository $stateRepository */ - $stateRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\StateRepository'); - - $carrier = new \Carrier($carrierData['id_reference']); - - $deliveryPriceByRanges = CarrierHelper::getDeliveryPriceByRange($carrier); - - if (!$deliveryPriceByRanges) { - return []; - } - - $carrierDetails = []; - - foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { - $range = CarrierHelper::getCarrierRange($deliveryPriceByRange); - - if (!$range) { - continue; - } - - foreach ($deliveryPriceByRange['zones'] as $zone) { - /** @var array $countryIsoCodes */ - $countryIsoCodes = $countryRepository->getCountyIsoCodesByZoneId($zone['id_zone'], true); - - /** @var array $stateIsoCodes */ - $stateIsoCodes = $stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); - - $carrierDetail = []; - $carrierDetail['id_reference'] = $carrier->id_reference; - $carrierDetail['id_zone'] = $zone['id_zone']; - $carrierDetail['id_range'] = $range->id; - $carrierDetail['id_carrier_detail'] = $range->id; - $carrierDetail['shipping_method'] = $carrier->getRangeTable(); - $carrierDetail['delimiter1'] = $range->delimiter1; - $carrierDetail['delimiter2'] = $range->delimiter2; - $carrierDetail['country_ids'] = implode(',', $countryIsoCodes); - $carrierDetail['state_ids'] = implode(',', $stateIsoCodes); - $carrierDetail['price'] = $zone['price']; - - array_push($carrierDetails, $carrierDetail); - } - } - - return $carrierDetails; - } - - /** - * Build a CarrierTaxes from Carrier - * - * @param array $carrierData - * - * @return array - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public static function buildCarrierTaxes($carrierData) - { - /** @var \Ps_eventbus $module */ - $module = \Module::getInstanceByName('ps_eventbus'); - - /** @var TaxeRepository $taxeRepository */ - $taxeRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\TaxeRepository'); - - $carrier = new \Carrier($carrierData['id_reference']); - - $deliveryPriceByRanges = CarrierHelper::getDeliveryPriceByRange($carrier); - - if (!$deliveryPriceByRanges) { - return []; - } - - $carrierTaxes = []; - - foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { - $range = CarrierHelper::getCarrierRange($deliveryPriceByRange); - - if (!$range) { - continue; - } - - foreach ($deliveryPriceByRange['zones'] as $zone) { - $taxRulesGroupId = (int) $carrier->getIdTaxRulesGroup(); - - /** @var array $carrierTaxesByZone */ - $carrierTaxesByZone = $taxeRepository->getCarrierTaxesByZone($zone['id_zone'], $taxRulesGroupId, true); - - if (!$carrierTaxesByZone[0]['country_iso_code']) { - continue; - } - - $carrierTaxesByZone = $carrierTaxesByZone[0]; - - $carrierTaxe = []; - - $carrierTaxe['id_reference'] = $carrier->id_reference; - $carrierTaxe['id_zone'] = $zone['id_zone']; - $carrierTaxe['id_range'] = $range->id; - $carrierTaxe['id_carrier_tax'] = $taxRulesGroupId; - $carrierTaxe['country_id'] = $carrierTaxesByZone['country_iso_code']; - $carrierTaxe['state_ids'] = $carrierTaxesByZone['state_iso_code']; - $carrierTaxe['tax_rate'] = $carrierTaxesByZone['rate']; - - array_push($carrierTaxes, $carrierTaxe); - } - } - - return $carrierTaxes; - } - - /** - * @param array $deliveryPriceByRange - * - * @return false|\RangeWeight|\RangePrice - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private static function getCarrierRange($deliveryPriceByRange) - { - if (isset($deliveryPriceByRange['id_range_weight'])) { - return new \RangeWeight($deliveryPriceByRange['id_range_weight']); - } - if (isset($deliveryPriceByRange['id_range_price'])) { - return new \RangePrice($deliveryPriceByRange['id_range_price']); - } - - return false; - } - - /** - * @param \Carrier $carrierObj - * - * @return array|false - */ - private static function getDeliveryPriceByRange(\Carrier $carrierObj) - { - $rangeTable = $carrierObj->getRangeTable(); - - switch ($rangeTable) { - case 'range_weight': - return CarrierHelper::getCarrierByWeightRange($carrierObj, 'range_weight'); - case 'range_price': - return CarrierHelper::getCarrierByPriceRange($carrierObj, 'range_price'); - default: - return false; - } - } - - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - private static function getCarrierByWeightRange(\Carrier $carrierObj, $rangeTable) - { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_weight']]['id_range_weight'] = $range['id_range_weight']; - $filteredRanges[$range['id_range_weight']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['price'] = $range['price']; - } - - return $filteredRanges; - } - - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - private static function getCarrierByPriceRange(\Carrier $carrierObj, $rangeTable) - { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_price']]['id_range_price'] = $range['id_range_price']; - $filteredRanges[$range['id_range_price']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['price'] = $range['price']; - } - - return $filteredRanges; - } -} diff --git a/src/Repository/NewRepository/AbstractRepository.php b/src/Repository/AbstractRepository.php similarity index 88% rename from src/Repository/NewRepository/AbstractRepository.php rename to src/Repository/AbstractRepository.php index 89aba5fa..37408c41 100644 --- a/src/Repository/NewRepository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; use PrestaShop\Module\PsEventbus\Service\CommonService; @@ -76,6 +76,20 @@ public function getContext() return $this->context; } + /** + * @return \Language|\PrestaShopBundle\Install\Language + * + * @throws \PrestaShopException + */ + public function getLanguageContext() + { + if ($this->context->language === null) { + throw new \PrestaShopException('No language context'); + } + + return $this->context->language; + } + /** * @return \Shop * diff --git a/src/Repository/NewRepository/CarrierRepository.php b/src/Repository/CarrierRepository.php similarity index 98% rename from src/Repository/NewRepository/CarrierRepository.php rename to src/Repository/CarrierRepository.php index d36529c2..37231c57 100644 --- a/src/Repository/NewRepository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/CartProductRepository.php b/src/Repository/CartProductRepository.php similarity index 98% rename from src/Repository/NewRepository/CartProductRepository.php rename to src/Repository/CartProductRepository.php index 486fa7f2..be0e3bde 100644 --- a/src/Repository/NewRepository/CartProductRepository.php +++ b/src/Repository/CartProductRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/CartRepository.php b/src/Repository/CartRepository.php similarity index 98% rename from src/Repository/NewRepository/CartRepository.php rename to src/Repository/CartRepository.php index 6133862d..3cf67031 100644 --- a/src/Repository/NewRepository/CartRepository.php +++ b/src/Repository/CartRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php similarity index 98% rename from src/Repository/NewRepository/CartRuleRepository.php rename to src/Repository/CartRuleRepository.php index 816dba93..6d1721e0 100644 --- a/src/Repository/NewRepository/CartRuleRepository.php +++ b/src/Repository/CartRuleRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/CategoryRepository.php b/src/Repository/CategoryRepository.php similarity index 98% rename from src/Repository/NewRepository/CategoryRepository.php rename to src/Repository/CategoryRepository.php index 0e08ed9d..097369f6 100644 --- a/src/Repository/NewRepository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php deleted file mode 100644 index 5be58906..00000000 --- a/src/Repository/ConfigurationRepository.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -use Configuration; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class ConfigurationRepository -{ - /** - * We wrap Configuration::get function in here to be able to mock static functions - * - * @param string $key - * - * @return bool|string - */ - public function get($key) - { - return \Configuration::get($key); - } -} diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index 6d24240b..8e77ff75 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -24,79 +24,48 @@ exit; } -class CountryRepository +class CountryRepository extends AbstractRepository { - /** - * @var \Db - */ - private $db; - - /** - * @var \Context - */ - private $context; + const TABLE_NAME = 'country'; /** * @var array */ private $countryIsoCodeCache = []; - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - if ($this->context->shop == null) { - throw new \PrestaShopException('No shop context'); - } - - if ($this->context->language == null) { - throw new \PrestaShopException('No language context'); - } - - $query = new \DbQuery(); - - $query->from('country', 'c') - ->innerJoin('country_shop', 'cs', 'cs.id_country = c.id_country') - ->innerJoin('country_lang', 'cl', 'cl.id_country = c.id_country') - ->where('cs.id_shop = ' . (int) $this->context->shop->id) - ->where('cl.id_lang = ' . (int) $this->context->language->id); - - return $query; - } - /** * @param int $zoneId * @param bool $active * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * @return array * * @throws \PrestaShopDatabaseException */ public function getCountyIsoCodesByZoneId($zoneId, $active) { $cacheKey = $zoneId . '-' . (int) $active; + $isoCodes = []; if (!isset($this->countryIsoCodeCache[$cacheKey])) { - $query = $this->getBaseQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'c'); + + $this->query + ->innerJoin('country_shop', 'cs', 'cs.id_country = c.id_country') + ->innerJoin('country_lang', 'cl', 'cl.id_country = c.id_country') + ->where('cs.id_shop = ' . (int) parent::getShopContext()->id) + ->where('cl.id_lang = ' . (int) parent::getLanguageContext()->id) + ->where('id_zone = ' . (int) $zoneId) + ->where('active = ' . (bool) $active) + ; - $query->select('iso_code'); - $query->where('id_zone = ' . (int) $zoneId); - $query->where('active = ' . (bool) $active); + $this->query->select('iso_code'); - $isoCodes = []; - $result = $this->db->executeS($query); - if (is_array($result)) { - foreach ($result as $country) { - $isoCodes[] = $country['iso_code']; - } + $result = $this->runQuery(false); + + foreach ($result as $country) { + $isoCodes[] = $country['iso_code']; } + $this->countryIsoCodeCache[$cacheKey] = $isoCodes; } diff --git a/src/Repository/NewRepository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php similarity index 98% rename from src/Repository/NewRepository/CurrencyRepository.php rename to src/Repository/CurrencyRepository.php index 220818c8..4af3dabf 100644 --- a/src/Repository/NewRepository/CurrencyRepository.php +++ b/src/Repository/CurrencyRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/CustomerRepository.php b/src/Repository/CustomerRepository.php similarity index 98% rename from src/Repository/NewRepository/CustomerRepository.php rename to src/Repository/CustomerRepository.php index c8a31a35..2fbe76e7 100644 --- a/src/Repository/NewRepository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php similarity index 98% rename from src/Repository/NewRepository/EmployeeRepository.php rename to src/Repository/EmployeeRepository.php index 0a4c42bf..65530995 100644 --- a/src/Repository/NewRepository/EmployeeRepository.php +++ b/src/Repository/EmployeeRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/EventbusSyncRepository.php b/src/Repository/EventbusSyncRepository.php index 8da7ad3e..d1be1af7 100644 --- a/src/Repository/EventbusSyncRepository.php +++ b/src/Repository/EventbusSyncRepository.php @@ -24,37 +24,11 @@ exit; } -class EventbusSyncRepository +class EventbusSyncRepository extends AbstractRepository { const TYPE_SYNC_TABLE_NAME = 'eventbus_type_sync'; const JOB_TABLE_NAME = 'eventbus_job'; - /** - * @var \Db - */ - private $db; - /** - * @var \Context - */ - private $context; - - /** - * @var int - */ - private $shopId; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; - } - /** * @param string $type * @param int $offset @@ -71,7 +45,7 @@ public function upsertTypeSync($type, $offset, $date, $fullSyncFinished, $langIs [ 'type' => pSQL((string) $type), 'offset' => (int) $offset, - 'id_shop' => $this->shopId, + 'id_shop' => parent::getShopContext()->id, 'lang_iso' => pSQL((string) $langIso), 'full_sync_finished' => (int) $fullSyncFinished, 'last_sync_date' => pSQL($date), @@ -108,12 +82,12 @@ public function insertJob($jobId, $date) */ public function findJobById($jobId) { - $query = new \DbQuery(); - $query->select('*') - ->from(self::JOB_TABLE_NAME) - ->where('job_id = "' . pSQL($jobId) . '"'); + $this->generateMinimalQuery(self::JOB_TABLE_NAME, 'ej'); + + $this->query->where('ej.job_id = "' . pSQL($jobId) . '"'); + $this->query->select('ej.*'); - return $this->db->getRow($query); + return $this->db->getRow($this->query); } /** @@ -124,14 +98,17 @@ public function findJobById($jobId) */ public function findTypeSync($type, $langIso = null) { - $query = new \DbQuery(); - $query->select('*') - ->from(self::TYPE_SYNC_TABLE_NAME) - ->where('type = "' . pSQL($type) . '"') - ->where('lang_iso = "' . pSQL((string) $langIso) . '"') - ->where('id_shop = ' . $this->shopId); - - return $this->db->getRow($query); + $this->generateMinimalQuery(self::TYPE_SYNC_TABLE_NAME, 'ets'); + + $this->query + ->where('ets.type = "' . pSQL($type) . '"') + ->where('ets.lang_iso = "' . pSQL((string) $langIso) . '"') + ->where('ets.id_shop = ' . parent::getShopContext()->id) + ; + + $this->query->select('ets.*'); + + return $this->db->getRow($this->query); } /** @@ -142,14 +119,16 @@ public function findTypeSync($type, $langIso = null) */ public function isFullSyncDoneForThisTypeSync($type, $langIso = null) { - $query = new \DbQuery(); + $this->generateMinimalQuery(self::TYPE_SYNC_TABLE_NAME, 'ets'); + + $this->query + ->where('ets.type = "' . pSQL($type) . '"') + ->where('ets.lang_iso = "' . pSQL((string) $langIso) . '"') + ->where('ets.id_shop = ' . parent::getShopContext()->id) + ; - $query->select('full_sync_finished') - ->from(self::TYPE_SYNC_TABLE_NAME) - ->where('type = "' . pSQL($type) . '"') - ->where('lang_iso = "' . pSQL((string) $langIso) . '"') - ->where('id_shop = ' . $this->shopId); + $this->query->select('ets.full_sync_finished'); - return (bool) $this->db->getValue($query); + return (bool) $this->db->getValue($this->query); } } diff --git a/src/Repository/NewRepository/ImageRepository.php b/src/Repository/ImageRepository.php similarity index 98% rename from src/Repository/NewRepository/ImageRepository.php rename to src/Repository/ImageRepository.php index fe806835..5cbd1667 100644 --- a/src/Repository/NewRepository/ImageRepository.php +++ b/src/Repository/ImageRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php similarity index 98% rename from src/Repository/NewRepository/ImageTypeRepository.php rename to src/Repository/ImageTypeRepository.php index bf94b89a..f1a96cea 100644 --- a/src/Repository/NewRepository/ImageTypeRepository.php +++ b/src/Repository/ImageTypeRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 4eeee744..dd3fbeae 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -26,39 +26,20 @@ exit; } -class IncrementalSyncRepository +class IncrementalSyncRepository extends AbstractRepository { - const INCREMENTAL_SYNC_TABLE = 'eventbus_incremental_sync'; + const TABLE_NAME = 'eventbus_incremental_sync'; - /** - * @var \Db - */ - private $db; - /** - * @var \Context - */ - private $context; /** * @var ErrorHandlerInterface */ private $errorHandler; - /** - * @var int - */ - private $shopId; - - public function __construct(\Context $context, ErrorHandlerInterface $errorHandler) + public function __construct(ErrorHandlerInterface $errorHandler) { - $this->db = \Db::getInstance(); - $this->context = $context; $this->errorHandler = $errorHandler; - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $this->shopId = (int) $this->context->shop->id; + parent::__construct(); } /** @@ -78,7 +59,7 @@ public function insertIncrementalObject($data) $elementsCount = count($arrayOfData); $index = 0; - $query = 'INSERT INTO `' . _DB_PREFIX_ . $this::INCREMENTAL_SYNC_TABLE . '` (type, id_object, id_shop, lang_iso, created_at) VALUES '; + $query = 'INSERT INTO `' . _DB_PREFIX_ . self::TABLE_NAME . '` (type, id_object, id_shop, lang_iso, created_at) VALUES '; foreach ($arrayOfData as $currenData) { $dateTime = new \DateTime($currenData['created_at']); @@ -126,9 +107,9 @@ public function insertIncrementalObject($data) public function removeIncrementalSyncObjects($type, $objectIds, $langIso) { return $this->db->delete( - self::INCREMENTAL_SYNC_TABLE, + self::TABLE_NAME, 'type = "' . pSQL($type) . '" - AND id_shop = ' . $this->shopId . ' + AND id_shop = ' . parent::getShopContext()->id . ' AND id_object IN(' . implode(',', array_map('intval', $objectIds)) . ') AND lang_iso = "' . pSQL($langIso) . '"' ); @@ -145,18 +126,20 @@ public function removeIncrementalSyncObjects($type, $objectIds, $langIso) */ public function getIncrementalSyncObjectIds($type, $langIso, $limit) { - $query = new \DbQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'eis'); - $query->select('id_object') - ->from(self::INCREMENTAL_SYNC_TABLE) - ->where('lang_iso = "' . pSQL($langIso) . '"') - ->where('id_shop = "' . $this->shopId . '"') - ->where('type = "' . pSQL($type) . '"') - ->limit($limit); + $this->query + ->where('eis.lang_iso = "' . pSQL($langIso) . '"') + ->where('eis.id_shop = "' . parent::getShopContext()->id . '"') + ->where('eis.type = "' . pSQL($type) . '"') + ->limit($limit) + ; - $result = $this->db->executeS($query); + $this->query->select('eis.id_object'); - if (is_array($result) && !empty($result)) { + $result = $this->runQuery(false); + + if (!empty($result)) { return array_map(function ($object) { return $object['id_object']; }, $result); @@ -173,15 +156,17 @@ public function getIncrementalSyncObjectIds($type, $langIso, $limit) */ public function getRemainingIncrementalObjects($type, $langIso) { - $query = new \DbQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'eis'); + + $this->query + ->where('eis.lang_iso = "' . pSQL($langIso) . '"') + ->where('eis.id_shop = "' . parent::getShopContext()->id . '"') + ->where('eis.type = "' . pSQL($type) . '"') + ; - $query->select('COUNT(id_object) as count') - ->from(self::INCREMENTAL_SYNC_TABLE) - ->where('lang_iso = "' . pSQL($langIso) . '"') - ->where('id_shop = "' . $this->shopId . '"') - ->where('type = "' . pSQL($type) . '"'); + $this->query->select('COUNT(eis.id_object) as count'); - return (int) $this->db->getValue($query); + return (int) $this->db->getValue($this->query); } /** @@ -193,9 +178,9 @@ public function getRemainingIncrementalObjects($type, $langIso) public function removeIncrementalSyncObject($type, $objectId) { return $this->db->delete( - self::INCREMENTAL_SYNC_TABLE, + self::TABLE_NAME, 'type = "' . pSQL($type) . '" - AND id_shop = ' . $this->shopId . ' + AND id_shop = ' . parent::getShopContext()->id . ' AND id_object = ' . (int) $objectId ); } @@ -207,13 +192,12 @@ public function removeIncrementalSyncObject($type, $objectId) */ public function getIncrementalSyncObjectCountByType($type) { - $query = new \DbQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 'eis'); - $query->select('COUNT(type) as count') - ->from(self::INCREMENTAL_SYNC_TABLE) - ->where('type = "' . psql($type) . '"'); + $this->query->where('eis.type = "' . psql($type) . '"'); + $this->query->select('COUNT(eis.type) as count'); - return (int) $this->db->getValue($query); + return (int) $this->db->getValue($this->query); } /** @@ -224,7 +208,7 @@ public function getIncrementalSyncObjectCountByType($type) public function removeIncrementaSyncObjectByType($type) { return $this->db->delete( - self::INCREMENTAL_SYNC_TABLE, + self::TABLE_NAME, 'type = "' . pSQL($type) . '"' ); } diff --git a/src/Repository/NewRepository/LanguageRepository.php b/src/Repository/LanguageRepository.php similarity index 98% rename from src/Repository/NewRepository/LanguageRepository.php rename to src/Repository/LanguageRepository.php index 4bf06682..e98c4508 100644 --- a/src/Repository/NewRepository/LanguageRepository.php +++ b/src/Repository/LanguageRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/LiveSyncRepository.php b/src/Repository/LiveSyncRepository.php index 0d3e7565..e0a174a7 100644 --- a/src/Repository/LiveSyncRepository.php +++ b/src/Repository/LiveSyncRepository.php @@ -26,6 +26,8 @@ class LiveSyncRepository { + const TABLE_NAME = 'eventbus_live_sync'; + /** * @var \Db */ diff --git a/src/Repository/NewRepository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php similarity index 98% rename from src/Repository/NewRepository/ManufacturerRepository.php rename to src/Repository/ManufacturerRepository.php index d21c6c01..01b24b3e 100644 --- a/src/Repository/NewRepository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/ModuleRepository.php b/src/Repository/ModuleRepository.php similarity index 98% rename from src/Repository/NewRepository/ModuleRepository.php rename to src/Repository/ModuleRepository.php index d4368a73..9a51cd7b 100644 --- a/src/Repository/NewRepository/ModuleRepository.php +++ b/src/Repository/ModuleRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php similarity index 98% rename from src/Repository/NewRepository/OrderCartRuleRepository.php rename to src/Repository/OrderCartRuleRepository.php index 52884bb4..6e7320c2 100644 --- a/src/Repository/NewRepository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/OrderDetailRepository.php b/src/Repository/OrderDetailRepository.php similarity index 98% rename from src/Repository/NewRepository/OrderDetailRepository.php rename to src/Repository/OrderDetailRepository.php index 26df8292..c6c0552a 100644 --- a/src/Repository/NewRepository/OrderDetailRepository.php +++ b/src/Repository/OrderDetailRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php similarity index 98% rename from src/Repository/NewRepository/OrderHistoryRepository.php rename to src/Repository/OrderHistoryRepository.php index 8065e892..2141fc7a 100644 --- a/src/Repository/NewRepository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/OrderRepository.php b/src/Repository/OrderRepository.php similarity index 99% rename from src/Repository/NewRepository/OrderRepository.php rename to src/Repository/OrderRepository.php index d256e6d2..e793e01b 100644 --- a/src/Repository/NewRepository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/ProductBundleRepository.php b/src/Repository/ProductBundleRepository.php similarity index 98% rename from src/Repository/NewRepository/ProductBundleRepository.php rename to src/Repository/ProductBundleRepository.php index cea73ba1..6ec4150a 100644 --- a/src/Repository/NewRepository/ProductBundleRepository.php +++ b/src/Repository/ProductBundleRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/ProductCarrierRepository.php b/src/Repository/ProductCarrierRepository.php similarity index 83% rename from src/Repository/NewRepository/ProductCarrierRepository.php rename to src/Repository/ProductCarrierRepository.php index fbbba94c..1b044749 100644 --- a/src/Repository/NewRepository/ProductCarrierRepository.php +++ b/src/Repository/ProductCarrierRepository.php @@ -18,7 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; + +use PrestaShopException; +use PrestaShopDatabaseException; if (!defined('_PS_VERSION_')) { exit; @@ -110,4 +113,23 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) return $result[0]['count']; } + + /** + * @param int $idProduct + * @return array + * + * @throws PrestaShopException + * @throws PrestaShopDatabaseException + */ + public function getProductCarrierIdsByCarrierId($idProduct) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'pc'); + + $this->query + ->where('pc.id_product = ' . (int) $idProduct) + ->where('pc.id_shop = ' . parent::getShopContext()->id) + ; + + return $this->runQuery(false); + } } diff --git a/src/Repository/NewRepository/ProductRepository.php b/src/Repository/ProductRepository.php similarity index 96% rename from src/Repository/NewRepository/ProductRepository.php rename to src/Repository/ProductRepository.php index 8201796f..6717b9b0 100644 --- a/src/Repository/NewRepository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; @@ -229,10 +229,6 @@ public function getProductAttributeValues($attributeIds, $langIso) } return $resultArray; - - /* return array_reduce($attributes, function ($key, $attribute) { - return $attribute[$attribute['id_product_attribute']][$attribute['name']] = $attribute['value']; - }); */ } /** @@ -270,10 +266,6 @@ public function getProductFeatures($productIds, $langIso) } return $resultArray; - - /* return array_reduce($features, function ($key, $feature) { - return $feature[$feature['id_product']][$feature['name']] = $feature['value']; - }); */ } /** diff --git a/src/Repository/NewRepository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php similarity index 98% rename from src/Repository/NewRepository/ProductSupplierRepository.php rename to src/Repository/ProductSupplierRepository.php index aafe335b..ee35f697 100644 --- a/src/Repository/NewRepository/ProductSupplierRepository.php +++ b/src/Repository/ProductSupplierRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/RepositoryInterface.php b/src/Repository/RepositoryInterface.php similarity index 96% rename from src/Repository/NewRepository/RepositoryInterface.php rename to src/Repository/RepositoryInterface.php index a434946a..bb1323aa 100644 --- a/src/Repository/NewRepository/RepositoryInterface.php +++ b/src/Repository/RepositoryInterface.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/ShopRepository.php b/src/Repository/ShopRepository.php index 1bf8d656..04afabd2 100644 --- a/src/Repository/ShopRepository.php +++ b/src/Repository/ShopRepository.php @@ -24,30 +24,19 @@ exit; } -class ShopRepository +class ShopRepository extends AbstractRepository { - /** - * @var \Db - */ - private $db; - - public function __construct() - { - $this->db = \Db::getInstance(); - } - /** * @return int */ public function getMultiShopCount() { - $query = new \DbQuery(); + $this->generateMinimalQuery('shop', 's'); - $query->select('COUNT(id_shop)') - ->from('shop') - ->where('active = 1 and deleted = 0'); + $this->query->where('s.active = 1 and s.deleted = 0'); + $this->query->select('COUNT(s.id_shop)'); - return (int) $this->db->getValue($query); + return (int) $this->db->getValue($this->query); } /** @@ -55,13 +44,12 @@ public function getMultiShopCount() */ public function getCreatedAt() { - $query = new \DbQuery(); + $this->generateMinimalQuery('configuration', 'c'); - $query->select('date_add as created_at') - ->from('configuration') - ->where('name = "PS_INSTALL_VERSION"'); + $this->query->where('c.name = "PS_INSTALL_VERSION"'); + $this->query->select('c.date_add as created_at'); - return (string) $this->db->getValue($query); + return (string) $this->db->getValue($this->query); } /** @@ -71,12 +59,11 @@ public function getCreatedAt() */ public function getShopCountryCode() { - $query = new \DbQuery(); + $this->generateMinimalQuery('country', 'c'); - $query->select('iso_code') - ->from('country') - ->where('active = 1'); + $this->query->where('c.active = 1'); + $this->query->select('c.iso_code'); - return (string) $this->db->getValue($query); + return (string) $this->db->getValue($this->query); } } diff --git a/src/Repository/NewRepository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php similarity index 98% rename from src/Repository/NewRepository/SpecificPriceRepository.php rename to src/Repository/SpecificPriceRepository.php index 4bc95b0c..7219b3c3 100644 --- a/src/Repository/NewRepository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index 58d807b3..85d5f592 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -24,64 +24,45 @@ exit; } -class StateRepository +class StateRepository extends AbstractRepository { - /** - * @var \Db - */ - private $db; + const TABLE_NAME = 'state'; /** * @var array */ private $stateIsoCodeCache = []; - public function __construct() - { - $this->db = \Db::getInstance(); - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - $query = new \DbQuery(); - - $query->from('state', 's'); - - return $query; - } - /** * @param int $zoneId * @param bool $active * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * @return array * * @throws \PrestaShopDatabaseException */ public function getStateIsoCodesByZoneId($zoneId, $active) { $cacheKey = $zoneId . '-' . (int) $active; + $isoCodes = []; if (!isset($this->stateIsoCodeCache[$cacheKey])) { - $query = $this->getBaseQuery(); + $this->generateMinimalQuery(self::TABLE_NAME, 's'); + + $this->query->innerJoin('country', 'c', 'c.id_country = s.id_country') + ->where('s.id_zone = ' . (int) $zoneId) + ->where('s.active = ' . (bool) $active) + ->where('c.active = ' . (bool) $active) + ; - $query->select('s.iso_code'); - $query->innerJoin('country', 'c', 'c.id_country = s.id_country'); - $query->where('s.id_zone = ' . (int) $zoneId); - $query->where('s.active = ' . (bool) $active); - $query->where('c.active = ' . (bool) $active); + $this->query->select('s.iso_code'); - $isoCodes = []; + $result = $this->runQuery(false); - $result = $this->db->executeS($query); - if (is_array($result)) { - foreach ($result as $state) { - $isoCodes[] = $state['iso_code']; - } + foreach ($result as $state) { + $isoCodes[] = $state['iso_code']; } + $this->stateIsoCodeCache[$cacheKey] = $isoCodes; } diff --git a/src/Repository/NewRepository/StockMvtRepository.php b/src/Repository/StockMvtRepository.php similarity index 98% rename from src/Repository/NewRepository/StockMvtRepository.php rename to src/Repository/StockMvtRepository.php index 8150dd66..abf36e86 100644 --- a/src/Repository/NewRepository/StockMvtRepository.php +++ b/src/Repository/StockMvtRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/StockRepository.php b/src/Repository/StockRepository.php similarity index 85% rename from src/Repository/NewRepository/StockRepository.php rename to src/Repository/StockRepository.php index f12386d5..b23b14d8 100644 --- a/src/Repository/NewRepository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -18,7 +18,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; + +use PrestaShopException; +use PrestaShopDatabaseException; if (!defined('_PS_VERSION_')) { exit; @@ -132,4 +135,26 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) return $result[0]['count']; } + + /** + * @param int $productId + * + * @return mixed + * @throws PrestaShopException + * @throws PrestaShopDatabaseException + */ + public function getStockIdByProductId($productId) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'sa'); + + $this->query + ->select('sa.id_stock_available') + ->where('sa.id_product = ' . (int) $productId) + ->where('sa.id_shop = ' . (int) parent::getShopContext()->id) + ; + + $result = $this->runQuery(false); + + return $result[0]['id_stock_available']; + } } diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index 0ddfbe7a..3c59e9e2 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -24,113 +24,107 @@ exit; } -class StoreRepository +class StoreRepository extends AbstractRepository implements RepositoryInterface { - const STORES_TABLE = 'store'; - - /** - * @var \Db - */ - private $db; - /** - * @var \Context - */ - private $context; - - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } + const TABLE_NAME = 'store'; /** * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed * - * @return \DbQuery + * @throws \PrestaShopException */ - public function getBaseQuery($langIso) + public function generateFullQuery($langIso, $withSelecParameters) { - if ($this->context->shop === null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; + $this->generateMinimalQuery(self::TABLE_NAME, 's'); $langId = (int) \Language::getIdByIso($langIso); - $query = new \DbQuery(); - // https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004 if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.3.0', '>=')) { - $query->from(self::STORES_TABLE, 's') + $this->query ->leftJoin('store_lang', 'sl', 's.id_store = sl.id_store') ->leftJoin('store_shop', 'ss', 's.id_store = ss.id_store') - ->where('ss.id_shop = ' . (int) $shopId) - ->where('sl.id_lang = ' . (int) $langId); - } else { - $query->from(self::STORES_TABLE, 's'); + ->where('ss.id_shop = ' . (int) parent::getShopContext()->id) + ->where('sl.id_lang = ' . (int) $langId) + ; } - return $query; + if ($withSelecParameters) { + $this->query + ->select('s.id_store') + ->select('s.id_country') + ->select('s.id_state') + ->select('s.city') + ->select('s.postcode') + ->select('s.active') + ->select('s.date_add as created_at') + ->select('s.date_upd as updated_at') + ; + + // https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.3.0', '>=')) { + $this->query + ->select('sl.id_lang') + ->select('sl.name') + ->select('sl.address1') + ->select('sl.address2') + ->select('sl.hours') + ->select('ss.id_shop') + ; + } else { + $this->query + ->select('s.name') + ->select('s.address1') + ->select('s.address2') + ->select('s.hours') + ; + } + } } /** * @param int $offset * @param int $limit * @param string $langIso + * @param bool $debug * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * @return array * + * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getStores($offset, $limit, $langIso) - { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); - - $query->limit((int) $limit, (int) $offset); - - return $this->db->executeS($query); - } - - /** - * @param int $offset - * @param string $langIso - * - * @return int - */ - public function getRemainingStoreCount($offset, $langIso) + public function retrieveContentsForFull($offset, $limit, $langIso, $debug) { - $stores = $this->getStores($offset, 1, $langIso); + $this->generateFullQuery($langIso, true); - if (!is_array($stores) || empty($stores)) { - return 0; - } + $this->query->limit((int) $limit, (int) $offset); - return count($stores); + return $this->runQuery($debug); } /** * @param int $limit + * @param array $contentIds * @param string $langIso - * @param array $storeIds + * @param bool $debug * * @return array * + * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getStoresIncremental($limit, $langIso, $storeIds) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) { - $query = $this->getBaseQuery($langIso); + $this->generateFullQuery($langIso, true); - $this->addSelectParameters($query); + $this->query + ->where('s.id_store IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit) + ; - $query->where('s.id_store IN(' . implode(',', array_map('intval', $storeIds)) . ')') - ->limit($limit); - - $result = $this->db->executeS($query); - - return is_array($result) ? $result : []; + return $this->runQuery($debug); } /** @@ -138,55 +132,19 @@ public function getStoresIncremental($limit, $langIso, $storeIds) * @param int $limit * @param string $langIso * - * @return array + * @return int * + * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getQueryForDebug($offset, $limit, $langIso) + public function countFullSyncContentLeft($offset, $limit, $langIso) { - $query = $this->getBaseQuery($langIso); - - $this->addSelectParameters($query); + $this->generateFullQuery($langIso, false); - $query->limit($limit, $offset); + $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $queryStringified = preg_replace('/\s+/', ' ', $query->build()); + $result = $this->runQuery(false); - return array_merge( - (array) $query, - ['queryStringified' => $queryStringified] - ); - } - - /** - * @param \DbQuery $query - * - * @return void - */ - private function addSelectParameters(\DbQuery $query) - { - $query->select('s.id_store'); - $query->select('s.id_country'); - $query->select('s.id_state'); - $query->select('s.city'); - $query->select('s.postcode'); - $query->select('s.active'); - $query->select('s.date_add as created_at'); - $query->select('s.date_upd as updated_at'); - - // https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004 - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.3.0', '>=')) { - $query->select('sl.id_lang'); - $query->select('sl.name'); - $query->select('sl.address1'); - $query->select('sl.address2'); - $query->select('sl.hours'); - $query->select('ss.id_shop'); - } else { - $query->select('s.name'); - $query->select('s.address1'); - $query->select('s.address2'); - $query->select('s.hours'); - } + return $result[0]['count']; } } diff --git a/src/Repository/NewRepository/SupplierRepository.php b/src/Repository/SupplierRepository.php similarity index 98% rename from src/Repository/NewRepository/SupplierRepository.php rename to src/Repository/SupplierRepository.php index 16f43260..8dd4849f 100644 --- a/src/Repository/NewRepository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; @@ -41,7 +41,7 @@ public function generateFullQuery($langIso, $withSelecParameters) $this->generateMinimalQuery(self::TABLE_NAME, 'su'); $langId = (int) \Language::getIdByIso($langIso); - + $this->query ->innerJoin('supplier_lang', 'sul', 'su.id_supplier = sul.id_supplier AND sul.id_lang = ' . (int) $langId) ->innerJoin('supplier_shop', 'sus', 'su.id_supplier = sus.id_supplier AND sus.id_shop = ' . parent::getShopContext()->id) diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php index d18d7caf..2c1dbe0b 100644 --- a/src/Repository/TaxeRepository.php +++ b/src/Repository/TaxeRepository.php @@ -24,65 +24,21 @@ exit; } -class TaxeRepository +class TaxeRepository extends AbstractRepository { - /** - * @var \Db - */ - private $db; - - /** - * @var \Context - */ - private $context; + const TABLE_NAME = 'tax'; /** * @var array */ private $countryIsoCodeCache = []; - public function __construct(\Context $context) - { - $this->db = \Db::getInstance(); - $this->context = $context; - } - - /** - * @return \DbQuery - */ - private function getBaseQuery() - { - if ($this->context->shop == null) { - throw new \PrestaShopException('No shop context'); - } - - $shopId = (int) $this->context->shop->id; - - if ($this->context->language == null) { - throw new \PrestaShopException('No language context'); - } - - $language = (int) $this->context->language->id; - - $query = new \DbQuery(); - - $query->from('tax', 't') - ->innerJoin('tax_rule', 'tr', 'tr.id_tax = t.id_tax') - ->innerJoin('tax_rules_group', 'trg', 'trg.id_tax_rules_group = tr.id_tax_rules_group') - ->innerJoin('tax_rules_group_shop', 'trgs', 'trgs.id_tax_rules_group = tr.id_tax_rules_group') - ->innerJoin('tax_lang', 'tl', 'tl.id_tax = t.id_tax') - ->where('trgs.id_shop = ' . $shopId) - ->where('tl.id_lang = ' . $language); - - return $query; - } - /** * @param int $zoneId * @param int $taxRulesGroupId * @param bool $active * - * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * @return array * * @throws \PrestaShopDatabaseException */ @@ -91,19 +47,32 @@ public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active) $cacheKey = $zoneId . '-' . (int) $active; if (!isset($this->countryIsoCodeCache[$cacheKey])) { - $query = $this->getBaseQuery(); - - $query->select('rate, c.iso_code as country_iso_code, GROUP_CONCAT(s.iso_code SEPARATOR ",") as state_iso_code'); - $query->leftJoin('country', 'c', 'c.id_country = tr.id_country'); - $query->leftJoin('state', 's', 's.id_state = tr.id_state'); - $query->where('tr.id_tax_rules_group = ' . (int) $taxRulesGroupId); - $query->where('c.active = ' . (bool) $active); - $query->where('s.active = ' . (bool) $active . ' OR s.active IS NULL'); - $query->where('t.active = ' . (bool) $active); - $query->where('c.id_zone = ' . (int) $zoneId . ' OR s.id_zone = ' . (int) $zoneId); - $query->where('c.iso_code IS NOT NULL'); - - $this->countryIsoCodeCache[$cacheKey] = $this->db->executeS($query); + $this->generateMinimalQuery(self::TABLE_NAME, 't'); + + $this->query + ->innerJoin('tax_rule', 'tr', 'tr.id_tax = t.id_tax') + ->innerJoin('tax_rules_group', 'trg', 'trg.id_tax_rules_group = tr.id_tax_rules_group') + ->innerJoin('tax_rules_group_shop', 'trgs', 'trgs.id_tax_rules_group = tr.id_tax_rules_group') + ->innerJoin('tax_lang', 'tl', 'tl.id_tax = t.id_tax') + ->leftJoin('country', 'c', 'c.id_country = tr.id_country') + ->leftJoin('state', 's', 's.id_state = tr.id_state') + ->where('tr.id_tax_rules_group = ' . (int) $taxRulesGroupId) + ->where('c.active = ' . (bool) $active) + ->where('s.active = ' . (bool) $active . ' OR s.active IS NULL') + ->where('t.active = ' . (bool) $active) + ->where('c.id_zone = ' . (int) $zoneId . ' OR s.id_zone = ' . (int) $zoneId) + ->where('c.iso_code IS NOT NULL') + ->where('trgs.id_shop = ' . parent::getShopContext()->id) + ->where('tl.id_lang = ' . (int) parent::getLanguageContext()->id) + ; + + $this->query + ->select('t.rate') + ->select('c.iso_code as country_iso_code') + ->select('GROUP_CONCAT(s.iso_code SEPARATOR ",") as state_iso_code') + ; + + $this->countryIsoCodeCache[$cacheKey] = $this->runQuery(false); } return $this->countryIsoCodeCache[$cacheKey]; diff --git a/src/Repository/NewRepository/TaxonomyRepository.php b/src/Repository/TaxonomyRepository.php similarity index 98% rename from src/Repository/NewRepository/TaxonomyRepository.php rename to src/Repository/TaxonomyRepository.php index 51e1e67d..15e80091 100644 --- a/src/Repository/NewRepository/TaxonomyRepository.php +++ b/src/Repository/TaxonomyRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/TranslationRepository.php b/src/Repository/TranslationRepository.php similarity index 98% rename from src/Repository/NewRepository/TranslationRepository.php rename to src/Repository/TranslationRepository.php index 523f2e89..5401f4e6 100644 --- a/src/Repository/NewRepository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php similarity index 98% rename from src/Repository/NewRepository/WishlistProductRepository.php rename to src/Repository/WishlistProductRepository.php index f6d3e70e..f0f4e2cc 100644 --- a/src/Repository/NewRepository/WishlistProductRepository.php +++ b/src/Repository/WishlistProductRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Repository/NewRepository/WishlistRepository.php b/src/Repository/WishlistRepository.php similarity index 98% rename from src/Repository/NewRepository/WishlistRepository.php rename to src/Repository/WishlistRepository.php index 4924b50d..86a7f5e8 100644 --- a/src/Repository/NewRepository/WishlistRepository.php +++ b/src/Repository/WishlistRepository.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PsEventbus\Repository\NewRepository; +namespace PrestaShop\Module\PsEventbus\Repository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 7b4477e8..ca356d02 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -25,7 +25,6 @@ use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; -use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService; @@ -111,12 +110,10 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync CommonService::exitWithResponse($response); } - /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $this->module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); /** @var LanguagesService $languagesService */ $languagesService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService'); - $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); + $timezone = (string) \Configuration::get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); $langIso = $langIso ? $langIso : $languagesService->getDefaultLanguageIsoCode(); diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index 752e4377..c39a39c6 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -21,8 +21,9 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Helper\CarrierHelper; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\CarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\CountryRepository; +use PrestaShop\Module\PsEventbus\Repository\StateRepository; if (!defined('_PS_VERSION_')) { exit; @@ -57,7 +58,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) $carrierDetails = []; foreach ($result as $carrierData) { - $carrierDetails = array_merge($carrierDetails, CarrierHelper::buildCarrierDetails($carrierData)); + $carrierDetails = array_merge($carrierDetails, $this->buildCarrierDetails($carrierData)); } $this->castCarrierDetails($carrierDetails); @@ -90,7 +91,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) $carrierDetails = []; foreach ($result as $carrierData) { - $carrierDetails = array_merge($carrierDetails, CarrierHelper::buildCarrierDetails($carrierData)); + $carrierDetails = array_merge($carrierDetails, $this->buildCarrierDetails($carrierData)); } $this->castCarrierDetails($carrierDetails); @@ -136,4 +137,68 @@ private function castCarrierDetails(&$carrierDetails) $carrierDetail['price'] = (float) $carrierDetail['price']; } } + + /** + * Build a CarrierDetail from Carrier data + * + * @param array $carrierData + * + * @return array + * + * @throws \PrestaShopDatabaseException + * @throws \PrestaShopException + */ + private function buildCarrierDetails($carrierData) + { + /** @var \Ps_eventbus $module */ + $module = \Module::getInstanceByName('ps_eventbus'); + + /** @var CountryRepository $countryRepository */ + $countryRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\CountryRepository'); + + /** @var StateRepository $stateRepository */ + $stateRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\StateRepository'); + + $carrier = new \Carrier($carrierData['id_reference']); + + $deliveryPriceByRanges = CarriersService::getDeliveryPriceByRange($carrier); + + if (!$deliveryPriceByRanges) { + return []; + } + + $carrierDetails = []; + + foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { + $range = CarriersService::getCarrierRange($deliveryPriceByRange); + + if (!$range) { + continue; + } + + foreach ($deliveryPriceByRange['zones'] as $zone) { + /** @var array $countryIsoCodes */ + $countryIsoCodes = $countryRepository->getCountyIsoCodesByZoneId($zone['id_zone'], true); + + /** @var array $stateIsoCodes */ + $stateIsoCodes = $stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); + + $carrierDetail = []; + $carrierDetail['id_reference'] = $carrier->id_reference; + $carrierDetail['id_zone'] = $zone['id_zone']; + $carrierDetail['id_range'] = $range->id; + $carrierDetail['id_carrier_detail'] = $range->id; + $carrierDetail['shipping_method'] = $carrier->getRangeTable(); + $carrierDetail['delimiter1'] = $range->delimiter1; + $carrierDetail['delimiter2'] = $range->delimiter2; + $carrierDetail['country_ids'] = implode(',', $countryIsoCodes); + $carrierDetail['state_ids'] = implode(',', $stateIsoCodes); + $carrierDetail['price'] = $zone['price']; + + array_push($carrierDetails, $carrierDetail); + } + } + + return $carrierDetails; + } } diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index f8b445e1..1093d9cc 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -21,8 +21,8 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Helper\CarrierHelper; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\CarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\TaxeRepository; if (!defined('_PS_VERSION_')) { exit; @@ -57,7 +57,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) $carrierTaxes = []; foreach ($result as $carrierData) { - $carrierTaxes = array_merge($carrierTaxes, CarrierHelper::buildCarrierTaxes($carrierData)); + $carrierTaxes = array_merge($carrierTaxes, $this->buildCarrierTaxes($carrierData)); } $this->castCarrierTaxes($carrierTaxes); @@ -90,7 +90,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) $carrierTaxes = []; foreach ($result as $carrierData) { - $carrierTaxes = array_merge($carrierTaxes, CarrierHelper::buildCarrierDetails($carrierData)); + $carrierTaxes = array_merge($carrierTaxes, $this->buildCarrierTaxes($carrierData)); } $this->castCarrierTaxes($carrierTaxes); @@ -135,4 +135,68 @@ private function castCarrierTaxes(&$carrierTaxes) $carrierTaxe['tax_rate'] = (float) $carrierTaxe['tax_rate']; } } + + /** + * Build a CarrierTaxes from Carrier + * + * @param array $carrierData + * + * @return array + * + * @throws \PrestaShopDatabaseException + * @throws \PrestaShopException + */ + private function buildCarrierTaxes($carrierData) + { + /** @var \Ps_eventbus $module */ + $module = \Module::getInstanceByName('ps_eventbus'); + + /** @var TaxeRepository $taxeRepository */ + $taxeRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\TaxeRepository'); + + $carrier = new \Carrier($carrierData['id_reference']); + + $deliveryPriceByRanges = CarriersService::getDeliveryPriceByRange($carrier); + + if (!$deliveryPriceByRanges) { + return []; + } + + $carrierTaxes = []; + + foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { + $range = CarriersService::getCarrierRange($deliveryPriceByRange); + + if (!$range) { + continue; + } + + foreach ($deliveryPriceByRange['zones'] as $zone) { + $taxRulesGroupId = (int) $carrier->getIdTaxRulesGroup(); + + /** @var array $carrierTaxesByZone */ + $carrierTaxesByZone = $taxeRepository->getCarrierTaxesByZone($zone['id_zone'], $taxRulesGroupId, true); + + if (!$carrierTaxesByZone[0]['country_iso_code']) { + continue; + } + + $carrierTaxesByZone = $carrierTaxesByZone[0]; + + $carrierTaxe = []; + + $carrierTaxe['id_reference'] = $carrier->id_reference; + $carrierTaxe['id_zone'] = $zone['id_zone']; + $carrierTaxe['id_range'] = $range->id; + $carrierTaxe['id_carrier_tax'] = $taxRulesGroupId; + $carrierTaxe['country_id'] = $carrierTaxesByZone['country_iso_code']; + $carrierTaxe['state_ids'] = $carrierTaxesByZone['state_iso_code']; + $carrierTaxe['tax_rate'] = $carrierTaxesByZone['rate']; + + array_push($carrierTaxes, $carrierTaxe); + } + } + + return $carrierTaxes; + } } diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 46fc279d..67dd6ee7 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -21,8 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\CarrierRepository; if (!defined('_PS_VERSION_')) { exit; @@ -33,15 +32,9 @@ class CarriersService implements ShopContentServiceInterface /** @var CarrierRepository */ private $carrierRepository; - /** @var ConfigurationRepository */ - private $configurationRepository; - - public function __construct( - CarrierRepository $carrierRepository, - ConfigurationRepository $configurationRepository - ) { + public function __construct(CarrierRepository $carrierRepository) + { $this->carrierRepository = $carrierRepository; - $this->configurationRepository = $configurationRepository; } /** @@ -110,6 +103,89 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) return $this->carrierRepository->countFullSyncContentLeft($offset, $limit, $langIso); } + /** + * @param array $deliveryPriceByRange + * + * @return false|\RangeWeight|\RangePrice + * + * @throws \PrestaShopDatabaseException + * @throws \PrestaShopException + */ + public static function getCarrierRange($deliveryPriceByRange) + { + if (isset($deliveryPriceByRange['id_range_weight'])) { + return new \RangeWeight($deliveryPriceByRange['id_range_weight']); + } + if (isset($deliveryPriceByRange['id_range_price'])) { + return new \RangePrice($deliveryPriceByRange['id_range_price']); + } + + return false; + } + + /** + * @param \Carrier $carrierObj + * + * @return array|false + */ + public static function getDeliveryPriceByRange(\Carrier $carrierObj) + { + $rangeTable = $carrierObj->getRangeTable(); + + switch ($rangeTable) { + case 'range_weight': + return CarriersService::getCarrierByWeightRange($carrierObj, 'range_weight'); + case 'range_price': + return CarriersService::getCarrierByPriceRange($carrierObj, 'range_price'); + default: + return false; + } + } + + /** + * @param \Carrier $carrierObj + * @param string $rangeTable + * + * @return array + */ + public static function getCarrierByWeightRange(\Carrier $carrierObj, $rangeTable) + { + $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); + + $filteredRanges = []; + + foreach ($deliveryPriceByRange as $range) { + $filteredRanges[$range['id_range_weight']]['id_range_weight'] = $range['id_range_weight']; + $filteredRanges[$range['id_range_weight']]['id_carrier'] = $range['id_carrier']; + $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; + $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['price'] = $range['price']; + } + + return $filteredRanges; + } + + /** + * @param \Carrier $carrierObj + * @param string $rangeTable + * + * @return array + */ + public static function getCarrierByPriceRange(\Carrier $carrierObj, $rangeTable) + { + $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); + + $filteredRanges = []; + + foreach ($deliveryPriceByRange as $range) { + $filteredRanges[$range['id_range_price']]['id_range_price'] = $range['id_range_price']; + $filteredRanges[$range['id_range_price']]['id_carrier'] = $range['id_carrier']; + $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; + $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['price'] = $range['price']; + } + + return $filteredRanges; + } + /** * @param array $carriers * @@ -123,12 +199,12 @@ private function castCarriers(&$carriers) throw new \PrestaShopException('Context is null'); } - $currency = new \Currency((int) $this->configurationRepository->get('PS_CURRENCY_DEFAULT')); - $freeShippingStartsAtPrice = (float) $this->configurationRepository->get('PS_SHIPPING_FREE_PRICE'); - $freeShippingStartsAtWeight = (float) $this->configurationRepository->get('PS_SHIPPING_FREE_WEIGHT'); + $currency = new \Currency((int) \Configuration::get('PS_CURRENCY_DEFAULT')); + $freeShippingStartsAtPrice = (float) \Configuration::get('PS_SHIPPING_FREE_PRICE'); + $freeShippingStartsAtWeight = (float) \Configuration::get('PS_SHIPPING_FREE_WEIGHT'); /** @var string $psWeightUnit */ - $psWeightUnit = $this->configurationRepository->get('PS_WEIGHT_UNIT'); + $psWeightUnit = \Configuration::get('PS_WEIGHT_UNIT'); foreach ($carriers as &$carrier) { $carrierTaxesRatesGroupId = \Carrier::getIdTaxRulesGroupByIdCarrier((int) $carrier['id_carrier'], \Context::getContext()); @@ -136,7 +212,7 @@ private function castCarriers(&$carriers) $shippingHandling = 0.0; if ($carrier['shipping_handling']) { - $shippingHandling = (float) $this->configurationRepository->get('PS_SHIPPING_HANDLING'); + $shippingHandling = (float) \Configuration::get('PS_SHIPPING_HANDLING'); } $carrier['id_carrier'] = (string) $carrier['id_carrier']; diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index ec7046f7..d8593835 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CartProductRepository; +use PrestaShop\Module\PsEventbus\Repository\CartProductRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index 18213bcc..0da3fad4 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRuleRepository; +use PrestaShop\Module\PsEventbus\Repository\CartRuleRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 7b520b36..0f3e99f5 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CartRepository; +use PrestaShop\Module\PsEventbus\Repository\CartRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index 94dff845..6e66526d 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CategoryRepository; +use PrestaShop\Module\PsEventbus\Repository\CategoryRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index 370cedb8..79947d0d 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CurrencyRepository; +use PrestaShop\Module\PsEventbus\Repository\CurrencyRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index 54cf9bf3..a5ddb24f 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\CustomerRepository; +use PrestaShop\Module\PsEventbus\Repository\CustomerRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index c27223ed..7ab69920 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\EmployeeRepository; +use PrestaShop\Module\PsEventbus\Repository\EmployeeRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index 2d2f32ac..a65d9517 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageTypeRepository; +use PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index 4d86a6a1..ef9a1b42 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ImageRepository; +use PrestaShop\Module\PsEventbus\Repository\ImageRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index 52e95b5f..981fc6e2 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\LanguageRepository; +use PrestaShop\Module\PsEventbus\Repository\LanguageRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ManufacturersService.php b/src/Service/ShopContent/ManufacturersService.php index 27274444..e39eefac 100644 --- a/src/Service/ShopContent/ManufacturersService.php +++ b/src/Service/ShopContent/ManufacturersService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ManufacturerRepository; +use PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 470e8e55..629bff8e 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ModuleRepository; +use PrestaShop\Module\PsEventbus\Repository\ModuleRepository; use PrestaShop\Module\PsEventbus\Repository\ShopRepository; if (!defined('_PS_VERSION_')) { diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index b8de764a..3cc76bb5 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderCartRuleRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index 2ff51778..b7537760 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderDetailRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index 244fd7a5..e84021cf 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 40f83b16..f64b7010 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -22,8 +22,8 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderHistoryRepository; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\OrderRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index fa072df7..fb267dbc 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductBundleRepository; +use PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/ProductCarriersService.php index e1496885..349aebc9 100644 --- a/src/Service/ShopContent/ProductCarriersService.php +++ b/src/Service/ShopContent/ProductCarriersService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductCarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index 3840eeef..e9be62f7 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductSupplierRepository; +use PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index b3fd31a2..3fb75de3 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -22,7 +22,7 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository; +use PrestaShop\Module\PsEventbus\Repository\ProductRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/ShopDetailsService.php b/src/Service/ShopContent/ShopDetailsService.php index 16e41e13..eb3f2997 100644 --- a/src/Service/ShopContent/ShopDetailsService.php +++ b/src/Service/ShopContent/ShopDetailsService.php @@ -21,7 +21,6 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\ShopRepository; if (!defined('_PS_VERSION_')) { @@ -36,9 +35,6 @@ class ShopDetailsService implements ShopContentServiceInterface /** @var LanguagesService */ private $languagesService; - /** @var ConfigurationRepository */ - private $configurationRepository; - /** @var \Context */ private $context; @@ -47,7 +43,6 @@ class ShopDetailsService implements ShopContentServiceInterface /** * @param \Context $context - * @param ConfigurationRepository $configurationRepository * @param ShopRepository $shopRepository * @param LanguagesService $languagesService * @param CurrenciesService $currenciesService @@ -56,14 +51,12 @@ class ShopDetailsService implements ShopContentServiceInterface */ public function __construct( \Context $context, - ConfigurationRepository $configurationRepository, ShopRepository $shopRepository, LanguagesService $languagesService, CurrenciesService $currenciesService ) { $this->currenciesService = $currenciesService; $this->languagesService = $languagesService; - $this->configurationRepository = $configurationRepository; $this->shopRepository = $shopRepository; $this->context = $context; } @@ -101,23 +94,23 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) 'created_at' => $this->shopRepository->getCreatedAt(), 'folder_created_at' => $folderCreatedAt, 'cms_version' => _PS_VERSION_, - 'url_is_simplified' => $this->configurationRepository->get('PS_REWRITING_SETTINGS') == '1', - 'cart_is_persistent' => $this->configurationRepository->get('PS_CART_FOLLOWING') == '1', + 'url_is_simplified' => \Configuration::get('PS_REWRITING_SETTINGS') == '1', + 'cart_is_persistent' => \Configuration::get('PS_CART_FOLLOWING') == '1', 'default_language' => $this->languagesService->getDefaultLanguageIsoCode(), 'languages' => implode(';', $this->languagesService->getLanguagesIsoCodes()), 'default_currency' => $this->currenciesService->getDefaultCurrencyIsoCode(), 'currencies' => implode(';', $this->currenciesService->getCurrenciesIsoCodes()), - 'weight_unit' => $this->configurationRepository->get('PS_WEIGHT_UNIT'), - 'distance_unit' => $this->configurationRepository->get('PS_BASE_DISTANCE_UNIT'), - 'volume_unit' => $this->configurationRepository->get('PS_VOLUME_UNIT'), - 'dimension_unit' => $this->configurationRepository->get('PS_DIMENSION_UNIT'), - 'timezone' => $this->configurationRepository->get('PS_TIMEZONE'), - 'is_order_return_enabled' => $this->configurationRepository->get('PS_ORDER_RETURN') == '1', - 'order_return_nb_days' => (int) $this->configurationRepository->get('PS_ORDER_RETURN_NB_DAYS'), + 'weight_unit' => \Configuration::get('PS_WEIGHT_UNIT'), + 'distance_unit' => \Configuration::get('PS_BASE_DISTANCE_UNIT'), + 'volume_unit' => \Configuration::get('PS_VOLUME_UNIT'), + 'dimension_unit' => \Configuration::get('PS_DIMENSION_UNIT'), + 'timezone' => \Configuration::get('PS_TIMEZONE'), + 'is_order_return_enabled' => \Configuration::get('PS_ORDER_RETURN') == '1', + 'order_return_nb_days' => (int) \Configuration::get('PS_ORDER_RETURN_NB_DAYS'), 'php_version' => phpversion(), 'http_server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '', 'url' => $this->context->link->getPageLink('index', null, $langId), - 'ssl' => $this->configurationRepository->get('PS_SSL_ENABLED') == '1', + 'ssl' => \Configuration::get('PS_SSL_ENABLED') == '1', 'multi_shop_count' => $this->shopRepository->getMultiShopCount(), 'country_code' => $this->shopRepository->getShopCountryCode(), ], diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index 5aa06ab3..57f3f8dd 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -21,8 +21,8 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\ProductRepository; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\SpecificPriceRepository; +use PrestaShop\Module\PsEventbus\Repository\ProductRepository; +use PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/StockMvtsService.php b/src/Service/ShopContent/StockMvtsService.php index 078cbc5a..699ec44d 100644 --- a/src/Service/ShopContent/StockMvtsService.php +++ b/src/Service/ShopContent/StockMvtsService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\StockMvtRepository; +use PrestaShop\Module\PsEventbus\Repository\StockMvtRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/StocksService.php b/src/Service/ShopContent/StocksService.php index 51f8be60..a1f4257e 100644 --- a/src/Service/ShopContent/StocksService.php +++ b/src/Service/ShopContent/StocksService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\StockRepository; +use PrestaShop\Module\PsEventbus\Repository\StockRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/StoresService.php b/src/Service/ShopContent/StoresService.php new file mode 100644 index 00000000..c814327b --- /dev/null +++ b/src/Service/ShopContent/StoresService.php @@ -0,0 +1,128 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\StoreRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class StoresService implements ShopContentServiceInterface +{ + /** @var StoreRepository */ + private $storeRepository; + + public function __construct(StoreRepository $storeRepository) + { + $this->storeRepository = $storeRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $debug) + { + $result = $this->storeRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castStores($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_store'], + 'collection' => Config::COLLECTION_STORES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $debug + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + { + $result = $this->storeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + + if (empty($result)) { + return []; + } + + $this->castStores($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_store'], + 'collection' => Config::COLLECTION_STORES, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->storeRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $stores + * + * @return void + */ + private function castStores(&$stores) + { + foreach ($stores as &$store) { + $store['id_store'] = (int) $store['id_store']; + $store['id_country'] = (int) $store['id_country']; + $store['id_state'] = (int) $store['id_state']; + $store['active'] = (bool) $store['active']; + $store['created_at'] = (string) $store['created_at']; + $store['updated_at'] = (string) $store['updated_at']; + + // https://github.com/PrestaShop/PrestaShop/commit/7dda2be62d8bd606edc269fa051c36ea68f81682#diff-e98d435095567c145b49744715fd575eaab7050328c211b33aa9a37158421ff4R2004 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.3.0', '>=')) { + $store['id_lang'] = (int) $store['id_lang']; + $store['id_shop'] = (int) $store['id_shop']; + } + } + } +} diff --git a/src/Service/ShopContent/SuppliersService.php b/src/Service/ShopContent/SuppliersService.php index 93b72068..b05a60fa 100644 --- a/src/Service/ShopContent/SuppliersService.php +++ b/src/Service/ShopContent/SuppliersService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\SupplierRepository; +use PrestaShop\Module\PsEventbus\Repository\SupplierRepository; if (!defined('_PS_VERSION_')) { exit; @@ -53,7 +53,7 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) return []; } - $this->castSuppliers($result, $langIso); + $this->castSuppliers($result); return array_map(function ($item) { return [ @@ -80,7 +80,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return []; } - $this->castSuppliers($result, $langIso); + $this->castSuppliers($result); return array_map(function ($item) { return [ @@ -105,11 +105,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $suppliers - * @param string $langIso * * @return void */ - private function castSuppliers(&$suppliers, $langIso) + private function castSuppliers(&$suppliers) { foreach ($suppliers as &$supplier) { $supplier['id_supplier'] = (int) $supplier['id_supplier']; diff --git a/src/Service/ShopContent/TaxonomiesService.php b/src/Service/ShopContent/TaxonomiesService.php index f2ebeef5..7bb452ba 100644 --- a/src/Service/ShopContent/TaxonomiesService.php +++ b/src/Service/ShopContent/TaxonomiesService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\TaxonomyRepository; +use PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/TranslationsService.php b/src/Service/ShopContent/TranslationsService.php index 312f3f91..43bf564b 100644 --- a/src/Service/ShopContent/TranslationsService.php +++ b/src/Service/ShopContent/TranslationsService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\TranslationRepository; +use PrestaShop\Module\PsEventbus\Repository\TranslationRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index f7d2fab4..2789c34c 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistProductRepository; +use PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index c9943461..8769a81c 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\NewRepository\WishlistRepository; +use PrestaShop\Module\PsEventbus\Repository\WishlistRepository; if (!defined('_PS_VERSION_')) { exit; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index b0897392..ec5d8721 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -22,7 +22,6 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; -use PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository; @@ -121,10 +120,7 @@ public function sendFullSync( /** @var ShopContentServiceInterface $shopContentApiService */ $shopContentApiService = $module->getService($serviceId); - /** @var ConfigurationRepository $configurationRepository */ - $configurationRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository'); - - $timezone = (string) $configurationRepository->get('PS_TIMEZONE'); + $timezone = (string) \Configuration::get('PS_TIMEZONE'); $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $debug); @@ -219,12 +215,12 @@ public function sendIncrementalSync( * disables liveSync * * @param string $shopContent - * @param int $shopContentId + * @param int $shopContentIds * @param string $action * * @return void */ - public function sendLiveSync($shopContent, $shopContentId, $action) + public function sendLiveSync($shopContent, $shopContentIds, $action) { if ($this->isFullSyncDone($shopContent, '')) { // $this->debounceLiveSync($shopContent); diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 43ba9c21..b775d371 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -21,6 +21,8 @@ namespace PrestaShop\Module\PsEventbus\Traits; use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\StockRepository; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; use Product; @@ -460,27 +462,40 @@ public function hookActionObjectProductDeleteAfter($parameters) */ public function hookActionObjectProductAddAfter($parameters) { + /** @var \Product $product */ + $product = $parameters['object']; + + if (!isset($product->id)) { + return; + } + /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \Product $product */ - $product = $parameters['object']; + /** @var ProductCarrierRepository $productCarrierRepository */ + $productCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); + $productCarriers = $productCarrierRepository->getProductCarrierIdsByCarrierId($product->id); + $productCarrierIds = array_column($productCarriers, 'id_carrier_reference'); - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + /** @var StockRepository $stockRepository */ + $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); + $stockId = $stockRepository->getStockIdByProductId($product->id); - // TODO: Need to insertContentIntoIncremental custom-product-carriers and stocks + $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('custom-product-carriers', $productCarrierIds, 'upsert'); + $synchronizationService->sendLiveSync('stocks', $stockId, 'upsert'); - $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS => $product->id], - Config::INCREMENTAL_TYPE_ADD, - date(DATE_ATOM), - $this->shopId, - true - ); - } + $synchronizationService->insertContentIntoIncremental( + [ + Config::COLLECTION_PRODUCTS => $product->id, + Config::COLLECTION_PRODUCT_CARRIERS => array_column($productCarrierIds, 'id_carrier_reference'), + Config::COLLECTION_STOCKS => $stockId, + ], + Config::INCREMENTAL_TYPE_ADD, + date(DATE_ATOM), + $this->shopId, + true + ); } /** @@ -490,27 +505,40 @@ public function hookActionObjectProductAddAfter($parameters) */ public function hookActionObjectProductUpdateAfter($parameters) { + /** @var \Product $product */ + $product = $parameters['object']; + + if (!isset($product->id)) { + return; + } + /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var \Product $product */ - $product = $parameters['object']; + /** @var ProductCarrierRepository $productCarrierRepository */ + $productCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); + $productCarriers = $productCarrierRepository->getProductCarrierIdsByCarrierId($product->id); + $productCarrierIds = array_column($productCarriers, 'id_carrier_reference'); - if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $product->id, 'upsert'); + /** @var StockRepository $stockRepository */ + $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); + $stockId = $stockRepository->getStockIdByProductId($product->id); - // TODO: Need to insertContentIntoIncremental custom-product-carriers and stocks + $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); + $synchronizationService->sendLiveSync('custom-product-carriers', $productCarrierIds, 'upsert'); + $synchronizationService->sendLiveSync('stocks', $stockId, 'upsert'); - $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS => $product->id], - Config::INCREMENTAL_TYPE_UPDATE, - date(DATE_ATOM), - $this->shopId, - true - ); - } + $synchronizationService->insertContentIntoIncremental( + [ + Config::COLLECTION_PRODUCTS => $product->id, + Config::COLLECTION_PRODUCT_CARRIERS => array_column($productCarrierIds, 'id_carrier_reference'), + Config::COLLECTION_STOCKS => $stockId, + ], + Config::INCREMENTAL_TYPE_UPDATE, + date(DATE_ATOM), + $this->shopId, + true + ); } /** @@ -1143,16 +1171,20 @@ public function hookActionObjectCarrierAddAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); + $synchronizationService->sendLiveSync('carrier-details', $carrier->id, 'upsert'); + $synchronizationService->sendLiveSync('carrier-taxes', $carrier->id, 'upsert'); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CARRIERS => $carrier->id], + [ + Config::COLLECTION_CARRIERS => $carrier->id, + Config::COLLECTION_CARRIER_DETAILS => $carrier->id, + Config::COLLECTION_CARRIER_TAXES => $carrier->id, + ], Config::INCREMENTAL_TYPE_ADD, date(DATE_ATOM), $this->shopId, false ); - - // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER DETAILS - // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER TAXES } } @@ -1171,16 +1203,20 @@ public function hookActionObjectCarrierUpdateAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); + $synchronizationService->sendLiveSync('carrier-details', $carrier->id, 'upsert'); + $synchronizationService->sendLiveSync('carrier-taxes', $carrier->id, 'upsert'); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CARRIERS => $carrier->id], + [ + Config::COLLECTION_CARRIERS => $carrier->id, + Config::COLLECTION_CARRIER_DETAILS => $carrier->id, + Config::COLLECTION_CARRIER_TAXES => $carrier->id, + ], Config::INCREMENTAL_TYPE_UPDATE, date(DATE_ATOM), $this->shopId, false ); - - // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER DETAILS - // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER TAXES } } @@ -1198,16 +1234,20 @@ public function hookActionObjectCarrierDeleteAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); + $synchronizationService->sendLiveSync('carrier-details', $carrier->id, 'delete'); + $synchronizationService->sendLiveSync('carrier-taxes', $carrier->id, 'delete'); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CARRIERS => $carrier->id], + [ + Config::COLLECTION_CARRIERS => $carrier->id, + Config::COLLECTION_CARRIER_DETAILS => $carrier->id, + Config::COLLECTION_CARRIER_TAXES => $carrier->id, + ], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId, false ); - - // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER DETAILS - // TODO INSERT INCREMENTAL SYNC AND LIVE SYNC OF CARRIER TAXES } } From 56dd4db64ee84cf47ca73cbb86d123f6745d486c Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 2 Oct 2024 10:24:47 +0200 Subject: [PATCH 100/162] fix: error with merge --- src/Service/SynchronizationService.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index d61ffd79..02c1524e 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -36,6 +36,11 @@ class SynchronizationService { + /** + * @var LiveSyncApiClient + */ + private $liveSyncApiClient; + /** * @var EventbusSyncRepository */ @@ -67,6 +72,7 @@ class SynchronizationService private $proxyService; public function __construct( + LiveSyncApiClient $liveSyncApiClient, EventbusSyncRepository $eventbusSyncRepository, IncrementalSyncRepository $incrementalSyncRepository, LiveSyncRepository $liveSyncRepository, @@ -74,6 +80,7 @@ public function __construct( ProxyServiceInterface $proxyService, PayloadDecorator $payloadDecorator ) { + $this->liveSyncApiClient = $liveSyncApiClient; $this->eventbusSyncRepository = $eventbusSyncRepository; $this->incrementalSyncRepository = $incrementalSyncRepository; $this->liveSyncRepository = $liveSyncRepository; @@ -223,14 +230,11 @@ public function sendIncrementalSync( */ public function sendLiveSync($shopContent, $shopContentIds, $action) { - $defaultIsoCode = $this->languageRepository->getDefaultLanguageIsoCode(); + $defaultIsoCode = $this->languagesService->getDefaultLanguageIsoCode(); if ($this->isFullSyncDone($shopContent, $defaultIsoCode) && $this->debounceLiveSync($shopContent)) { try { - /** @var LiveSyncApiClient $liveSyncApiClient */ - $liveSyncApiClient = $this->module->getService('PrestaShop\Module\PsEventbus\Api\LiveSyncApiClient'); - - $liveSyncApiClient->liveSync($shopContent, (int) $shopContentId, $action); + $this->liveSyncApiClient->liveSync($shopContent, (int) $shopContentIds, $action); } catch (\Exception $e) { // FIXME : report this error somehow } From ff365e434b62bd50e80041a32bf443027b560129 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 2 Oct 2024 11:17:36 +0200 Subject: [PATCH 101/162] fix: phpcs-fixer and phpstan --- src/Api/LiveSyncApiClient.php | 2 +- src/Repository/ProductCarrierRepository.php | 8 +- src/Repository/StockRepository.php | 10 +- src/Service/SynchronizationService.php | 61 ++++++--- src/Traits/UseHooks.php | 144 ++++++++++++-------- 5 files changed, 134 insertions(+), 91 deletions(-) diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index faae7f17..64035b17 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -104,7 +104,7 @@ public function liveSync($shopContent, $shopContentId, $action) 'Authorization' => 'Bearer ' . $this->jwt, 'User-Agent' => 'ps-eventbus/' . $this->module->version, 'Content-Type' => 'application/json', - ], + ], // TODO: @Vincent Probably need to transform snake_case to kebab-case '{"shopContents": ["' . $shopContent . '"], "shopContentId": ' . $shopContentId . ', "action": "' . $action . '"}' ) ); diff --git a/src/Repository/ProductCarrierRepository.php b/src/Repository/ProductCarrierRepository.php index 1b044749..db48fd6a 100644 --- a/src/Repository/ProductCarrierRepository.php +++ b/src/Repository/ProductCarrierRepository.php @@ -20,9 +20,6 @@ namespace PrestaShop\Module\PsEventbus\Repository; -use PrestaShopException; -use PrestaShopDatabaseException; - if (!defined('_PS_VERSION_')) { exit; } @@ -116,10 +113,11 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) /** * @param int $idProduct + * * @return array * - * @throws PrestaShopException - * @throws PrestaShopDatabaseException + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException */ public function getProductCarrierIdsByCarrierId($idProduct) { diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index b23b14d8..353135b9 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -20,9 +20,6 @@ namespace PrestaShop\Module\PsEventbus\Repository; -use PrestaShopException; -use PrestaShopDatabaseException; - if (!defined('_PS_VERSION_')) { exit; } @@ -139,9 +136,10 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) /** * @param int $productId * - * @return mixed - * @throws PrestaShopException - * @throws PrestaShopDatabaseException + * @return mixed + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException */ public function getStockIdByProductId($productId) { diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 02c1524e..34a187f9 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -20,8 +20,8 @@ namespace PrestaShop\Module\PsEventbus\Service; -use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Api\LiveSyncApiClient; +use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; @@ -222,27 +222,38 @@ public function sendIncrementalSync( /** * liveSync * - * @param string $shopContent - * @param int $shopContentIds - * @param string $action + * @param array $contentTypesWithIds + * @param string $actionType * * @return void */ - public function sendLiveSync($shopContent, $shopContentIds, $action) + public function sendLiveSync($contentTypesWithIds, $actionType) { + if (count($contentTypesWithIds) == 0) { + return; + } + $defaultIsoCode = $this->languagesService->getDefaultLanguageIsoCode(); - if ($this->isFullSyncDone($shopContent, $defaultIsoCode) && $this->debounceLiveSync($shopContent)) { - try { - $this->liveSyncApiClient->liveSync($shopContent, (int) $shopContentIds, $action); - } catch (\Exception $e) { - // FIXME : report this error somehow + foreach ($contentTypesWithIds as $contentType => $contentIds) { + if ($this->isFullSyncDone($contentType, $defaultIsoCode) && $this->debounceLiveSync($contentType)) { + if (!is_array($contentIds)) { + $contentIds = [$contentIds]; + } + + foreach ($contentIds as $contentId) { + try { + $this->liveSyncApiClient->liveSync($contentType, $contentId, $actionType); + } catch (\Exception $e) { + // FIXME : report this error somehow + } + } } } } /** - * @param array $contentTypesWithIds + * @param array $contentTypesWithIds * @param string $actionType * @param string $createdAt * @param int $shopId @@ -289,9 +300,13 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $allIsoCodes = $this->languagesService->getLanguagesIsoCodes(); foreach ($allIsoCodes as $langIso) { - foreach ($contentTypesWithIds as $contentType => $contentId) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { if ($this->isFullSyncDone($contentType, $langIso)) { - array_push($contentToInsert, + if (!is_array($contentIds)) { + $contentIds = [$contentIds]; + } + + $finalContent = array_map(function ($contentId) use ($contentType, $shopId, $langIso, $actionType, $createdAt) { [ 'type' => $contentType, 'id_object' => $contentId, @@ -299,17 +314,23 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, 'lang_iso' => $langIso, 'action' => $actionType, 'created_at' => $createdAt, - ] - ); + ]; + }, $contentIds); + + $contentToInsert = array_merge($contentToInsert, $finalContent); } } } } else { $defaultIsoCode = $this->languagesService->getDefaultLanguageIsoCode(); - foreach ($contentTypesWithIds as $contentType => $contentId) { + foreach ($contentTypesWithIds as $contentType => $contentIds) { if ($this->isFullSyncDone($contentType, $defaultIsoCode)) { - array_push($contentToInsert, + if (!is_array($contentIds)) { + $contentIds = [$contentIds]; + } + + $finalContent = array_map(function ($contentId) use ($contentType, $shopId, $defaultIsoCode, $actionType, $createdAt) { [ 'type' => $contentType, 'id_object' => $contentId, @@ -317,8 +338,10 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, 'lang_iso' => $defaultIsoCode, 'action' => $actionType, 'created_at' => $createdAt, - ] - ); + ]; + }, $contentIds); + + $contentToInsert = array_merge($contentToInsert, $finalContent); } } } diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index b775d371..3532a139 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -24,7 +24,6 @@ use PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository; use PrestaShop\Module\PsEventbus\Repository\StockRepository; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; -use Product; if (!defined('_PS_VERSION_')) { exit; @@ -144,7 +143,7 @@ public function hookActionObjectImageDeleteAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $image->id_product], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], Config::INCREMENTAL_TYPE_DELETE, @@ -169,7 +168,7 @@ public function hookActionObjectImageAddAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $image->id_product], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], Config::INCREMENTAL_TYPE_ADD, @@ -194,7 +193,7 @@ public function hookActionObjectImageUpdateAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync('products', $image->id_product, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $image->id_product], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], Config::INCREMENTAL_TYPE_UPDATE, @@ -219,7 +218,7 @@ public function hookActionObjectLanguageDeleteAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync('languages', $language->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_LANGUAGES => $language->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_DELETE, @@ -244,7 +243,7 @@ public function hookActionObjectLanguageAddAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync('languages', $language->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_LANGUAGES => $language->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_ADD, @@ -269,7 +268,7 @@ public function hookActionObjectLanguageUpdateAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync('languages', $language->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_LANGUAGES => $language->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -294,7 +293,7 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_MANUFACTURERS => $manufacturer->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_DELETE, @@ -319,7 +318,7 @@ public function hookActionObjectManufacturerAddAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_MANUFACTURERS => $manufacturer->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_ADD, @@ -344,7 +343,7 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync('manufacturers', $manufacturer->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_MANUFACTURERS => $manufacturer->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -369,7 +368,7 @@ public function hookActionObjectSupplierDeleteAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_SUPPLIERS => $supplier->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_DELETE, @@ -394,7 +393,7 @@ public function hookActionObjectSupplierAddAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_SUPPLIERS => $supplier->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_ADD, @@ -419,7 +418,7 @@ public function hookActionObjectSupplierUpdateAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync('suppliers', $supplier->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_SUPPLIERS => $supplier->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -444,7 +443,7 @@ public function hookActionObjectProductDeleteAfter($parameters) $product = $parameters['object']; if (isset($product->id)) { - $synchronizationService->sendLiveSync('products', $product->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $product->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_DELETE, @@ -481,9 +480,14 @@ public function hookActionObjectProductAddAfter($parameters) $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); $stockId = $stockRepository->getStockIdByProductId($product->id); - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $productCarrierIds, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $stockId, 'upsert'); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_PRODUCTS => $product->id, + Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, + Config::COLLECTION_STOCKS => $stockId, + ], + 'upsert' + ); $synchronizationService->insertContentIntoIncremental( [ @@ -524,9 +528,14 @@ public function hookActionObjectProductUpdateAfter($parameters) $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); $stockId = $stockRepository->getStockIdByProductId($product->id); - $synchronizationService->sendLiveSync('products', $product->id, 'upsert'); - $synchronizationService->sendLiveSync('custom-product-carriers', $productCarrierIds, 'upsert'); - $synchronizationService->sendLiveSync('stocks', $stockId, 'upsert'); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_PRODUCTS => $product->id, + Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, + Config::COLLECTION_STOCKS => $stockId, + ], + 'upsert' + ); $synchronizationService->insertContentIntoIncremental( [ @@ -554,7 +563,7 @@ public function hookActionObjectWishlistDeleteAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_WISHLISTS => $wishlist->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_DELETE, @@ -578,7 +587,7 @@ public function hookActionObjectWishlistAddAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_WISHLISTS => $wishlist->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_ADD, @@ -602,7 +611,7 @@ public function hookActionObjectWishlistUpdateAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync('wishlists', $wishlist->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_WISHLISTS => $wishlist->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -627,7 +636,7 @@ public function hookActionObjectStockAddAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_STOCKS => $stock->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], Config::INCREMENTAL_TYPE_ADD, @@ -652,7 +661,7 @@ public function hookActionObjectStockUpdateAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync('stocks', $stock->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_STOCKS => $stock->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -677,7 +686,7 @@ public function hookActionObjectStoreDeleteAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync('stores', $store->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_STORES => $store->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_DELETE, @@ -702,7 +711,7 @@ public function hookActionObjectStoreAddAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_STORES => $store->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_ADD, @@ -727,7 +736,7 @@ public function hookActionObjectStoreUpdateAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync('stores', $store->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_STORES => $store->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -752,7 +761,7 @@ public function hookActionObjectCombinationDeleteAfter($parameters) $combination = $parameters['object']; if (isset($combination->id)) { - $synchronizationService->sendLiveSync('products', $combination->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $combination->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCT_ATTRIBUTES => $combination->id], Config::INCREMENTAL_TYPE_DELETE, @@ -777,7 +786,7 @@ public function hookActionObjectCategoryAddAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CATEGORIES => $category->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_ADD, @@ -802,7 +811,7 @@ public function hookActionObjectCategoryUpdateAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CATEGORIES => $category->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -827,7 +836,7 @@ public function hookActionObjectCategoryDeleteAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync('categories', $category->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CATEGORIES => $category->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_DELETE, @@ -852,7 +861,7 @@ public function hookActionObjectCustomerAddAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CUSTOMERS => $customer->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_ADD, @@ -877,7 +886,7 @@ public function hookActionObjectCustomerUpdateAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CUSTOMERS => $customer->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -902,7 +911,7 @@ public function hookActionObjectCustomerDeleteAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync('customers', $customer->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CUSTOMERS => $customer->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_DELETE, @@ -927,7 +936,7 @@ public function hookActionObjectCurrencyAddAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CURRENCIES => $currency->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_ADD, @@ -952,7 +961,7 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CURRENCIES => $currency->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -977,7 +986,7 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync('currencies', $currency->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CURRENCIES => $currency->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_DELETE, @@ -1001,7 +1010,7 @@ public function hookActionObjectCartAddAfter($parameters) $cart = $parameters['object']; if (isset($cart->id)) { - $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CARTS => $cart->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_ADD, @@ -1025,7 +1034,7 @@ public function hookActionObjectCartUpdateAfter($parameters) $cart = $parameters['object']; if (isset($cart->id)) { - $synchronizationService->sendLiveSync('carts', $cart->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CARTS => $cart->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1049,7 +1058,7 @@ public function hookActionObjectCartRuleAddAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CART_RULES => $cartRule->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_ADD, @@ -1073,7 +1082,7 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CART_RULES => $cartRule->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_DELETE, @@ -1097,7 +1106,7 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync('cart_rules', $cartRule->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_CART_RULES => $cartRule->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1121,7 +1130,7 @@ public function hookActionObjectOrderAddAfter($parameters) $order = $parameters['object']; if (isset($order->id)) { - $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_ORDERS => $order->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_ADD, @@ -1145,7 +1154,7 @@ public function hookActionObjectOrderUpdateAfter($parameters) $order = $parameters['object']; if (isset($order->id)) { - $synchronizationService->sendLiveSync('orders', $order->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_ORDERS => $order->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1170,10 +1179,15 @@ public function hookActionObjectCarrierAddAfter($parameters) $carrier = $parameters['object']; if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->sendLiveSync('carrier-details', $carrier->id, 'upsert'); - $synchronizationService->sendLiveSync('carrier-taxes', $carrier->id, 'upsert'); - + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_CARRIERS => $carrier->id, + Config::COLLECTION_CARRIER_DETAILS => $carrier->id, + Config::COLLECTION_CARRIER_TAXES => $carrier->id, + ], + 'upsert' + ); + $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_CARRIERS => $carrier->id, @@ -1202,10 +1216,15 @@ public function hookActionObjectCarrierUpdateAfter($parameters) $carrier = $parameters['object']; if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'upsert'); - $synchronizationService->sendLiveSync('carrier-details', $carrier->id, 'upsert'); - $synchronizationService->sendLiveSync('carrier-taxes', $carrier->id, 'upsert'); - + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_CARRIERS => $carrier->id, + Config::COLLECTION_CARRIER_DETAILS => $carrier->id, + Config::COLLECTION_CARRIER_TAXES => $carrier->id, + ], + 'upsert' + ); + $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_CARRIERS => $carrier->id, @@ -1233,10 +1252,15 @@ public function hookActionObjectCarrierDeleteAfter($parameters) $carrier = $parameters['object']; if (isset($carrier->id)) { - $synchronizationService->sendLiveSync('carriers', $carrier->id, 'delete'); - $synchronizationService->sendLiveSync('carrier-details', $carrier->id, 'delete'); - $synchronizationService->sendLiveSync('carrier-taxes', $carrier->id, 'delete'); - + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_CARRIERS => $carrier->id, + Config::COLLECTION_CARRIER_DETAILS => $carrier->id, + Config::COLLECTION_CARRIER_TAXES => $carrier->id, + ], + 'delete' + ); + $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_CARRIERS => $carrier->id, @@ -1634,7 +1658,7 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_ADD, @@ -1661,7 +1685,7 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'upsert'); + $synchronizationService->sendLiveSync([Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1688,7 +1712,7 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync('specific-prices', $specificPrice->id, 'delete'); + $synchronizationService->sendLiveSync([Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_DELETE, From 8b689c656dcf799d843816acaab1c2fd7d8b6aa0 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 2 Oct 2024 11:20:57 +0200 Subject: [PATCH 102/162] fix: error --- config/front/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/front/services.yml b/config/front/services.yml index 34b498a9..951328ff 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -16,6 +16,7 @@ services: class: PrestaShop\Module\PsEventbus\Service\SynchronizationService public: true arguments: + - '@PrestaShop\Module\PsEventbus\Api\LiveSyncApiClient' - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' From 067931e469570a5ce0da6caf33cedbd9a7d03e2b Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 2 Oct 2024 14:32:48 +0200 Subject: [PATCH 103/162] fix: useless code --- src/Service/ShopContent/OrderHistoriesService.php | 1 - src/Service/ShopContent/ProductBundlesService.php | 3 --- src/Service/SynchronizationService.php | 3 --- 3 files changed, 7 deletions(-) diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index e84021cf..0232a786 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -116,7 +116,6 @@ private function castOrderHistories(&$orderHistories) $orderHistory['id_order_history'] = (int) $orderHistory['id_order_history']; $orderHistory['name'] = (string) $orderHistory['name']; $orderHistory['template'] = (string) $orderHistory['template']; - $orderHistory['date_add'] = $orderHistory['date_add']; $orderHistory['is_validated'] = (bool) $orderHistory['is_validated']; $orderHistory['is_delivered'] = (bool) $orderHistory['is_delivered']; $orderHistory['is_shipped'] = (bool) $orderHistory['is_shipped']; diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index fb267dbc..2728d7ce 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -112,11 +112,8 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) private function castProductsBundles(&$productBundles, $langIso) { foreach ($productBundles as &$productBundle) { - $productBundle['id_bundle'] = $productBundle['id_bundle']; $productBundle['id_product'] = $productBundle['id_product_item']; - $productBundle['id_product_attribute'] = $productBundle['id_product_attribute']; $productBundle['unique_product_id'] = "{$productBundle['id_bundle']}-{$productBundle['product_id_attribute']}-{$langIso}"; - $productBundle['quantity'] = $productBundle['quantity']; unset($productBundle['product_id_attribute']); unset($productBundle['id_product_item']); diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 34a187f9..c9d1d6cd 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -128,9 +128,6 @@ public function sendFullSync( /** @var ShopContentServiceInterface $shopContentApiService */ $shopContentApiService = $module->getService($serviceId); - $timezone = (string) \Configuration::get('PS_TIMEZONE'); - $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); - $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $debug); $this->payloadDecorator->convertDateFormat($data); From 03bc9617b173053a8d039bf40005ca7ee58f3cac Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 3 Oct 2024 10:45:48 +0200 Subject: [PATCH 104/162] fix: last problems --- .../PaginatedApiDataProviderInterface.php | 67 -------- OLD/Provider/WishlistDataProvider.php | 160 ------------------ config/common/decorator.yml | 12 -- config/front/services.yml | 2 - src/Api/LiveSyncApiClient.php | 13 +- src/Decorator/PayloadDecorator.php | 75 -------- src/Exception/HmacException.php | 29 ---- .../PsAccountsRsaSignDataEmptyException.php | 29 ---- src/Exception/UnauthorizedException.php | 29 ---- src/Exception/WebhookException.php | 29 ---- src/Repository/IncrementalSyncRepository.php | 4 +- src/Service/CommonService.php | 39 +++++ .../ShopContent/WishlistProductsService.php | 2 +- src/Service/SynchronizationService.php | 44 ++--- src/Traits/UseHooks.php | 110 ++++++------ 15 files changed, 122 insertions(+), 522 deletions(-) delete mode 100644 OLD/Provider/PaginatedApiDataProviderInterface.php delete mode 100644 OLD/Provider/WishlistDataProvider.php delete mode 100644 config/common/decorator.yml delete mode 100644 src/Decorator/PayloadDecorator.php delete mode 100644 src/Exception/HmacException.php delete mode 100644 src/Exception/PsAccountsRsaSignDataEmptyException.php delete mode 100644 src/Exception/UnauthorizedException.php delete mode 100644 src/Exception/WebhookException.php diff --git a/OLD/Provider/PaginatedApiDataProviderInterface.php b/OLD/Provider/PaginatedApiDataProviderInterface.php deleted file mode 100644 index d16b5558..00000000 --- a/OLD/Provider/PaginatedApiDataProviderInterface.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -interface PaginatedApiDataProviderInterface -{ - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso); - - /** - * @param int $offset - * @param string $langIso - * - * @return int - * - * @@throws \PrestaShopDatabaseException - */ - public function getRemainingObjectsCount($offset, $langIso); - - /** - * @param int $limit - * @param string $langIso - * @param array $objectIds - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds); - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getQueryForDebug($offset, $limit, $langIso); -} diff --git a/OLD/Provider/WishlistDataProvider.php b/OLD/Provider/WishlistDataProvider.php deleted file mode 100644 index 942fdb24..00000000 --- a/OLD/Provider/WishlistDataProvider.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Provider; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\WishlistDecorator; -use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository; -use PrestaShop\Module\PsEventbus\Repository\WishlistRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class WishlistDataProvider implements PaginatedApiDataProviderInterface -{ - /** - * @var WishlistRepository - */ - private $wishlistRepository; - /** - * @var WishlistProductRepository - */ - private $wishlistProductRepository; - /** - * @var WishlistDecorator - */ - private $wishlistDecorator; - /** - * @var ArrayFormatter - */ - private $arrayFormatter; - - public function __construct( - WishlistRepository $wishlistRepository, - WishlistProductRepository $wishlistProductRepository, - WishlistDecorator $wishlistDecorator, - ArrayFormatter $arrayFormatter - ) { - $this->wishlistRepository = $wishlistRepository; - $this->wishlistProductRepository = $wishlistProductRepository; - $this->wishlistDecorator = $wishlistDecorator; - $this->arrayFormatter = $arrayFormatter; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedData($offset, $limit, $langIso) - { - $wishlists = $this->wishlistRepository->getWishlists($offset, $limit); - - if (empty($wishlists)) { - return []; - } - - $wishlistProducts = $this->getWishlistProducts($wishlists); - - $this->wishlistDecorator->decorateWishlists($wishlists); - - $wishlists = array_map(function ($wishlist) { - return [ - 'id' => $wishlist['id_wishlist'], - 'collection' => Config::COLLECTION_WISHLISTS, - 'properties' => $wishlist, - ]; - }, $wishlists); - - return array_merge($wishlists, $wishlistProducts); - } - - /** - * @param int $limit - * @param string $langIso - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - public function getFormattedDataIncremental($limit, $langIso, $objectIds) - { - $wishlists = $this->wishlistRepository->getWishlistsIncremental($limit, $objectIds); - - if (!is_array($wishlists) || empty($wishlists)) { - return []; - } - - $wishlistProducts = $this->getWishlistProducts($wishlists); - - $this->wishlistDecorator->decorateWishlists($wishlists); - - $wishlists = array_map(function ($wishlist) { - return [ - 'id' => $wishlist['id_wishlist'], - 'collection' => Config::COLLECTION_WISHLISTS, - 'properties' => $wishlist, - ]; - }, $wishlists); - - return array_merge($wishlists, $wishlistProducts); - } - - /** - * @param array $wishlists - * - * @return array - * - * @@throws \PrestaShopDatabaseException - */ - private function getWishlistProducts(&$wishlists) - { - if (empty($wishlists)) { - return []; - } - - $wishlistIds = $this->arrayFormatter->formatValueArray($wishlists, 'id_wishlist'); - - $wishlistProducts = $this->wishlistProductRepository->getWishlistProducts($wishlistIds); - - if (!is_array($wishlistProducts) || empty($wishlistProducts)) { - return []; - } - - $this->wishlistDecorator->decorateWishlistProducts($wishlistProducts); - - $wishlistProducts = array_map(function ($wishlistProduct) { - return [ - 'id' => $wishlistProduct['id_wishlist_product'], - 'collection' => Config::COLLECTION_WISHLIST_PRODUCTS, - 'properties' => $wishlistProduct, - ]; - }, $wishlistProducts); - - return $wishlistProducts; - } -} diff --git a/config/common/decorator.yml b/config/common/decorator.yml deleted file mode 100644 index 1f9307f4..00000000 --- a/config/common/decorator.yml +++ /dev/null @@ -1,12 +0,0 @@ -services: - PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\StoreDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\StoreDecorator - public: true - - PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator: - class: PrestaShop\Module\PsEventbus\Decorator\SupplierDecorator - public: true diff --git a/config/front/services.yml b/config/front/services.yml index 951328ff..b96c910e 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -1,7 +1,6 @@ imports: - { resource: api.yml } - { resource: ../common/common.yml } - - { resource: ../common/decorator.yml } - { resource: ../common/repository.yml } services: @@ -22,7 +21,6 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ProxyService' - - '@PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator' PrestaShop\Module\PsEventbus\Service\PresenterService: class: PrestaShop\Module\PsEventbus\Service\PresenterService diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index 64035b17..69fdc760 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -88,13 +88,18 @@ private function getClient($timeout = Config::SYNC_API_MAX_TIMEOUT) /** * @param string $shopContent - * @param int $shopContentId * @param string $action * * @return array */ - public function liveSync($shopContent, $shopContentId, $action) + public function liveSync($shopContent, $action) { + // shop content send to the API must be in kebab-case + $kebabCasedShopContent = str_replace('_', '-', $shopContent); + + // This parameter is purely useless, but it is required by the API + $uselessParameter = 0; + $response = $this->getClient(3)->sendRequest( new Request( 'POST', @@ -104,8 +109,8 @@ public function liveSync($shopContent, $shopContentId, $action) 'Authorization' => 'Bearer ' . $this->jwt, 'User-Agent' => 'ps-eventbus/' . $this->module->version, 'Content-Type' => 'application/json', - ], // TODO: @Vincent Probably need to transform snake_case to kebab-case - '{"shopContents": ["' . $shopContent . '"], "shopContentId": ' . $shopContentId . ', "action": "' . $action . '"}' + ], + '{"shopContents": ["' . $kebabCasedShopContent . '"], "shopContentId": ' . $uselessParameter . ', "action": "' . $action . '"}' ) ); diff --git a/src/Decorator/PayloadDecorator.php b/src/Decorator/PayloadDecorator.php deleted file mode 100644 index 6cf5fead..00000000 --- a/src/Decorator/PayloadDecorator.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Decorator; - -// use hardcoded format to avoid problems with interface change in PHP 7.2 -const ISO8601 = 'Y-m-d\TH:i:sO'; -const DATE_FIELDS = [ - 'created_at', - 'updated_at', - 'last_connection_date', - 'folder_created_at', - 'date_add', - 'newsletter_date_add', - 'from', - 'to', -]; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class PayloadDecorator -{ - /** - * @var string - */ - private $timezone; - - public function __construct() - { - $this->timezone = (string) \Configuration::get('PS_TIMEZONE'); - } - - /** - * @param array $payload - * - * @return void - * - * @throws \Exception - */ - public function convertDateFormat(&$payload) - { - foreach ($payload as &$payloadItem) { - foreach (DATE_FIELDS as $dateField) { - if (isset($payloadItem['properties'][$dateField])) { - $date = &$payloadItem['properties'][$dateField]; - if (!empty($date) && $date !== '0000-00-00 00:00:00') { - $dateTime = new \DateTime($date, new \DateTimeZone($this->timezone)); - $date = $dateTime->format(ISO8601); - } else { - $date = null; - } - } - } - } - } -} diff --git a/src/Exception/HmacException.php b/src/Exception/HmacException.php deleted file mode 100644 index 35b2359f..00000000 --- a/src/Exception/HmacException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Exception; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class HmacException extends \Exception -{ -} diff --git a/src/Exception/PsAccountsRsaSignDataEmptyException.php b/src/Exception/PsAccountsRsaSignDataEmptyException.php deleted file mode 100644 index 96b42a58..00000000 --- a/src/Exception/PsAccountsRsaSignDataEmptyException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Exception; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class PsAccountsRsaSignDataEmptyException extends \Exception -{ -} diff --git a/src/Exception/UnauthorizedException.php b/src/Exception/UnauthorizedException.php deleted file mode 100644 index 48350f33..00000000 --- a/src/Exception/UnauthorizedException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Exception; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class UnauthorizedException extends \Exception -{ -} diff --git a/src/Exception/WebhookException.php b/src/Exception/WebhookException.php deleted file mode 100644 index b1c17f01..00000000 --- a/src/Exception/WebhookException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Exception; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class WebhookException extends \Exception -{ -} diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index dd3fbeae..ef4b6587 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -59,7 +59,7 @@ public function insertIncrementalObject($data) $elementsCount = count($arrayOfData); $index = 0; - $query = 'INSERT INTO `' . _DB_PREFIX_ . self::TABLE_NAME . '` (type, id_object, id_shop, lang_iso, created_at) VALUES '; + $query = 'INSERT INTO `' . _DB_PREFIX_ . self::TABLE_NAME . '` (type, id_object, id_shop, lang_iso, action, created_at) VALUES '; foreach ($arrayOfData as $currenData) { $dateTime = new \DateTime($currenData['created_at']); @@ -70,6 +70,7 @@ public function insertIncrementalObject($data) {$this->db->escape($currenData['id_object'])}, {$this->db->escape($currenData['id_shop'])}, '{$this->db->escape($currenData['lang_iso'])}', + '{$this->db->escape($currenData['action'])}', '{$this->db->escape($date)}' )"; @@ -84,6 +85,7 @@ public function insertIncrementalObject($data) id_object = VALUES(id_object), id_shop = VALUES(id_shop), lang_iso = VALUES(lang_iso), + action = VALUES(action), created_at = VALUES(created_at) '; diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index b84c91b8..9541785c 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -102,4 +102,43 @@ public static function dieWithResponse($response, $code) exit; } + + /** + * @param array $payload + * + * @return void + * + * @throws \Exception + */ + public static function convertDateFormat(&$payload) + { + // use hardcoded format to avoid problems with interface change in PHP 7.2 + $ISO8601 = 'Y-m-d\TH:i:sO'; + $dateFields = [ + 'created_at', + 'updated_at', + 'last_connection_date', + 'folder_created_at', + 'date_add', + 'newsletter_date_add', + 'from', + 'to', + ]; + + $timezone = (string) \Configuration::get('PS_TIMEZONE'); + + foreach ($payload as &$payloadItem) { + foreach ($dateFields as $dateField) { + if (isset($payloadItem['properties'][$dateField])) { + $date = &$payloadItem['properties'][$dateField]; + if (!empty($date) && $date !== '0000-00-00 00:00:00') { + $dateTime = new \DateTime($date, new \DateTimeZone($timezone)); + $date = $dateTime->format($ISO8601); + } else { + $date = null; + } + } + } + } + } } diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index 2789c34c..12a38344 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -84,7 +84,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) return array_map(function ($item) { return [ - 'id' => $item['COLLECTION_WISHLIST_PRODUCTS'], + 'id' => $item['id_wishlist_product'], 'collection' => Config::COLLECTION_WISHLIST_PRODUCTS, 'properties' => $item, ]; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index c9d1d6cd..6e80bea3 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -22,7 +22,6 @@ use PrestaShop\Module\PsEventbus\Api\LiveSyncApiClient; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Decorator\PayloadDecorator; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository; @@ -61,11 +60,6 @@ class SynchronizationService */ private $languagesService; - /** - * @var PayloadDecorator - */ - private $payloadDecorator; - /** * @var ProxyServiceInterface */ @@ -77,8 +71,7 @@ public function __construct( IncrementalSyncRepository $incrementalSyncRepository, LiveSyncRepository $liveSyncRepository, LanguagesService $languagesService, - ProxyServiceInterface $proxyService, - PayloadDecorator $payloadDecorator + ProxyServiceInterface $proxyService ) { $this->liveSyncApiClient = $liveSyncApiClient; $this->eventbusSyncRepository = $eventbusSyncRepository; @@ -86,7 +79,6 @@ public function __construct( $this->liveSyncRepository = $liveSyncRepository; $this->languagesService = $languagesService; $this->proxyService = $proxyService; - $this->payloadDecorator = $payloadDecorator; } /** @@ -130,7 +122,7 @@ public function sendFullSync( $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $debug); - $this->payloadDecorator->convertDateFormat($data); + CommonService::convertDateFormat($data); if (!empty($data)) { $response = $this->proxyService->upload($jobId, $data, $startTime, true); @@ -199,7 +191,7 @@ public function sendIncrementalSync( $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso, $debug); - $this->payloadDecorator->convertDateFormat($data); + CommonService::convertDateFormat($data); if (!empty($data)) { $response = $this->proxyService->upload($jobId, $data, $startTime, false); @@ -219,31 +211,25 @@ public function sendIncrementalSync( /** * liveSync * - * @param array $contentTypesWithIds + * @param array $contents * @param string $actionType * * @return void */ - public function sendLiveSync($contentTypesWithIds, $actionType) + public function sendLiveSync($contents, $actionType) { - if (count($contentTypesWithIds) == 0) { + if (count($contents) == 0) { return; } $defaultIsoCode = $this->languagesService->getDefaultLanguageIsoCode(); - foreach ($contentTypesWithIds as $contentType => $contentIds) { - if ($this->isFullSyncDone($contentType, $defaultIsoCode) && $this->debounceLiveSync($contentType)) { - if (!is_array($contentIds)) { - $contentIds = [$contentIds]; - } - - foreach ($contentIds as $contentId) { - try { - $this->liveSyncApiClient->liveSync($contentType, $contentId, $actionType); - } catch (\Exception $e) { - // FIXME : report this error somehow - } + foreach ($contents as $content) { + if ($this->isFullSyncDone($content, $defaultIsoCode) && $this->debounceLiveSync($content)) { + try { + $this->liveSyncApiClient->liveSync($content, $actionType); + } catch (\Exception $e) { + // FIXME : report this error somehow } } } @@ -304,7 +290,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } $finalContent = array_map(function ($contentId) use ($contentType, $shopId, $langIso, $actionType, $createdAt) { - [ + return [ 'type' => $contentType, 'id_object' => $contentId, 'id_shop' => $shopId, @@ -328,7 +314,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } $finalContent = array_map(function ($contentId) use ($contentType, $shopId, $defaultIsoCode, $actionType, $createdAt) { - [ + return [ 'type' => $contentType, 'id_object' => $contentId, 'id_shop' => $shopId, @@ -337,11 +323,11 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, 'created_at' => $createdAt, ]; }, $contentIds); - $contentToInsert = array_merge($contentToInsert, $finalContent); } } } + dump($contentToInsert); if (empty($contentToInsert) == false) { $this->incrementalSyncRepository->insertIncrementalObject($contentToInsert); diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 3532a139..1629ae3a 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -143,7 +143,7 @@ public function hookActionObjectImageDeleteAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $image->id_product], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], Config::INCREMENTAL_TYPE_DELETE, @@ -168,7 +168,7 @@ public function hookActionObjectImageAddAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $image->id_product], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], Config::INCREMENTAL_TYPE_ADD, @@ -193,7 +193,7 @@ public function hookActionObjectImageUpdateAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $image->id_product], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], Config::INCREMENTAL_TYPE_UPDATE, @@ -218,7 +218,7 @@ public function hookActionObjectLanguageDeleteAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_LANGUAGES => $language->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_DELETE, @@ -243,7 +243,7 @@ public function hookActionObjectLanguageAddAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_LANGUAGES => $language->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_ADD, @@ -268,7 +268,7 @@ public function hookActionObjectLanguageUpdateAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_LANGUAGES => $language->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -293,7 +293,7 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_MANUFACTURERS => $manufacturer->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_DELETE, @@ -318,7 +318,7 @@ public function hookActionObjectManufacturerAddAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_MANUFACTURERS => $manufacturer->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_ADD, @@ -343,7 +343,7 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_MANUFACTURERS => $manufacturer->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -368,7 +368,7 @@ public function hookActionObjectSupplierDeleteAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_SUPPLIERS => $supplier->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_DELETE, @@ -393,7 +393,7 @@ public function hookActionObjectSupplierAddAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_SUPPLIERS => $supplier->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_ADD, @@ -418,7 +418,7 @@ public function hookActionObjectSupplierUpdateAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_SUPPLIERS => $supplier->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -443,7 +443,7 @@ public function hookActionObjectProductDeleteAfter($parameters) $product = $parameters['object']; if (isset($product->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $product->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $product->id], Config::INCREMENTAL_TYPE_DELETE, @@ -482,9 +482,9 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->sendLiveSync( [ - Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, - Config::COLLECTION_STOCKS => $stockId, + Config::COLLECTION_PRODUCTS, + Config::COLLECTION_PRODUCT_CARRIERS, + Config::COLLECTION_STOCKS, ], 'upsert' ); @@ -492,7 +492,7 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_PRODUCT_CARRIERS => array_column($productCarrierIds, 'id_carrier_reference'), + Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], Config::INCREMENTAL_TYPE_ADD, @@ -530,9 +530,9 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->sendLiveSync( [ - Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, - Config::COLLECTION_STOCKS => $stockId, + Config::COLLECTION_PRODUCTS, + Config::COLLECTION_PRODUCT_CARRIERS, + Config::COLLECTION_STOCKS, ], 'upsert' ); @@ -540,7 +540,7 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_PRODUCT_CARRIERS => array_column($productCarrierIds, 'id_carrier_reference'), + Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], Config::INCREMENTAL_TYPE_UPDATE, @@ -563,7 +563,7 @@ public function hookActionObjectWishlistDeleteAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_WISHLISTS => $wishlist->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_DELETE, @@ -587,7 +587,7 @@ public function hookActionObjectWishlistAddAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_WISHLISTS => $wishlist->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_ADD, @@ -611,7 +611,7 @@ public function hookActionObjectWishlistUpdateAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_WISHLISTS => $wishlist->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -636,7 +636,7 @@ public function hookActionObjectStockAddAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_STOCKS => $stock->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], Config::INCREMENTAL_TYPE_ADD, @@ -661,7 +661,7 @@ public function hookActionObjectStockUpdateAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_STOCKS => $stock->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -686,7 +686,7 @@ public function hookActionObjectStoreDeleteAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_STORES => $store->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_DELETE, @@ -711,7 +711,7 @@ public function hookActionObjectStoreAddAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_STORES => $store->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_ADD, @@ -736,7 +736,7 @@ public function hookActionObjectStoreUpdateAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_STORES => $store->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -761,7 +761,7 @@ public function hookActionObjectCombinationDeleteAfter($parameters) $combination = $parameters['object']; if (isset($combination->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_PRODUCTS => $combination->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCT_ATTRIBUTES => $combination->id], Config::INCREMENTAL_TYPE_DELETE, @@ -786,7 +786,7 @@ public function hookActionObjectCategoryAddAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CATEGORIES => $category->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_ADD, @@ -811,7 +811,7 @@ public function hookActionObjectCategoryUpdateAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CATEGORIES => $category->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -836,7 +836,7 @@ public function hookActionObjectCategoryDeleteAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CATEGORIES => $category->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_DELETE, @@ -861,7 +861,7 @@ public function hookActionObjectCustomerAddAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CUSTOMERS => $customer->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_ADD, @@ -886,7 +886,7 @@ public function hookActionObjectCustomerUpdateAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CUSTOMERS => $customer->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -911,7 +911,7 @@ public function hookActionObjectCustomerDeleteAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CUSTOMERS => $customer->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_DELETE, @@ -936,7 +936,7 @@ public function hookActionObjectCurrencyAddAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CURRENCIES => $currency->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_ADD, @@ -961,7 +961,7 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CURRENCIES => $currency->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -986,7 +986,7 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CURRENCIES => $currency->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_DELETE, @@ -1010,7 +1010,7 @@ public function hookActionObjectCartAddAfter($parameters) $cart = $parameters['object']; if (isset($cart->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CARTS => $cart->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_ADD, @@ -1034,7 +1034,7 @@ public function hookActionObjectCartUpdateAfter($parameters) $cart = $parameters['object']; if (isset($cart->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CARTS => $cart->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARTS => $cart->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1058,7 +1058,7 @@ public function hookActionObjectCartRuleAddAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CART_RULES => $cartRule->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_ADD, @@ -1082,7 +1082,7 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CART_RULES => $cartRule->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_DELETE, @@ -1106,7 +1106,7 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_CART_RULES => $cartRule->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1130,7 +1130,7 @@ public function hookActionObjectOrderAddAfter($parameters) $order = $parameters['object']; if (isset($order->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_ORDERS => $order->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_ORDERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_ADD, @@ -1154,7 +1154,7 @@ public function hookActionObjectOrderUpdateAfter($parameters) $order = $parameters['object']; if (isset($order->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_ORDERS => $order->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_ORDERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1218,9 +1218,9 @@ public function hookActionObjectCarrierUpdateAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync( [ - Config::COLLECTION_CARRIERS => $carrier->id, - Config::COLLECTION_CARRIER_DETAILS => $carrier->id, - Config::COLLECTION_CARRIER_TAXES => $carrier->id, + Config::COLLECTION_CARRIERS, + Config::COLLECTION_CARRIER_DETAILS, + Config::COLLECTION_CARRIER_TAXES, ], 'upsert' ); @@ -1254,9 +1254,9 @@ public function hookActionObjectCarrierDeleteAfter($parameters) if (isset($carrier->id)) { $synchronizationService->sendLiveSync( [ - Config::COLLECTION_CARRIERS => $carrier->id, - Config::COLLECTION_CARRIER_DETAILS => $carrier->id, - Config::COLLECTION_CARRIER_TAXES => $carrier->id, + Config::COLLECTION_CARRIERS, + Config::COLLECTION_CARRIER_DETAILS, + Config::COLLECTION_CARRIER_TAXES, ], 'delete' ); @@ -1658,7 +1658,7 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_ADD, @@ -1685,7 +1685,7 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_UPDATE, @@ -1712,7 +1712,7 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) if ($specificPrice instanceof \SpecificPrice) { if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync([Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_DELETE, From ea344c7964913351538d7d69aea6b513fedb6c3e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 3 Oct 2024 15:22:01 +0200 Subject: [PATCH 105/162] fix: some errors --- src/Handler/ErrorHandler/ErrorHandler.php | 2 +- .../ErrorHandler/ErrorHandlerInterface.php | 38 ------------------- src/Repository/IncrementalSyncRepository.php | 4 +- src/Service/HealthCheckService.php | 4 +- src/Service/SynchronizationService.php | 21 ++++++---- src/Traits/UseHooks.php | 2 +- 6 files changed, 20 insertions(+), 51 deletions(-) delete mode 100644 src/Handler/ErrorHandler/ErrorHandlerInterface.php diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index b977c0ae..0042c70e 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -30,7 +30,7 @@ /** * Handle Error. */ -class ErrorHandler implements ErrorHandlerInterface +class ErrorHandler { /** * @var ?\Raven_Client diff --git a/src/Handler/ErrorHandler/ErrorHandlerInterface.php b/src/Handler/ErrorHandler/ErrorHandlerInterface.php deleted file mode 100644 index dd02bf1b..00000000 --- a/src/Handler/ErrorHandler/ErrorHandlerInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; - -if (!defined('_PS_VERSION_')) { - exit; -} - -interface ErrorHandlerInterface -{ - /** - * @param \Exception $error - * @param mixed $code - * @param bool|null $throw - * @param array|null $data - * - * @return void - */ - public function handle($error, $code = null, $throw = null, $data = null); -} diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index ef4b6587..38d4a681 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -90,9 +90,9 @@ public function insertIncrementalObject($data) '; return (bool) $this->db->query($query); - } catch (\PrestaShopDatabaseException $e) { + } catch (\PrestaShopDatabaseException $exception) { $this->errorHandler->handle( - new \PrestaShopDatabaseException('Failed to insert incremental object', $e->getCode(), $e) + new \PrestaShopDatabaseException('Failed to insert incremental object', $exception->getCode(), $exception) ); return false; diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index d2c89df5..75772974 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -107,8 +107,8 @@ public function getHealthCheck($isAuthentified) $tokenValid = true; } } - } catch (\Exception $e) { - $this->errorHandler->handle($e); + } catch (\Exception $exception) { + $this->errorHandler->handle($exception); $tokenIsSet = false; } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 6e80bea3..73fa7f3b 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -22,6 +22,7 @@ use PrestaShop\Module\PsEventbus\Api\LiveSyncApiClient; use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository; @@ -65,13 +66,19 @@ class SynchronizationService */ private $proxyService; + /** + * @var ErrorHandler + */ + private $errorHandler; + public function __construct( LiveSyncApiClient $liveSyncApiClient, EventbusSyncRepository $eventbusSyncRepository, IncrementalSyncRepository $incrementalSyncRepository, LiveSyncRepository $liveSyncRepository, LanguagesService $languagesService, - ProxyServiceInterface $proxyService + ProxyServiceInterface $proxyService, + ErrorHandler $errorHandler ) { $this->liveSyncApiClient = $liveSyncApiClient; $this->eventbusSyncRepository = $eventbusSyncRepository; @@ -79,6 +86,7 @@ public function __construct( $this->liveSyncRepository = $liveSyncRepository; $this->languagesService = $languagesService; $this->proxyService = $proxyService; + $this->errorHandler = $errorHandler; } /** @@ -211,15 +219,15 @@ public function sendIncrementalSync( /** * liveSync * - * @param array $contents + * @param mixed $contents * @param string $actionType * * @return void */ public function sendLiveSync($contents, $actionType) { - if (count($contents) == 0) { - return; + if (!is_array($contents)) { + $contents = [$contents]; } $defaultIsoCode = $this->languagesService->getDefaultLanguageIsoCode(); @@ -228,8 +236,8 @@ public function sendLiveSync($contents, $actionType) if ($this->isFullSyncDone($content, $defaultIsoCode) && $this->debounceLiveSync($content)) { try { $this->liveSyncApiClient->liveSync($content, $actionType); - } catch (\Exception $e) { - // FIXME : report this error somehow + } catch (\Exception $exception) { + $this->errorHandler->handle($exception); } } } @@ -327,7 +335,6 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } } } - dump($contentToInsert); if (empty($contentToInsert) == false) { $this->incrementalSyncRepository->insertIncrementalObject($contentToInsert); diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 1629ae3a..cc890c82 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -479,7 +479,7 @@ public function hookActionObjectProductAddAfter($parameters) /** @var StockRepository $stockRepository */ $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); $stockId = $stockRepository->getStockIdByProductId($product->id); - + $synchronizationService->sendLiveSync( [ Config::COLLECTION_PRODUCTS, From 72619a1689ca94e1e376cdb8a9e17538eb361d8f Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 3 Oct 2024 15:23:34 +0200 Subject: [PATCH 106/162] fix: useless code in error handler --- src/Handler/ErrorHandler/ErrorHandler.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 0042c70e..48ee68d1 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -73,25 +73,18 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc /** * @param \Exception $error - * @param mixed $code - * @param bool|null $throw - * @param array|null $data * * @return void * * @@throws Exception */ - public function handle($error, $code = null, $throw = null, $data = null) + public function handle($error) { - if ($throw == null) { - $throw = true; - } - if (!$this->client) { return; } - $this->client->captureException($error, $data); + $this->client->captureException($error); \PrestaShopLogger::addLog( $error->getMessage() . ' : ' . $error->getFile() . ':' . $error->getLine() . ' | ' . $error->getTraceAsString(), @@ -101,11 +94,6 @@ public function handle($error, $code = null, $throw = null, $data = null) \Module::getModuleIdByName('ps_eventbus'), true ); - - if (is_int($code) && true === $throw) { - http_response_code($code); - throw $error; - } } /** From 50e283231b264363a8e480430dbed1f4134c7659 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 3 Oct 2024 15:26:16 +0200 Subject: [PATCH 107/162] fix: problem after merge main --- .github/workflows/quality-check.yml | 6 ++---- src/Service/ShopContent/EmployeesService.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index 9ba25e91..a82fd70e 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -55,8 +55,7 @@ jobs: timeout-minutes: 15 strategy: matrix: - # @TODO: "1.6.1.24" is temporarily disabled here - ps_version: ["1.7.8.10", "8.1.6"] + ps_version: ["1.6.1.11", "1.7.8.10", "8.1.6"] steps: - name: Checkout uses: actions/checkout@v4 @@ -90,8 +89,7 @@ jobs: if: ${{ github.event_name == 'pull_request' }} strategy: matrix: - # @TODO: "1.6.1.24" is temporarily disabled here - ps_version: ["1.7.8.10", "8.1.4", "nightly"] + ps_version: ["1.6.1.11", "1.7.8.10", "8.1.4", "nightly"] steps: - name: Checkout the repository uses: actions/checkout@v4 diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index 7ab69920..851b6b97 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -139,7 +139,7 @@ private function castEmployees(&$currencies) $employee['has_enabled_gravatar'] = (bool) $employee['has_enabled_gravatar']; } - // FIXME : use a random salt generated during module install + // FIXME: use a random salt generated during module install $employee['email_hash'] = hash('sha256', $employee['email'] . 'dUj4GMBD6689pL9pyr'); unset($employee['email']); } From 1aaae1ac1cf5a9afa08c9e46e0ebebfa41807c69 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 3 Oct 2024 15:29:55 +0200 Subject: [PATCH 108/162] fix: phpcs-fixer and phpstan --- config/common/common.yml | 4 +- config/common/repository.yml | 2 +- config/front/services.yml | 2 +- src/Repository/IncrementalSyncRepository.php | 6 +-- src/Service/CommonService.php | 48 ++++++++++---------- src/Service/HealthCheckService.php | 8 ++-- src/Service/ProxyService.php | 6 +-- src/Traits/UseHooks.php | 2 +- 8 files changed, 38 insertions(+), 40 deletions(-) diff --git a/config/common/common.yml b/config/common/common.yml index 3d024759..431885cc 100644 --- a/config/common/common.yml +++ b/config/common/common.yml @@ -43,9 +43,7 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Api\CollectorApiClient' - '@PrestaShop\Module\PsEventbus\Formatter\JsonFormatter' - - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' - - PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface: '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler: class: PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler diff --git a/config/common/repository.yml b/config/common/repository.yml index 87cf2c4c..063e4f88 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -9,7 +9,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository public: true arguments: - - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' PrestaShop\Module\PsEventbus\Repository\ShopRepository: class: PrestaShop\Module\PsEventbus\Repository\ShopRepository diff --git a/config/front/services.yml b/config/front/services.yml index b96c910e..a82509ed 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -43,7 +43,7 @@ services: arguments: - '@ps_eventbus' - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - '%ps_eventbus.sync_api_url%' - '%ps_eventbus.live_sync_api_url%' - '%ps_eventbus.proxy_api_url%' diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 38d4a681..be263623 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -20,7 +20,7 @@ namespace PrestaShop\Module\PsEventbus\Repository; -use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; if (!defined('_PS_VERSION_')) { exit; @@ -31,11 +31,11 @@ class IncrementalSyncRepository extends AbstractRepository const TABLE_NAME = 'eventbus_incremental_sync'; /** - * @var ErrorHandlerInterface + * @var ErrorHandler */ private $errorHandler; - public function __construct(ErrorHandlerInterface $errorHandler) + public function __construct(ErrorHandler $errorHandler) { $this->errorHandler = $errorHandler; diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 9541785c..fcc0c4e0 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -104,14 +104,14 @@ public static function dieWithResponse($response, $code) } /** - * @param array $payload - * - * @return void - * - * @throws \Exception - */ - public static function convertDateFormat(&$payload) - { + * @param array $payload + * + * @return void + * + * @throws \Exception + */ + public static function convertDateFormat(&$payload) + { // use hardcoded format to avoid problems with interface change in PHP 7.2 $ISO8601 = 'Y-m-d\TH:i:sO'; $dateFields = [ @@ -125,20 +125,20 @@ public static function convertDateFormat(&$payload) 'to', ]; - $timezone = (string) \Configuration::get('PS_TIMEZONE'); - - foreach ($payload as &$payloadItem) { - foreach ($dateFields as $dateField) { - if (isset($payloadItem['properties'][$dateField])) { - $date = &$payloadItem['properties'][$dateField]; - if (!empty($date) && $date !== '0000-00-00 00:00:00') { - $dateTime = new \DateTime($date, new \DateTimeZone($timezone)); - $date = $dateTime->format($ISO8601); - } else { - $date = null; - } - } - } - } - } + $timezone = (string) \Configuration::get('PS_TIMEZONE'); + + foreach ($payload as &$payloadItem) { + foreach ($dateFields as $dateField) { + if (isset($payloadItem['properties'][$dateField])) { + $date = &$payloadItem['properties'][$dateField]; + if (!empty($date) && $date !== '0000-00-00 00:00:00') { + $dateTime = new \DateTime($date, new \DateTimeZone($timezone)); + $date = $dateTime->format($ISO8601); + } else { + $date = null; + } + } + } + } + } } diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 75772974..953b5a3a 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -20,7 +20,7 @@ namespace PrestaShop\Module\PsEventbus\Service; -use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; if (!defined('_PS_VERSION_')) { exit; @@ -40,7 +40,7 @@ class HealthCheckService /** @var array */ private $configuration; - /** @var ErrorHandlerInterface */ + /** @var ErrorHandler */ private $errorHandler; /** @@ -55,7 +55,7 @@ class HealthCheckService /** * @param \Ps_eventbus $module * @param PsAccountsAdapterService $psAccountsAdapterService - * @param ErrorHandlerInterface $errorHandler + * @param ErrorHandler $errorHandler * @param string $eventbusSyncApiUrl * @param string $eventbusLiveSyncApiUrl * @param string $eventbusProxyApiUrl @@ -65,7 +65,7 @@ class HealthCheckService public function __construct( \Ps_eventbus $module, PsAccountsAdapterService $psAccountsAdapterService, - ErrorHandlerInterface $errorHandler, + ErrorHandler $errorHandler, $eventbusSyncApiUrl, $eventbusLiveSyncApiUrl, $eventbusProxyApiUrl diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index 0f430c48..fe7610f8 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -25,7 +25,7 @@ use PrestaShop\Module\PsEventbus\Api\CollectorApiClient; use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Formatter\JsonFormatter; -use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandlerInterface; +use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; if (!defined('_PS_VERSION_')) { exit; @@ -42,11 +42,11 @@ class ProxyService implements ProxyServiceInterface */ private $jsonFormatter; /** - * @var ErrorHandlerInterface + * @var ErrorHandler */ private $errorHandler; - public function __construct(CollectorApiClient $eventBusProxyClient, JsonFormatter $jsonFormatter, ErrorHandlerInterface $errorHandler) + public function __construct(CollectorApiClient $eventBusProxyClient, JsonFormatter $jsonFormatter, ErrorHandler $errorHandler) { $this->eventBusProxyClient = $eventBusProxyClient; $this->jsonFormatter = $jsonFormatter; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index cc890c82..1629ae3a 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -479,7 +479,7 @@ public function hookActionObjectProductAddAfter($parameters) /** @var StockRepository $stockRepository */ $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); $stockId = $stockRepository->getStockIdByProductId($product->id); - + $synchronizationService->sendLiveSync( [ Config::COLLECTION_PRODUCTS, From f37c77553e2f9fb789b61f57e7e096f966a8c016 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 3 Oct 2024 15:37:13 +0200 Subject: [PATCH 109/162] fix: e2e --- config/front/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/front/services.yml b/config/front/services.yml index a82509ed..76b0d970 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -36,6 +36,7 @@ services: - '@PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService' - '@PrestaShop\Module\PsEventbus\Service\SynchronizationService' - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' PrestaShop\Module\PsEventbus\Service\HealthCheckService: class: PrestaShop\Module\PsEventbus\Service\HealthCheckService From 6d48ad8c3e8d30ec74535b7755016faf05c6c9d5 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 4 Oct 2024 09:45:33 +0200 Subject: [PATCH 110/162] chore: add fixme --- src/Api/LiveSyncApiClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index 69fdc760..d344ab8e 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -109,7 +109,7 @@ public function liveSync($shopContent, $action) 'Authorization' => 'Bearer ' . $this->jwt, 'User-Agent' => 'ps-eventbus/' . $this->module->version, 'Content-Type' => 'application/json', - ], + ], // FIXME: Pass real array of shop contents. at the moment, only one shop content is sent for match CS rate limiter '{"shopContents": ["' . $kebabCasedShopContent . '"], "shopContentId": ' . $uselessParameter . ', "action": "' . $action . '"}' ) ); From 8e5a77052f8d773b9bfae2cc6c088034c48ad21e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 4 Oct 2024 16:01:29 +0200 Subject: [PATCH 111/162] fix: debug mode and anothers query params --- config/front/services.yml | 1 + controllers/front/apiFront.php | 13 +++-- src/Config/Config.php | 8 +-- src/Handler/ErrorHandler/ErrorHandler.php | 33 +++++++---- src/Repository/AbstractRepository.php | 6 +- src/Repository/CarrierRepository.php | 12 ++-- src/Repository/CartProductRepository.php | 12 ++-- src/Repository/CartRepository.php | 12 ++-- src/Repository/CartRuleRepository.php | 12 ++-- src/Repository/CategoryRepository.php | 12 ++-- src/Repository/CurrencyRepository.php | 12 ++-- src/Repository/CustomerRepository.php | 12 ++-- src/Repository/EmployeeRepository.php | 12 ++-- src/Repository/ImageRepository.php | 12 ++-- src/Repository/ImageTypeRepository.php | 12 ++-- src/Repository/LanguageRepository.php | 12 ++-- src/Repository/ManufacturerRepository.php | 12 ++-- src/Repository/ModuleRepository.php | 12 ++-- src/Repository/OrderCartRuleRepository.php | 12 ++-- src/Repository/OrderDetailRepository.php | 12 ++-- src/Repository/OrderHistoryRepository.php | 18 +++--- src/Repository/OrderRepository.php | 12 ++-- src/Repository/ProductBundleRepository.php | 12 ++-- src/Repository/ProductCarrierRepository.php | 12 ++-- src/Repository/ProductRepository.php | 12 ++-- src/Repository/ProductSupplierRepository.php | 12 ++-- src/Repository/RepositoryInterface.php | 8 +-- src/Repository/SpecificPriceRepository.php | 12 ++-- src/Repository/StockMvtRepository.php | 12 ++-- src/Repository/StockRepository.php | 12 ++-- src/Repository/StoreRepository.php | 12 ++-- src/Repository/SupplierRepository.php | 12 ++-- src/Repository/TaxonomyRepository.php | 12 ++-- src/Repository/TranslationRepository.php | 12 ++-- src/Repository/WishlistProductRepository.php | 12 ++-- src/Repository/WishlistRepository.php | 12 ++-- src/Service/FrontApiService.php | 57 ++++++------------- .../ShopContent/CarrierDetailsService.php | 12 ++-- .../ShopContent/CarrierTaxesService.php | 12 ++-- src/Service/ShopContent/CarriersService.php | 12 ++-- .../ShopContent/CartProductsService.php | 12 ++-- src/Service/ShopContent/CartRulesService.php | 12 ++-- src/Service/ShopContent/CartsService.php | 12 ++-- src/Service/ShopContent/CategoriesService.php | 12 ++-- src/Service/ShopContent/CurrenciesService.php | 12 ++-- src/Service/ShopContent/CustomersService.php | 12 ++-- src/Service/ShopContent/EmployeesService.php | 12 ++-- src/Service/ShopContent/ImageTypesService.php | 12 ++-- src/Service/ShopContent/ImagesService.php | 12 ++-- src/Service/ShopContent/LanguagesService.php | 12 ++-- .../ShopContent/ManufacturersService.php | 12 ++-- src/Service/ShopContent/ModulesService.php | 12 ++-- .../ShopContent/OrderCartRulesService.php | 12 ++-- .../ShopContent/OrderDetailsService.php | 12 ++-- .../ShopContent/OrderHistoriesService.php | 12 ++-- src/Service/ShopContent/OrdersService.php | 18 +++--- .../ShopContent/ProductBundlesService.php | 12 ++-- .../ShopContent/ProductCarriersService.php | 12 ++-- .../ShopContent/ProductSuppliersService.php | 12 ++-- src/Service/ShopContent/ProductsService.php | 12 ++-- .../ShopContentServiceInterface.php | 8 +-- .../ShopContent/ShopDetailsService.php | 8 +-- .../ShopContent/SpecificPricesService.php | 12 ++-- src/Service/ShopContent/StockMvtsService.php | 12 ++-- src/Service/ShopContent/StocksService.php | 12 ++-- src/Service/ShopContent/StoresService.php | 12 ++-- src/Service/ShopContent/SuppliersService.php | 12 ++-- src/Service/ShopContent/TaxonomiesService.php | 12 ++-- src/Service/ShopContent/ThemesService.php | 8 +-- .../ShopContent/TranslationsService.php | 12 ++-- .../ShopContent/WishlistProductsService.php | 12 ++-- src/Service/ShopContent/WishlistsService.php | 12 ++-- src/Service/SynchronizationService.php | 12 ++-- src/Traits/UseHooks.php | 2 +- 74 files changed, 455 insertions(+), 465 deletions(-) diff --git a/config/front/services.yml b/config/front/services.yml index 76b0d970..e2bb6283 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -21,6 +21,7 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ProxyService' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' PrestaShop\Module\PsEventbus\Service\PresenterService: class: PrestaShop\Module\PsEventbus\Service\PresenterService diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 7a00c238..999c7114 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -48,11 +48,14 @@ public function postProcess() /** @var bool $fullSyncRequested */ $fullSyncRequested = Tools::getValue('full', 0) == 1; - /** @var bool $debug */ - $debug = Tools::getValue('debug') == 1; + /** @var bool $explainSql */ + $explainSql = Tools::getValue('explain_sql', 0) == 1; - /** @var bool $ise2e */ - $ise2e = Tools::getValue('is_e2e') == 1; + /** @var bool $verbose */ + $verbose = Tools::getValue('verbose', 0) == 1; + + /** @var bool $psLogsEnabled */ + $psLogsEnabled = Tools::getValue('ps_logs_enabled', 0) == 1; /** @var Ps_eventbus $module */ $module = Module::getInstanceByName('ps_eventbus'); @@ -63,6 +66,6 @@ public function postProcess() // edit shopContent for matching Config.php const $shopContentEdited = str_replace('-', '_', $shopContent); - $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $fullSyncRequested, $debug, $ise2e); + $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $fullSyncRequested, $explainSql, $verbose, $psLogsEnabled); } } diff --git a/src/Config/Config.php b/src/Config/Config.php index 4ed3a3ec..890453f4 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -76,14 +76,13 @@ class Config const COLLECTION_ORDER_DETAILS = 'order_details'; const COLLECTION_ORDER_HISTORIES = 'order_histories'; const COLLECTION_PRODUCTS = 'products'; - const COLLECTION_PRODUCT_ATTRIBUTES = 'attributes'; const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; - const COLLECTION_PRODUCT_CARRIERS = 'product_carriers'; + const COLLECTION_PRODUCT_CARRIERS = 'product_carriers'; // TODO: rename to #custom-product-carriers const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; - const COLLECTION_SHOP_DETAILS = 'shop_details'; + const COLLECTION_SHOP_DETAILS = 'shop_details'; // TODO: rename to #infos const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; const COLLECTION_STOCKS = 'stocks'; - const COLLECTION_STOCK_MVTS = 'stock_mvts'; + const COLLECTION_STOCK_MVTS = 'stock_mvts'; // TODO: rename to #stock-movements const COLLECTION_STORES = 'stores'; const COLLECTION_SUPPLIERS = 'suppliers'; const COLLECTION_TAXONOMIES = 'taxonomies'; @@ -114,7 +113,6 @@ class Config self::COLLECTION_ORDER_DETAILS, self::COLLECTION_ORDER_HISTORIES, self::COLLECTION_PRODUCTS, - self::COLLECTION_PRODUCT_ATTRIBUTES, self::COLLECTION_PRODUCT_BUNDLES, self::COLLECTION_PRODUCT_CARRIERS, self::COLLECTION_PRODUCT_SUPPLIERS, diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 48ee68d1..d8ddc416 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -21,6 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; use Exception; +use PrestaShop\Module\PsEventbus\Service\CommonService; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; if (!defined('_PS_VERSION_')) { @@ -72,28 +73,38 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc } /** - * @param \Exception $error + * @param mixed $exception + * @param bool $verbose + * @param bool $psLogsEnabled * * @return void * * @@throws Exception */ - public function handle($error) + public function handle($exception, $verbose, $psLogsEnabled) { if (!$this->client) { return; } - $this->client->captureException($error); + if ($psLogsEnabled) { + \PrestaShopLogger::addLog( + $exception->getMessage() . ' : ' . $exception->getFile() . ':' . $exception->getLine() . ' | ' . $exception->getTraceAsString(), + 3, + $exception->getCode() > 0 ? $exception->getCode() : 500, + 'Module', + \Module::getModuleIdByName('ps_eventbus'), + true + ); + } - \PrestaShopLogger::addLog( - $error->getMessage() . ' : ' . $error->getFile() . ':' . $error->getLine() . ' | ' . $error->getTraceAsString(), - 3, - $error->getCode() > 0 ? $error->getCode() : 500, - 'Module', - \Module::getModuleIdByName('ps_eventbus'), - true - ); + // if debug mode enabled, print error + if (_PS_MODE_DEV_ == true && $verbose == true) { + throw $exception; + } else { + $this->client->captureException($exception); + CommonService::exitWithExceptionMessage($exception); + } } /** diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 37408c41..9844a109 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -105,16 +105,16 @@ public function getShopContext() } /** - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - protected function runQuery($debug) + protected function runQuery($explainSql) { - if ($debug != null && $debug === true) { + if ($explainSql != null && $explainSql === true) { $this->debugQuery(); } diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php index 37231c57..c9c575af 100644 --- a/src/Repository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -62,34 +62,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -97,7 +97,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->where('c.id_carrier IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/CartProductRepository.php b/src/Repository/CartProductRepository.php index be0e3bde..42f4a9c6 100644 --- a/src/Repository/CartProductRepository.php +++ b/src/Repository/CartProductRepository.php @@ -57,34 +57,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -93,7 +93,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/CartRepository.php b/src/Repository/CartRepository.php index 3cf67031..b047d1a3 100644 --- a/src/Repository/CartRepository.php +++ b/src/Repository/CartRepository.php @@ -55,34 +55,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -91,7 +91,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php index 6d1721e0..f51276f1 100644 --- a/src/Repository/CartRuleRepository.php +++ b/src/Repository/CartRuleRepository.php @@ -86,34 +86,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -122,7 +122,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php index 097369f6..c49a8940 100644 --- a/src/Repository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -71,34 +71,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -107,7 +107,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php index 4af3dabf..38baf8b1 100644 --- a/src/Repository/CurrencyRepository.php +++ b/src/Repository/CurrencyRepository.php @@ -70,34 +70,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -106,7 +106,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index 2fbe76e7..14dce301 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -63,34 +63,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -99,7 +99,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php index 65530995..294734c2 100644 --- a/src/Repository/EmployeeRepository.php +++ b/src/Repository/EmployeeRepository.php @@ -77,34 +77,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -113,7 +113,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ImageRepository.php b/src/Repository/ImageRepository.php index 5cbd1667..fbb09bc2 100644 --- a/src/Repository/ImageRepository.php +++ b/src/Repository/ImageRepository.php @@ -61,34 +61,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -97,7 +97,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php index f1a96cea..8e181b34 100644 --- a/src/Repository/ImageTypeRepository.php +++ b/src/Repository/ImageTypeRepository.php @@ -59,34 +59,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -95,7 +95,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/LanguageRepository.php b/src/Repository/LanguageRepository.php index e98c4508..c5856d22 100644 --- a/src/Repository/LanguageRepository.php +++ b/src/Repository/LanguageRepository.php @@ -66,34 +66,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -102,7 +102,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 01b24b3e..f437a934 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -66,34 +66,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -102,7 +102,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php index 9a51cd7b..aead3ebd 100644 --- a/src/Repository/ModuleRepository.php +++ b/src/Repository/ModuleRepository.php @@ -72,34 +72,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -108,7 +108,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php index 6e7320c2..d94a39a2 100644 --- a/src/Repository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -61,34 +61,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -96,7 +96,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->where('ocr.id_order_cart_rule IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/OrderDetailRepository.php b/src/Repository/OrderDetailRepository.php index c6c0552a..8b11aaa7 100644 --- a/src/Repository/OrderDetailRepository.php +++ b/src/Repository/OrderDetailRepository.php @@ -82,14 +82,14 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -97,21 +97,21 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $debug) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -120,7 +120,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php index 2141fc7a..50b85783 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -68,34 +68,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -104,7 +104,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** @@ -131,13 +131,13 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $orderIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopDatabaseException */ - public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $debug) + public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $explainSql) { if (!$orderIds) { return []; @@ -147,6 +147,6 @@ public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $debug) $this->query->where('oh.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')'); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } } diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php index e793e01b..0bb3e0c4 100644 --- a/src/Repository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -112,14 +112,14 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -127,21 +127,21 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $debug) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -150,7 +150,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ProductBundleRepository.php b/src/Repository/ProductBundleRepository.php index 6ec4150a..bbd81baa 100644 --- a/src/Repository/ProductBundleRepository.php +++ b/src/Repository/ProductBundleRepository.php @@ -65,34 +65,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -101,7 +101,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ProductCarrierRepository.php b/src/Repository/ProductCarrierRepository.php index db48fd6a..94744bbb 100644 --- a/src/Repository/ProductCarrierRepository.php +++ b/src/Repository/ProductCarrierRepository.php @@ -51,34 +51,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -87,7 +87,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index 6717b9b0..c7a0d8a1 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -132,34 +132,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -168,7 +168,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php index ee35f697..810efb21 100644 --- a/src/Repository/ProductSupplierRepository.php +++ b/src/Repository/ProductSupplierRepository.php @@ -57,34 +57,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -93,7 +93,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/RepositoryInterface.php b/src/Repository/RepositoryInterface.php index bb1323aa..db3646c2 100644 --- a/src/Repository/RepositoryInterface.php +++ b/src/Repository/RepositoryInterface.php @@ -41,21 +41,21 @@ public function generateFullQuery($langIso, $withSelecParameters); * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug); + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql); /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); /** * @param int $offset diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index 7219b3c3..ebf52eed 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -75,34 +75,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -111,7 +111,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/StockMvtRepository.php b/src/Repository/StockMvtRepository.php index abf36e86..cb8b8542 100644 --- a/src/Repository/StockMvtRepository.php +++ b/src/Repository/StockMvtRepository.php @@ -72,34 +72,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -108,7 +108,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index 353135b9..4013d94d 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -73,34 +73,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -109,7 +109,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index 3c59e9e2..fc10095e 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -88,34 +88,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -124,7 +124,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index 8dd4849f..fed730f9 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -68,34 +68,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -104,7 +104,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/TaxonomyRepository.php b/src/Repository/TaxonomyRepository.php index 15e80091..cdddb096 100644 --- a/src/Repository/TaxonomyRepository.php +++ b/src/Repository/TaxonomyRepository.php @@ -54,14 +54,14 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { // need this module for this table : https://addons.prestashop.com/en/products-on-facebook-social-networks/50291-prestashop-social-with-facebook-instagram.html if (empty($this->checkIfPsFacebookIsInstalled())) { @@ -72,21 +72,21 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $debug) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -95,7 +95,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 5401f4e6..44681a19 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -56,34 +56,34 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -92,7 +92,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php index f0f4e2cc..a66dab5c 100644 --- a/src/Repository/WishlistProductRepository.php +++ b/src/Repository/WishlistProductRepository.php @@ -56,14 +56,14 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html if (empty($this->checkIfPsWishlistIsInstalled())) { @@ -74,21 +74,21 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $debug) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -97,7 +97,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php index 86a7f5e8..e7569254 100644 --- a/src/Repository/WishlistRepository.php +++ b/src/Repository/WishlistRepository.php @@ -62,14 +62,14 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $debug) + public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html if (empty($this->checkIfPsWishlistIsInstalled())) { @@ -80,21 +80,21 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $debug) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $this->generateFullQuery($langIso, true); @@ -103,7 +103,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $d ->limit($limit) ; - return $this->runQuery($debug); + return $this->runQuery($explainSql); } /** diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index ca356d02..81239b32 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -81,14 +81,17 @@ public function __construct( * @param string $langIso * @param int $limit * @param bool $fullSyncRequested - * @param bool $debug - * @param bool $ise2e - * + * @param bool $explainSql + * @param bool $verbose + * @param bool $psLogEnabled + * * @return void */ - public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested, $debug, $ise2e) + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested, $explainSql, $verbose, $psLogEnabled) { try { + throw new \Exception('This method is not implemented'); + if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } @@ -159,7 +162,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $limit, $this->startTime, $dateNow, - $debug + $explainSql ); } else { $response = $this->synchronizationService->sendIncrementalSync( @@ -168,7 +171,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $langIso, $limit, $this->startTime, - $debug + $explainSql ); } @@ -183,39 +186,16 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync ) ); } catch (\PrestaShopDatabaseException $exception) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + $this->errorHandler->handle($exception, $verbose, $psLogEnabled); } catch (EnvVarException $exception) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + $this->errorHandler->handle($exception, $verbose, $psLogEnabled); } catch (FirebaseException $exception) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + $this->errorHandler->handle($exception, $verbose, $psLogEnabled); } catch (ServiceNotFoundException $exception) { - $this->catchGenericException($exception, $ise2e); + $this->errorHandler->handle($exception, $verbose, $psLogEnabled); } catch (\Exception $exception) { - $this->catchGenericException($exception, $ise2e); - } - } - - /** - * @param mixed $exception - * @param mixed $ise2e - * - * @return void - * - * @throws \Exception - */ - private function catchGenericException($exception, $ise2e) - { - $this->errorHandler->handle($exception); - - // if debug mode enabled, print error - if (_PS_MODE_DEV_ == true && $ise2e == false) { - throw $exception; + $this->errorHandler->handle($exception, $verbose, $psLogEnabled); } - - CommonService::dieWithResponse(['message' => 'An error occured. Please check shop logs for more information'], 500); } /** @@ -255,14 +235,11 @@ private function authorize($jobId, $isHealthCheck) } if ($exception instanceof \PrestaShopDatabaseException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + $this->errorHandler->handle($exception, false, false); } elseif ($exception instanceof EnvVarException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + $this->errorHandler->handle($exception, false, false); } elseif ($exception instanceof FirebaseException) { - $this->errorHandler->handle($exception); - CommonService::exitWithExceptionMessage($exception); + $this->errorHandler->handle($exception, false, false); } return false; diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index c39a39c6..da75e41a 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -43,13 +43,13 @@ public function __construct(CarrierRepository $carrierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -76,13 +76,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 1093d9cc..0416064f 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -42,13 +42,13 @@ public function __construct(CarrierRepository $carrierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -75,13 +75,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 67dd6ee7..6d3c11dc 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -41,13 +41,13 @@ public function __construct(CarrierRepository $carrierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index d8593835..07c2d5b4 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -41,13 +41,13 @@ public function __construct(CartProductRepository $cartProductRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->cartProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->cartProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->cartProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->cartProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index 0da3fad4..9c50a221 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -41,13 +41,13 @@ public function __construct(CartRuleRepository $cartRuleRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->cartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->cartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->cartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->cartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 0f3e99f5..6473c044 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -41,13 +41,13 @@ public function __construct(CartRepository $cartRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->cartRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->cartRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->cartRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->cartRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index 6e66526d..82990299 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -41,13 +41,13 @@ public function __construct(CategoryRepository $categoryRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->categoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->categoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->categoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->categoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index 79947d0d..9a150b95 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -41,13 +41,13 @@ public function __construct(CurrencyRepository $currencyRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->currencyRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->currencyRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->currencyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->currencyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index a5ddb24f..dc39dad8 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -41,13 +41,13 @@ public function __construct(CustomerRepository $customerRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->customerRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->customerRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->customerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->customerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index 851b6b97..500f3c86 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -41,13 +41,13 @@ public function __construct(EmployeeRepository $employeeRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->employeeRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->employeeRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->employeeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->employeeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index a65d9517..9f9e4949 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -41,13 +41,13 @@ public function __construct(ImageTypeRepository $imageTypeRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->imageTypeRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->imageTypeRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->imageTypeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->imageTypeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index ef9a1b42..68c1032c 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -41,13 +41,13 @@ public function __construct(ImageRepository $imageRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->imageRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->imageRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->imageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->imageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index 981fc6e2..85e1366e 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -41,13 +41,13 @@ public function __construct(LanguageRepository $languageRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->languageRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->languageRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->languageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->languageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ManufacturersService.php b/src/Service/ShopContent/ManufacturersService.php index e39eefac..c759aacb 100644 --- a/src/Service/ShopContent/ManufacturersService.php +++ b/src/Service/ShopContent/ManufacturersService.php @@ -41,13 +41,13 @@ public function __construct(ManufacturerRepository $manufacturerRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->manufacturerRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->manufacturerRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->manufacturerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->manufacturerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 629bff8e..1284b264 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -48,13 +48,13 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->moduleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->moduleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -75,13 +75,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->moduleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->moduleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index 3cc76bb5..47df016a 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -41,13 +41,13 @@ public function __construct(OrderCartRuleRepository $orderCartRuleRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->orderCartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderCartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->orderCartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderCartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index b7537760..faf75f41 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -41,13 +41,13 @@ public function __construct(OrderDetailRepository $orderDetailRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->orderDetailRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderDetailRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $orderDetailIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $debug) + public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $explainSql) { - $result = $this->orderDetailRepository->retrieveContentsForIncremental($limit, $orderDetailIds, $langIso, $debug); + $result = $this->orderDetailRepository->retrieveContentsForIncremental($limit, $orderDetailIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index 0232a786..2c18a897 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -41,13 +41,13 @@ public function __construct(OrderHistoryRepository $orderHistoryRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->orderHistoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderHistoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->orderHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index f64b7010..bbde6d47 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -54,13 +54,13 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->orderRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->orderRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -81,13 +81,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->orderRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->orderRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; @@ -175,18 +175,18 @@ private function castOrders(&$orders, $langIso) * @param array $orders * @param array $order * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return bool * * @@throws \PrestaShopDatabaseException */ - private function castIsPaidValue($orders, $order, $langIso, $debug) + private function castIsPaidValue($orders, $order, $langIso, $explainSql) { $isPaid = $dateAdd = 0; $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); /** @var array $orderHistoryStatuss */ - $orderHistoryStatuss = $this->orderHistoryRepository->getOrderHistoryIdsByOrderIds($orderIds, $langIso, $debug); + $orderHistoryStatuss = $this->orderHistoryRepository->getOrderHistoryIdsByOrderIds($orderIds, $langIso, $explainSql); foreach ($orderHistoryStatuss as &$orderHistoryStatus) { if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index 2728d7ce..29432186 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -41,13 +41,13 @@ public function __construct(ProductBundleRepository $productBundleRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->productBundleRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->productBundleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->productBundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->productBundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/ProductCarriersService.php index 349aebc9..e602551c 100644 --- a/src/Service/ShopContent/ProductCarriersService.php +++ b/src/Service/ShopContent/ProductCarriersService.php @@ -41,13 +41,13 @@ public function __construct(ProductCarrierRepository $productCarrierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->productCarrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->productCarrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -66,13 +66,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->productCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->productCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index e9be62f7..30439d5f 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -41,13 +41,13 @@ public function __construct(ProductSupplierRepository $productSupplierRepository * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->productSupplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->productSupplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->productSupplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->productSupplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index 3fb75de3..d6049de4 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -78,13 +78,13 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->productRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->productRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -106,13 +106,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->productRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->productRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index 94a2a159..fe20f096 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -30,21 +30,21 @@ interface ShopContentServiceInterface * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug); + public function getContentsForFull($offset, $limit, $langIso, $explainSql); /** * @param int $limit * @param mixed $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug); + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql); /** * @param int $offset diff --git a/src/Service/ShopContent/ShopDetailsService.php b/src/Service/ShopContent/ShopDetailsService.php index eb3f2997..5ef35f2e 100644 --- a/src/Service/ShopContent/ShopDetailsService.php +++ b/src/Service/ShopContent/ShopDetailsService.php @@ -65,11 +65,11 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { $langId = !empty($langIso) ? (int) \Language::getIdByIso($langIso) : null; @@ -122,11 +122,11 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { return []; } diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index 57f3f8dd..ced4d289 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -48,13 +48,13 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->specificPriceRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->specificPriceRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -75,13 +75,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->specificPriceRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->specificPriceRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/StockMvtsService.php b/src/Service/ShopContent/StockMvtsService.php index 699ec44d..1fb026cf 100644 --- a/src/Service/ShopContent/StockMvtsService.php +++ b/src/Service/ShopContent/StockMvtsService.php @@ -41,13 +41,13 @@ public function __construct(StockMvtRepository $stockMvtRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->stockMvtRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->stockMvtRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->stockMvtRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->stockMvtRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/StocksService.php b/src/Service/ShopContent/StocksService.php index a1f4257e..e07c546e 100644 --- a/src/Service/ShopContent/StocksService.php +++ b/src/Service/ShopContent/StocksService.php @@ -41,13 +41,13 @@ public function __construct(StockRepository $stockRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->stockRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->stockRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->stockRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->stockRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/StoresService.php b/src/Service/ShopContent/StoresService.php index c814327b..ff40afca 100644 --- a/src/Service/ShopContent/StoresService.php +++ b/src/Service/ShopContent/StoresService.php @@ -41,13 +41,13 @@ public function __construct(StoreRepository $storeRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->storeRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->storeRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->storeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->storeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/SuppliersService.php b/src/Service/ShopContent/SuppliersService.php index b05a60fa..da942bcd 100644 --- a/src/Service/ShopContent/SuppliersService.php +++ b/src/Service/ShopContent/SuppliersService.php @@ -41,13 +41,13 @@ public function __construct(SupplierRepository $supplierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->supplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->supplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->supplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->supplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/TaxonomiesService.php b/src/Service/ShopContent/TaxonomiesService.php index 7bb452ba..f439b4b5 100644 --- a/src/Service/ShopContent/TaxonomiesService.php +++ b/src/Service/ShopContent/TaxonomiesService.php @@ -41,13 +41,13 @@ public function __construct(TaxonomyRepository $taxonomyRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->taxonomyRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->taxonomyRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->taxonomyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->taxonomyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php index 7fa27c5a..3e51c76e 100644 --- a/src/Service/ShopContent/ThemesService.php +++ b/src/Service/ShopContent/ThemesService.php @@ -41,11 +41,11 @@ public function __construct(\Context $context) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { $result = $this->getAllThemes(); @@ -68,11 +68,11 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { $result = $this->getAllThemes(); diff --git a/src/Service/ShopContent/TranslationsService.php b/src/Service/ShopContent/TranslationsService.php index 43bf564b..aac957c3 100644 --- a/src/Service/ShopContent/TranslationsService.php +++ b/src/Service/ShopContent/TranslationsService.php @@ -41,13 +41,13 @@ public function __construct(TranslationRepository $translationRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->translationRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->translationRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->translationRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->translationRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index 12a38344..860ef578 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -41,13 +41,13 @@ public function __construct(WishlistProductRepository $wishlistProductRepository * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->wishlistProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->wishlistProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->wishlistProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->wishlistProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index 8769a81c..bfa1df98 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -41,13 +41,13 @@ public function __construct(WishlistRepository $wishlistRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $debug) + public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->wishlistRepository->retrieveContentsForFull($offset, $limit, $langIso, $debug); + $result = $this->wishlistRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -68,13 +68,13 @@ public function getContentsForFull($offset, $limit, $langIso, $debug) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $debug + * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $debug) + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $debug); + $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 73fa7f3b..e51bb72e 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -97,7 +97,7 @@ public function __construct( * @param int $limit * @param int $startTime * @param string $dateNow - * @param bool $debug + * @param bool $explainSql * * @return array * @@ -111,7 +111,7 @@ public function sendFullSync( int $limit, int $startTime, string $dateNow, - bool $debug + bool $explainSql ) { $response = []; @@ -128,7 +128,7 @@ public function sendFullSync( /** @var ShopContentServiceInterface $shopContentApiService */ $shopContentApiService = $module->getService($serviceId); - $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $debug); + $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $explainSql); CommonService::convertDateFormat($data); @@ -158,7 +158,7 @@ public function sendFullSync( * @param string $langIso * @param int $limit * @param int $startTime - * @param bool $debug + * @param bool $explainSql * * @return array * @@ -170,7 +170,7 @@ public function sendIncrementalSync( string $langIso, int $limit, int $startTime, - bool $debug + bool $explainSql ) { $response = []; @@ -197,7 +197,7 @@ public function sendIncrementalSync( ]; } - $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso, $debug); + $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso, $explainSql); CommonService::convertDateFormat($data); diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 1629ae3a..25cd8ed0 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -763,7 +763,7 @@ public function hookActionObjectCombinationDeleteAfter($parameters) if (isset($combination->id)) { $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCT_ATTRIBUTES => $combination->id], + [Config::COLLECTION_PRODUCTS => $combination->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId, From 98f1c4a2cd0daf9a4efd50e37080e49b8a8d66f3 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 7 Oct 2024 10:45:11 +0200 Subject: [PATCH 112/162] chore: ordering services and repository and rename product carrier shop content --- config/common/repository.yml | 86 ++++----- config/front/services.yml | 177 +++++++++--------- controllers/front/apiFront.php | 11 +- src/Config/Config.php | 2 +- ...php => CustomProductCarrierRepository.php} | 4 +- src/Repository/ProductRepository.php | 3 +- src/Service/FrontApiService.php | 2 - ...e.php => CustomProductCarriersService.php} | 22 +-- src/Traits/UseHooks.php | 20 +- 9 files changed, 168 insertions(+), 159 deletions(-) rename src/Repository/{ProductCarrierRepository.php => CustomProductCarrierRepository.php} (95%) rename src/Service/ShopContent/{ProductCarriersService.php => CustomProductCarriersService.php} (71%) diff --git a/config/common/repository.yml b/config/common/repository.yml index 063e4f88..07a7dd71 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -39,22 +39,6 @@ services: ###################################### SHOP CONTENT REPOSITORIES ########################################### ############################################################################################################ - PrestaShop\Module\PsEventbus\Repository\OrderRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository - public: true - PrestaShop\Module\PsEventbus\Repository\CarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\CarrierRepository public: true @@ -71,19 +55,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\CartRuleRepository public: true - PrestaShop\Module\PsEventbus\Repository\ProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository: + PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository public: true @@ -115,14 +87,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ModuleRepository public: true - PrestaShop\Module\PsEventbus\Repository\WishlistRepository: - class: PrestaShop\Module\PsEventbus\Repository\WishlistRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository: - class: PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository - public: true - PrestaShop\Module\PsEventbus\Repository\LanguageRepository: class: PrestaShop\Module\PsEventbus\Repository\LanguageRepository public: true @@ -131,8 +95,32 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository public: true - PrestaShop\Module\PsEventbus\Repository\TranslationRepository: - class: PrestaShop\Module\PsEventbus\Repository\TranslationRepository + PrestaShop\Module\PsEventbus\Repository\OrderRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\ProductRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository: + class: PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository: + class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository public: true PrestaShop\Module\PsEventbus\Repository\StockRepository: @@ -147,10 +135,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository public: true - PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository: - class: PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository - public: true - PrestaShop\Module\PsEventbus\Repository\SupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\SupplierRepository public: true @@ -158,3 +142,19 @@ services: PrestaShop\Module\PsEventbus\Repository\StoreRepository: class: PrestaShop\Module\PsEventbus\Repository\StoreRepository public: true + + PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository: + class: PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\TranslationRepository: + class: PrestaShop\Module\PsEventbus\Repository\TranslationRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\WishlistRepository: + class: PrestaShop\Module\PsEventbus\Repository\WishlistRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository: + class: PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository + public: true diff --git a/config/front/services.yml b/config/front/services.yml index e2bb6283..35e47845 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -53,33 +53,7 @@ services: ############################################################################################################ ###################################### SHOP CONTENT SERVICES ############################################### ############################################################################################################ - - PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' - - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - - PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - - PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService public: true @@ -116,44 +90,23 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\CartRuleRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' - - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService' - - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - - PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository' - - PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService + PrestaShop\Module\PsEventbus\Service\ShopContent\CustomProductCarriersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CustomProductCarriersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository' - - PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductCarriersService + - '@PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CustomerRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\CategoryRepository' - - PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\CustomersService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CustomerRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService @@ -179,14 +132,18 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\ImageTypeRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService + + PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' - - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' + - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ModulesService @@ -195,41 +152,68 @@ services: - '@PrestaShop\Module\PsEventbus\Repository\ModuleRepository' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService + PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrdersService public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistsService + PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\WishlistRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService + PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderDetailsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService + PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\LanguageRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ManufacturersService + PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ManufacturerRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService' + - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService + PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\TranslationRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService + public: true + arguments: + - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' + - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' + + PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository' + - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\StocksService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\StocksService @@ -243,12 +227,17 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\StockMvtRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\SpecificPricesService + PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository' - - '@PrestaShop\Module\PsEventbus\Repository\ProductRepository' + - '@PrestaShop\Module\PsEventbus\Repository\StoreRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\SupplierRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\TaxonomiesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\TaxonomiesService @@ -256,14 +245,26 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\TaxonomyRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\SuppliersService + PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\SupplierRepository' + - '@=service("prestashop.adapter.legacy.context").getContext()' + + PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\TranslationRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService + PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\StoreRepository' + - '@PrestaShop\Module\PsEventbus\Repository\WishlistRepository' + + PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\WishlistProductsService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\WishlistProductRepository' diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 999c7114..4f476767 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -66,6 +66,15 @@ public function postProcess() // edit shopContent for matching Config.php const $shopContentEdited = str_replace('-', '_', $shopContent); - $frontApiService->handleDataSync($shopContentEdited, $jobId, $langIso, $limit, $fullSyncRequested, $explainSql, $verbose, $psLogsEnabled); + $frontApiService->handleDataSync( + $shopContentEdited, + $jobId, + $langIso, + $limit, + $fullSyncRequested, + $explainSql, + $verbose, + $psLogsEnabled + ); } } diff --git a/src/Config/Config.php b/src/Config/Config.php index 890453f4..983b8818 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -63,6 +63,7 @@ class Config const COLLECTION_CATEGORIES = 'categories'; const COLLECTION_CURRENCIES = 'currencies'; const COLLECTION_CUSTOMERS = 'customers'; + const COLLECTION_CUSTOM_PRODUCT_CARRIERS = 'custom_product_carriers'; const COLLECTION_DELETED = 'deleted'; const COLLECTION_EMPLOYEES = 'employees'; const COLLECTION_HEALTHCHECK = 'healthcheck'; @@ -77,7 +78,6 @@ class Config const COLLECTION_ORDER_HISTORIES = 'order_histories'; const COLLECTION_PRODUCTS = 'products'; const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; - const COLLECTION_PRODUCT_CARRIERS = 'product_carriers'; // TODO: rename to #custom-product-carriers const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; const COLLECTION_SHOP_DETAILS = 'shop_details'; // TODO: rename to #infos const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; diff --git a/src/Repository/ProductCarrierRepository.php b/src/Repository/CustomProductCarrierRepository.php similarity index 95% rename from src/Repository/ProductCarrierRepository.php rename to src/Repository/CustomProductCarrierRepository.php index 94744bbb..9ea3f781 100644 --- a/src/Repository/ProductCarrierRepository.php +++ b/src/Repository/CustomProductCarrierRepository.php @@ -24,7 +24,7 @@ exit; } -class ProductCarrierRepository extends AbstractRepository implements RepositoryInterface +class CustomProductCarrierRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'product_carrier'; @@ -119,7 +119,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function getProductCarrierIdsByCarrierId($idProduct) + public function getCustomProductCarrierIdsByCarrierId($idProduct) { $this->generateMinimalQuery(self::TABLE_NAME, 'pc'); diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index c7a0d8a1..657a4b46 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -56,7 +56,8 @@ public function generateFullQuery($langIso, $withSelecParameters) ->leftJoin('product_attribute_shop', 'pas', 'pas.id_product = p.id_product AND pas.id_shop = ps.id_shop') ->leftJoin('product_attribute', 'pa', 'pas.id_product_attribute = pa.id_product_attribute') ->leftJoin('category_lang', 'cl', 'ps.id_category_default = cl.id_category AND ps.id_shop = cl.id_shop AND cl.id_lang = ' . $langId) - ->leftJoin('manufacturer', 'm', 'p.id_manufacturer = m.id_manufacturer'); + ->leftJoin('manufacturer', 'm', 'p.id_manufacturer = m.id_manufacturer') + ; if (parent::getShopContext()->getGroup()->share_stock) { $this->query->leftJoin( diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 81239b32..9ea2061e 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -90,8 +90,6 @@ public function __construct( public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested, $explainSql, $verbose, $psLogEnabled) { try { - throw new \Exception('This method is not implemented'); - if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } diff --git a/src/Service/ShopContent/ProductCarriersService.php b/src/Service/ShopContent/CustomProductCarriersService.php similarity index 71% rename from src/Service/ShopContent/ProductCarriersService.php rename to src/Service/ShopContent/CustomProductCarriersService.php index e602551c..3e32f314 100644 --- a/src/Service/ShopContent/ProductCarriersService.php +++ b/src/Service/ShopContent/CustomProductCarriersService.php @@ -21,20 +21,20 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository; if (!defined('_PS_VERSION_')) { exit; } -class ProductCarriersService implements ShopContentServiceInterface +class CustomProductCarriersService implements ShopContentServiceInterface { - /** @var ProductCarrierRepository */ - private $productCarrierRepository; + /** @var CustomProductCarrierRepository */ + private $customProductCarrierRepository; - public function __construct(ProductCarrierRepository $productCarrierRepository) + public function __construct(CustomProductCarrierRepository $customProductCarrierRepository) { - $this->productCarrierRepository = $productCarrierRepository; + $this->customProductCarrierRepository = $customProductCarrierRepository; } /** @@ -47,7 +47,7 @@ public function __construct(ProductCarrierRepository $productCarrierRepository) */ public function getContentsForFull($offset, $limit, $langIso, $explainSql) { - $result = $this->productCarrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->customProductCarrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); if (empty($result)) { return []; @@ -56,7 +56,7 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) return array_map(function ($item) { return [ 'id' => $item['id_product'] . '-' . $item['id_carrier_reference'], - 'collection' => Config::COLLECTION_PRODUCT_CARRIERS, + 'collection' => Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, 'properties' => $item, ]; }, $result); @@ -72,7 +72,7 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) */ public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) { - $result = $this->productCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->customProductCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); if (empty($result)) { return []; @@ -81,7 +81,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $explai return array_map(function ($item) { return [ 'id' => $item['id_product'] . '-' . $item['id_carrier_reference'], - 'collection' => Config::COLLECTION_PRODUCT_CARRIERS, + 'collection' => Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, 'properties' => $item, ]; }, $result); @@ -96,6 +96,6 @@ public function getContentsForIncremental($limit, $contentIds, $langIso, $explai */ public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->productCarrierRepository->countFullSyncContentLeft($offset, $limit, $langIso); + return $this->customProductCarrierRepository->countFullSyncContentLeft($offset, $limit, $langIso); } } diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 25cd8ed0..a0aadada 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -471,9 +471,9 @@ public function hookActionObjectProductAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var ProductCarrierRepository $productCarrierRepository */ - $productCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); - $productCarriers = $productCarrierRepository->getProductCarrierIdsByCarrierId($product->id); + /** @var CustomProductCarrierRepository $customProductCarrierRepository */ + $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); + $productCarriers = $customProductCarrierRepository->getCustomProductCarrierIdsByCarrierId($product->id); $productCarrierIds = array_column($productCarriers, 'id_carrier_reference'); /** @var StockRepository $stockRepository */ @@ -483,7 +483,7 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->sendLiveSync( [ Config::COLLECTION_PRODUCTS, - Config::COLLECTION_PRODUCT_CARRIERS, + Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, Config::COLLECTION_STOCKS, ], 'upsert' @@ -492,7 +492,7 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, + Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $productCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], Config::INCREMENTAL_TYPE_ADD, @@ -519,9 +519,9 @@ public function hookActionObjectProductUpdateAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); - /** @var ProductCarrierRepository $productCarrierRepository */ - $productCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); - $productCarriers = $productCarrierRepository->getProductCarrierIdsByCarrierId($product->id); + /** @var CustomProductCarrierRepository $customProductCarrierRepository */ + $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); + $productCarriers = $customProductCarrierRepository->getCustomProductCarrierIdsByCarrierId($product->id); $productCarrierIds = array_column($productCarriers, 'id_carrier_reference'); /** @var StockRepository $stockRepository */ @@ -531,7 +531,7 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->sendLiveSync( [ Config::COLLECTION_PRODUCTS, - Config::COLLECTION_PRODUCT_CARRIERS, + Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, Config::COLLECTION_STOCKS, ], 'upsert' @@ -540,7 +540,7 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_PRODUCT_CARRIERS => $productCarrierIds, + Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $productCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], Config::INCREMENTAL_TYPE_UPDATE, From 481a1aa681755d612726483d3e5ec8222311a583 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 7 Oct 2024 15:29:30 +0200 Subject: [PATCH 113/162] fix: last rename --- config/common/repository.yml | 6 +- config/front/services.yml | 10 +- ...iers.json => custom_product_carriers.json} | 0 .../1.6/{shop_details.json => shops.json} | 2 +- .../{stock_mvts.json => stock_movements.json} | 0 ...iers.json => custom_product_carriers.json} | 0 .../1.7/{shop_details.json => shops.json} | 2 +- .../{stock_mvts.json => stock_movements.json} | 0 ...iers.json => custom_product_carriers.json} | 0 .../8/{shop_details.json => shops.json} | 2 +- .../{stock_mvts.json => stock_movements.json} | 0 ...iers.json => custom_product_carriers.json} | 0 .../9/{shop_details.json => shops.json} | 2 +- .../{stock_mvts.json => stock_movements.json} | 0 e2e/src/helpers/shop-contents.ts | 6 +- src/Config/Config.php | 10 +- ...sitory.php => StockMovementRepository.php} | 2 +- ...hopDetailsService.php => ShopsService.php} | 4 +- .../ShopContent/StockMovementsService.php | 134 ++++++++++++++++++ src/Service/ShopContent/StockMvtsService.php | 134 ------------------ src/Traits/UseHooks.php | 18 +-- 21 files changed, 166 insertions(+), 166 deletions(-) rename e2e/src/fixtures/1.6/{product_carriers.json => custom_product_carriers.json} (100%) rename e2e/src/fixtures/1.6/{shop_details.json => shops.json} (95%) rename e2e/src/fixtures/1.6/{stock_mvts.json => stock_movements.json} (100%) rename e2e/src/fixtures/1.7/{product_carriers.json => custom_product_carriers.json} (100%) rename e2e/src/fixtures/1.7/{shop_details.json => shops.json} (95%) rename e2e/src/fixtures/1.7/{stock_mvts.json => stock_movements.json} (100%) rename e2e/src/fixtures/8/{product_carriers.json => custom_product_carriers.json} (100%) rename e2e/src/fixtures/8/{shop_details.json => shops.json} (95%) rename e2e/src/fixtures/8/{stock_mvts.json => stock_movements.json} (100%) rename e2e/src/fixtures/9/{product_carriers.json => custom_product_carriers.json} (100%) rename e2e/src/fixtures/9/{shop_details.json => shops.json} (95%) rename e2e/src/fixtures/9/{stock_mvts.json => stock_movements.json} (100%) rename src/Repository/{StockMvtRepository.php => StockMovementRepository.php} (97%) rename src/Service/ShopContent/{ShopDetailsService.php => ShopsService.php} (97%) create mode 100644 src/Service/ShopContent/StockMovementsService.php delete mode 100644 src/Service/ShopContent/StockMvtsService.php diff --git a/config/common/repository.yml b/config/common/repository.yml index 07a7dd71..ef304052 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -56,7 +56,7 @@ services: public: true PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository + class: PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository public: true PrestaShop\Module\PsEventbus\Repository\CategoryRepository: @@ -127,8 +127,8 @@ services: class: PrestaShop\Module\PsEventbus\Repository\StockRepository public: true - PrestaShop\Module\PsEventbus\Repository\StockMvtRepository: - class: PrestaShop\Module\PsEventbus\Repository\StockMvtRepository + PrestaShop\Module\PsEventbus\Repository\StockMovementRepository: + class: PrestaShop\Module\PsEventbus\Repository\StockMovementRepository public: true PrestaShop\Module\PsEventbus\Repository\SpecificPriceRepository: diff --git a/config/front/services.yml b/config/front/services.yml index 35e47845..760dcb69 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -199,8 +199,8 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopDetailsService + PrestaShop\Module\PsEventbus\Service\ShopContent\ShopsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopsService public: true arguments: - '@=service("prestashop.adapter.legacy.context").getContext()' @@ -221,11 +221,11 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\StockRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\StockMvtsService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\StockMvtsService + PrestaShop\Module\PsEventbus\Service\ShopContent\StockMovementsService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\StockMovementsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\StockMvtRepository' + - '@PrestaShop\Module\PsEventbus\Repository\StockMovementRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\StoresService diff --git a/e2e/src/fixtures/1.6/product_carriers.json b/e2e/src/fixtures/1.6/custom_product_carriers.json similarity index 100% rename from e2e/src/fixtures/1.6/product_carriers.json rename to e2e/src/fixtures/1.6/custom_product_carriers.json diff --git a/e2e/src/fixtures/1.6/shop_details.json b/e2e/src/fixtures/1.6/shops.json similarity index 95% rename from e2e/src/fixtures/1.6/shop_details.json rename to e2e/src/fixtures/1.6/shops.json index 9cd1e3b6..5ccb60ce 100644 --- a/e2e/src/fixtures/1.6/shop_details.json +++ b/e2e/src/fixtures/1.6/shops.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_details", + "collection": "shops", "properties": { "created_at": "2024-07-16 15:33:52", "folder_created_at": "2024-07-16 15:34:17", diff --git a/e2e/src/fixtures/1.6/stock_mvts.json b/e2e/src/fixtures/1.6/stock_movements.json similarity index 100% rename from e2e/src/fixtures/1.6/stock_mvts.json rename to e2e/src/fixtures/1.6/stock_movements.json diff --git a/e2e/src/fixtures/1.7/product_carriers.json b/e2e/src/fixtures/1.7/custom_product_carriers.json similarity index 100% rename from e2e/src/fixtures/1.7/product_carriers.json rename to e2e/src/fixtures/1.7/custom_product_carriers.json diff --git a/e2e/src/fixtures/1.7/shop_details.json b/e2e/src/fixtures/1.7/shops.json similarity index 95% rename from e2e/src/fixtures/1.7/shop_details.json rename to e2e/src/fixtures/1.7/shops.json index cd3a96b0..b29741e3 100644 --- a/e2e/src/fixtures/1.7/shop_details.json +++ b/e2e/src/fixtures/1.7/shops.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_details", + "collection": "shops", "properties": { "created_at": "2023-12-20 22:56:03", "folder_created_at": "2024-03-05 12:59:12", diff --git a/e2e/src/fixtures/1.7/stock_mvts.json b/e2e/src/fixtures/1.7/stock_movements.json similarity index 100% rename from e2e/src/fixtures/1.7/stock_mvts.json rename to e2e/src/fixtures/1.7/stock_movements.json diff --git a/e2e/src/fixtures/8/product_carriers.json b/e2e/src/fixtures/8/custom_product_carriers.json similarity index 100% rename from e2e/src/fixtures/8/product_carriers.json rename to e2e/src/fixtures/8/custom_product_carriers.json diff --git a/e2e/src/fixtures/8/shop_details.json b/e2e/src/fixtures/8/shops.json similarity index 95% rename from e2e/src/fixtures/8/shop_details.json rename to e2e/src/fixtures/8/shops.json index ad085f79..66e78af4 100644 --- a/e2e/src/fixtures/8/shop_details.json +++ b/e2e/src/fixtures/8/shops.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_details", + "collection": "shops", "properties": { "created_at": "2024-08-22T12:27:09+0200", "folder_created_at": "2024-08-27T10:07:19+0200", diff --git a/e2e/src/fixtures/8/stock_mvts.json b/e2e/src/fixtures/8/stock_movements.json similarity index 100% rename from e2e/src/fixtures/8/stock_mvts.json rename to e2e/src/fixtures/8/stock_movements.json diff --git a/e2e/src/fixtures/9/product_carriers.json b/e2e/src/fixtures/9/custom_product_carriers.json similarity index 100% rename from e2e/src/fixtures/9/product_carriers.json rename to e2e/src/fixtures/9/custom_product_carriers.json diff --git a/e2e/src/fixtures/9/shop_details.json b/e2e/src/fixtures/9/shops.json similarity index 95% rename from e2e/src/fixtures/9/shop_details.json rename to e2e/src/fixtures/9/shops.json index 57254296..49605475 100644 --- a/e2e/src/fixtures/9/shop_details.json +++ b/e2e/src/fixtures/9/shops.json @@ -1,7 +1,7 @@ [ { "id": "1", - "collection": "shop_details", + "collection": "shops", "properties": { "created_at": "2024-06-10 02:27:21", "folder_created_at": "2024-06-10 18:01:29", diff --git a/e2e/src/fixtures/9/stock_mvts.json b/e2e/src/fixtures/9/stock_movements.json similarity index 100% rename from e2e/src/fixtures/9/stock_mvts.json rename to e2e/src/fixtures/9/stock_movements.json diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 2e969c5a..465ee0ce 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -10,6 +10,7 @@ export const shopContentMapping = { categories: "categories", currencies: "currencies", customers: "customers", + custom_product_carriers: "custom-product-carriers", employees: "employees", images: "images", image_types: "image-types", @@ -22,12 +23,11 @@ export const shopContentMapping = { order_histories: "order-histories", products: "products", product_bundles: "product-bundles", - product_carriers: "product-carriers", product_suppliers: "product-suppliers", - shop_details: "shop-details", + shops: "shops", specific_prices: "specific-prices", stocks: "stocks", - stock_mvts: "stock-mvts", + stock_movements: "stock-movements", stores: "stores", suppliers: "suppliers", taxonomies: "taxonomies", diff --git a/src/Config/Config.php b/src/Config/Config.php index 983b8818..c1a341c2 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -79,10 +79,10 @@ class Config const COLLECTION_PRODUCTS = 'products'; const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; - const COLLECTION_SHOP_DETAILS = 'shop_details'; // TODO: rename to #infos + const COLLECTION_SHOPS = 'shops'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; const COLLECTION_STOCKS = 'stocks'; - const COLLECTION_STOCK_MVTS = 'stock_mvts'; // TODO: rename to #stock-movements + const COLLECTION_STOCK_MOVEMENTS = 'stock_movements'; const COLLECTION_STORES = 'stores'; const COLLECTION_SUPPLIERS = 'suppliers'; const COLLECTION_TAXONOMIES = 'taxonomies'; @@ -114,12 +114,12 @@ class Config self::COLLECTION_ORDER_HISTORIES, self::COLLECTION_PRODUCTS, self::COLLECTION_PRODUCT_BUNDLES, - self::COLLECTION_PRODUCT_CARRIERS, + self::COLLECTION_CUSTOM_PRODUCT_CARRIERS, self::COLLECTION_PRODUCT_SUPPLIERS, - self::COLLECTION_SHOP_DETAILS, + self::COLLECTION_SHOPS, self::COLLECTION_SPECIFIC_PRICES, self::COLLECTION_STOCKS, - self::COLLECTION_STOCK_MVTS, + self::COLLECTION_STOCK_MOVEMENTS, self::COLLECTION_STORES, self::COLLECTION_SUPPLIERS, self::COLLECTION_TAXONOMIES, diff --git a/src/Repository/StockMvtRepository.php b/src/Repository/StockMovementRepository.php similarity index 97% rename from src/Repository/StockMvtRepository.php rename to src/Repository/StockMovementRepository.php index cb8b8542..7b1a1ff9 100644 --- a/src/Repository/StockMvtRepository.php +++ b/src/Repository/StockMovementRepository.php @@ -24,7 +24,7 @@ exit; } -class StockMvtRepository extends AbstractRepository implements RepositoryInterface +class StockMovementRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'stock_mvt'; diff --git a/src/Service/ShopContent/ShopDetailsService.php b/src/Service/ShopContent/ShopsService.php similarity index 97% rename from src/Service/ShopContent/ShopDetailsService.php rename to src/Service/ShopContent/ShopsService.php index 5ef35f2e..26d640f3 100644 --- a/src/Service/ShopContent/ShopDetailsService.php +++ b/src/Service/ShopContent/ShopsService.php @@ -27,7 +27,7 @@ exit; } -class ShopDetailsService implements ShopContentServiceInterface +class ShopsService implements ShopContentServiceInterface { /** @var CurrenciesService */ private $currenciesService; @@ -89,7 +89,7 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) return [ [ 'id' => '1', - 'collection' => Config::COLLECTION_SHOP_DETAILS, + 'collection' => Config::COLLECTION_SHOPS, 'properties' => [ 'created_at' => $this->shopRepository->getCreatedAt(), 'folder_created_at' => $folderCreatedAt, diff --git a/src/Service/ShopContent/StockMovementsService.php b/src/Service/ShopContent/StockMovementsService.php new file mode 100644 index 00000000..1c8a00c8 --- /dev/null +++ b/src/Service/ShopContent/StockMovementsService.php @@ -0,0 +1,134 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; +use PrestaShop\Module\PsEventbus\Repository\StockMovementRepository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class StockMovementsService implements ShopContentServiceInterface +{ + /** @var StockMovementRepository */ + private $stockMovementRepository; + + public function __construct(StockMovementRepository $stockMovementRepository) + { + $this->stockMovementRepository = $stockMovementRepository; + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * @param bool $explainSql + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso, $explainSql) + { + $result = $this->stockMovementRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + + if (empty($result)) { + return []; + } + + $this->castStockMovements($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_stock_mvt'], + 'collection' => Config::COLLECTION_STOCK_MOVEMENTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * @param bool $explainSql + * + * @return array + */ + public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + { + $result = $this->stockMovementRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + + if (empty($result)) { + return []; + } + + $this->castStockMovements($result); + + return array_map(function ($item) { + return [ + 'id' => $item['id_stock_mvt'], + 'collection' => Config::COLLECTION_STOCK_MOVEMENTS, + 'properties' => $item, + ]; + }, $result); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return $this->stockMovementRepository->countFullSyncContentLeft($offset, $limit, $langIso); + } + + /** + * @param array $stockMovements + * + * @return void + */ + private function castStockMovements(&$stockMovements) + { + foreach ($stockMovements as &$stockMovement) { + $date = $stockMovement['date_add']; + + $stockMovement['id_stock_mvt'] = (int) $stockMovement['id_stock_mvt']; + $stockMovement['id_stock'] = (int) $stockMovement['id_stock']; + $stockMovement['id_order'] = (int) $stockMovement['id_order']; + $stockMovement['id_supply_order'] = (int) $stockMovement['id_supply_order']; + $stockMovement['id_stock_mvt_reason'] = (int) $stockMovement['id_stock_mvt_reason']; + $stockMovement['id_lang'] = (int) $stockMovement['id_lang']; + $stockMovement['id_employee'] = (int) $stockMovement['id_employee']; + $stockMovement['physical_quantity'] = (int) $stockMovement['physical_quantity']; + $stockMovement['date_add'] = $date; + $stockMovement['sign'] = (int) $stockMovement['sign']; + $stockMovement['price_te'] = (float) $stockMovement['price_te']; + $stockMovement['last_wa'] = (float) $stockMovement['last_wa']; + $stockMovement['current_wa'] = (float) $stockMovement['current_wa']; + $stockMovement['referer'] = (int) $stockMovement['referer']; + $stockMovement['deleted'] = (bool) $stockMovement['deleted']; + $stockMovement['created_at'] = $date; + } + } +} diff --git a/src/Service/ShopContent/StockMvtsService.php b/src/Service/ShopContent/StockMvtsService.php deleted file mode 100644 index 1fb026cf..00000000 --- a/src/Service/ShopContent/StockMvtsService.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsEventbus\Service\ShopContent; - -use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\StockMvtRepository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StockMvtsService implements ShopContentServiceInterface -{ - /** @var StockMvtRepository */ - private $stockMvtRepository; - - public function __construct(StockMvtRepository $stockMvtRepository) - { - $this->stockMvtRepository = $stockMvtRepository; - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * @param bool $explainSql - * - * @return array - */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) - { - $result = $this->stockMvtRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); - - if (empty($result)) { - return []; - } - - $this->castStockMvts($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_stock_mvt'], - 'collection' => Config::COLLECTION_STOCK_MVTS, - 'properties' => $item, - ]; - }, $result); - } - - /** - * @param int $limit - * @param array $contentIds - * @param string $langIso - * @param bool $explainSql - * - * @return array - */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) - { - $result = $this->stockMvtRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); - - if (empty($result)) { - return []; - } - - $this->castStockMvts($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_stock_mvt'], - 'collection' => Config::COLLECTION_STOCK_MVTS, - 'properties' => $item, - ]; - }, $result); - } - - /** - * @param int $offset - * @param int $limit - * @param string $langIso - * - * @return int - */ - public function getFullSyncContentLeft($offset, $limit, $langIso) - { - return $this->stockMvtRepository->countFullSyncContentLeft($offset, $limit, $langIso); - } - - /** - * @param array $stockMvts - * - * @return void - */ - private function castStockMvts(&$stockMvts) - { - foreach ($stockMvts as &$stockMvt) { - $date = $stockMvt['date_add']; - - $stockMvt['id_stock_mvt'] = (int) $stockMvt['id_stock_mvt']; - $stockMvt['id_stock'] = (int) $stockMvt['id_stock']; - $stockMvt['id_order'] = (int) $stockMvt['id_order']; - $stockMvt['id_supply_order'] = (int) $stockMvt['id_supply_order']; - $stockMvt['id_stock_mvt_reason'] = (int) $stockMvt['id_stock_mvt_reason']; - $stockMvt['id_lang'] = (int) $stockMvt['id_lang']; - $stockMvt['id_employee'] = (int) $stockMvt['id_employee']; - $stockMvt['physical_quantity'] = (int) $stockMvt['physical_quantity']; - $stockMvt['date_add'] = $date; - $stockMvt['sign'] = (int) $stockMvt['sign']; - $stockMvt['price_te'] = (float) $stockMvt['price_te']; - $stockMvt['last_wa'] = (float) $stockMvt['last_wa']; - $stockMvt['current_wa'] = (float) $stockMvt['current_wa']; - $stockMvt['referer'] = (int) $stockMvt['referer']; - $stockMvt['deleted'] = (bool) $stockMvt['deleted']; - $stockMvt['created_at'] = $date; - } - } -} diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index a0aadada..1e10c7fc 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\PsEventbus\Traits; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository; +use PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository; use PrestaShop\Module\PsEventbus\Repository\StockRepository; use PrestaShop\Module\PsEventbus\Service\SynchronizationService; @@ -472,9 +472,9 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); /** @var CustomProductCarrierRepository $customProductCarrierRepository */ - $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); - $productCarriers = $customProductCarrierRepository->getCustomProductCarrierIdsByCarrierId($product->id); - $productCarrierIds = array_column($productCarriers, 'id_carrier_reference'); + $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository'); + $customProductCarriers = $customProductCarrierRepository->getCustomProductCarrierIdsByCarrierId($product->id); + $customProductCarrierIds = array_column($customProductCarriers, 'id_carrier_reference'); /** @var StockRepository $stockRepository */ $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); @@ -492,7 +492,7 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $productCarrierIds, + Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $customProductCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], Config::INCREMENTAL_TYPE_ADD, @@ -520,9 +520,9 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); /** @var CustomProductCarrierRepository $customProductCarrierRepository */ - $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\ProductCarrierRepository'); - $productCarriers = $customProductCarrierRepository->getCustomProductCarrierIdsByCarrierId($product->id); - $productCarrierIds = array_column($productCarriers, 'id_carrier_reference'); + $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository'); + $customProductCarriers = $customProductCarrierRepository->getCustomProductCarrierIdsByCarrierId($product->id); + $customProductCarrierIds = array_column($customProductCarriers, 'id_carrier_reference'); /** @var StockRepository $stockRepository */ $stockRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\StockRepository'); @@ -540,7 +540,7 @@ public function hookActionObjectProductUpdateAfter($parameters) $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_PRODUCTS => $product->id, - Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $productCarrierIds, + Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $customProductCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], Config::INCREMENTAL_TYPE_UPDATE, From 5b9e8c39eeccf66f540d05597e9ff0dca08431f8 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 7 Oct 2024 15:37:22 +0200 Subject: [PATCH 114/162] fix: error handler --- src/Handler/ErrorHandler/ErrorHandler.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index d8ddc416..0d929132 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -81,8 +81,16 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc * * @@throws Exception */ - public function handle($exception, $verbose, $psLogsEnabled) + public function handle($exception, $verbose = null, $psLogsEnabled = null) { + if ($verbose === null) { + $verbose = false; + } + + if ($psLogsEnabled === null) { + $psLogsEnabled = false; + } + if (!$this->client) { return; } @@ -98,7 +106,7 @@ public function handle($exception, $verbose, $psLogsEnabled) ); } - // if debug mode enabled, print error + // if debug mode enabled and verbose set to true, print error in front office if (_PS_MODE_DEV_ == true && $verbose == true) { throw $exception; } else { From c76d3b4529811622919957f4f54db0af7e3c3baa Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 7 Oct 2024 16:05:35 +0200 Subject: [PATCH 115/162] chore: update some var to global constant --- controllers/front/apiFront.php | 12 +++++---- src/Handler/ErrorHandler/ErrorHandler.php | 16 +++-------- src/Repository/AbstractRepository.php | 8 +++--- src/Repository/CarrierRepository.php | 10 +++---- src/Repository/CartProductRepository.php | 10 +++---- src/Repository/CartRepository.php | 10 +++---- src/Repository/CartRuleRepository.php | 10 +++---- src/Repository/CategoryRepository.php | 10 +++---- src/Repository/CurrencyRepository.php | 10 +++---- .../CustomProductCarrierRepository.php | 10 +++---- src/Repository/CustomerRepository.php | 10 +++---- src/Repository/EmployeeRepository.php | 10 +++---- src/Repository/ImageRepository.php | 10 +++---- src/Repository/ImageTypeRepository.php | 10 +++---- src/Repository/LanguageRepository.php | 10 +++---- src/Repository/ManufacturerRepository.php | 10 +++---- src/Repository/ModuleRepository.php | 10 +++---- src/Repository/OrderCartRuleRepository.php | 10 +++---- src/Repository/OrderDetailRepository.php | 10 +++---- src/Repository/OrderHistoryRepository.php | 13 ++++----- src/Repository/OrderRepository.php | 10 +++---- src/Repository/ProductBundleRepository.php | 10 +++---- src/Repository/ProductRepository.php | 10 +++---- src/Repository/ProductSupplierRepository.php | 10 +++---- src/Repository/RepositoryInterface.php | 6 ++--- src/Repository/SpecificPriceRepository.php | 10 +++---- src/Repository/StockMovementRepository.php | 10 +++---- src/Repository/StockRepository.php | 10 +++---- src/Repository/StoreRepository.php | 10 +++---- src/Repository/SupplierRepository.php | 10 +++---- src/Repository/TaxonomyRepository.php | 10 +++---- src/Repository/TranslationRepository.php | 10 +++---- src/Repository/WishlistProductRepository.php | 10 +++---- src/Repository/WishlistRepository.php | 10 +++---- src/Service/FrontApiService.php | 27 ++++++++----------- src/Service/ProxyService.php | 2 +- .../ShopContent/CarrierDetailsService.php | 10 +++---- .../ShopContent/CarrierTaxesService.php | 10 +++---- src/Service/ShopContent/CarriersService.php | 10 +++---- .../ShopContent/CartProductsService.php | 10 +++---- src/Service/ShopContent/CartRulesService.php | 10 +++---- src/Service/ShopContent/CartsService.php | 10 +++---- src/Service/ShopContent/CategoriesService.php | 10 +++---- src/Service/ShopContent/CurrenciesService.php | 10 +++---- .../CustomProductCarriersService.php | 10 +++---- src/Service/ShopContent/CustomersService.php | 10 +++---- src/Service/ShopContent/EmployeesService.php | 10 +++---- src/Service/ShopContent/ImageTypesService.php | 10 +++---- src/Service/ShopContent/ImagesService.php | 10 +++---- src/Service/ShopContent/LanguagesService.php | 10 +++---- .../ShopContent/ManufacturersService.php | 10 +++---- src/Service/ShopContent/ModulesService.php | 10 +++---- .../ShopContent/OrderCartRulesService.php | 10 +++---- .../ShopContent/OrderDetailsService.php | 6 ++--- .../ShopContent/OrderHistoriesService.php | 10 +++---- src/Service/ShopContent/OrdersService.php | 11 +++----- .../ShopContent/ProductBundlesService.php | 10 +++---- .../ShopContent/ProductSuppliersService.php | 10 +++---- src/Service/ShopContent/ProductsService.php | 10 +++---- .../ShopContentServiceInterface.php | 6 ++--- src/Service/ShopContent/ShopsService.php | 6 ++--- .../ShopContent/SpecificPricesService.php | 10 +++---- .../ShopContent/StockMovementsService.php | 10 +++---- src/Service/ShopContent/StocksService.php | 10 +++---- src/Service/ShopContent/StoresService.php | 10 +++---- src/Service/ShopContent/SuppliersService.php | 10 +++---- src/Service/ShopContent/TaxonomiesService.php | 10 +++---- src/Service/ShopContent/ThemesService.php | 6 ++--- .../ShopContent/TranslationsService.php | 10 +++---- .../ShopContent/WishlistProductsService.php | 10 +++---- src/Service/ShopContent/WishlistsService.php | 10 +++---- src/Service/SynchronizationService.php | 8 ++---- 72 files changed, 283 insertions(+), 434 deletions(-) diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 4f476767..fde1121c 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -50,7 +50,7 @@ public function postProcess() /** @var bool $explainSql */ $explainSql = Tools::getValue('explain_sql', 0) == 1; - + /** @var bool $verbose */ $verbose = Tools::getValue('verbose', 0) == 1; @@ -63,6 +63,11 @@ public function postProcess() /** @var FrontApiService $frontApiService */ $frontApiService = $module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); + // Define our 3 constants here to be retrieved later in the application (errorHandler, repositories) + define('PS_EVENTBUS_EXPLAIN_SQL_ENABLED', $explainSql); + define('PS_EVENTBUS_VERBOSE_ENABLED', $verbose); + define('PS_EVENTBUS_LOGS_ENABLED', $psLogsEnabled); + // edit shopContent for matching Config.php const $shopContentEdited = str_replace('-', '_', $shopContent); @@ -71,10 +76,7 @@ public function postProcess() $jobId, $langIso, $limit, - $fullSyncRequested, - $explainSql, - $verbose, - $psLogsEnabled + $fullSyncRequested ); } } diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 0d929132..77de6880 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -74,28 +74,18 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc /** * @param mixed $exception - * @param bool $verbose - * @param bool $psLogsEnabled * * @return void * * @@throws Exception */ - public function handle($exception, $verbose = null, $psLogsEnabled = null) + public function handle($exception) { - if ($verbose === null) { - $verbose = false; - } - - if ($psLogsEnabled === null) { - $psLogsEnabled = false; - } - if (!$this->client) { return; } - if ($psLogsEnabled) { + if (PS_EVENTBUS_LOGS_ENABLED) { \PrestaShopLogger::addLog( $exception->getMessage() . ' : ' . $exception->getFile() . ':' . $exception->getLine() . ' | ' . $exception->getTraceAsString(), 3, @@ -107,7 +97,7 @@ public function handle($exception, $verbose = null, $psLogsEnabled = null) } // if debug mode enabled and verbose set to true, print error in front office - if (_PS_MODE_DEV_ == true && $verbose == true) { + if (_PS_MODE_DEV_ == true && PS_EVENTBUS_VERBOSE_ENABLED == true) { throw $exception; } else { $this->client->captureException($exception); diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 9844a109..fd1777cb 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -105,16 +105,16 @@ public function getShopContext() } /** - * @param bool $explainSql - * + + * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - protected function runQuery($explainSql) + protected function runQuery() { - if ($explainSql != null && $explainSql === true) { + if (PS_EVENTBUS_EXPLAIN_SQL_ENABLED === true) { $this->debugQuery(); } diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php index c9c575af..a36b3590 100644 --- a/src/Repository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -62,34 +62,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -97,7 +95,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->where('c.id_carrier IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/CartProductRepository.php b/src/Repository/CartProductRepository.php index 42f4a9c6..efccd14a 100644 --- a/src/Repository/CartProductRepository.php +++ b/src/Repository/CartProductRepository.php @@ -57,34 +57,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -93,7 +91,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/CartRepository.php b/src/Repository/CartRepository.php index b047d1a3..43ccffc6 100644 --- a/src/Repository/CartRepository.php +++ b/src/Repository/CartRepository.php @@ -55,34 +55,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -91,7 +89,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php index f51276f1..2c4c4d71 100644 --- a/src/Repository/CartRuleRepository.php +++ b/src/Repository/CartRuleRepository.php @@ -86,34 +86,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -122,7 +120,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php index c49a8940..357a071f 100644 --- a/src/Repository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -71,34 +71,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -107,7 +105,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php index 38baf8b1..07d95eb5 100644 --- a/src/Repository/CurrencyRepository.php +++ b/src/Repository/CurrencyRepository.php @@ -70,34 +70,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -106,7 +104,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/CustomProductCarrierRepository.php b/src/Repository/CustomProductCarrierRepository.php index 9ea3f781..495cac7c 100644 --- a/src/Repository/CustomProductCarrierRepository.php +++ b/src/Repository/CustomProductCarrierRepository.php @@ -51,34 +51,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -87,7 +85,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index 14dce301..fe76813f 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -63,34 +63,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -99,7 +97,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php index 294734c2..4521caf4 100644 --- a/src/Repository/EmployeeRepository.php +++ b/src/Repository/EmployeeRepository.php @@ -77,34 +77,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -113,7 +111,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/ImageRepository.php b/src/Repository/ImageRepository.php index fbb09bc2..6a38a905 100644 --- a/src/Repository/ImageRepository.php +++ b/src/Repository/ImageRepository.php @@ -61,34 +61,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -97,7 +95,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php index 8e181b34..e98e5016 100644 --- a/src/Repository/ImageTypeRepository.php +++ b/src/Repository/ImageTypeRepository.php @@ -59,34 +59,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -95,7 +93,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/LanguageRepository.php b/src/Repository/LanguageRepository.php index c5856d22..c62cff66 100644 --- a/src/Repository/LanguageRepository.php +++ b/src/Repository/LanguageRepository.php @@ -66,34 +66,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -102,7 +100,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index f437a934..58ff4dc6 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -66,34 +66,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -102,7 +100,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php index aead3ebd..db9793aa 100644 --- a/src/Repository/ModuleRepository.php +++ b/src/Repository/ModuleRepository.php @@ -72,34 +72,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -108,7 +106,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php index d94a39a2..e71e7259 100644 --- a/src/Repository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -61,34 +61,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -96,7 +94,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->where('ocr.id_order_cart_rule IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/OrderDetailRepository.php b/src/Repository/OrderDetailRepository.php index 8b11aaa7..3e0eacae 100644 --- a/src/Repository/OrderDetailRepository.php +++ b/src/Repository/OrderDetailRepository.php @@ -82,14 +82,13 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); @@ -97,21 +96,20 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -120,7 +118,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php index 50b85783..82d4e7e8 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -68,34 +68,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -104,7 +102,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** @@ -131,7 +129,6 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $orderIds * @param string $langIso - * @param bool $explainSql * * @return array * @@ -147,6 +144,6 @@ public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $explainSql) $this->query->where('oh.id_order IN (' . implode(',', array_map('intval', $orderIds)) . ')'); - return $this->runQuery($explainSql); + return $this->runQuery(); } } diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php index 0bb3e0c4..effc8aba 100644 --- a/src/Repository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -112,14 +112,13 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); @@ -127,21 +126,20 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -150,7 +148,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/ProductBundleRepository.php b/src/Repository/ProductBundleRepository.php index bbd81baa..6bf2d567 100644 --- a/src/Repository/ProductBundleRepository.php +++ b/src/Repository/ProductBundleRepository.php @@ -65,34 +65,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -101,7 +99,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index 657a4b46..f382ab40 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -133,34 +133,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -169,7 +167,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php index 810efb21..4d1b4cc9 100644 --- a/src/Repository/ProductSupplierRepository.php +++ b/src/Repository/ProductSupplierRepository.php @@ -57,34 +57,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -93,7 +91,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/RepositoryInterface.php b/src/Repository/RepositoryInterface.php index db3646c2..fd1e5a43 100644 --- a/src/Repository/RepositoryInterface.php +++ b/src/Repository/RepositoryInterface.php @@ -41,21 +41,19 @@ public function generateFullQuery($langIso, $withSelecParameters); * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + public function retrieveContentsForFull($offset, $limit, $langIso); /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + public function retrieveContentsForIncremental($limit, $contentIds, $langIso); /** * @param int $offset diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index ebf52eed..9c67121d 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -75,34 +75,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -111,7 +109,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/StockMovementRepository.php b/src/Repository/StockMovementRepository.php index 7b1a1ff9..b730b7fa 100644 --- a/src/Repository/StockMovementRepository.php +++ b/src/Repository/StockMovementRepository.php @@ -72,34 +72,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -108,7 +106,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index 4013d94d..4228cdab 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -73,34 +73,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -109,7 +107,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index fc10095e..ef6b8956 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -88,34 +88,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -124,7 +122,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index fed730f9..14cfe432 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -68,34 +68,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -104,7 +102,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/TaxonomyRepository.php b/src/Repository/TaxonomyRepository.php index cdddb096..d5511976 100644 --- a/src/Repository/TaxonomyRepository.php +++ b/src/Repository/TaxonomyRepository.php @@ -54,14 +54,13 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { // need this module for this table : https://addons.prestashop.com/en/products-on-facebook-social-networks/50291-prestashop-social-with-facebook-instagram.html if (empty($this->checkIfPsFacebookIsInstalled())) { @@ -72,21 +71,20 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -95,7 +93,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 44681a19..0727bded 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -56,34 +56,32 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -92,7 +90,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php index a66dab5c..135a56e6 100644 --- a/src/Repository/WishlistProductRepository.php +++ b/src/Repository/WishlistProductRepository.php @@ -56,14 +56,13 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html if (empty($this->checkIfPsWishlistIsInstalled())) { @@ -74,21 +73,20 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -97,7 +95,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php index e7569254..78216b44 100644 --- a/src/Repository/WishlistRepository.php +++ b/src/Repository/WishlistRepository.php @@ -62,14 +62,13 @@ public function generateFullQuery($langIso, $withSelecParameters) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) + public function retrieveContentsForFull($offset, $limit, $langIso) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html if (empty($this->checkIfPsWishlistIsInstalled())) { @@ -80,21 +79,20 @@ public function retrieveContentsForFull($offset, $limit, $langIso, $explainSql) $this->query->limit((int) $limit, (int) $offset); - return $this->runQuery($explainSql); + return $this->runQuery(); } /** * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { $this->generateFullQuery($langIso, true); @@ -103,7 +101,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso, $e ->limit($limit) ; - return $this->runQuery($explainSql); + return $this->runQuery(); } /** diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 9ea2061e..80052077 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -81,13 +81,10 @@ public function __construct( * @param string $langIso * @param int $limit * @param bool $fullSyncRequested - * @param bool $explainSql - * @param bool $verbose - * @param bool $psLogEnabled * * @return void */ - public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested, $explainSql, $verbose, $psLogEnabled) + public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested) { try { if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { @@ -159,8 +156,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $offset, $limit, $this->startTime, - $dateNow, - $explainSql + $dateNow ); } else { $response = $this->synchronizationService->sendIncrementalSync( @@ -168,8 +164,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $jobId, $langIso, $limit, - $this->startTime, - $explainSql + $this->startTime ); } @@ -184,15 +179,15 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync ) ); } catch (\PrestaShopDatabaseException $exception) { - $this->errorHandler->handle($exception, $verbose, $psLogEnabled); + $this->errorHandler->handle($exception); } catch (EnvVarException $exception) { - $this->errorHandler->handle($exception, $verbose, $psLogEnabled); + $this->errorHandler->handle($exception); } catch (FirebaseException $exception) { - $this->errorHandler->handle($exception, $verbose, $psLogEnabled); + $this->errorHandler->handle($exception); } catch (ServiceNotFoundException $exception) { - $this->errorHandler->handle($exception, $verbose, $psLogEnabled); + $this->errorHandler->handle($exception); } catch (\Exception $exception) { - $this->errorHandler->handle($exception, $verbose, $psLogEnabled); + $this->errorHandler->handle($exception); } } @@ -233,11 +228,11 @@ private function authorize($jobId, $isHealthCheck) } if ($exception instanceof \PrestaShopDatabaseException) { - $this->errorHandler->handle($exception, false, false); + $this->errorHandler->handle($exception); } elseif ($exception instanceof EnvVarException) { - $this->errorHandler->handle($exception, false, false); + $this->errorHandler->handle($exception); } elseif ($exception instanceof FirebaseException) { - $this->errorHandler->handle($exception, false, false); + $this->errorHandler->handle($exception); } return false; diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index fe7610f8..e6044e12 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -74,7 +74,7 @@ public function upload($jobId, $data, $scriptStartTime, $isFull) return ['error' => $exception->getMessage()]; } catch (ConnectException $exception) { - $this->errorHandler->handle(new \Exception($exception)); + $this->errorHandler->handle($exception); return ['error' => $exception->getMessage()]; } diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index da75e41a..4f88ff36 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -43,13 +43,12 @@ public function __construct(CarrierRepository $carrierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -76,13 +75,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 0416064f..840ee52e 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -42,13 +42,12 @@ public function __construct(CarrierRepository $carrierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -75,13 +74,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 6d3c11dc..bc37ef36 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -41,13 +41,12 @@ public function __construct(CarrierRepository $carrierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index 07c2d5b4..55785276 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -41,13 +41,12 @@ public function __construct(CartProductRepository $cartProductRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->cartProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->cartProductRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->cartProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->cartProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index 9c50a221..3f0d9355 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -41,13 +41,12 @@ public function __construct(CartRuleRepository $cartRuleRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->cartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->cartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->cartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->cartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 6473c044..13c9eda1 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -41,13 +41,12 @@ public function __construct(CartRepository $cartRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->cartRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->cartRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->cartRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->cartRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index 82990299..6d526bbb 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -41,13 +41,12 @@ public function __construct(CategoryRepository $categoryRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->categoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->categoryRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->categoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->categoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index 9a150b95..34ecf360 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -41,13 +41,12 @@ public function __construct(CurrencyRepository $currencyRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->currencyRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->currencyRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->currencyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->currencyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CustomProductCarriersService.php b/src/Service/ShopContent/CustomProductCarriersService.php index 3e32f314..25103552 100644 --- a/src/Service/ShopContent/CustomProductCarriersService.php +++ b/src/Service/ShopContent/CustomProductCarriersService.php @@ -41,13 +41,12 @@ public function __construct(CustomProductCarrierRepository $customProductCarrier * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->customProductCarrierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->customProductCarrierRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -66,13 +65,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->customProductCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->customProductCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index dc39dad8..7314ebd8 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -41,13 +41,12 @@ public function __construct(CustomerRepository $customerRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->customerRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->customerRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->customerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->customerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index 500f3c86..9c132fd2 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -41,13 +41,12 @@ public function __construct(EmployeeRepository $employeeRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->employeeRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->employeeRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->employeeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->employeeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index 9f9e4949..48bf9247 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -41,13 +41,12 @@ public function __construct(ImageTypeRepository $imageTypeRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->imageTypeRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->imageTypeRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->imageTypeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->imageTypeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index 68c1032c..4f2a9c5a 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -41,13 +41,12 @@ public function __construct(ImageRepository $imageRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->imageRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->imageRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->imageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->imageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index 85e1366e..35e7bfd7 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -41,13 +41,12 @@ public function __construct(LanguageRepository $languageRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->languageRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->languageRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->languageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->languageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ManufacturersService.php b/src/Service/ShopContent/ManufacturersService.php index c759aacb..05437ee8 100644 --- a/src/Service/ShopContent/ManufacturersService.php +++ b/src/Service/ShopContent/ManufacturersService.php @@ -41,13 +41,12 @@ public function __construct(ManufacturerRepository $manufacturerRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->manufacturerRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->manufacturerRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->manufacturerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->manufacturerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 1284b264..1be837c1 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -48,13 +48,12 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->moduleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->moduleRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -75,13 +74,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->moduleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->moduleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index 47df016a..e864ff92 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -41,13 +41,12 @@ public function __construct(OrderCartRuleRepository $orderCartRuleRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->orderCartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->orderCartRuleRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->orderCartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->orderCartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index faf75f41..7983bb9a 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -41,13 +41,12 @@ public function __construct(OrderDetailRepository $orderDetailRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->orderDetailRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->orderDetailRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,7 +67,6 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $orderDetailIds * @param string $langIso - * @param bool $explainSql * * @return array */ diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index 2c18a897..5f4c6d83 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -41,13 +41,12 @@ public function __construct(OrderHistoryRepository $orderHistoryRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->orderHistoryRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->orderHistoryRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->orderHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->orderHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index bbde6d47..21ca9c34 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -54,13 +54,12 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->orderRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->orderRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -81,13 +80,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->orderRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->orderRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; @@ -175,7 +173,6 @@ private function castOrders(&$orders, $langIso) * @param array $orders * @param array $order * @param string $langIso - * @param bool $explainSql * * @return bool * diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index 29432186..0ba691ec 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -41,13 +41,12 @@ public function __construct(ProductBundleRepository $productBundleRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->productBundleRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->productBundleRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->productBundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->productBundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index 30439d5f..dacf7fb8 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -41,13 +41,12 @@ public function __construct(ProductSupplierRepository $productSupplierRepository * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->productSupplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->productSupplierRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->productSupplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->productSupplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index d6049de4..304db7f4 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -78,13 +78,12 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->productRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->productRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -106,13 +105,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->productRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->productRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index fe20f096..434de553 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -30,21 +30,19 @@ interface ShopContentServiceInterface * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql); + public function getContentsForFull($offset, $limit, $langIso); /** * @param int $limit * @param mixed $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + public function getContentsForIncremental($limit, $contentIds, $langIso); /** * @param int $offset diff --git a/src/Service/ShopContent/ShopsService.php b/src/Service/ShopContent/ShopsService.php index 26d640f3..043755f2 100644 --- a/src/Service/ShopContent/ShopsService.php +++ b/src/Service/ShopContent/ShopsService.php @@ -65,11 +65,10 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { $langId = !empty($langIso) ? (int) \Language::getIdByIso($langIso) : null; @@ -122,11 +121,10 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { return []; } diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index ced4d289..9a8d869a 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -48,13 +48,12 @@ public function __construct( * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->specificPriceRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->specificPriceRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -75,13 +74,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->specificPriceRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->specificPriceRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/StockMovementsService.php b/src/Service/ShopContent/StockMovementsService.php index 1c8a00c8..09390d52 100644 --- a/src/Service/ShopContent/StockMovementsService.php +++ b/src/Service/ShopContent/StockMovementsService.php @@ -41,13 +41,12 @@ public function __construct(StockMovementRepository $stockMovementRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->stockMovementRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->stockMovementRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->stockMovementRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->stockMovementRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/StocksService.php b/src/Service/ShopContent/StocksService.php index e07c546e..c3c8333c 100644 --- a/src/Service/ShopContent/StocksService.php +++ b/src/Service/ShopContent/StocksService.php @@ -41,13 +41,12 @@ public function __construct(StockRepository $stockRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->stockRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->stockRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->stockRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->stockRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/StoresService.php b/src/Service/ShopContent/StoresService.php index ff40afca..d0f04a56 100644 --- a/src/Service/ShopContent/StoresService.php +++ b/src/Service/ShopContent/StoresService.php @@ -41,13 +41,12 @@ public function __construct(StoreRepository $storeRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->storeRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->storeRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->storeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->storeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/SuppliersService.php b/src/Service/ShopContent/SuppliersService.php index da942bcd..2903b42b 100644 --- a/src/Service/ShopContent/SuppliersService.php +++ b/src/Service/ShopContent/SuppliersService.php @@ -41,13 +41,12 @@ public function __construct(SupplierRepository $supplierRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->supplierRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->supplierRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->supplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->supplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/TaxonomiesService.php b/src/Service/ShopContent/TaxonomiesService.php index f439b4b5..e13d2208 100644 --- a/src/Service/ShopContent/TaxonomiesService.php +++ b/src/Service/ShopContent/TaxonomiesService.php @@ -41,13 +41,12 @@ public function __construct(TaxonomyRepository $taxonomyRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->taxonomyRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->taxonomyRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->taxonomyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->taxonomyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php index 3e51c76e..b0798978 100644 --- a/src/Service/ShopContent/ThemesService.php +++ b/src/Service/ShopContent/ThemesService.php @@ -41,11 +41,10 @@ public function __construct(\Context $context) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { $result = $this->getAllThemes(); @@ -68,11 +67,10 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { $result = $this->getAllThemes(); diff --git a/src/Service/ShopContent/TranslationsService.php b/src/Service/ShopContent/TranslationsService.php index aac957c3..c07274d1 100644 --- a/src/Service/ShopContent/TranslationsService.php +++ b/src/Service/ShopContent/TranslationsService.php @@ -41,13 +41,12 @@ public function __construct(TranslationRepository $translationRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->translationRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->translationRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->translationRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->translationRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index 860ef578..ccfc3232 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -41,13 +41,12 @@ public function __construct(WishlistProductRepository $wishlistProductRepository * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->wishlistProductRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->wishlistProductRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->wishlistProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->wishlistProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index bfa1df98..1dbae3ce 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -41,13 +41,12 @@ public function __construct(WishlistRepository $wishlistRepository) * @param int $offset * @param int $limit * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForFull($offset, $limit, $langIso, $explainSql) + public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->wishlistRepository->retrieveContentsForFull($offset, $limit, $langIso, $explainSql); + $result = $this->wishlistRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; @@ -68,13 +67,12 @@ public function getContentsForFull($offset, $limit, $langIso, $explainSql) * @param int $limit * @param array $contentIds * @param string $langIso - * @param bool $explainSql * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index e51bb72e..d61f0fd9 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -97,7 +97,6 @@ public function __construct( * @param int $limit * @param int $startTime * @param string $dateNow - * @param bool $explainSql * * @return array * @@ -111,7 +110,6 @@ public function sendFullSync( int $limit, int $startTime, string $dateNow, - bool $explainSql ) { $response = []; @@ -128,7 +126,7 @@ public function sendFullSync( /** @var ShopContentServiceInterface $shopContentApiService */ $shopContentApiService = $module->getService($serviceId); - $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso, $explainSql); + $data = $shopContentApiService->getContentsForFull($offset, $limit, $langIso); CommonService::convertDateFormat($data); @@ -158,7 +156,6 @@ public function sendFullSync( * @param string $langIso * @param int $limit * @param int $startTime - * @param bool $explainSql * * @return array * @@ -170,7 +167,6 @@ public function sendIncrementalSync( string $langIso, int $limit, int $startTime, - bool $explainSql ) { $response = []; @@ -197,7 +193,7 @@ public function sendIncrementalSync( ]; } - $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso, $explainSql); + $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso); CommonService::convertDateFormat($data); From a71e60ce04e9394b5342721bd7ead060122c25c7 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 7 Oct 2024 16:31:58 +0200 Subject: [PATCH 116/162] fix: phpstan --- src/Handler/ErrorHandler/ErrorHandler.php | 4 ++-- src/Repository/AbstractRepository.php | 10 +++++++--- src/Repository/OrderHistoryRepository.php | 2 +- src/Service/ShopContent/CarrierTaxesService.php | 2 +- src/Service/ShopContent/OrderDetailsService.php | 4 ++-- src/Service/ShopContent/OrdersService.php | 6 +++--- tests/phpstan/phpstan.neon | 3 +++ 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 77de6880..f671f8e5 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -85,7 +85,7 @@ public function handle($exception) return; } - if (PS_EVENTBUS_LOGS_ENABLED) { + if (defined(PS_EVENTBUS_LOGS_ENABLED) && PS_EVENTBUS_LOGS_ENABLED == true) { \PrestaShopLogger::addLog( $exception->getMessage() . ' : ' . $exception->getFile() . ':' . $exception->getLine() . ' | ' . $exception->getTraceAsString(), 3, @@ -97,7 +97,7 @@ public function handle($exception) } // if debug mode enabled and verbose set to true, print error in front office - if (_PS_MODE_DEV_ == true && PS_EVENTBUS_VERBOSE_ENABLED == true) { + if (_PS_MODE_DEV_ == true && (defined(PS_EVENTBUS_VERBOSE_ENABLED) && PS_EVENTBUS_VERBOSE_ENABLED == true)) { throw $exception; } else { $this->client->captureException($exception); diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index fd1777cb..a9bbe88e 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -105,16 +105,20 @@ public function getShopContext() } /** - + * @param bool $enableCurrentExplain * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - protected function runQuery() + protected function runQuery($enableCurrentExplain = null) { - if (PS_EVENTBUS_EXPLAIN_SQL_ENABLED === true) { + if ($enableCurrentExplain === null) { + $enableCurrentExplain = true; + } + + if ((defined(PS_EVENTBUS_EXPLAIN_SQL_ENABLED) && PS_EVENTBUS_EXPLAIN_SQL_ENABLED == true) && $enableCurrentExplain) { $this->debugQuery(); } diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php index 82d4e7e8..1e52df5a 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -134,7 +134,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) * * @throws \PrestaShopDatabaseException */ - public function getOrderHistoryIdsByOrderIds($orderIds, $langIso, $explainSql) + public function getOrderHistoryIdsByOrderIds($orderIds, $langIso) { if (!$orderIds) { return []; diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 840ee52e..a449139f 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -111,7 +111,7 @@ public function getContentsForIncremental($limit, $contentIds, $langIso) */ public function getFullSyncContentLeft($offset, $limit, $langIso) { - $data = $this->getContentsForFull($offset, 50, $langIso, false); + $data = $this->getContentsForFull($offset, 50, $langIso); return count($data); } diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index 7983bb9a..57622cc2 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -70,9 +70,9 @@ public function getContentsForFull($offset, $limit, $langIso) * * @return array */ - public function getContentsForIncremental($limit, $orderDetailIds, $langIso, $explainSql) + public function getContentsForIncremental($limit, $orderDetailIds, $langIso) { - $result = $this->orderDetailRepository->retrieveContentsForIncremental($limit, $orderDetailIds, $langIso, $explainSql); + $result = $this->orderDetailRepository->retrieveContentsForIncremental($limit, $orderDetailIds, $langIso); if (empty($result)) { return []; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 21ca9c34..a4f94bb6 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -132,7 +132,7 @@ private function castOrders(&$orders, $langIso) $order['refund'] = (float) $order['refund']; $order['refund_tax_excl'] = (float) $order['refund_tax_excl']; $order['new_customer'] = $order['new_customer'] == 1; - $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langIso, false); + $order['is_paid'] = $this->castIsPaidValue($orders, $order, $langIso); $order['shipping_cost'] = (float) $order['shipping_cost']; $order['total_paid_tax'] = $order['total_paid_tax_incl'] - $order['total_paid_tax_excl']; $order['id_carrier'] = (int) $order['id_carrier']; @@ -178,12 +178,12 @@ private function castOrders(&$orders, $langIso) * * @@throws \PrestaShopDatabaseException */ - private function castIsPaidValue($orders, $order, $langIso, $explainSql) + private function castIsPaidValue($orders, $order, $langIso) { $isPaid = $dateAdd = 0; $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); /** @var array $orderHistoryStatuss */ - $orderHistoryStatuss = $this->orderHistoryRepository->getOrderHistoryIdsByOrderIds($orderIds, $langIso, $explainSql); + $orderHistoryStatuss = $this->orderHistoryRepository->getOrderHistoryIdsByOrderIds($orderIds, $langIso); foreach ($orderHistoryStatuss as &$orderHistoryStatus) { if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index 4ceb5bc6..0211e05d 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -45,4 +45,7 @@ parameters: - '#Property PrestaShop\\Module\\PsEventbus\\Helper\\ModuleHelper::\$moduleManager has unknown class PrestaShop\\PrestaShop\\Core\\Addon\\Module\\ModuleManager as its type.#' - '#Call to method isInstalled\(\) on an unknown class PrestaShop\\PrestaShop\\Core\\Addon\\Module\\ModuleManager.#' - '#Call to method isEnabled\(\) on an unknown class PrestaShop\\PrestaShop\\Core\\Addon\\Module\\ModuleManager.#' + - '#Constant PS_EVENTBUS_LOGS_ENABLED not found.#' + - '#Constant PS_EVENTBUS_VERBOSE_ENABLED not found.#' + - '#Constant PS_EVENTBUS_EXPLAIN_SQL_ENABLED not found.#' level: 8 From 7f1ba67c4592f0e88f649be6f851fd85bb0bd8b8 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 7 Oct 2024 16:32:18 +0200 Subject: [PATCH 117/162] fix: php-cs-fixer --- controllers/front/apiFront.php | 2 +- src/Repository/AbstractRepository.php | 2 +- src/Service/FrontApiService.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index fde1121c..7e0d6a51 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -50,7 +50,7 @@ public function postProcess() /** @var bool $explainSql */ $explainSql = Tools::getValue('explain_sql', 0) == 1; - + /** @var bool $verbose */ $verbose = Tools::getValue('verbose', 0) == 1; diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index a9bbe88e..a72557f2 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -106,7 +106,7 @@ public function getShopContext() /** * @param bool $enableCurrentExplain - * + * * @return array * * @throws \PrestaShopException diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 80052077..7b6dff25 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -81,7 +81,7 @@ public function __construct( * @param string $langIso * @param int $limit * @param bool $fullSyncRequested - * + * * @return void */ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested) From 2f4f6c9cd4609d0ba4778e927efaf781aab56fd7 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 7 Oct 2024 16:53:43 +0200 Subject: [PATCH 118/162] fix: error php --- src/Service/SynchronizationService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index d61f0fd9..293414ed 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -109,7 +109,7 @@ public function sendFullSync( int $offset, int $limit, int $startTime, - string $dateNow, + string $dateNow ) { $response = []; @@ -166,7 +166,7 @@ public function sendIncrementalSync( string $jobId, string $langIso, int $limit, - int $startTime, + int $startTime ) { $response = []; From 77d1e5cacac34463d779b8365d45baa01ac636c5 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 9 Oct 2024 11:06:20 +0200 Subject: [PATCH 119/162] fix: after review --- README.md | 34 ++++++++++++++++++++++++-- e2e-env/README.md | 4 +-- e2e-env/docker-compose.yml | 2 +- e2e/README.md | 4 +-- e2e/src/full-sync.spec.ts | 2 +- e2e/src/helpers/data-helper.ts | 2 +- e2e/src/helpers/mock-probe.ts | 2 +- e2e/src/job-id-validation.spec.ts | 2 +- src/Api/LiveSyncApiClient.php | 4 +-- src/Config/Config.php | 2 +- src/Service/CommonService.php | 21 ++++++++++------ src/Service/FrontApiService.php | 12 ++++----- src/Service/SynchronizationService.php | 2 +- 13 files changed, 64 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 8535a04a..3b9060ce 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ | 1.7.3-1.7.8 | 7.1+ | From 2.x | | 1.6.1.11 - 1.7.2.5 | 7.1 | From 3.1 | +## BREAKING CHANGES + +### Front controllers and API endpoints +Depuis la version 4.0, tout les endpoints API sont regroupé sous un seul controller "apiFront.php". La route a appeller est donc maintenant unique, et le shopContent n'est plus un endpoint en particulier, mais un paramètre query de la requête (ex: "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healtcheck") + PS Accounts compatibility matrix [can be viewed here](https://github.com/PrestaShopCorp/ps_accounts#compatibility-matrix). ### Product Images Issue in PHP 8.1 @@ -51,7 +56,7 @@ To check the module healthiness (authenticated route): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck&job_id=valid-job-stuff" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-stuff" | jq . { "prestashop_version": "1.6.1.24", "ps_eventbus_version": "0.0.0", @@ -72,7 +77,7 @@ To check the fallback route (unauthenticated): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=healthcheck" | jq . { "ps_account": true, "is_valid_jwt": true, @@ -119,3 +124,28 @@ Or an up-to-date [Docker engine](https://docs.docker.com/engine/install). ¹ Feature enabled only with PsWishlist module
² Feature enabled only with PsFacebook module + +## How to add new shop content +Prenons pour exemple l'ajout d'un shopContent nommé "plane". + +- Ajoutez le shop content dans le fichier [Config.php](src/Config/Config.php) (créez une constante, et ajoutez là au tableau SHOP_CONTENTS). +```PHP +const COLLECTION_PLANES = 'planes'; + +const SHOP_CONTENTS = [ + ... + self::COLLECTION_PLANES + ... +]; +``` +- Créez un service "monShopContentsService.php" dans le [dossier des service shop content](src/Service/ShopContent/) qui implémente l'interface [ShopContentServiceInterface.php](src/Service/ShopContent/ShopContentServiceInterface.php). Pour la structure des méthodes, reprenez la base existante sur tout les autres service de shop content pour garder une cohérence. +- Créez un repository pour votre shop content (ex: monShopContentRepository.php) dans le dossier [Repository](src/Repository/) qui etends la classe [AbstractRepository.php](src/Repository/AbstractRepository.php) et implemente l'interface [RepositoryInterface.php](src/Repository/RepositoryInterface.php). De la même manière, gardez une cohérence avec les autres repository de shop content. +- Ajoutez dans le fichier de [config e2e](e2e/src/helpers/shop-contents.ts) votre shop content, puis lancez les tests une fois pour générer les dumps nécessaire (seront présent dans le dossier [dump](e2e/dumps/)). Une fois le test réalisé (et échoué), copier le fichier json correspondant à votre shop content, et collez le dans le dossier fixture, pour votre version donné. Faites la même chose pour chaque version (si les versions retournent des résultats différent). + +## Debugging +There are 3 variables that are passed "magically" from the apiFront file to the end of the chain (repositories and errorHandler): +- PS_EVENTBUS_EXPLAIN_SQL_ENABLED +- PS_EVENTBUS_VERBOSE_ENABLED +- PS_EVENTBUS_LOGS_ENABLED + +These variables are defined via the PHP function define() and reused in the files mentioned above. The reason for this usage is to avoid having to pass these variables through the entire execution chain to retrieve them at the end of the chain (e.g., apiFront => frontService => shopContentService => shopContentRepository). diff --git a/e2e-env/README.md b/e2e-env/README.md index 3c68ea81..bff42189 100644 --- a/e2e-env/README.md +++ b/e2e-env/README.md @@ -54,13 +54,13 @@ Simple! Is the module healthy? ```sh -curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-1" | jq . +curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-1" | jq . ``` Capture orders: ```sh -curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiOrders&job_id=valid-job-1" | jq . +curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=orders&job_id=valid-job-1" | jq . ``` ## Make changes to the mock diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index add5990e..f724d11f 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -12,7 +12,7 @@ services: "-sI", "-H", "Host: localhost:8000", - "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=healthcheck", + "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=healthcheck", ] interval: 30s volumes: diff --git a/e2e/README.md b/e2e/README.md index 08bfa19d..c0893217 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -18,12 +18,12 @@ import testConfig from './helpers/test.config'; import request from 'supertest'; const controller = 'categories'; -const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5`; +const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=${shopContent}&limit=5`; describe('CategoriesShopContent', () => { it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; // jobId starting with "valid-job-" will be considered valid by the mock sync-api and will always return 201; // other values will be rejected by the mock const jobId = 'valid-job-1' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 675ffd8e..56784161 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -51,7 +51,7 @@ describe("Full Sync", () => { describe.each(shopContentList)("%s", (shopContent) => { it(`${shopContent} should accept full sync`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const callId = { call_id: Math.random().toString(36).substring(2, 11) }; diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 9cf915b5..6b43dc6d 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -59,7 +59,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=healthcheck&job_id=valid-job-healthcheck`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=healthcheck&job_id=valid-job-healthcheck`, ); healthCheck = res.data; cachedHealthCheck = healthCheck; diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index 75e66dd6..8c3ccddc 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -96,7 +96,7 @@ export function doFullSync( const requestNext = (full: number) => { return axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, callId, { headers: { diff --git a/e2e/src/job-id-validation.spec.ts b/e2e/src/job-id-validation.spec.ts index 50bea911..53eecdb8 100644 --- a/e2e/src/job-id-validation.spec.ts +++ b/e2e/src/job-id-validation.spec.ts @@ -22,7 +22,7 @@ describe("Reject invalid job-id", () => { async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront&is_e2e=0&shop_content=${shopContent}&limit=5&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=${shopContent}&limit=5&job_id=${jobId}`; const message$ = probe({ params: { id: jobId } }); //act diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index d344ab8e..9904631f 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -109,8 +109,8 @@ public function liveSync($shopContent, $action) 'Authorization' => 'Bearer ' . $this->jwt, 'User-Agent' => 'ps-eventbus/' . $this->module->version, 'Content-Type' => 'application/json', - ], // FIXME: Pass real array of shop contents. at the moment, only one shop content is sent for match CS rate limiter - '{"shopContents": ["' . $kebabCasedShopContent . '"], "shopContentId": ' . $uselessParameter . ', "action": "' . $action . '"}' + ], // FIXME: Pass real array of shop contents. at the moment, only one shop content is sent to match CS rate limiter + '{"shopContents": ["' . $kebabCasedShopContent . '"], "action": "' . $action . '"}' ) ); diff --git a/src/Config/Config.php b/src/Config/Config.php index c1a341c2..8a297984 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -29,7 +29,7 @@ class Config 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_SYNC_MAX_PAGE_SIZE = 10000; const SYNC_API_MAX_TIMEOUT = 5; const COLLECTOR_MAX_TIMEOUT = 30; diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index fcc0c4e0..3a170b0f 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -56,14 +56,19 @@ public static function exitWithExceptionMessage(\Exception $exception) { $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); - if ($exception instanceof \PrestaShopDatabaseException) { - $code = Config::DATABASE_QUERY_ERROR_CODE; - } elseif ($exception instanceof EnvVarException) { - $code = Config::ENV_MISCONFIGURED_ERROR_CODE; - } elseif ($exception instanceof FirebaseException) { - $code = Config::REFRESH_TOKEN_ERROR_CODE; - } elseif ($exception instanceof QueryParamsException) { - $code = Config::INVALID_URL_QUERY; + switch ($exception) { + case $exception instanceof \PrestaShopDatabaseException: + $code = Config::DATABASE_QUERY_ERROR_CODE; + break; + case $exception instanceof EnvVarException: + $code = Config::ENV_MISCONFIGURED_ERROR_CODE; + break; + case $exception instanceof FirebaseException: + $code = Config::REFRESH_TOKEN_ERROR_CODE; + break; + case $exception instanceof QueryParamsException: + $code = Config::INVALID_URL_QUERY; + break; } $response = [ diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index 7b6dff25..a2fc70ae 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -227,12 +227,12 @@ private function authorize($jobId, $isHealthCheck) return false; } - if ($exception instanceof \PrestaShopDatabaseException) { - $this->errorHandler->handle($exception); - } elseif ($exception instanceof EnvVarException) { - $this->errorHandler->handle($exception); - } elseif ($exception instanceof FirebaseException) { - $this->errorHandler->handle($exception); + switch ($exception) { + case $exception instanceof \PrestaShopDatabaseException: + case $exception instanceof EnvVarException: + case $exception instanceof FirebaseException: + $this->errorHandler->handle($exception); + break; } return false; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 293414ed..30aed5ff 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -263,7 +263,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, foreach ($contentTypesWithIds as $contentType => $contentIds) { $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($contentType); - if ($count > Config::INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT) { + if ($count > Config::INCREMENTAL_SYNC_MAX_PAGE_SIZE) { $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); if ($hasDeleted) { From 130b4410556fe562f212ab093a491d6a93c39f7d Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 9 Oct 2024 12:04:09 +0200 Subject: [PATCH 120/162] docs: update readme --- README.md | 66 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3b9060ce..92aae567 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,52 @@ Dev requirements: Or an up-to-date [Docker engine](https://docs.docker.com/engine/install). -## List of missing data in a database and why is missing +### How to add new shop content +Let's take the example of adding a shopContent named "plane". + +Add the shop content in the [Config.php](src/Config/Config.php) file (create a constant, and add it to the SHOP_CONTENTS array). +```PHP +const COLLECTION_PLANES = 'planes'; + +const SHOP_CONTENTS = [ + ... + self::COLLECTION_PLANES + ... +]; +``` + +Create a service "planesService.php" (in plural) in the [shop content services folder](src/Service/ShopContent/) that implements the [ShopContentServiceInterface.php](src/Service/ShopContent/ShopContentServiceInterface.php) interface. For the method structure, use the existing base on all other shop content services to maintain consistency. +```PHP +class PlanesService implements ShopContentServiceInterface +{ + ... +} +``` + +Then create a repository PlaneRepository.php (in singular) in the [Repository](src/Repository/) folder that extends the [AbstractRepository.php](src/Repository/AbstractRepository.php) class and implements the [RepositoryInterface.php](src/Repository/RepositoryInterface.php) interface. Similarly, maintain consistency with other shop content repositories. +```PHP +class PlaneRepository extends AbstractRepository implements RepositoryInterface +{ + ... +} +``` + +Add your shop content in the [e2e config file](e2e/src/helpers/shop-contents.ts). +```javascript +export const shopContentMapping = { + ... + planes: 'planes' + ... +} +``` + +Run the tests once to generate the necessary dumps (they will be present in the [dump](e2e/dumps/) folder). Once the test is performed (and failed), copy the planes.json file, and paste it into the fixture folder for your given version. Do the same for each version (if the versions return different results). + +You can run the tests again and ensure everything is green. + +In case your shopContent cannot return results (absence of data in the tables), please add a planes.json file in the folders of each version containing an empty array. + +### List of missing data in a database and why is missing | Object content | Reason | Added in PS version | Link with more info | |:----------------------------------:|:--------------------:|:-------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| @@ -125,24 +170,7 @@ Or an up-to-date [Docker engine](https://docs.docker.com/engine/install). ¹ Feature enabled only with PsWishlist module
² Feature enabled only with PsFacebook module -## How to add new shop content -Prenons pour exemple l'ajout d'un shopContent nommé "plane". - -- Ajoutez le shop content dans le fichier [Config.php](src/Config/Config.php) (créez une constante, et ajoutez là au tableau SHOP_CONTENTS). -```PHP -const COLLECTION_PLANES = 'planes'; - -const SHOP_CONTENTS = [ - ... - self::COLLECTION_PLANES - ... -]; -``` -- Créez un service "monShopContentsService.php" dans le [dossier des service shop content](src/Service/ShopContent/) qui implémente l'interface [ShopContentServiceInterface.php](src/Service/ShopContent/ShopContentServiceInterface.php). Pour la structure des méthodes, reprenez la base existante sur tout les autres service de shop content pour garder une cohérence. -- Créez un repository pour votre shop content (ex: monShopContentRepository.php) dans le dossier [Repository](src/Repository/) qui etends la classe [AbstractRepository.php](src/Repository/AbstractRepository.php) et implemente l'interface [RepositoryInterface.php](src/Repository/RepositoryInterface.php). De la même manière, gardez une cohérence avec les autres repository de shop content. -- Ajoutez dans le fichier de [config e2e](e2e/src/helpers/shop-contents.ts) votre shop content, puis lancez les tests une fois pour générer les dumps nécessaire (seront présent dans le dossier [dump](e2e/dumps/)). Une fois le test réalisé (et échoué), copier le fichier json correspondant à votre shop content, et collez le dans le dossier fixture, pour votre version donné. Faites la même chose pour chaque version (si les versions retournent des résultats différent). - -## Debugging +### Debugging There are 3 variables that are passed "magically" from the apiFront file to the end of the chain (repositories and errorHandler): - PS_EVENTBUS_EXPLAIN_SQL_ENABLED - PS_EVENTBUS_VERBOSE_ENABLED From f18b0b35295fe57c73ff48d64d0efceee1c76f7a Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 09:47:31 +0200 Subject: [PATCH 121/162] fix: update header-stamps --- Makefile | 4 ++-- controllers/front/apiFront.php | 12 +++++++++--- ps_eventbus.php | 12 +++++++++--- src/Api/CollectorApiClient.php | 12 +++++++++--- src/Api/LiveSyncApiClient.php | 12 +++++++++--- src/Api/Post/MultipartBody.php | 12 +++++++++--- src/Api/Post/PostFileApi.php | 12 +++++++++--- src/Api/Post/PostFileInterface.php | 12 +++++++++--- src/Api/Post/Stream.php | 12 +++++++++--- src/Api/SyncApiClient.php | 12 +++++++++--- src/Config/Config.php | 12 +++++++++--- src/DependencyInjection/ContainerProvider.php | 12 +++++++++--- src/DependencyInjection/ServiceContainer.php | 12 +++++++++--- src/Exception/ApiException.php | 12 +++++++++--- src/Exception/EnvVarException.php | 12 +++++++++--- src/Exception/FirebaseException.php | 12 +++++++++--- src/Exception/QueryParamsException.php | 12 +++++++++--- src/Factory/ContextFactory.php | 12 +++++++++--- src/Formatter/ArrayFormatter.php | 12 +++++++++--- src/Formatter/JsonFormatter.php | 12 +++++++++--- src/Handler/ErrorHandler/ErrorHandler.php | 12 +++++++++--- src/Helper/ModuleHelper.php | 12 +++++++++--- src/Module/Install.php | 12 +++++++++--- src/Module/Uninstall.php | 12 +++++++++--- src/Repository/AbstractRepository.php | 12 +++++++++--- src/Repository/CarrierRepository.php | 12 +++++++++--- src/Repository/CartProductRepository.php | 12 +++++++++--- src/Repository/CartRepository.php | 12 +++++++++--- src/Repository/CartRuleRepository.php | 12 +++++++++--- src/Repository/CategoryRepository.php | 12 +++++++++--- src/Repository/CountryRepository.php | 12 +++++++++--- src/Repository/CurrencyRepository.php | 12 +++++++++--- src/Repository/CustomProductCarrierRepository.php | 12 +++++++++--- src/Repository/CustomerRepository.php | 12 +++++++++--- src/Repository/EmployeeRepository.php | 12 +++++++++--- src/Repository/EventbusSyncRepository.php | 12 +++++++++--- src/Repository/ImageRepository.php | 12 +++++++++--- src/Repository/ImageTypeRepository.php | 12 +++++++++--- src/Repository/IncrementalSyncRepository.php | 12 +++++++++--- src/Repository/LanguageRepository.php | 12 +++++++++--- src/Repository/LiveSyncRepository.php | 12 +++++++++--- src/Repository/ManufacturerRepository.php | 12 +++++++++--- src/Repository/ModuleRepository.php | 12 +++++++++--- src/Repository/OrderCartRuleRepository.php | 12 +++++++++--- src/Repository/OrderDetailRepository.php | 12 +++++++++--- src/Repository/OrderHistoryRepository.php | 12 +++++++++--- src/Repository/OrderRepository.php | 12 +++++++++--- src/Repository/ProductBundleRepository.php | 12 +++++++++--- src/Repository/ProductRepository.php | 12 +++++++++--- src/Repository/ProductSupplierRepository.php | 12 +++++++++--- src/Repository/RepositoryInterface.php | 12 +++++++++--- src/Repository/ShopRepository.php | 12 +++++++++--- src/Repository/SpecificPriceRepository.php | 12 +++++++++--- src/Repository/StateRepository.php | 12 +++++++++--- src/Repository/StockMovementRepository.php | 12 +++++++++--- src/Repository/StockRepository.php | 12 +++++++++--- src/Repository/StoreRepository.php | 12 +++++++++--- src/Repository/SupplierRepository.php | 12 +++++++++--- src/Repository/TaxeRepository.php | 12 +++++++++--- src/Repository/TaxonomyRepository.php | 12 +++++++++--- src/Repository/TranslationRepository.php | 12 +++++++++--- src/Repository/WishlistProductRepository.php | 12 +++++++++--- src/Repository/WishlistRepository.php | 12 +++++++++--- src/Service/ApiAuthorizationService.php | 12 +++++++++--- src/Service/CommonService.php | 12 +++++++++--- src/Service/FrontApiService.php | 12 +++++++++--- src/Service/HealthCheckService.php | 12 +++++++++--- src/Service/PresenterService.php | 12 +++++++++--- src/Service/ProxyService.php | 12 +++++++++--- src/Service/ProxyServiceInterface.php | 12 +++++++++--- src/Service/PsAccountsAdapterService.php | 12 +++++++++--- src/Service/ShopContent/CarrierDetailsService.php | 12 +++++++++--- src/Service/ShopContent/CarrierTaxesService.php | 12 +++++++++--- src/Service/ShopContent/CarriersService.php | 12 +++++++++--- src/Service/ShopContent/CartProductsService.php | 12 +++++++++--- src/Service/ShopContent/CartRulesService.php | 12 +++++++++--- src/Service/ShopContent/CartsService.php | 12 +++++++++--- src/Service/ShopContent/CategoriesService.php | 12 +++++++++--- src/Service/ShopContent/CurrenciesService.php | 12 +++++++++--- .../ShopContent/CustomProductCarriersService.php | 12 +++++++++--- src/Service/ShopContent/CustomersService.php | 12 +++++++++--- src/Service/ShopContent/EmployeesService.php | 12 +++++++++--- src/Service/ShopContent/ImageTypesService.php | 12 +++++++++--- src/Service/ShopContent/ImagesService.php | 12 +++++++++--- src/Service/ShopContent/LanguagesService.php | 12 +++++++++--- src/Service/ShopContent/ManufacturersService.php | 12 +++++++++--- src/Service/ShopContent/ModulesService.php | 12 +++++++++--- src/Service/ShopContent/OrderCartRulesService.php | 12 +++++++++--- src/Service/ShopContent/OrderDetailsService.php | 12 +++++++++--- src/Service/ShopContent/OrderHistoriesService.php | 12 +++++++++--- src/Service/ShopContent/OrdersService.php | 12 +++++++++--- src/Service/ShopContent/ProductBundlesService.php | 12 +++++++++--- src/Service/ShopContent/ProductSuppliersService.php | 12 +++++++++--- src/Service/ShopContent/ProductsService.php | 12 +++++++++--- .../ShopContent/ShopContentServiceInterface.php | 12 +++++++++--- src/Service/ShopContent/ShopsService.php | 12 +++++++++--- src/Service/ShopContent/SpecificPricesService.php | 12 +++++++++--- src/Service/ShopContent/StockMovementsService.php | 12 +++++++++--- src/Service/ShopContent/StocksService.php | 12 +++++++++--- src/Service/ShopContent/StoresService.php | 12 +++++++++--- src/Service/ShopContent/SuppliersService.php | 12 +++++++++--- src/Service/ShopContent/TaxonomiesService.php | 12 +++++++++--- src/Service/ShopContent/ThemesService.php | 12 +++++++++--- src/Service/ShopContent/TranslationsService.php | 12 +++++++++--- src/Service/ShopContent/WishlistProductsService.php | 12 +++++++++--- src/Service/ShopContent/WishlistsService.php | 12 +++++++++--- src/Service/SynchronizationService.php | 12 +++++++++--- src/Traits/UseHooks.php | 12 +++++++++--- translations/en.php | 12 +++++++++--- translations/es.php | 12 +++++++++--- translations/fr.php | 12 +++++++++--- translations/it.php | 12 +++++++++--- upgrade/Upgrade-1.10.0.php | 12 +++++++++--- upgrade/Upgrade-1.10.3.php | 12 +++++++++--- upgrade/Upgrade-1.10.7.php | 12 +++++++++--- upgrade/Upgrade-1.10.8.php | 12 +++++++++--- upgrade/Upgrade-1.3.7.php | 12 +++++++++--- upgrade/Upgrade-1.5.1.php | 12 +++++++++--- upgrade/Upgrade-1.5.2.php | 12 +++++++++--- upgrade/Upgrade-1.6.9.php | 12 +++++++++--- upgrade/Upgrade-1.7.1.php | 12 +++++++++--- upgrade/Upgrade-1.7.11.php | 12 +++++++++--- upgrade/Upgrade-1.7.15.php | 12 +++++++++--- upgrade/Upgrade-1.7.2.php | 12 +++++++++--- upgrade/Upgrade-1.8.1.php | 12 +++++++++--- upgrade/Upgrade-1.9.3.php | 12 +++++++++--- upgrade/Upgrade-1.9.7.php | 12 +++++++++--- upgrade/Upgrade-2.1.0.php | 12 +++++++++--- upgrade/Upgrade-2.3.0.php | 12 +++++++++--- upgrade/Upgrade-2.3.2.php | 12 +++++++++--- upgrade/Upgrade-3.0.0.php | 12 +++++++++--- upgrade/Upgrade-3.0.12.php | 12 +++++++++--- upgrade/Upgrade-3.0.13.php | 12 +++++++++--- upgrade/Upgrade-3.0.5.php | 12 +++++++++--- upgrade/Upgrade-4.0.0.php | 12 +++++++++--- 135 files changed, 1208 insertions(+), 404 deletions(-) diff --git a/Makefile b/Makefile index fcf9b246..dff473e2 100644 --- a/Makefile +++ b/Makefile @@ -157,7 +157,7 @@ docker-phpstan: tools/vendor # target: header-stamp - check Headers of PHP files .PHONY:header-stamp header-stamp: - tools/vendor/bin/header-stamp --license=tools/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,tools,e2e,e2e-env,tests,composer.json,scoper.inc.php --dry-run + tools/vendor/bin/header-stamp --license=tools/vendor/prestashop/header-stamp/assets/osl3.txt --exclude=vendor,tools,e2e,e2e-env,tests,composer.json,scoper.inc.php define COMMENT Fixme: add "allure-framework/allure-phpunit" in composer.json to solve this. @@ -183,7 +183,7 @@ define create_module cp -r $(shell cat .zip-contents) ${TMP_DIR}/${MODULE_NAME}; $(call replace_version,${TMP_DIR}/${MODULE_NAME},${SEM_VERSION}) ./tools/vendor/bin/autoindex prestashop:add:index ${TMP_DIR} - tools/vendor/bin/header-stamp --target=${TMP_DIR}/${MODULE_NAME} --license=tools/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,e2e,e2e-env,tests,composer.json,scoper.inc.php + tools/vendor/bin/header-stamp --target=${TMP_DIR}/${MODULE_NAME} --license=tools/vendor/prestashop/header-stamp/assets/osl3.txt --exclude=vendor,e2e,e2e-env,tests,composer.json,scoper.inc.php cp $1 ${TMP_DIR}/${MODULE_NAME}/config/parameters.yml cd ${TMP_DIR}/${MODULE_NAME} && composer dump-autoload endef diff --git a/controllers/front/apiFront.php b/controllers/front/apiFront.php index 7e0d6a51..3ff0f9f9 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiFront.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ use PrestaShop\Module\PsEventbus\Service\FrontApiService; diff --git a/ps_eventbus.php b/ps_eventbus.php index 5728289f..1474d662 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ use PrestaShop\Module\PsEventbus\DependencyInjection\ServiceContainer; diff --git a/src/Api/CollectorApiClient.php b/src/Api/CollectorApiClient.php index 13ec776a..7a30065e 100644 --- a/src/Api/CollectorApiClient.php +++ b/src/Api/CollectorApiClient.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Api; diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index 9904631f..bdffc643 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Api; diff --git a/src/Api/Post/MultipartBody.php b/src/Api/Post/MultipartBody.php index 9cc771e2..f37cd657 100755 --- a/src/Api/Post/MultipartBody.php +++ b/src/Api/Post/MultipartBody.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/PostFileApi.php b/src/Api/Post/PostFileApi.php index 0de358ac..ee001f5a 100644 --- a/src/Api/Post/PostFileApi.php +++ b/src/Api/Post/PostFileApi.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/PostFileInterface.php b/src/Api/Post/PostFileInterface.php index 661aeccb..d603dbeb 100755 --- a/src/Api/Post/PostFileInterface.php +++ b/src/Api/Post/PostFileInterface.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/Post/Stream.php b/src/Api/Post/Stream.php index faf58868..7fb60cda 100644 --- a/src/Api/Post/Stream.php +++ b/src/Api/Post/Stream.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Api\Post; diff --git a/src/Api/SyncApiClient.php b/src/Api/SyncApiClient.php index d250b8c8..071d33a9 100644 --- a/src/Api/SyncApiClient.php +++ b/src/Api/SyncApiClient.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Api; diff --git a/src/Config/Config.php b/src/Config/Config.php index 8a297984..71efd5e7 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Config; diff --git a/src/DependencyInjection/ContainerProvider.php b/src/DependencyInjection/ContainerProvider.php index 12e17230..ebad03ef 100644 --- a/src/DependencyInjection/ContainerProvider.php +++ b/src/DependencyInjection/ContainerProvider.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\DependencyInjection; diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php index 3b610d87..63d063d1 100644 --- a/src/DependencyInjection/ServiceContainer.php +++ b/src/DependencyInjection/ServiceContainer.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\DependencyInjection; diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index f9da2ef9..db1fef15 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/EnvVarException.php b/src/Exception/EnvVarException.php index b3839b4b..6843f0b6 100644 --- a/src/Exception/EnvVarException.php +++ b/src/Exception/EnvVarException.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/FirebaseException.php b/src/Exception/FirebaseException.php index 2a138a6a..fdddd958 100644 --- a/src/Exception/FirebaseException.php +++ b/src/Exception/FirebaseException.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Exception/QueryParamsException.php b/src/Exception/QueryParamsException.php index e39c31ef..5864438b 100644 --- a/src/Exception/QueryParamsException.php +++ b/src/Exception/QueryParamsException.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Exception; diff --git a/src/Factory/ContextFactory.php b/src/Factory/ContextFactory.php index 8a83ffb9..8cad3d81 100644 --- a/src/Factory/ContextFactory.php +++ b/src/Factory/ContextFactory.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Factory; diff --git a/src/Formatter/ArrayFormatter.php b/src/Formatter/ArrayFormatter.php index 5e8bdcdc..67f249c7 100644 --- a/src/Formatter/ArrayFormatter.php +++ b/src/Formatter/ArrayFormatter.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Formatter; diff --git a/src/Formatter/JsonFormatter.php b/src/Formatter/JsonFormatter.php index 4da26b0c..f95be74b 100644 --- a/src/Formatter/JsonFormatter.php +++ b/src/Formatter/JsonFormatter.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Formatter; diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index f671f8e5..cea9dfde 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; diff --git a/src/Helper/ModuleHelper.php b/src/Helper/ModuleHelper.php index 89d99128..f9309587 100644 --- a/src/Helper/ModuleHelper.php +++ b/src/Helper/ModuleHelper.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Helper; diff --git a/src/Module/Install.php b/src/Module/Install.php index 72afb06b..01e90761 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Module; diff --git a/src/Module/Uninstall.php b/src/Module/Uninstall.php index 4b2c08b1..b15e4a19 100644 --- a/src/Module/Uninstall.php +++ b/src/Module/Uninstall.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Module; diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index a72557f2..7943544c 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php index a36b3590..38c0e552 100644 --- a/src/Repository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CartProductRepository.php b/src/Repository/CartProductRepository.php index efccd14a..0cfc6dd3 100644 --- a/src/Repository/CartProductRepository.php +++ b/src/Repository/CartProductRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CartRepository.php b/src/Repository/CartRepository.php index 43ccffc6..1b9d9623 100644 --- a/src/Repository/CartRepository.php +++ b/src/Repository/CartRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php index 2c4c4d71..51047b20 100644 --- a/src/Repository/CartRuleRepository.php +++ b/src/Repository/CartRuleRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php index 357a071f..6ebd64e6 100644 --- a/src/Repository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index 8e77ff75..f765d84f 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php index 07d95eb5..8aec00ba 100644 --- a/src/Repository/CurrencyRepository.php +++ b/src/Repository/CurrencyRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CustomProductCarrierRepository.php b/src/Repository/CustomProductCarrierRepository.php index 495cac7c..a1d3d82d 100644 --- a/src/Repository/CustomProductCarrierRepository.php +++ b/src/Repository/CustomProductCarrierRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index fe76813f..9ad61d71 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php index 4521caf4..b75986f7 100644 --- a/src/Repository/EmployeeRepository.php +++ b/src/Repository/EmployeeRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/EventbusSyncRepository.php b/src/Repository/EventbusSyncRepository.php index d1be1af7..7217ff87 100644 --- a/src/Repository/EventbusSyncRepository.php +++ b/src/Repository/EventbusSyncRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ImageRepository.php b/src/Repository/ImageRepository.php index 6a38a905..e2b1ba26 100644 --- a/src/Repository/ImageRepository.php +++ b/src/Repository/ImageRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php index e98e5016..2d28044b 100644 --- a/src/Repository/ImageTypeRepository.php +++ b/src/Repository/ImageTypeRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index be263623..8fc5aac6 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/LanguageRepository.php b/src/Repository/LanguageRepository.php index c62cff66..e3aaf6e9 100644 --- a/src/Repository/LanguageRepository.php +++ b/src/Repository/LanguageRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/LiveSyncRepository.php b/src/Repository/LiveSyncRepository.php index e0a174a7..5ee0637e 100644 --- a/src/Repository/LiveSyncRepository.php +++ b/src/Repository/LiveSyncRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 58ff4dc6..60de2b69 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php index db9793aa..c957ca83 100644 --- a/src/Repository/ModuleRepository.php +++ b/src/Repository/ModuleRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php index e71e7259..7ae1b182 100644 --- a/src/Repository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/OrderDetailRepository.php b/src/Repository/OrderDetailRepository.php index 3e0eacae..0b4329d6 100644 --- a/src/Repository/OrderDetailRepository.php +++ b/src/Repository/OrderDetailRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php index 1e52df5a..820eeb6c 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php index effc8aba..d916ad77 100644 --- a/src/Repository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ProductBundleRepository.php b/src/Repository/ProductBundleRepository.php index 6bf2d567..41bbffeb 100644 --- a/src/Repository/ProductBundleRepository.php +++ b/src/Repository/ProductBundleRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index f382ab40..067abdbb 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php index 4d1b4cc9..5b0efb5c 100644 --- a/src/Repository/ProductSupplierRepository.php +++ b/src/Repository/ProductSupplierRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/RepositoryInterface.php b/src/Repository/RepositoryInterface.php index fd1e5a43..9904a316 100644 --- a/src/Repository/RepositoryInterface.php +++ b/src/Repository/RepositoryInterface.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/ShopRepository.php b/src/Repository/ShopRepository.php index 04afabd2..c9bae43d 100644 --- a/src/Repository/ShopRepository.php +++ b/src/Repository/ShopRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index 9c67121d..78999b2f 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index 85d5f592..9abb6467 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StockMovementRepository.php b/src/Repository/StockMovementRepository.php index b730b7fa..cf2fd54a 100644 --- a/src/Repository/StockMovementRepository.php +++ b/src/Repository/StockMovementRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index 4228cdab..746e4459 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index ef6b8956..f4564ad8 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index 14cfe432..38a4cfc8 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php index 2c1dbe0b..14de8c10 100644 --- a/src/Repository/TaxeRepository.php +++ b/src/Repository/TaxeRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/TaxonomyRepository.php b/src/Repository/TaxonomyRepository.php index d5511976..b7c793e4 100644 --- a/src/Repository/TaxonomyRepository.php +++ b/src/Repository/TaxonomyRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 0727bded..73f2782a 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php index 135a56e6..05b65494 100644 --- a/src/Repository/WishlistProductRepository.php +++ b/src/Repository/WishlistProductRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php index 78216b44..f08285bc 100644 --- a/src/Repository/WishlistRepository.php +++ b/src/Repository/WishlistRepository.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Repository; diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index 3dc81aa3..cb9a8606 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index 3a170b0f..cfa09450 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/FrontApiService.php b/src/Service/FrontApiService.php index a2fc70ae..15e57bc1 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/FrontApiService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/HealthCheckService.php b/src/Service/HealthCheckService.php index 953b5a3a..3740d394 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/HealthCheckService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/PresenterService.php b/src/Service/PresenterService.php index 93ad9940..7907fc68 100644 --- a/src/Service/PresenterService.php +++ b/src/Service/PresenterService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/ProxyService.php b/src/Service/ProxyService.php index e6044e12..29fdf4a2 100644 --- a/src/Service/ProxyService.php +++ b/src/Service/ProxyService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/ProxyServiceInterface.php b/src/Service/ProxyServiceInterface.php index 22774370..3ec8f616 100644 --- a/src/Service/ProxyServiceInterface.php +++ b/src/Service/ProxyServiceInterface.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/PsAccountsAdapterService.php b/src/Service/PsAccountsAdapterService.php index a969ac9e..bad8891e 100644 --- a/src/Service/PsAccountsAdapterService.php +++ b/src/Service/PsAccountsAdapterService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index 4f88ff36..d3660397 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index a449139f..e2eea16b 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index bc37ef36..12c3bc6f 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index 55785276..82b95bef 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index 3f0d9355..f55caff5 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 13c9eda1..3b94c011 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index 6d526bbb..c1d4cbbb 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index 34ecf360..036ae967 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CustomProductCarriersService.php b/src/Service/ShopContent/CustomProductCarriersService.php index 25103552..b33a3828 100644 --- a/src/Service/ShopContent/CustomProductCarriersService.php +++ b/src/Service/ShopContent/CustomProductCarriersService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index 7314ebd8..d10f25cb 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index 9c132fd2..dbc105b1 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index 48bf9247..deee446f 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index 4f2a9c5a..5ccf147b 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index 35e7bfd7..bb2600f2 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ManufacturersService.php b/src/Service/ShopContent/ManufacturersService.php index 05437ee8..08221d01 100644 --- a/src/Service/ShopContent/ManufacturersService.php +++ b/src/Service/ShopContent/ManufacturersService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 1be837c1..26f58251 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index e864ff92..22c37bd2 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index 57622cc2..a83d441a 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderHistoriesService.php index 5f4c6d83..868c9e37 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderHistoriesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index a4f94bb6..98d1edc9 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/ProductBundlesService.php index 0ba691ec..ec025754 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/ProductBundlesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index dacf7fb8..380c053a 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index 304db7f4..707506e6 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index 434de553..36e4212d 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ShopsService.php b/src/Service/ShopContent/ShopsService.php index 043755f2..24586972 100644 --- a/src/Service/ShopContent/ShopsService.php +++ b/src/Service/ShopContent/ShopsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index 9a8d869a..4cd770dd 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/StockMovementsService.php b/src/Service/ShopContent/StockMovementsService.php index 09390d52..d42a419f 100644 --- a/src/Service/ShopContent/StockMovementsService.php +++ b/src/Service/ShopContent/StockMovementsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/StocksService.php b/src/Service/ShopContent/StocksService.php index c3c8333c..fa54127a 100644 --- a/src/Service/ShopContent/StocksService.php +++ b/src/Service/ShopContent/StocksService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/StoresService.php b/src/Service/ShopContent/StoresService.php index d0f04a56..effa9922 100644 --- a/src/Service/ShopContent/StoresService.php +++ b/src/Service/ShopContent/StoresService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/SuppliersService.php b/src/Service/ShopContent/SuppliersService.php index 2903b42b..b79da85a 100644 --- a/src/Service/ShopContent/SuppliersService.php +++ b/src/Service/ShopContent/SuppliersService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/TaxonomiesService.php b/src/Service/ShopContent/TaxonomiesService.php index e13d2208..2f8df63d 100644 --- a/src/Service/ShopContent/TaxonomiesService.php +++ b/src/Service/ShopContent/TaxonomiesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php index b0798978..d953b1d2 100644 --- a/src/Service/ShopContent/ThemesService.php +++ b/src/Service/ShopContent/ThemesService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/TranslationsService.php b/src/Service/ShopContent/TranslationsService.php index c07274d1..a035fe01 100644 --- a/src/Service/ShopContent/TranslationsService.php +++ b/src/Service/ShopContent/TranslationsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index ccfc3232..29edefe2 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index 1dbae3ce..0327dbd2 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 30aed5ff..2c367962 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Service; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 1e10c7fc..80e7cd26 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\Module\PsEventbus\Traits; diff --git a/translations/en.php b/translations/en.php index 59bebffa..811bb906 100644 --- a/translations/en.php +++ b/translations/en.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ global $_MODULE; diff --git a/translations/es.php b/translations/es.php index 099f790e..e5a9d557 100644 --- a/translations/es.php +++ b/translations/es.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ global $_MODULE; diff --git a/translations/fr.php b/translations/fr.php index 3b321736..bf8693f5 100644 --- a/translations/fr.php +++ b/translations/fr.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ global $_MODULE; diff --git a/translations/it.php b/translations/it.php index b72aa739..b1f0cf60 100644 --- a/translations/it.php +++ b/translations/it.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ global $_MODULE; diff --git a/upgrade/Upgrade-1.10.0.php b/upgrade/Upgrade-1.10.0.php index cf9e4216..7ef36e4f 100644 --- a/upgrade/Upgrade-1.10.0.php +++ b/upgrade/Upgrade-1.10.0.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.10.3.php b/upgrade/Upgrade-1.10.3.php index dc8741be..228f79b5 100644 --- a/upgrade/Upgrade-1.10.3.php +++ b/upgrade/Upgrade-1.10.3.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.10.7.php b/upgrade/Upgrade-1.10.7.php index c4cd2710..ab10f02a 100644 --- a/upgrade/Upgrade-1.10.7.php +++ b/upgrade/Upgrade-1.10.7.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.10.8.php b/upgrade/Upgrade-1.10.8.php index c4e0cce6..2c67432f 100644 --- a/upgrade/Upgrade-1.10.8.php +++ b/upgrade/Upgrade-1.10.8.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.3.7.php b/upgrade/Upgrade-1.3.7.php index 38a2cd64..57d5a054 100644 --- a/upgrade/Upgrade-1.3.7.php +++ b/upgrade/Upgrade-1.3.7.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.5.1.php b/upgrade/Upgrade-1.5.1.php index 312bd4e3..cc577a95 100644 --- a/upgrade/Upgrade-1.5.1.php +++ b/upgrade/Upgrade-1.5.1.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.5.2.php b/upgrade/Upgrade-1.5.2.php index cc761d37..7168e3f5 100644 --- a/upgrade/Upgrade-1.5.2.php +++ b/upgrade/Upgrade-1.5.2.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.6.9.php b/upgrade/Upgrade-1.6.9.php index c5e9c749..5035670b 100644 --- a/upgrade/Upgrade-1.6.9.php +++ b/upgrade/Upgrade-1.6.9.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.7.1.php b/upgrade/Upgrade-1.7.1.php index 36a7b664..04df0964 100644 --- a/upgrade/Upgrade-1.7.1.php +++ b/upgrade/Upgrade-1.7.1.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.7.11.php b/upgrade/Upgrade-1.7.11.php index 898c34ac..4364d5ac 100644 --- a/upgrade/Upgrade-1.7.11.php +++ b/upgrade/Upgrade-1.7.11.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.7.15.php b/upgrade/Upgrade-1.7.15.php index e8cc4d03..217fc9a0 100644 --- a/upgrade/Upgrade-1.7.15.php +++ b/upgrade/Upgrade-1.7.15.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.7.2.php b/upgrade/Upgrade-1.7.2.php index 77c6bd7a..f546b7ec 100644 --- a/upgrade/Upgrade-1.7.2.php +++ b/upgrade/Upgrade-1.7.2.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.8.1.php b/upgrade/Upgrade-1.8.1.php index 4005a56a..7cf3e632 100644 --- a/upgrade/Upgrade-1.8.1.php +++ b/upgrade/Upgrade-1.8.1.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.9.3.php b/upgrade/Upgrade-1.9.3.php index 4c26dbb7..907cd115 100644 --- a/upgrade/Upgrade-1.9.3.php +++ b/upgrade/Upgrade-1.9.3.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-1.9.7.php b/upgrade/Upgrade-1.9.7.php index 5bf2ea51..a376e878 100644 --- a/upgrade/Upgrade-1.9.7.php +++ b/upgrade/Upgrade-1.9.7.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-2.1.0.php b/upgrade/Upgrade-2.1.0.php index 3a1a2583..09daa220 100644 --- a/upgrade/Upgrade-2.1.0.php +++ b/upgrade/Upgrade-2.1.0.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-2.3.0.php b/upgrade/Upgrade-2.3.0.php index b354f786..5667c050 100644 --- a/upgrade/Upgrade-2.3.0.php +++ b/upgrade/Upgrade-2.3.0.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-2.3.2.php b/upgrade/Upgrade-2.3.2.php index 975dc718..18e110e2 100644 --- a/upgrade/Upgrade-2.3.2.php +++ b/upgrade/Upgrade-2.3.2.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-3.0.0.php b/upgrade/Upgrade-3.0.0.php index fa7f8b5b..50e275cd 100644 --- a/upgrade/Upgrade-3.0.0.php +++ b/upgrade/Upgrade-3.0.0.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-3.0.12.php b/upgrade/Upgrade-3.0.12.php index e8a84a76..28310cd1 100644 --- a/upgrade/Upgrade-3.0.12.php +++ b/upgrade/Upgrade-3.0.12.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-3.0.13.php b/upgrade/Upgrade-3.0.13.php index ab5bb061..6d2befa8 100644 --- a/upgrade/Upgrade-3.0.13.php +++ b/upgrade/Upgrade-3.0.13.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-3.0.5.php b/upgrade/Upgrade-3.0.5.php index 1f09d410..47a2ef1b 100644 --- a/upgrade/Upgrade-3.0.5.php +++ b/upgrade/Upgrade-3.0.5.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index 38a48e36..63d45366 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -5,17 +5,23 @@ * * NOTICE OF LICENSE * - * This source file is subject to the Academic Free License version 3.0 + * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 + * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer + * versions in the future. If you wish to customize PrestaShop for your + * needs please refer to https://devdocs.prestashop.com/ for more information. + * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; From 0ac7cfa46efa26f1860ccfc1bf68a896e2d370c1 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 15:27:40 +0200 Subject: [PATCH 122/162] fix: cut api --- e2e-env/README.md | 4 ++-- e2e-env/docker-compose.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-env/README.md b/e2e-env/README.md index bff42189..6a78f769 100644 --- a/e2e-env/README.md +++ b/e2e-env/README.md @@ -54,13 +54,13 @@ Simple! Is the module healthy? ```sh -curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-1" | jq . +curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck&job_id=valid-job-1" | jq . ``` Capture orders: ```sh -curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=orders&job_id=valid-job-1" | jq . +curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=orders&job_id=valid-job-1" | jq . ``` ## Make changes to the mock diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index f724d11f..5aa4306c 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -12,7 +12,7 @@ services: "-sI", "-H", "Host: localhost:8000", - "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=healthcheck", + "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck", ] interval: 30s volumes: From 021f95da690b0f995cd47335e98bb63514325259 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 15:27:51 +0200 Subject: [PATCH 123/162] fix: cut api --- README.md | 30 ++++---- config/front/services.yml | 12 +-- controllers/front/apiHealthCheck.php | 55 ++++++++++++++ .../{apiFront.php => apiShopContent.php} | 24 ++++-- e2e/README.md | 4 +- e2e/src/full-sync.spec.ts | 2 +- e2e/src/helpers/data-helper.ts | 2 +- e2e/src/helpers/mock-probe.ts | 2 +- e2e/src/job-id-validation.spec.ts | 2 +- src/Config/Config.php | 4 +- src/Service/ApiAuthorizationService.php | 73 +++++++++++++++++-- ...kService.php => ApiHealthCheckService.php} | 13 +++- ...iService.php => ApiShopContentService.php} | 68 +---------------- src/Service/SynchronizationService.php | 4 +- 14 files changed, 181 insertions(+), 114 deletions(-) create mode 100644 controllers/front/apiHealthCheck.php rename controllers/front/{apiFront.php => apiShopContent.php} (76%) rename src/Service/{HealthCheckService.php => ApiHealthCheckService.php} (93%) rename src/Service/{FrontApiService.php => ApiShopContentService.php} (74%) diff --git a/README.md b/README.md index 92aae567..a7683039 100644 --- a/README.md +++ b/README.md @@ -7,24 +7,24 @@ ## Compatibility matrix | PrestaShop platform | PHP | PS EventBus | -| ------------------- | ---- | ----------- | -| 8.0 | 7.1+ | From 2.x | -| 1.7.3-1.7.8 | 7.1+ | From 2.x | -| 1.6.1.11 - 1.7.2.5 | 7.1 | From 3.1 | - -## BREAKING CHANGES - -### Front controllers and API endpoints -Depuis la version 4.0, tout les endpoints API sont regroupé sous un seul controller "apiFront.php". La route a appeller est donc maintenant unique, et le shopContent n'est plus un endpoint en particulier, mais un paramètre query de la requête (ex: "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healtcheck") +| ------------------- | ---- | ----------------------- | +| 8.0 | 7.1+ | From 2.x - to latest | +| 1.7.3-1.7.8 | 7.1+ | From 2.x - to latest | +| 1.6.1.11 - 1.7.2.5 | 7.1 | From 3.1 - to latest | PS Accounts compatibility matrix [can be viewed here](https://github.com/PrestaShopCorp/ps_accounts#compatibility-matrix). -### Product Images Issue in PHP 8.1 +#### Product Images Issue in PHP 8.1 Please note that starting from PHP 8.1, product images may be missing due to a known issue. This is a recognized problem and is being tracked in the PrestaShop repository. You can follow the progress and find more details about the resolution [here](https://github.com/PrestaShop/PrestaShop/issues/36836). +### BREAKING CHANGES + +Since version 4.0, all API endpoints are grouped under a single controller "apiShopContent.php" (except for the healthcheck). The route to call is now unique, and the shopContent is no longer a specific endpoint but a query parameter of the request: +```"http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=products"``` + ## Use ```sh @@ -56,7 +56,7 @@ To check the module healthiness (authenticated route): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront&shop_content=healthcheck&job_id=valid-job-stuff" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck&job_id=valid-job-stuff" | jq . { "prestashop_version": "1.6.1.24", "ps_eventbus_version": "0.0.0", @@ -77,7 +77,7 @@ To check the fallback route (unauthenticated): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=healthcheck" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck" | jq . { "ps_account": true, "is_valid_jwt": true, @@ -147,7 +147,7 @@ Run the tests once to generate the necessary dumps (they will be present in the You can run the tests again and ensure everything is green. -In case your shopContent cannot return results (absence of data in the tables), please add a planes.json file in the folders of each version containing an empty array. +In case your shopContent cannot return results (missing data in the tables), please add a planes.json file in the folders of each version containing an empty array. ### List of missing data in a database and why is missing @@ -171,9 +171,9 @@ In case your shopContent cannot return results (absence of data in the tables), ² Feature enabled only with PsFacebook module ### Debugging -There are 3 variables that are passed "magically" from the apiFront file to the end of the chain (repositories and errorHandler): +There are 3 variables that are passed globally from the apiShopContent file to the end of the chain (repositories and errorHandler): - PS_EVENTBUS_EXPLAIN_SQL_ENABLED - PS_EVENTBUS_VERBOSE_ENABLED - PS_EVENTBUS_LOGS_ENABLED -These variables are defined via the PHP function define() and reused in the files mentioned above. The reason for this usage is to avoid having to pass these variables through the entire execution chain to retrieve them at the end of the chain (e.g., apiFront => frontService => shopContentService => shopContentRepository). +These variables are defined via the PHP function define() and reused in the files mentioned above. The reason for this usage is to avoid having to pass these variables through the entire execution chain to retrieve them at the end of the chain (e.g., apiShopContent => frontService => shopContentService => shopContentRepository). diff --git a/config/front/services.yml b/config/front/services.yml index 760dcb69..fa46fbf0 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -10,6 +10,8 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Api\SyncApiClient' + - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' + - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' PrestaShop\Module\PsEventbus\Service\SynchronizationService: class: PrestaShop\Module\PsEventbus\Service\SynchronizationService @@ -27,24 +29,24 @@ services: class: PrestaShop\Module\PsEventbus\Service\PresenterService public: true - PrestaShop\Module\PsEventbus\Service\FrontApiService: - class: PrestaShop\Module\PsEventbus\Service\FrontApiService + PrestaShop\Module\PsEventbus\Service\ApiShopContentService: + class: PrestaShop\Module\PsEventbus\Service\ApiShopContentService public: true arguments: - '@ps_eventbus' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - '@PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService' - '@PrestaShop\Module\PsEventbus\Service\SynchronizationService' - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - PrestaShop\Module\PsEventbus\Service\HealthCheckService: - class: PrestaShop\Module\PsEventbus\Service\HealthCheckService + PrestaShop\Module\PsEventbus\Service\ApiHealthCheckService: + class: PrestaShop\Module\PsEventbus\Service\ApiHealthCheckService public: true arguments: - '@ps_eventbus' - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' + - '@PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - '%ps_eventbus.sync_api_url%' - '%ps_eventbus.live_sync_api_url%' diff --git a/controllers/front/apiHealthCheck.php b/controllers/front/apiHealthCheck.php new file mode 100644 index 00000000..bfef183b --- /dev/null +++ b/controllers/front/apiHealthCheck.php @@ -0,0 +1,55 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +use PrestaShop\Module\PsEventbus\Service\CommonService; +use PrestaShop\Module\PsEventbus\Service\ApiHealthCheckService; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class ps_EventbusApiHealthCheckModuleFrontController extends ModuleFrontController +{ + /** + * @return void + * + * @throws\PrestaShopException + */ + public function postProcess() + { + /** @var string $jobId */ + $jobId = Tools::getValue('job_id'); + + /** @var Ps_eventbus $module */ + $module = Module::getInstanceByName('ps_eventbus'); + + /** @var ApiHealthCheckService $apiHealthCheckService */ + $apiHealthCheckService = $module->getService('PrestaShop\Module\PsEventbus\Service\ApiHealthCheckService'); + $response = $apiHealthCheckService->getHealthCheck($jobId); + + CommonService::exitWithResponse($response); + } +} diff --git a/controllers/front/apiFront.php b/controllers/front/apiShopContent.php similarity index 76% rename from controllers/front/apiFront.php rename to controllers/front/apiShopContent.php index 3ff0f9f9..b44e5dbb 100644 --- a/controllers/front/apiFront.php +++ b/controllers/front/apiShopContent.php @@ -24,13 +24,13 @@ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ -use PrestaShop\Module\PsEventbus\Service\FrontApiService; +use PrestaShop\Module\PsEventbus\Service\ApiShopContentService; if (!defined('_PS_VERSION_')) { exit; } -class ps_EventbusApiFrontModuleFrontController extends ModuleFrontController +class ps_EventbusApiShopContentModuleFrontController extends ModuleFrontController { /** * @return void @@ -66,18 +66,26 @@ public function postProcess() /** @var Ps_eventbus $module */ $module = Module::getInstanceByName('ps_eventbus'); - /** @var FrontApiService $frontApiService */ - $frontApiService = $module->getService('PrestaShop\Module\PsEventbus\Service\FrontApiService'); + /** @var ApiShopContentService $apiShopContentService */ + $apiShopContentService = $module->getService('PrestaShop\Module\PsEventbus\Service\ApiShopContentService'); // Define our 3 constants here to be retrieved later in the application (errorHandler, repositories) - define('PS_EVENTBUS_EXPLAIN_SQL_ENABLED', $explainSql); - define('PS_EVENTBUS_VERBOSE_ENABLED', $verbose); - define('PS_EVENTBUS_LOGS_ENABLED', $psLogsEnabled); + if (!defined('PS_EVENTBUS_EXPLAIN_SQL_ENABLED')) { + define('PS_EVENTBUS_EXPLAIN_SQL_ENABLED', $explainSql); + } + + if (!defined('PS_EVENTBUS_VERBOSE_ENABLED')) { + define('PS_EVENTBUS_VERBOSE_ENABLED', $verbose); + } + + if (!defined('PS_EVENTBUS_LOGS_ENABLED')) { + define('PS_EVENTBUS_LOGS_ENABLED', $psLogsEnabled); + } // edit shopContent for matching Config.php const $shopContentEdited = str_replace('-', '_', $shopContent); - $frontApiService->handleDataSync( + $apiShopContentService->handleDataSync( $shopContentEdited, $jobId, $langIso, diff --git a/e2e/README.md b/e2e/README.md index c0893217..e5dde583 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -18,12 +18,12 @@ import testConfig from './helpers/test.config'; import request from 'supertest'; const controller = 'categories'; -const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=${shopContent}&limit=5`; +const endpoint = `/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=${shopContent}&limit=5`; describe('CategoriesShopContent', () => { it(`${shopContent} should upload to collector`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=1&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; // jobId starting with "valid-job-" will be considered valid by the mock sync-api and will always return 201; // other values will be rejected by the mock const jobId = 'valid-job-1' diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 56784161..70c81276 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -51,7 +51,7 @@ describe("Full Sync", () => { describe.each(shopContentList)("%s", (shopContent) => { it(`${shopContent} should accept full sync`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const callId = { call_id: Math.random().toString(36).substring(2, 11) }; diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 6b43dc6d..af6e6a96 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -59,7 +59,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=healthcheck&job_id=valid-job-healthcheck`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=healthcheck&job_id=valid-job-healthcheck`, ); healthCheck = res.data; cachedHealthCheck = healthCheck; diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index 8c3ccddc..80001022 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -96,7 +96,7 @@ export function doFullSync( const requestNext = (full: number) => { return axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, callId, { headers: { diff --git a/e2e/src/job-id-validation.spec.ts b/e2e/src/job-id-validation.spec.ts index 53eecdb8..64bc02ee 100644 --- a/e2e/src/job-id-validation.spec.ts +++ b/e2e/src/job-id-validation.spec.ts @@ -22,7 +22,7 @@ describe("Reject invalid job-id", () => { async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiFront=0&shop_content=${shopContent}&limit=5&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=${shopContent}&limit=5&job_id=${jobId}`; const message$ = probe({ params: { id: jobId } }); //act diff --git a/src/Config/Config.php b/src/Config/Config.php index 71efd5e7..07ee9bc1 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -34,8 +34,8 @@ class Config { const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s'; - const RANDOM_SYNC_CHECK_MAX = 20; - const INCREMENTAL_SYNC_MAX_PAGE_SIZE = 10000; + const INCREMENTAL_SYNC_TABLE_SIZE_CHECK_MOD = 20; + const INCREMENTAL_SYNC_MAX_TABLE_SIZE = 100000; const SYNC_API_MAX_TIMEOUT = 5; const COLLECTOR_MAX_TIMEOUT = 30; diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index cb9a8606..4e7278a6 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -27,6 +27,9 @@ namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Api\SyncApiClient; +use PrestaShop\Module\PsEventbus\Exception\EnvVarException; +use PrestaShop\Module\PsEventbus\Exception\FirebaseException; +use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; if (!defined('_PS_VERSION_')) { @@ -35,22 +38,76 @@ class ApiAuthorizationService { - /** - * @var EventbusSyncRepository - */ + /** @var EventbusSyncRepository */ private $eventbusSyncRepository; - /** - * @var SyncApiClient - */ + /** @var SyncApiClient */ private $syncApiClient; + /** @var PsAccountsAdapterService */ + private $psAccountsAdapterService; + + /** @var ErrorHandler */ + private $errorHandler; + public function __construct( EventbusSyncRepository $eventbusSyncRepository, - SyncApiClient $syncApiClient + SyncApiClient $syncApiClient, + PsAccountsAdapterService $psAccountsAdapterService, + ErrorHandler $errorHandler ) { $this->eventbusSyncRepository = $eventbusSyncRepository; $this->syncApiClient = $syncApiClient; + $this->psAccountsAdapterService = $psAccountsAdapterService; + $this->errorHandler = $errorHandler; + } + + /** + * @param string $jobId + * @param bool $isHealthCheck + * + * @return bool + * + * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException + */ + public function authorize($jobId, $isHealthCheck) + { + try { + $authorizationResponse = $this->authorizeCall($jobId); + + if (is_array($authorizationResponse)) { + CommonService::exitWithResponse($authorizationResponse); + } elseif (!$authorizationResponse) { + throw new \PrestaShopDatabaseException('Failed saving job id to database'); + } + + try { + $token = $this->psAccountsAdapterService->getOrRefreshToken(); + } catch (\Exception $exception) { + throw new FirebaseException($exception->getMessage()); + } + + if (!$token) { + throw new FirebaseException('Invalid token'); + } + + return true; + } catch (\Exception $exception) { + // For ApiHealthCheck, handle the error, and return false + if ($isHealthCheck) { + return false; + } + + switch ($exception) { + case $exception instanceof \PrestaShopDatabaseException: + case $exception instanceof EnvVarException: + case $exception instanceof FirebaseException: + $this->errorHandler->handle($exception); + break; + } + + return false; + } } /** @@ -60,7 +117,7 @@ public function __construct( * * @return array|bool */ - public function authorizeCall($jobId) + private function authorizeCall($jobId) { // Check if the job already exists $job = $this->eventbusSyncRepository->findJobById($jobId); diff --git a/src/Service/HealthCheckService.php b/src/Service/ApiHealthCheckService.php similarity index 93% rename from src/Service/HealthCheckService.php rename to src/Service/ApiHealthCheckService.php index 3740d394..c15dc247 100644 --- a/src/Service/HealthCheckService.php +++ b/src/Service/ApiHealthCheckService.php @@ -32,7 +32,7 @@ exit; } -class HealthCheckService +class ApiHealthCheckService { /** @var \Ps_eventbus */ private $module; @@ -43,6 +43,9 @@ class HealthCheckService /** @var PsAccountsAdapterService */ private $psAccountsAdapterService; + /** @var ApiAuthorizationService */ + private $apiAuthorizationService; + /** @var array */ private $configuration; @@ -71,6 +74,7 @@ class HealthCheckService public function __construct( \Ps_eventbus $module, PsAccountsAdapterService $psAccountsAdapterService, + ApiAuthorizationService $apiAuthorizationService, ErrorHandler $errorHandler, $eventbusSyncApiUrl, $eventbusLiveSyncApiUrl, @@ -78,6 +82,7 @@ public function __construct( ) { $this->module = $module; $this->db = \Db::getInstance(); + $this->apiAuthorizationService = $apiAuthorizationService; $this->psAccountsAdapterService = $psAccountsAdapterService; $this->configuration = [ 'EVENT_BUS_SYNC_API_URL' => $eventbusSyncApiUrl, @@ -88,18 +93,20 @@ public function __construct( } /** - * @param bool $isAuthentified + * @param string $jobId * * @return array * * @throws \PrestaShopException */ - public function getHealthCheck($isAuthentified) + public function getHealthCheck($jobId) { $tokenValid = false; $tokenIsSet = false; $allTablesInstalled = false; + $isAuthentified = $this->apiAuthorizationService->authorize($jobId, false); + try { $token = $this->psAccountsAdapterService->getOrRefreshToken(); if ($token) { diff --git a/src/Service/FrontApiService.php b/src/Service/ApiShopContentService.php similarity index 74% rename from src/Service/FrontApiService.php rename to src/Service/ApiShopContentService.php index 15e57bc1..47325d46 100644 --- a/src/Service/FrontApiService.php +++ b/src/Service/ApiShopContentService.php @@ -40,7 +40,7 @@ exit; } -class FrontApiService +class ApiShopContentService { /** @var int */ public $startTime; @@ -51,9 +51,6 @@ class FrontApiService /** @var EventbusSyncRepository */ private $eventbusSyncRepository; - /** @var PsAccountsAdapterService */ - private $psAccountsAdapterService; - /** @var SynchronizationService */ private $synchronizationService; @@ -66,7 +63,6 @@ class FrontApiService public function __construct( \Ps_eventbus $module, ErrorHandler $errorHandler, - PsAccountsAdapterService $psAccountsAdapterService, ApiAuthorizationService $apiAuthorizationService, SynchronizationService $synchronizationService, EventbusSyncRepository $eventbusSyncRepository @@ -75,7 +71,6 @@ public function __construct( $this->module = $module; $this->errorHandler = $errorHandler; - $this->psAccountsAdapterService = $psAccountsAdapterService; $this->apiAuthorizationService = $apiAuthorizationService; $this->synchronizationService = $synchronizationService; $this->eventbusSyncRepository = $eventbusSyncRepository; @@ -101,18 +96,9 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync CommonService::exitWithExceptionMessage(new QueryParamsException('Invalid URL Parameters', Config::INVALID_URL_QUERY)); } - $isHealthCheck = $shopContent == Config::COLLECTION_HEALTHCHECK; - $isAuthentified = $this->authorize($jobId, $isHealthCheck); - $response = []; - - // If is healthcheck, return healthcheck response - if ($isHealthCheck) { - /** @var HealthCheckService $healthCheckService */ - $healthCheckService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\HealthCheckService'); - $response = $healthCheckService->getHealthCheck($isAuthentified); + $this->apiAuthorizationService->authorize($jobId, false); - CommonService::exitWithResponse($response); - } + $response = []; /** @var LanguagesService $languagesService */ $languagesService = $this->module->getService('PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService'); @@ -196,52 +182,4 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $this->errorHandler->handle($exception); } } - - /** - * @param string $jobId - * @param bool $isHealthCheck - * - * @return bool - * - * @throws \PrestaShopDatabaseException|EnvVarException|FirebaseException - */ - private function authorize($jobId, $isHealthCheck) - { - try { - $authorizationResponse = $this->apiAuthorizationService->authorizeCall($jobId); - - if (is_array($authorizationResponse)) { - CommonService::exitWithResponse($authorizationResponse); - } elseif (!$authorizationResponse) { - throw new \PrestaShopDatabaseException('Failed saving job id to database'); - } - - try { - $token = $this->psAccountsAdapterService->getOrRefreshToken(); - } catch (\Exception $exception) { - throw new FirebaseException($exception->getMessage()); - } - - if (!$token) { - throw new FirebaseException('Invalid token'); - } - - return true; - } catch (\Exception $exception) { - // For ApiHealthCheck, handle the error, and return false - if ($isHealthCheck) { - return false; - } - - switch ($exception) { - case $exception instanceof \PrestaShopDatabaseException: - case $exception instanceof EnvVarException: - case $exception instanceof FirebaseException: - $this->errorHandler->handle($exception); - break; - } - - return false; - } - } } diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 2c367962..34ba140a 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -265,11 +265,11 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, * When random number == 10, we count number of entry exist in database for this specific shop content * If count > 100 000, we removed all entry corresponding to this shop content, and we enable full sync for this */ - if (mt_rand() % Config::RANDOM_SYNC_CHECK_MAX == 0) { + if (mt_rand() % Config::INCREMENTAL_SYNC_TABLE_SIZE_CHECK_MOD == 0) { foreach ($contentTypesWithIds as $contentType => $contentIds) { $count = $this->incrementalSyncRepository->getIncrementalSyncObjectCountByType($contentType); - if ($count > Config::INCREMENTAL_SYNC_MAX_PAGE_SIZE) { + if ($count > Config::INCREMENTAL_SYNC_MAX_TABLE_SIZE) { $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); if ($hasDeleted) { From 750e4f8fc32f9aabfc315f62414a54b052d506aa Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 16:15:12 +0200 Subject: [PATCH 124/162] fix: php-cs-fixer --- README.md | 4 ++-- controllers/front/apiHealthCheck.php | 2 +- e2e-env/README.md | 2 +- e2e-env/docker-compose.yml | 2 +- e2e/src/helpers/data-helper.ts | 2 +- src/Api/SyncApiClient.php | 2 +- src/Config/Config.php | 1 - src/Service/ApiAuthorizationService.php | 6 +++--- src/Service/ApiShopContentService.php | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a7683039..a5ce09d8 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ To check the module healthiness (authenticated route): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck&job_id=valid-job-stuff" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-stuff" | jq . { "prestashop_version": "1.6.1.24", "ps_eventbus_version": "0.0.0", @@ -77,7 +77,7 @@ To check the fallback route (unauthenticated): ```sh BASE_URL="http://localhost:8000" -curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck" | jq . +curl -s -L "$BASE_URL/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck" | jq . { "ps_account": true, "is_valid_jwt": true, diff --git a/controllers/front/apiHealthCheck.php b/controllers/front/apiHealthCheck.php index bfef183b..867364b8 100644 --- a/controllers/front/apiHealthCheck.php +++ b/controllers/front/apiHealthCheck.php @@ -24,8 +24,8 @@ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ -use PrestaShop\Module\PsEventbus\Service\CommonService; use PrestaShop\Module\PsEventbus\Service\ApiHealthCheckService; +use PrestaShop\Module\PsEventbus\Service\CommonService; if (!defined('_PS_VERSION_')) { exit; diff --git a/e2e-env/README.md b/e2e-env/README.md index 6a78f769..388282ac 100644 --- a/e2e-env/README.md +++ b/e2e-env/README.md @@ -54,7 +54,7 @@ Simple! Is the module healthy? ```sh -curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck&job_id=valid-job-1" | jq . +curl -s "http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-1" | jq . ``` Capture orders: diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index 5aa4306c..32721fdd 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -12,7 +12,7 @@ services: "-sI", "-H", "Host: localhost:8000", - "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=healthcheck", + "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck", ] interval: 30s volumes: diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index af6e6a96..0556d045 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -59,7 +59,7 @@ export async function getShopHealthCheck(options?: { healthCheck = cachedHealthCheck; } else { const res = await axios.get( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=healthcheck&job_id=valid-job-healthcheck`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck&job_id=valid-job-healthcheck`, ); healthCheck = res.data; cachedHealthCheck = healthCheck; diff --git a/src/Api/SyncApiClient.php b/src/Api/SyncApiClient.php index 071d33a9..4b64bfe1 100644 --- a/src/Api/SyncApiClient.php +++ b/src/Api/SyncApiClient.php @@ -87,7 +87,7 @@ private function getClient($timeout = Config::SYNC_API_MAX_TIMEOUT) /** * @param string $jobId * - * @return array|bool + * @return array */ public function validateJobId($jobId) { diff --git a/src/Config/Config.php b/src/Config/Config.php index 07ee9bc1..8d8e1e42 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -72,7 +72,6 @@ class Config const COLLECTION_CUSTOM_PRODUCT_CARRIERS = 'custom_product_carriers'; const COLLECTION_DELETED = 'deleted'; const COLLECTION_EMPLOYEES = 'employees'; - const COLLECTION_HEALTHCHECK = 'healthcheck'; const COLLECTION_IMAGES = 'images'; const COLLECTION_IMAGE_TYPES = 'image_types'; const COLLECTION_LANGUAGES = 'languages'; diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index 4e7278a6..dcf7c139 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -75,7 +75,7 @@ public function authorize($jobId, $isHealthCheck) try { $authorizationResponse = $this->authorizeCall($jobId); - if (is_array($authorizationResponse)) { + if ($authorizationResponse) { CommonService::exitWithResponse($authorizationResponse); } elseif (!$authorizationResponse) { throw new \PrestaShopDatabaseException('Failed saving job id to database'); @@ -115,7 +115,7 @@ public function authorize($jobId, $isHealthCheck) * * @param string $jobId * - * @return array|bool + * @return bool */ private function authorizeCall($jobId) { @@ -129,7 +129,7 @@ private function authorizeCall($jobId) // Check the jobId validity to avoid Denial Of Service $jobValidationResponse = $this->syncApiClient->validateJobId($jobId); - if (!is_array($jobValidationResponse) || (int) $jobValidationResponse['httpCode'] !== 201) { + if ((int) $jobValidationResponse['httpCode'] !== 201) { return false; } diff --git a/src/Service/ApiShopContentService.php b/src/Service/ApiShopContentService.php index 47325d46..3cd78882 100644 --- a/src/Service/ApiShopContentService.php +++ b/src/Service/ApiShopContentService.php @@ -88,7 +88,7 @@ public function __construct( public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSyncRequested) { try { - if (!in_array($shopContent, array_merge(Config::SHOP_CONTENTS, [Config::COLLECTION_HEALTHCHECK]), true)) { + if (!in_array($shopContent, Config::SHOP_CONTENTS, true)) { CommonService::exitWithExceptionMessage(new QueryParamsException('404 - ShopContent not found', Config::INVALID_URL_QUERY)); } From 3c77ab5e5b44a8d99b7defa63100e236ef1a6f7d Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 18:20:19 +0200 Subject: [PATCH 125/162] fix: some problems after rework --- src/Handler/ErrorHandler/ErrorHandler.php | 17 +++++++++++++++-- src/Repository/AbstractRepository.php | 12 +++++++----- src/Repository/CarrierRepository.php | 2 +- src/Repository/CartProductRepository.php | 2 +- src/Repository/CartRepository.php | 2 +- src/Repository/CartRuleRepository.php | 2 +- src/Repository/CategoryRepository.php | 4 ++-- src/Repository/CountryRepository.php | 2 +- src/Repository/CurrencyRepository.php | 2 +- .../CustomProductCarrierRepository.php | 4 ++-- src/Repository/CustomerRepository.php | 2 +- src/Repository/EmployeeRepository.php | 2 +- src/Repository/ImageRepository.php | 2 +- src/Repository/ImageTypeRepository.php | 2 +- src/Repository/IncrementalSyncRepository.php | 2 +- src/Repository/LanguageRepository.php | 2 +- src/Repository/ManufacturerRepository.php | 2 +- src/Repository/ModuleRepository.php | 2 +- src/Repository/OrderCartRuleRepository.php | 2 +- src/Repository/OrderDetailRepository.php | 2 +- src/Repository/OrderHistoryRepository.php | 2 +- src/Repository/OrderRepository.php | 2 +- src/Repository/ProductBundleRepository.php | 2 +- src/Repository/ProductRepository.php | 12 ++++++------ src/Repository/ProductSupplierRepository.php | 2 +- src/Repository/SpecificPriceRepository.php | 4 ++-- src/Repository/StateRepository.php | 2 +- src/Repository/StockMovementRepository.php | 2 +- src/Repository/StockRepository.php | 4 ++-- src/Repository/StoreRepository.php | 2 +- src/Repository/SupplierRepository.php | 2 +- src/Repository/TaxeRepository.php | 2 +- src/Repository/TaxonomyRepository.php | 2 +- src/Repository/TranslationRepository.php | 2 +- src/Repository/WishlistProductRepository.php | 2 +- src/Repository/WishlistRepository.php | 2 +- src/Service/ApiAuthorizationService.php | 8 +++----- src/Service/ApiHealthCheckService.php | 2 +- 38 files changed, 69 insertions(+), 56 deletions(-) diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index cea9dfde..c71c1ccc 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -26,6 +26,7 @@ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; +use Context; use Exception; use PrestaShop\Module\PsEventbus\Service\CommonService; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; @@ -87,11 +88,23 @@ public function __construct(\Ps_eventbus $module, PsAccountsAdapterService $psAc */ public function handle($exception) { + $logsEnabled = false; + $verboseEnabled = false; + if (!$this->client) { return; } - if (defined(PS_EVENTBUS_LOGS_ENABLED) && PS_EVENTBUS_LOGS_ENABLED == true) { + if (defined('PS_EVENTBUS_VERBOSE_ENABLED')) { + $logsEnabled = PS_EVENTBUS_VERBOSE_ENABLED; + } + + if (defined('PS_EVENTBUS_VERBOSE_ENABLED')) { + $verboseEnabled = PS_EVENTBUS_VERBOSE_ENABLED; + } + + + if ($logsEnabled == true) { \PrestaShopLogger::addLog( $exception->getMessage() . ' : ' . $exception->getFile() . ':' . $exception->getLine() . ' | ' . $exception->getTraceAsString(), 3, @@ -103,7 +116,7 @@ public function handle($exception) } // if debug mode enabled and verbose set to true, print error in front office - if (_PS_MODE_DEV_ == true && (defined(PS_EVENTBUS_VERBOSE_ENABLED) && PS_EVENTBUS_VERBOSE_ENABLED == true)) { + if (_PS_MODE_DEV_ == true && $verboseEnabled == true) { throw $exception; } else { $this->client->captureException($exception); diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 7943544c..3198d071 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -111,20 +111,22 @@ public function getShopContext() } /** - * @param bool $enableCurrentExplain + * @param bool $disableCurrentExplain * * @return array * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - protected function runQuery($enableCurrentExplain = null) + protected function runQuery($disableCurrentExplain = null) { - if ($enableCurrentExplain === null) { - $enableCurrentExplain = true; + $explainSql = false; + + if (defined('PS_EVENTBUS_EXPLAIN_SQL_ENABLED')) { + $explainSql = PS_EVENTBUS_EXPLAIN_SQL_ENABLED; } - if ((defined(PS_EVENTBUS_EXPLAIN_SQL_ENABLED) && PS_EVENTBUS_EXPLAIN_SQL_ENABLED == true) && $enableCurrentExplain) { + if ($explainSql && $disableCurrentExplain == false) { $this->debugQuery(); } diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php index 38c0e552..974c67ef 100644 --- a/src/Repository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -120,7 +120,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/CartProductRepository.php b/src/Repository/CartProductRepository.php index 0cfc6dd3..1ae56288 100644 --- a/src/Repository/CartProductRepository.php +++ b/src/Repository/CartProductRepository.php @@ -116,7 +116,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/CartRepository.php b/src/Repository/CartRepository.php index 1b9d9623..6136c9c9 100644 --- a/src/Repository/CartRepository.php +++ b/src/Repository/CartRepository.php @@ -114,7 +114,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php index 51047b20..b9a76ff2 100644 --- a/src/Repository/CartRuleRepository.php +++ b/src/Repository/CartRuleRepository.php @@ -145,7 +145,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php index 6ebd64e6..42354496 100644 --- a/src/Repository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -130,7 +130,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } @@ -159,6 +159,6 @@ public function getCategoriesWithParentInfo($langId, $shopId) ->select('c.id_parent') ; - return $this->runQuery(false); + return $this->runQuery(true); } } diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index f765d84f..e5381906 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -66,7 +66,7 @@ public function getCountyIsoCodesByZoneId($zoneId, $active) $this->query->select('iso_code'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); foreach ($result as $country) { $isoCodes[] = $country['iso_code']; diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php index 8aec00ba..c8862d0d 100644 --- a/src/Repository/CurrencyRepository.php +++ b/src/Repository/CurrencyRepository.php @@ -129,7 +129,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/CustomProductCarrierRepository.php b/src/Repository/CustomProductCarrierRepository.php index a1d3d82d..7fdc75c2 100644 --- a/src/Repository/CustomProductCarrierRepository.php +++ b/src/Repository/CustomProductCarrierRepository.php @@ -110,7 +110,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } @@ -132,6 +132,6 @@ public function getCustomProductCarrierIdsByCarrierId($idProduct) ->where('pc.id_shop = ' . parent::getShopContext()->id) ; - return $this->runQuery(false); + return $this->runQuery(true); } } diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index 9ad61d71..3e9b57ac 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -122,7 +122,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php index b75986f7..62e088ca 100644 --- a/src/Repository/EmployeeRepository.php +++ b/src/Repository/EmployeeRepository.php @@ -136,7 +136,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/ImageRepository.php b/src/Repository/ImageRepository.php index e2b1ba26..7a23e839 100644 --- a/src/Repository/ImageRepository.php +++ b/src/Repository/ImageRepository.php @@ -120,7 +120,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php index 2d28044b..2b3f70c1 100644 --- a/src/Repository/ImageTypeRepository.php +++ b/src/Repository/ImageTypeRepository.php @@ -118,7 +118,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 8fc5aac6..3d95d75c 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -145,7 +145,7 @@ public function getIncrementalSyncObjectIds($type, $langIso, $limit) $this->query->select('eis.id_object'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); if (!empty($result)) { return array_map(function ($object) { diff --git a/src/Repository/LanguageRepository.php b/src/Repository/LanguageRepository.php index e3aaf6e9..eccc980f 100644 --- a/src/Repository/LanguageRepository.php +++ b/src/Repository/LanguageRepository.php @@ -125,7 +125,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 60de2b69..19df7120 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -125,7 +125,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php index c957ca83..e2190669 100644 --- a/src/Repository/ModuleRepository.php +++ b/src/Repository/ModuleRepository.php @@ -131,7 +131,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php index 7ae1b182..6c256e57 100644 --- a/src/Repository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -119,7 +119,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/OrderDetailRepository.php b/src/Repository/OrderDetailRepository.php index 0b4329d6..5f203305 100644 --- a/src/Repository/OrderDetailRepository.php +++ b/src/Repository/OrderDetailRepository.php @@ -143,7 +143,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderHistoryRepository.php index 820eeb6c..07a74cfb 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderHistoryRepository.php @@ -127,7 +127,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php index d916ad77..f7a374be 100644 --- a/src/Repository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -173,7 +173,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/ProductBundleRepository.php b/src/Repository/ProductBundleRepository.php index 41bbffeb..216cd3fb 100644 --- a/src/Repository/ProductBundleRepository.php +++ b/src/Repository/ProductBundleRepository.php @@ -124,7 +124,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index 067abdbb..05acb8f4 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -192,7 +192,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } @@ -225,7 +225,7 @@ public function getProductAttributeValues($attributeIds, $langIso) ->select('al.name as value') ; - $attributes = $this->runQuery(false); + $attributes = $this->runQuery(true); $resultArray = []; @@ -262,7 +262,7 @@ public function getProductFeatures($productIds, $langIso) ->select('fvl.value') ; - $features = $this->runQuery(false); + $features = $this->runQuery(true); $resultArray = []; @@ -293,7 +293,7 @@ public function getProductImages($productIds) ->select('IFNULL(imgs.cover, 0) as cover') ; - return $this->runQuery(false); + return $this->runQuery(true); } /** @@ -316,7 +316,7 @@ public function getAttributeImages($attributeIds) ->select('id_image') ; - return $this->runQuery(false); + return $this->runQuery(true); } /** @@ -354,6 +354,6 @@ public function getProductPriceAndDeclinations($productId) $this->query->select('0 as id_product_attribute'); } - return $this->runQuery(false); + return $this->runQuery(true); } } diff --git a/src/Repository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php index 5b0efb5c..1f35e561 100644 --- a/src/Repository/ProductSupplierRepository.php +++ b/src/Repository/ProductSupplierRepository.php @@ -116,7 +116,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index 78999b2f..c43110a5 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -134,7 +134,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } @@ -176,6 +176,6 @@ public function getSpecificPriceById($specificPriceId) ->select('sp.id_cart') // different ; - return $this->runQuery(false); + return $this->runQuery(true); } } diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index 9abb6467..75d65855 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -63,7 +63,7 @@ public function getStateIsoCodesByZoneId($zoneId, $active) $this->query->select('s.iso_code'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); foreach ($result as $state) { $isoCodes[] = $state['iso_code']; diff --git a/src/Repository/StockMovementRepository.php b/src/Repository/StockMovementRepository.php index cf2fd54a..921fed08 100644 --- a/src/Repository/StockMovementRepository.php +++ b/src/Repository/StockMovementRepository.php @@ -131,7 +131,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index 746e4459..bedbd977 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -132,7 +132,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } @@ -155,7 +155,7 @@ public function getStockIdByProductId($productId) ->where('sa.id_shop = ' . (int) parent::getShopContext()->id) ; - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['id_stock_available']; } diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index f4564ad8..b2834968 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -147,7 +147,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index 38a4cfc8..912b58cc 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -127,7 +127,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php index 14de8c10..535fd0b2 100644 --- a/src/Repository/TaxeRepository.php +++ b/src/Repository/TaxeRepository.php @@ -78,7 +78,7 @@ public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active) ->select('GROUP_CONCAT(s.iso_code SEPARATOR ",") as state_iso_code') ; - $this->countryIsoCodeCache[$cacheKey] = $this->runQuery(false); + $this->countryIsoCodeCache[$cacheKey] = $this->runQuery(true); } return $this->countryIsoCodeCache[$cacheKey]; diff --git a/src/Repository/TaxonomyRepository.php b/src/Repository/TaxonomyRepository.php index b7c793e4..96153e87 100644 --- a/src/Repository/TaxonomyRepository.php +++ b/src/Repository/TaxonomyRepository.php @@ -123,7 +123,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 73f2782a..590fbd24 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -115,7 +115,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php index 05b65494..df4524fc 100644 --- a/src/Repository/WishlistProductRepository.php +++ b/src/Repository/WishlistProductRepository.php @@ -125,7 +125,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php index f08285bc..c0caf6db 100644 --- a/src/Repository/WishlistRepository.php +++ b/src/Repository/WishlistRepository.php @@ -131,7 +131,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); - $result = $this->runQuery(false); + $result = $this->runQuery(true); return $result[0]['count']; } diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index dcf7c139..eb743860 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -75,9 +75,7 @@ public function authorize($jobId, $isHealthCheck) try { $authorizationResponse = $this->authorizeCall($jobId); - if ($authorizationResponse) { - CommonService::exitWithResponse($authorizationResponse); - } elseif (!$authorizationResponse) { + if (!$authorizationResponse) { throw new \PrestaShopDatabaseException('Failed saving job id to database'); } @@ -121,11 +119,11 @@ private function authorizeCall($jobId) { // Check if the job already exists $job = $this->eventbusSyncRepository->findJobById($jobId); - + if ($job) { return true; } - + // Check the jobId validity to avoid Denial Of Service $jobValidationResponse = $this->syncApiClient->validateJobId($jobId); diff --git a/src/Service/ApiHealthCheckService.php b/src/Service/ApiHealthCheckService.php index c15dc247..e9769e2f 100644 --- a/src/Service/ApiHealthCheckService.php +++ b/src/Service/ApiHealthCheckService.php @@ -105,7 +105,7 @@ public function getHealthCheck($jobId) $tokenIsSet = false; $allTablesInstalled = false; - $isAuthentified = $this->apiAuthorizationService->authorize($jobId, false); + $isAuthentified = $this->apiAuthorizationService->authorize($jobId, true); try { $token = $this->psAccountsAdapterService->getOrRefreshToken(); From 47bf9a6426613ced9b9d09e025b9b4d247bb6e18 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 18:23:14 +0200 Subject: [PATCH 126/162] fix: bug --- e2e/src/full-sync.spec.ts | 2 +- e2e/src/helpers/mock-probe.ts | 2 +- e2e/src/job-id-validation.spec.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 70c81276..65c0eb3e 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -51,7 +51,7 @@ describe("Full Sync", () => { describe.each(shopContentList)("%s", (shopContent) => { it(`${shopContent} should accept full sync`, async () => { // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; const callId = { call_id: Math.random().toString(36).substring(2, 11) }; diff --git a/e2e/src/helpers/mock-probe.ts b/e2e/src/helpers/mock-probe.ts index 80001022..69e9b4ed 100644 --- a/e2e/src/helpers/mock-probe.ts +++ b/e2e/src/helpers/mock-probe.ts @@ -96,7 +96,7 @@ export function doFullSync( const requestNext = (full: number) => { return axios.post( - `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, + `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=${shopContent}&limit=5&full=${full}&job_id=${jobId}`, callId, { headers: { diff --git a/e2e/src/job-id-validation.spec.ts b/e2e/src/job-id-validation.spec.ts index 64bc02ee..3a6f6339 100644 --- a/e2e/src/job-id-validation.spec.ts +++ b/e2e/src/job-id-validation.spec.ts @@ -22,7 +22,7 @@ describe("Reject invalid job-id", () => { async (shopContent) => { expect.assertions(6); // arrange - const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent=0&shop_content=${shopContent}&limit=5&job_id=${jobId}`; + const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=${shopContent}&limit=5&job_id=${jobId}`; const message$ = probe({ params: { id: jobId } }); //act From 891bad500c93ed9da47f329e11f1543e6d6fb563 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 18:24:04 +0200 Subject: [PATCH 127/162] fix: php-cs-fixer --- src/Handler/ErrorHandler/ErrorHandler.php | 4 +--- src/Service/ApiAuthorizationService.php | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index c71c1ccc..0b6329f7 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -26,7 +26,6 @@ namespace PrestaShop\Module\PsEventbus\Handler\ErrorHandler; -use Context; use Exception; use PrestaShop\Module\PsEventbus\Service\CommonService; use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService; @@ -90,7 +89,7 @@ public function handle($exception) { $logsEnabled = false; $verboseEnabled = false; - + if (!$this->client) { return; } @@ -103,7 +102,6 @@ public function handle($exception) $verboseEnabled = PS_EVENTBUS_VERBOSE_ENABLED; } - if ($logsEnabled == true) { \PrestaShopLogger::addLog( $exception->getMessage() . ' : ' . $exception->getFile() . ':' . $exception->getLine() . ' | ' . $exception->getTraceAsString(), diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index eb743860..dcf5ed5d 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -119,11 +119,11 @@ private function authorizeCall($jobId) { // Check if the job already exists $job = $this->eventbusSyncRepository->findJobById($jobId); - + if ($job) { return true; } - + // Check the jobId validity to avoid Denial Of Service $jobValidationResponse = $this->syncApiClient->validateJobId($jobId); From 026b1e1835c826be33385e86ad77a17194be3829 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 10 Oct 2024 18:25:42 +0200 Subject: [PATCH 128/162] fix: readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5ce09d8..0ae17997 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ You can follow the progress and find more details about the resolution [here](ht ### BREAKING CHANGES Since version 4.0, all API endpoints are grouped under a single controller "apiShopContent.php" (except for the healthcheck). The route to call is now unique, and the shopContent is no longer a specific endpoint but a query parameter of the request: -```"http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=products"``` +```http://localhost:8000/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=products``` ## Use From a7a9fc1137422947b420db6bdad271aa59c7a51b Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 11 Oct 2024 12:19:50 +0200 Subject: [PATCH 129/162] refactor: set mytuns to docker --- e2e-env/.env.dist | 2 ++ e2e-env/credentials.dist.json | 5 +++++ e2e-env/docker-compose.yml | 30 +++++++++++++++--------------- 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 e2e-env/credentials.dist.json diff --git a/e2e-env/.env.dist b/e2e-env/.env.dist index b99b0ede..d713ea4c 100644 --- a/e2e-env/.env.dist +++ b/e2e-env/.env.dist @@ -14,3 +14,5 @@ SYNC_API_PORT=3232 COLLECTOR_API_PORT=3333 LIVE_SYNC_API_PORT=3434 WS_PORT=8080 + +TUNNEL_NAME=replace-me.hostname.com diff --git a/e2e-env/credentials.dist.json b/e2e-env/credentials.dist.json new file mode 100644 index 00000000..56bef42e --- /dev/null +++ b/e2e-env/credentials.dist.json @@ -0,0 +1,5 @@ +{ + "AccountTag": "00000000000000000000000000000000", + "TunnelSecret": "ZWggbm9uIHBhcyBkZSBzZWNyZXQgaWNpLCBiaWVuIGVzc2F5w6k=", + "TunnelID": "00000000-0000-0000-0000-000000000000" +} diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index 32721fdd..b306e9e8 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -1,9 +1,12 @@ +version: "3" services: prestashop: image: ${DOCKER_IMAGE_PRESTASHOP:?See e2e-env/.env.dist} depends_on: mysql: condition: service_healthy + cloudflared: + condition: service_started healthcheck: test: [ @@ -22,15 +25,14 @@ services: # - /var/www/html/modules/ps_eventbus/vendor # - /var/www/html/modules/ps_eventbus/tools/vendor environment: - - PS_DOMAIN=localhost:8000 - ON_INIT_SCRIPT_FAILURE=fail - DEBUG_MODE=true - INIT_SCRIPTS_USER=root + - PS_DOMAIN=${TUNNEL_NAME} + - PS_PROTOCOL=https ports: - ${HOST_PORT_BIND_PRESTASHOP:?See e2e-env/.env.dist}:80 - networks: - - prestashop - + mysql: image: mariadb:${DOCKER_VERSION_MARIADB:?See e2e-env/.env.dist} healthcheck: @@ -44,8 +46,6 @@ services: - MYSQL_DATABASE=prestashop ports: - ${HOST_PORT_BIND_MYSQL:?See e2e-env/.env.dist}:3306 - networks: - - prestashop phpmyadmin: image: phpmyadmin:latest @@ -60,8 +60,6 @@ services: - PMA_USER=prestashop - PMA_PASSWORD=prestashop - MYSQL_ROOT_PASSWORD=prestashop - networks: - - prestashop cloudsync-mock: build: @@ -78,8 +76,6 @@ services: - ${COLLECTOR_API_PORT:?See e2e-env/.env.dist}:3333 - ${LIVE_SYNC_API_PORT:?See e2e-env/.env.dist}:3434 - ${WS_PORT:?See e2e-env/.env.dist}:8080 - networks: - - prestashop reverse-proxy: image: nginx:stable-alpine @@ -88,11 +84,15 @@ services: volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro,cached command: [nginx-debug, "-g", "daemon off;"] - networks: - - prestashop ports: - ${HOST_PORT_BIND_CLOUDSYNC_REVERSE_PROXY:?See e2e-env/.env.dist}:80 -networks: - prestashop: - driver: bridge + cloudflared: + image: cloudflare/cloudflared:latest + command: tunnel run $${TUNNEL_NAME} + environment: + - TUNNEL_CRED_FILE=/credentials.json + - TUNNEL_URL=http://prestashop:80 + - TUNNEL_HTTP_HOST_HEADER=${TUNNEL_NAME} + volumes: + - ./credentials.json:/credentials.json From b5677ea241c6e10e934f04f200251522fa913a1e Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 11 Oct 2024 15:15:35 +0200 Subject: [PATCH 130/162] fix: service not found in 1.6 --- .gitignore | 3 +++ config/common/repository.yml | 6 +++--- config/front/services.yml | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3ccb114b..a67af851 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ e2e/dumps sonar-project.properties *.cache + +### Mytuns +credentials.json diff --git a/config/common/repository.yml b/config/common/repository.yml index ef304052..43770398 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -3,7 +3,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@=service("ps_eventbus").getContext()' PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository @@ -19,7 +19,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\CountryRepository public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@=service("ps_eventbus").getContext()' PrestaShop\Module\PsEventbus\Repository\StateRepository: class: PrestaShop\Module\PsEventbus\Repository\StateRepository @@ -29,7 +29,7 @@ services: class: PrestaShop\Module\PsEventbus\Repository\TaxeRepository public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@=service("ps_eventbus").getContext()' PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository diff --git a/config/front/services.yml b/config/front/services.yml index fa46fbf0..f6b4ae76 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -205,7 +205,7 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ShopsService public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@=service("ps_eventbus").getContext()' - '@PrestaShop\Module\PsEventbus\Repository\ShopRepository' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CurrenciesService' @@ -251,7 +251,7 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ThemesService public: true arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' + - '@=service("ps_eventbus").getContext()' PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\TranslationsService From 5e47b5727794936a127c8adec76f7704495eead7 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 11 Oct 2024 15:19:54 +0200 Subject: [PATCH 131/162] fix: repair compat 1.6 with accounts --- src/Service/ApiHealthCheckService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Service/ApiHealthCheckService.php b/src/Service/ApiHealthCheckService.php index e9769e2f..a686999f 100644 --- a/src/Service/ApiHealthCheckService.php +++ b/src/Service/ApiHealthCheckService.php @@ -27,6 +27,7 @@ namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; +use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient; if (!defined('_PS_VERSION_')) { exit; @@ -110,7 +111,10 @@ public function getHealthCheck($jobId) try { $token = $this->psAccountsAdapterService->getOrRefreshToken(); if ($token) { - $accountsClient = $this->module->getService('PrestaShop\Module\PsAccounts\Api\Client\AccountsClient'); + $psAccount = \Module::getInstanceByName('ps_accounts'); + + /* @phpstan-ignore-next-line */ + $accountsClient = $psAccount->getService(AccountsClient::class); $tokenIsSet = true; From 43f73174ec044284933a13d67e0c61f5ce3d5b62 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 11 Oct 2024 15:27:50 +0200 Subject: [PATCH 132/162] fix: readme after review --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0ae17997..cc0ad59b 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ class PlanesService implements ShopContentServiceInterface ... } ``` +_Don't missing to declare this new service to [service.yml](config/front/services.yml) file._ Then create a repository PlaneRepository.php (in singular) in the [Repository](src/Repository/) folder that extends the [AbstractRepository.php](src/Repository/AbstractRepository.php) class and implements the [RepositoryInterface.php](src/Repository/RepositoryInterface.php) interface. Similarly, maintain consistency with other shop content repositories. ```PHP @@ -133,6 +134,7 @@ class PlaneRepository extends AbstractRepository implements RepositoryInterface ... } ``` +_Don't missing to declare this new repository to [repository.yml](config/common/repository.yml) file._ Add your shop content in the [e2e config file](e2e/src/helpers/shop-contents.ts). ```javascript From 7bf799f94bb3af24db40a30d0bbdae6e305e6aaf Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 11 Oct 2024 15:41:58 +0200 Subject: [PATCH 133/162] fix: php-stan and php-cs-fixer --- config/front/services.yml | 1 - src/Service/ApiHealthCheckService.php | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/config/front/services.yml b/config/front/services.yml index f6b4ae76..c58dd889 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -44,7 +44,6 @@ services: class: PrestaShop\Module\PsEventbus\Service\ApiHealthCheckService public: true arguments: - - '@ps_eventbus' - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - '@PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' diff --git a/src/Service/ApiHealthCheckService.php b/src/Service/ApiHealthCheckService.php index a686999f..ebea7a73 100644 --- a/src/Service/ApiHealthCheckService.php +++ b/src/Service/ApiHealthCheckService.php @@ -26,8 +26,8 @@ namespace PrestaShop\Module\PsEventbus\Service; -use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient; +use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; if (!defined('_PS_VERSION_')) { exit; @@ -35,9 +35,6 @@ class ApiHealthCheckService { - /** @var \Ps_eventbus */ - private $module; - /** @var \Db */ private $db; @@ -63,7 +60,6 @@ class ApiHealthCheckService ]; /** - * @param \Ps_eventbus $module * @param PsAccountsAdapterService $psAccountsAdapterService * @param ErrorHandler $errorHandler * @param string $eventbusSyncApiUrl @@ -73,7 +69,6 @@ class ApiHealthCheckService * @return void */ public function __construct( - \Ps_eventbus $module, PsAccountsAdapterService $psAccountsAdapterService, ApiAuthorizationService $apiAuthorizationService, ErrorHandler $errorHandler, @@ -81,7 +76,6 @@ public function __construct( $eventbusLiveSyncApiUrl, $eventbusProxyApiUrl ) { - $this->module = $module; $this->db = \Db::getInstance(); $this->apiAuthorizationService = $apiAuthorizationService; $this->psAccountsAdapterService = $psAccountsAdapterService; @@ -112,7 +106,7 @@ public function getHealthCheck($jobId) $token = $this->psAccountsAdapterService->getOrRefreshToken(); if ($token) { $psAccount = \Module::getInstanceByName('ps_accounts'); - + /* @phpstan-ignore-next-line */ $accountsClient = $psAccount->getService(AccountsClient::class); From 151606a3564fa56097d8a5fdf119c18e0b564c78 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Fri, 11 Oct 2024 18:33:05 +0200 Subject: [PATCH 134/162] fix: e2e test in 1.6 --- e2e/src/fixtures/1.6/carriers.json | 2 +- e2e/src/fixtures/1.6/order_histories.json | 135 ++++++++++++++++++ e2e/src/full-sync.spec.ts | 7 + ...r-status-history.ts => order-histories.ts} | 4 +- src/Repository/AbstractRepository.php | 21 ++- src/Repository/TranslationRepository.php | 10 ++ src/Repository/WishlistProductRepository.php | 17 +-- src/Repository/WishlistRepository.php | 17 +-- src/Service/ShopContent/ModulesService.php | 4 +- .../ShopContent/SpecificPricesService.php | 4 +- 10 files changed, 180 insertions(+), 41 deletions(-) create mode 100644 e2e/src/fixtures/1.6/order_histories.json rename e2e/src/type/{order-status-history.ts => order-histories.ts} (88%) diff --git a/e2e/src/fixtures/1.6/carriers.json b/e2e/src/fixtures/1.6/carriers.json index f125a26c..eeccf889 100644 --- a/e2e/src/fixtures/1.6/carriers.json +++ b/e2e/src/fixtures/1.6/carriers.json @@ -5,7 +5,7 @@ "properties": { "id_carrier": "1", "id_reference": "1", - "name": "PrestaShop", + "name": "0", "carrier_taxes_rates_group_id": "1", "url": "", "active": true, diff --git a/e2e/src/fixtures/1.6/order_histories.json b/e2e/src/fixtures/1.6/order_histories.json new file mode 100644 index 00000000..310f587e --- /dev/null +++ b/e2e/src/fixtures/1.6/order_histories.json @@ -0,0 +1,135 @@ +[ + { + "id": 1, + "collection": "order_histories", + "properties": { + "id_order_state": 1, + "id_order": 1, + "id_order_history": 1, + "name": "Awaiting check payment", + "template": "cheque", + "date_add": "2023-12-20T22:56:49+0100", + "is_validated": false, + "is_delivered": false, + "is_shipped": false, + "is_paid": false, + "is_deleted": false, + "created_at": "2023-12-20T22:56:49+0100", + "updated_at": "2023-12-20T22:56:49+0100" + } + }, + { + "id": 2, + "collection": "order_histories", + "properties": { + "id_order_state": 1, + "id_order": 2, + "id_order_history": 2, + "name": "Awaiting check payment", + "template": "cheque", + "date_add": "2023-12-20T22:56:49+0100", + "is_validated": false, + "is_delivered": false, + "is_shipped": false, + "is_paid": false, + "is_deleted": false, + "created_at": "2023-12-20T22:56:49+0100", + "updated_at": "2023-12-20T22:56:49+0100" + } + }, + { + "id": 3, + "collection": "order_histories", + "properties": { + "id_order_state": 1, + "id_order": 3, + "id_order_history": 3, + "name": "Awaiting check payment", + "template": "cheque", + "date_add": "2023-12-20T22:56:49+0100", + "is_validated": false, + "is_delivered": false, + "is_shipped": false, + "is_paid": false, + "is_deleted": false, + "created_at": "2023-12-20T22:56:49+0100", + "updated_at": "2023-12-20T22:56:49+0100" + } + }, + { + "id": 4, + "collection": "order_histories", + "properties": { + "id_order_state": 1, + "id_order": 4, + "id_order_history": 4, + "name": "Awaiting check payment", + "template": "cheque", + "date_add": "2023-12-20T22:56:49+0100", + "is_validated": false, + "is_delivered": false, + "is_shipped": false, + "is_paid": false, + "is_deleted": false, + "created_at": "2023-12-20T22:56:49+0100", + "updated_at": "2023-12-20T22:56:49+0100" + } + }, + { + "id": 5, + "collection": "order_histories", + "properties": { + "id_order_state": 10, + "id_order": 5, + "id_order_history": 5, + "name": "Awaiting bank wire payment", + "template": "bankwire", + "date_add": "2023-12-20T22:56:49+0100", + "is_validated": false, + "is_delivered": false, + "is_shipped": false, + "is_paid": false, + "is_deleted": false, + "created_at": "2023-12-20T22:56:49+0100", + "updated_at": "2023-12-20T22:56:49+0100" + } + }, + { + "id": 6, + "collection": "order_histories", + "properties": { + "id_order_state": 6, + "id_order": 1, + "id_order_history": 6, + "name": "Canceled", + "template": "order_canceled", + "date_add": "2023-12-20T22:56:49+0100", + "is_validated": false, + "is_delivered": false, + "is_shipped": false, + "is_paid": false, + "is_deleted": false, + "created_at": "2023-12-20T22:56:49+0100", + "updated_at": "2023-12-20T22:56:49+0100" + } + }, + { + "id": 7, + "collection": "order_histories", + "properties": { + "id_order_state": 8, + "id_order": 3, + "id_order_history": 7, + "name": "Payment error", + "template": "payment_error", + "date_add": "2023-12-20T22:56:49+0100", + "is_validated": false, + "is_delivered": false, + "is_shipped": false, + "is_paid": false, + "is_deleted": false, + "created_at": "2023-12-20T22:56:49+0100", + "updated_at": "2023-12-20T22:56:49+0100" + } + } +] diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 65c0eb3e..1234de97 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -21,6 +21,8 @@ const isString = (val) => val ? expect(val).toBeString() : expect(val).toBeNull(); const isNumber = (val) => val ? expect(val).toBeNumber() : expect(val).toBeNull(); +const isBoolean = (val) => + val ? expect(val).toBeBoolean() : expect(val).toBeNull(); const specialFieldAssert: { [index: string]: (val) => void } = { created_at: isDateString, updated_at: isDateString, @@ -36,6 +38,11 @@ const specialFieldAssert: { [index: string]: (val) => void } = { theme_version: isString, php_version: isString, http_server: isString, + cover: isString, + link: isString, + url: isString, + images: isString, + ssl: isBoolean }; describe("Full Sync", () => { diff --git a/e2e/src/type/order-status-history.ts b/e2e/src/type/order-histories.ts similarity index 88% rename from e2e/src/type/order-status-history.ts rename to e2e/src/type/order-histories.ts index 1bd46b21..4dac7526 100644 --- a/e2e/src/type/order-status-history.ts +++ b/e2e/src/type/order-histories.ts @@ -2,9 +2,9 @@ import fixture from "../fixtures/latest/order_histories.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars -const t: OrderHistory[] = fixture; +const t: OrderHistories[] = fixture; -export type OrderHistory = { +export type OrderHistories = { id: number; collection: string; properties: { diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 3198d071..eb5f8fe7 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -67,7 +67,7 @@ public function __construct() * * @return void */ - public function generateMinimalQuery($tableName, $alias) + protected function generateMinimalQuery($tableName, $alias) { $this->query = new \DbQuery(); @@ -77,7 +77,7 @@ public function generateMinimalQuery($tableName, $alias) /** * @return \Context */ - public function getContext() + protected function getContext() { return $this->context; } @@ -87,7 +87,7 @@ public function getContext() * * @throws \PrestaShopException */ - public function getLanguageContext() + protected function getLanguageContext() { if ($this->context->language === null) { throw new \PrestaShopException('No language context'); @@ -101,7 +101,7 @@ public function getLanguageContext() * * @throws \PrestaShopException */ - public function getShopContext() + protected function getShopContext() { if ($this->context->shop === null) { throw new \PrestaShopException('No shop context'); @@ -110,6 +110,19 @@ public function getShopContext() return $this->context->shop; } + /** + * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + protected function checkIfTableExist($query) + { + $request = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \''. $query . '\' LIMIT 1;'; + + return $this->db->executeS($request); + } + /** * @param bool $disableCurrentExplain * diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 590fbd24..74cdee52 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -70,6 +70,11 @@ public function generateFullQuery($langIso, $withSelecParameters) */ public function retrieveContentsForFull($offset, $limit, $langIso) { + // this table doesn't exist in the database before 1.7 + if (empty(parent::checkIfTableExist('%translation'))) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query->limit((int) $limit, (int) $offset); @@ -111,6 +116,11 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) */ public function countFullSyncContentLeft($offset, $limit, $langIso) { + // this table doesn't exist in the database before 1.7 + if (empty(parent::checkIfTableExist('%translation'))) { + return []; + } + $this->generateFullQuery($langIso, false); $this->query->select('(COUNT(*) - ' . (int) $offset . ') as count'); diff --git a/src/Repository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php index df4524fc..ef59c54f 100644 --- a/src/Repository/WishlistProductRepository.php +++ b/src/Repository/WishlistProductRepository.php @@ -71,7 +71,7 @@ public function generateFullQuery($langIso, $withSelecParameters) public function retrieveContentsForFull($offset, $limit, $langIso) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html - if (empty($this->checkIfPsWishlistIsInstalled())) { + if (empty(parent::checkIfTableExist('%wishlist'))) { return []; } @@ -117,7 +117,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) public function countFullSyncContentLeft($offset, $limit, $langIso) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html - if (empty($this->checkIfPsWishlistIsInstalled())) { + if (empty(parent::checkIfTableExist('%wishlist'))) { return 0; } @@ -129,17 +129,4 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) return $result[0]['count']; } - - /** - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopException - * @throws \PrestaShopDatabaseException - */ - private function checkIfPsWishlistIsInstalled() - { - $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%wishlist\' LIMIT 1;'; - - return $this->db->executeS($moduleisInstalledQuery); - } } diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php index c0caf6db..c6ddef26 100644 --- a/src/Repository/WishlistRepository.php +++ b/src/Repository/WishlistRepository.php @@ -77,7 +77,7 @@ public function generateFullQuery($langIso, $withSelecParameters) public function retrieveContentsForFull($offset, $limit, $langIso) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html - if (empty($this->checkIfPsWishlistIsInstalled())) { + if (empty(parent::checkIfTableExist('%wishlist'))) { return []; } @@ -123,7 +123,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) public function countFullSyncContentLeft($offset, $limit, $langIso) { // need this module for this table : https://addons.prestashop.com/en/undownloadable/9131-wishlist-block.html - if (empty($this->checkIfPsWishlistIsInstalled())) { + if (empty(parent::checkIfTableExist('%wishlist'))) { return 0; } @@ -135,17 +135,4 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) return $result[0]['count']; } - - /** - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopException - * @throws \PrestaShopDatabaseException - */ - private function checkIfPsWishlistIsInstalled() - { - $moduleisInstalledQuery = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'%wishlist\' LIMIT 1;'; - - return $this->db->executeS($moduleisInstalledQuery, false); - } } diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 26f58251..5414f1be 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -126,8 +126,8 @@ private function castModules(&$modules) foreach ($modules as &$module) { $module['module_id'] = (string) $module['module_id']; $module['active'] = $module['active'] == '1'; - $module['created_at'] = $module['created_at'] ?: $shopCreatedAt; - $module['updated_at'] = $module['updated_at'] ?: $shopCreatedAt; + $module['created_at'] = isset($module['created_at']) ? $module['created_at'] : $shopCreatedAt; + $module['updated_at'] = isset($module['updated_at']) ? $module['updated_at'] : $shopCreatedAt; } } } diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index 4cd770dd..c2f04811 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -186,8 +186,8 @@ private function castCustomPrices(&$customPrices) $customPrice['id_currency'] = (int) $customPrice['id_currency']; $customPrice['id_country'] = (int) $customPrice['id_country']; $customPrice['id_customer'] = (int) $customPrice['id_customer']; - $customPrice['currency'] = $customPrice['currency'] ?: 'ALL'; - $customPrice['country'] = $customPrice['country'] ?: 'ALL'; + $customPrice['currency'] = isset($customPrice['currency']) ? $customPrice['currency'] : 'ALL'; + $customPrice['country'] = isset($customPrice['country']) ? $customPrice['country'] : 'ALL'; $customPrice['price_tax_included'] = (float) $customPrice['price_tax_included']; $customPrice['price_tax_excluded'] = (float) $customPrice['price_tax_excluded']; $customPrice['sale_price_tax_incl'] = (float) $customPrice['sale_price_tax_incl']; From 34ff38443e624b3ed68f2bf4d1cf8a4465eb610d Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 16 Oct 2024 16:07:08 +0200 Subject: [PATCH 135/162] fix: e2e test --- e2e/src/full-sync.spec.ts | 10 +++++----- src/Repository/AbstractRepository.php | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 1234de97..90332f3a 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -56,7 +56,7 @@ describe("Full Sync", () => { }); describe.each(shopContentList)("%s", (shopContent) => { - it(`${shopContent} should accept full sync`, async () => { + it.skip(`${shopContent} should accept full sync`, async () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; @@ -87,9 +87,9 @@ describe("Full Sync", () => { it(`${shopContent} should upload complete dataset collector`, async () => { // arrange - const response$ = doFullSync(jobId, shopContent, { timeout: 4000 }); - const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); - + const response$ = doFullSync(jobId, shopContent, { timeout: 30000 }); + const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 30000 }); + // this combines each response from ps_eventbus to the last request captured by the probe. // it works because ps_eventbus sends a response after calling our mock collector server // if ps_eventbus doesn't need to call the collector, the probe completes without value after its timeout @@ -140,6 +140,6 @@ describe("Full Sync", () => { } } } - }); + }, 30000); }); }); diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index eb5f8fe7..e5041568 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -111,17 +111,17 @@ protected function getShopContext() } /** - * @return array|bool|\mysqli_result|\PDOStatement|resource|null - * - * @throws \PrestaShopException - * @throws \PrestaShopDatabaseException - */ + * @return array|bool|\mysqli_result|\PDOStatement|resource|null + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ protected function checkIfTableExist($query) - { - $request = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \''. $query . '\' LIMIT 1;'; + { + $request = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'' . $query . '\' LIMIT 1;'; - return $this->db->executeS($request); - } + return $this->db->executeS($request); + } /** * @param bool $disableCurrentExplain From 832cbb2d95f1a74ac7efacd55a90ae2a53686e85 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 16 Oct 2024 16:14:00 +0200 Subject: [PATCH 136/162] fix: e2e lint --- e2e/src/full-sync.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 90332f3a..4fc64a90 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -42,7 +42,7 @@ const specialFieldAssert: { [index: string]: (val) => void } = { link: isString, url: isString, images: isString, - ssl: isBoolean + ssl: isBoolean, }; describe("Full Sync", () => { @@ -89,7 +89,7 @@ describe("Full Sync", () => { // arrange const response$ = doFullSync(jobId, shopContent, { timeout: 30000 }); const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 30000 }); - + // this combines each response from ps_eventbus to the last request captured by the probe. // it works because ps_eventbus sends a response after calling our mock collector server // if ps_eventbus doesn't need to call the collector, the probe completes without value after its timeout From f97a802e0debecfe37187ae4c104380eb7216072 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 16 Oct 2024 16:16:58 +0200 Subject: [PATCH 137/162] chore: add comment --- e2e/src/full-sync.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 4fc64a90..c30de692 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -140,6 +140,6 @@ describe("Full Sync", () => { } } } - }, 30000); + }, 30000); // Timeout set to 30s because full sync can take a long time }); }); From 6569b429c7c87fcfd2995d83d4d0f65c8ad507db Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 16 Oct 2024 16:38:06 +0200 Subject: [PATCH 138/162] chore: update dockerfile and ci with profiles --- .github/workflows/build-release-publish.yml | 4 ++-- .github/workflows/quality-check.yml | 4 ++-- e2e-env/docker-compose.yml | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release-publish.yml b/.github/workflows/build-release-publish.yml index 382fd743..235f6386 100644 --- a/.github/workflows/build-release-publish.yml +++ b/.github/workflows/build-release-publish.yml @@ -61,7 +61,7 @@ jobs: run: | cp .env.dist .env docker compose build - docker compose up --detach --wait + docker compose --profile cicd up --detach --wait env: DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{matrix.ps_version}} working-directory: e2e-env @@ -74,7 +74,7 @@ jobs: if: failure() run: | docker compose logs cloudsync-mock - docker compose down -v + docker compose --profile cicd down -v working-directory: e2e-env upload_release_assets: diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index a82fd70e..2b713fb3 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -123,7 +123,7 @@ jobs: run: | cp .env.dist .env docker compose build - docker compose up --detach --wait + docker compose --profile cicd up --detach --wait env: DOCKER_IMAGE_PRESTASHOP: prestashop/prestashop-flashlight:${{matrix.ps_version}} working-directory: e2e-env @@ -136,7 +136,7 @@ jobs: if: failure() run: | docker compose logs cloudsync-mock prestashop - docker compose down -v + docker compose --profile cicd down -v working-directory: e2e-env e2e-lint: diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index b306e9e8..4fbcc4e1 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -5,8 +5,6 @@ services: depends_on: mysql: condition: service_healthy - cloudflared: - condition: service_started healthcheck: test: [ @@ -32,6 +30,7 @@ services: - PS_PROTOCOL=https ports: - ${HOST_PORT_BIND_PRESTASHOP:?See e2e-env/.env.dist}:80 + profiles: [cicd, development] mysql: image: mariadb:${DOCKER_VERSION_MARIADB:?See e2e-env/.env.dist} @@ -46,6 +45,7 @@ services: - MYSQL_DATABASE=prestashop ports: - ${HOST_PORT_BIND_MYSQL:?See e2e-env/.env.dist}:3306 + profiles: [cicd, development] phpmyadmin: image: phpmyadmin:latest @@ -60,6 +60,7 @@ services: - PMA_USER=prestashop - PMA_PASSWORD=prestashop - MYSQL_ROOT_PASSWORD=prestashop + profiles: [development] cloudsync-mock: build: @@ -76,6 +77,7 @@ services: - ${COLLECTOR_API_PORT:?See e2e-env/.env.dist}:3333 - ${LIVE_SYNC_API_PORT:?See e2e-env/.env.dist}:3434 - ${WS_PORT:?See e2e-env/.env.dist}:8080 + profiles: [cicd, development] reverse-proxy: image: nginx:stable-alpine @@ -86,6 +88,7 @@ services: command: [nginx-debug, "-g", "daemon off;"] ports: - ${HOST_PORT_BIND_CLOUDSYNC_REVERSE_PROXY:?See e2e-env/.env.dist}:80 + profiles: [cicd, development] cloudflared: image: cloudflare/cloudflared:latest @@ -96,3 +99,4 @@ services: - TUNNEL_HTTP_HOST_HEADER=${TUNNEL_NAME} volumes: - ./credentials.json:/credentials.json + profiles: [development] From a6d4d896a158647eef38e3947d013f3b99ad4b09 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 16 Oct 2024 16:49:32 +0200 Subject: [PATCH 139/162] fix: carrier details tests --- e2e/src/fixtures/1.6/carrier_details.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/e2e/src/fixtures/1.6/carrier_details.json b/e2e/src/fixtures/1.6/carrier_details.json index f6fa1176..02be9cbf 100644 --- a/e2e/src/fixtures/1.6/carrier_details.json +++ b/e2e/src/fixtures/1.6/carrier_details.json @@ -1,7 +1,7 @@ [ { - "collection": "carrier_details", "id": "2-1-range_weight-1", + "collection": "carrier_details", "properties": { "id_reference": "2", "id_zone": "1", @@ -14,5 +14,21 @@ "state_ids": "", "price": 5 } + }, + { + "id": "2-2-range_weight-1", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "2", + "id_range": "1", + "id_carrier_detail": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "", + "state_ids": "", + "price": 5 + } } ] From cfc26f4408c77bdbf2f0c4fdfa07cef6d54e03f3 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 16 Oct 2024 17:01:32 +0200 Subject: [PATCH 140/162] fix: e2e timeout --- e2e/src/full-sync.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index c30de692..6e5d259f 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -56,7 +56,7 @@ describe("Full Sync", () => { }); describe.each(shopContentList)("%s", (shopContent) => { - it.skip(`${shopContent} should accept full sync`, async () => { + it(`${shopContent} should accept full sync`, async () => { // arrange const url = `${testConfig.prestashopUrl}/index.php?fc=module&module=ps_eventbus&controller=apiShopContent&shop_content=${shopContent}&limit=5&full=1&job_id=${jobId}`; @@ -140,6 +140,6 @@ describe("Full Sync", () => { } } } - }, 30000); // Timeout set to 30s because full sync can take a long time + }); // Timeout set to 30s because full sync can take a long time }); }); From ef2e557a12d47e063492bfcc02f8df7cd1fffbe5 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 17 Oct 2024 10:16:46 +0200 Subject: [PATCH 141/162] fix: docker e2e --- e2e-env/docker-compose.yml | 51 +++++++++++++------ ...-module.sh => install-ps-accounts-mock.sh} | 10 ---- e2e-env/init-scripts/install-ps-eventbus.sh | 23 +++++++++ e2e/src/full-sync.spec.ts | 4 +- 4 files changed, 60 insertions(+), 28 deletions(-) rename e2e-env/init-scripts/{install-module.sh => install-ps-accounts-mock.sh} (72%) mode change 100755 => 100644 create mode 100644 e2e-env/init-scripts/install-ps-eventbus.sh diff --git a/e2e-env/docker-compose.yml b/e2e-env/docker-compose.yml index 4fbcc4e1..9b08d28e 100644 --- a/e2e-env/docker-compose.yml +++ b/e2e-env/docker-compose.yml @@ -1,6 +1,5 @@ -version: "3" -services: - prestashop: +x-service: + prestashop-base: &prestashop-base image: ${DOCKER_IMAGE_PRESTASHOP:?See e2e-env/.env.dist} depends_on: mysql: @@ -12,26 +11,49 @@ services: "curl", "-sI", "-H", - "Host: localhost:8000", + "Host: localhost:${HOST_PORT_BIND_PRESTASHOP:?See e2e-env/.env.dist}", "http://localhost:80/index.php?fc=module&module=ps_eventbus&controller=apiHealthCheck", ] interval: 30s + environment: + - ON_INIT_SCRIPT_FAILURE=fail + - DEBUG_MODE=true + - INIT_SCRIPTS_USER=root + - PS_DOMAIN=localhost:${HOST_PORT_BIND_PRESTASHOP} + ports: + - ${HOST_PORT_BIND_PRESTASHOP:?See e2e-env/.env.dist}:80 + +services: + # This service ir for local development and testing with ps-accounts mock + prestashop-local: + <<: *prestashop-base + environment: + - PS_DOMAIN=localhost:${HOST_PORT_BIND_PRESTASHOP} volumes: - ..:/var/www/html/modules/ps_eventbus:rw - - ./init-scripts:/tmp/init-scripts:ro + - ./init-scripts/install-ps-accounts-mock.sh:/tmp/init-scripts/install-ps-accounts-mock.sh:ro + - ./init-scripts/install-ps-eventbus.sh:/tmp/init-scripts/install-ps-eventbus.sh:ro # Notice: you might enable this if your uid is not 1000, or encounter permission issues # - /var/www/html/modules/ps_eventbus/vendor # - /var/www/html/modules/ps_eventbus/tools/vendor + profiles: [localhost, cicd] + + # This service is for testing with real ps-accounts, and exposed the service to the internet + prestashop-exposed: + <<: *prestashop-base environment: - - ON_INIT_SCRIPT_FAILURE=fail - - DEBUG_MODE=true - - INIT_SCRIPTS_USER=root - PS_DOMAIN=${TUNNEL_NAME} - PS_PROTOCOL=https ports: - ${HOST_PORT_BIND_PRESTASHOP:?See e2e-env/.env.dist}:80 - profiles: [cicd, development] - + volumes: + - ..:/var/www/html/modules/ps_eventbus:rw + - ./init-scripts/install-ps-eventbus.sh:/tmp/init-scripts/install-ps-eventbus.sh:ro + # Notice: you might enable this if your uid is not 1000, or encounter permission issues + # - /var/www/html/modules/ps_eventbus/vendor + # - /var/www/html/modules/ps_eventbus/tools/vendor + profiles: [cloudflared] + mysql: image: mariadb:${DOCKER_VERSION_MARIADB:?See e2e-env/.env.dist} healthcheck: @@ -45,7 +67,6 @@ services: - MYSQL_DATABASE=prestashop ports: - ${HOST_PORT_BIND_MYSQL:?See e2e-env/.env.dist}:3306 - profiles: [cicd, development] phpmyadmin: image: phpmyadmin:latest @@ -60,7 +81,7 @@ services: - PMA_USER=prestashop - PMA_PASSWORD=prestashop - MYSQL_ROOT_PASSWORD=prestashop - profiles: [development] + profiles: [localhost, cloudflared] cloudsync-mock: build: @@ -77,7 +98,6 @@ services: - ${COLLECTOR_API_PORT:?See e2e-env/.env.dist}:3333 - ${LIVE_SYNC_API_PORT:?See e2e-env/.env.dist}:3434 - ${WS_PORT:?See e2e-env/.env.dist}:8080 - profiles: [cicd, development] reverse-proxy: image: nginx:stable-alpine @@ -88,15 +108,14 @@ services: command: [nginx-debug, "-g", "daemon off;"] ports: - ${HOST_PORT_BIND_CLOUDSYNC_REVERSE_PROXY:?See e2e-env/.env.dist}:80 - profiles: [cicd, development] cloudflared: image: cloudflare/cloudflared:latest command: tunnel run $${TUNNEL_NAME} environment: - TUNNEL_CRED_FILE=/credentials.json - - TUNNEL_URL=http://prestashop:80 + - TUNNEL_URL=http://prestashop-exposed:80 - TUNNEL_HTTP_HOST_HEADER=${TUNNEL_NAME} volumes: - ./credentials.json:/credentials.json - profiles: [development] + profiles: [cloudflared] diff --git a/e2e-env/init-scripts/install-module.sh b/e2e-env/init-scripts/install-ps-accounts-mock.sh old mode 100755 new mode 100644 similarity index 72% rename from e2e-env/init-scripts/install-module.sh rename to e2e-env/init-scripts/install-ps-accounts-mock.sh index 7d53fe32..217be2d6 --- a/e2e-env/init-scripts/install-module.sh +++ b/e2e-env/init-scripts/install-ps-accounts-mock.sh @@ -24,14 +24,4 @@ ps_accounts_mock_install() { php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_accounts" } -ps_eventbus_install() { - # Notice: you might enable this if your uid is not 1000, or encounter permission issues - # composer install -n -d ./modules/ps_eventbus - echo "* [ps_eventbus] installing the module..." - cd "$PS_FOLDER" - php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_eventbus" -} - ps_accounts_mock_install -ps_eventbus_install - diff --git a/e2e-env/init-scripts/install-ps-eventbus.sh b/e2e-env/init-scripts/install-ps-eventbus.sh new file mode 100644 index 00000000..904eed40 --- /dev/null +++ b/e2e-env/init-scripts/install-ps-eventbus.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# +# This is an init-script for prestashop-flashlight. +# +# Storing a folder in /var/www/html/modules is not enough to register the module +# into PrestaShop, hence why we have to call the console install CLI. +# +set -eu + +error() { + printf "\e[1;31m%s\e[0m\n" "${1:-Unknown error}" + exit "${2:-1}" +} + +ps_eventbus_install() { + # Notice: you might enable this if your uid is not 1000, or encounter permission issues + # composer install -n -d ./modules/ps_eventbus + echo "* [ps_eventbus] installing the module..." + cd "$PS_FOLDER" + php -d memory_limit=-1 bin/console prestashop:module --no-interaction install "ps_eventbus" +} + +ps_eventbus_install diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 6e5d259f..9bef6edc 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -87,8 +87,8 @@ describe("Full Sync", () => { it(`${shopContent} should upload complete dataset collector`, async () => { // arrange - const response$ = doFullSync(jobId, shopContent, { timeout: 30000 }); - const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 30000 }); + const response$ = doFullSync(jobId, shopContent, { timeout: 5000 }); + const message$ = probe({ url: `/upload/${jobId}` }, { timeout: 4000 }); // this combines each response from ps_eventbus to the last request captured by the probe. // it works because ps_eventbus sends a response after calling our mock collector server From 92d096cb027efb04fce7a4dd4c4a3b8a3af1c156 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 17 Oct 2024 10:26:53 +0200 Subject: [PATCH 142/162] fix: init-scripts executable --- e2e-env/init-scripts/install-ps-accounts-mock.sh | 0 e2e-env/init-scripts/install-ps-eventbus.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 e2e-env/init-scripts/install-ps-accounts-mock.sh mode change 100644 => 100755 e2e-env/init-scripts/install-ps-eventbus.sh diff --git a/e2e-env/init-scripts/install-ps-accounts-mock.sh b/e2e-env/init-scripts/install-ps-accounts-mock.sh old mode 100644 new mode 100755 diff --git a/e2e-env/init-scripts/install-ps-eventbus.sh b/e2e-env/init-scripts/install-ps-eventbus.sh old mode 100644 new mode 100755 From dbcdbab4bf73816db6079a9ec37fbd5cd626a3f2 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 22 Oct 2024 11:23:43 +0200 Subject: [PATCH 143/162] fix: V4 | revert order histories and bundles naming (#384) --- config/common/repository.yml | 12 +- config/front/services.yml | 21 ++- .../{product_bundles.json => bundles.json} | 0 ...history.json => order_status_history.json} | 14 +- .../{product_bundles.json => bundles.json} | 4 +- e2e/src/fixtures/1.7/order_histories.json | 135 ------------------ .../order_status_history.json} | 14 +- .../8/{product_bundles.json => bundles.json} | 4 +- ...stories.json => order_status_history.json} | 14 +- .../9/{product_bundles.json => bundles.json} | 4 +- ...stories.json => order_status_history.json} | 14 +- e2e/src/helpers/shop-contents.ts | 4 +- e2e/src/type/bundles.ts | 2 +- ...r-histories.ts => order-status-history.ts} | 6 +- src/Config/Config.php | 8 +- src/Repository/AbstractRepository.php | 2 + ...dleRepository.php => BundleRepository.php} | 2 +- ...y.php => OrderStatusHistoryRepository.php} | 4 +- src/Repository/TranslationRepository.php | 2 +- ...tBundlesService.php => BundlesService.php} | 42 +++--- ...vice.php => OrderStatusHistoryService.php} | 56 ++++---- src/Service/ShopContent/OrdersService.php | 22 +-- 22 files changed, 126 insertions(+), 260 deletions(-) rename e2e/src/fixtures/1.6/{product_bundles.json => bundles.json} (100%) rename e2e/src/fixtures/1.6/{order_history.json => order_status_history.json} (91%) rename e2e/src/fixtures/1.7/{product_bundles.json => bundles.json} (84%) delete mode 100644 e2e/src/fixtures/1.7/order_histories.json rename e2e/src/fixtures/{1.6/order_histories.json => 1.7/order_status_history.json} (91%) rename e2e/src/fixtures/8/{product_bundles.json => bundles.json} (83%) rename e2e/src/fixtures/8/{order_histories.json => order_status_history.json} (91%) rename e2e/src/fixtures/9/{product_bundles.json => bundles.json} (83%) rename e2e/src/fixtures/9/{order_histories.json => order_status_history.json} (91%) rename e2e/src/type/{order-histories.ts => order-status-history.ts} (75%) rename src/Repository/{ProductBundleRepository.php => BundleRepository.php} (97%) rename src/Repository/{OrderHistoryRepository.php => OrderStatusHistoryRepository.php} (96%) rename src/Service/ShopContent/{ProductBundlesService.php => BundlesService.php} (62%) rename src/Service/ShopContent/{OrderHistoriesService.php => OrderStatusHistoryService.php} (52%) diff --git a/config/common/repository.yml b/config/common/repository.yml index 43770398..0188df65 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -39,6 +39,10 @@ services: ###################################### SHOP CONTENT REPOSITORIES ########################################### ############################################################################################################ + PrestaShop\Module\PsEventbus\Repository\BundleRepository: + class: PrestaShop\Module\PsEventbus\Repository\BundleRepository + public: true + PrestaShop\Module\PsEventbus\Repository\CarrierRepository: class: PrestaShop\Module\PsEventbus\Repository\CarrierRepository public: true @@ -103,8 +107,8 @@ services: class: PrestaShop\Module\PsEventbus\Repository\OrderCartRuleRepository public: true - PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository: - class: PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository + PrestaShop\Module\PsEventbus\Repository\OrderstatusHistoryRepository: + class: PrestaShop\Module\PsEventbus\Repository\OrderStatusHistoryRepository public: true PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository: @@ -115,10 +119,6 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ProductRepository public: true - PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository: - class: PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository - public: true - PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository: class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index c58dd889..93eb94f4 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -54,7 +54,12 @@ services: ############################################################################################################ ###################################### SHOP CONTENT SERVICES ############################################### ############################################################################################################ - + PrestaShop\Module\PsEventbus\Service\ShopContent\BundlesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\BundlesService + public: true + arguments: + - '@PrestaShop\Module\PsEventbus\Repository\BundleRepository' + PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarriersService public: true @@ -158,7 +163,7 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Repository\OrderRepository' - - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderstatusHistoryRepository' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' PrestaShop\Module\PsEventbus\Service\ShopContent\OrderCartRulesService: @@ -173,11 +178,11 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Repository\OrderDetailRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderHistoriesService + PrestaShop\Module\PsEventbus\Service\ShopContent\OrderStatusHistoryService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\OrderStatusHistoryService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository' + - '@PrestaShop\Module\PsEventbus\Repository\OrderstatusHistoryRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductsService @@ -188,12 +193,6 @@ services: - '@PrestaShop\Module\PsEventbus\Service\ShopContent\CategoriesService' - '@PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter' - PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService: - class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductBundlesService - public: true - arguments: - - '@PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository' - PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\ProductSuppliersService public: true diff --git a/e2e/src/fixtures/1.6/product_bundles.json b/e2e/src/fixtures/1.6/bundles.json similarity index 100% rename from e2e/src/fixtures/1.6/product_bundles.json rename to e2e/src/fixtures/1.6/bundles.json diff --git a/e2e/src/fixtures/1.6/order_history.json b/e2e/src/fixtures/1.6/order_status_history.json similarity index 91% rename from e2e/src/fixtures/1.6/order_history.json rename to e2e/src/fixtures/1.6/order_status_history.json index 962c6777..e39bdde7 100644 --- a/e2e/src/fixtures/1.6/order_history.json +++ b/e2e/src/fixtures/1.6/order_status_history.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/fixtures/1.7/product_bundles.json b/e2e/src/fixtures/1.7/bundles.json similarity index 84% rename from e2e/src/fixtures/1.7/product_bundles.json rename to e2e/src/fixtures/1.7/bundles.json index 563190cc..7fced11c 100644 --- a/e2e/src/fixtures/1.7/product_bundles.json +++ b/e2e/src/fixtures/1.7/bundles.json @@ -1,7 +1,7 @@ [ { "id": "15", - "collection": "product_bundles", + "collection": "bundles", "properties": { "id_bundle": "15", "id_product": "5", @@ -12,7 +12,7 @@ }, { "id": "15", - "collection": "product_bundles", + "collection": "bundles", "properties": { "id_bundle": "15", "id_product": "7", diff --git a/e2e/src/fixtures/1.7/order_histories.json b/e2e/src/fixtures/1.7/order_histories.json deleted file mode 100644 index 310f587e..00000000 --- a/e2e/src/fixtures/1.7/order_histories.json +++ /dev/null @@ -1,135 +0,0 @@ -[ - { - "id": 1, - "collection": "order_histories", - "properties": { - "id_order_state": 1, - "id_order": 1, - "id_order_history": 1, - "name": "Awaiting check payment", - "template": "cheque", - "date_add": "2023-12-20T22:56:49+0100", - "is_validated": false, - "is_delivered": false, - "is_shipped": false, - "is_paid": false, - "is_deleted": false, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100" - } - }, - { - "id": 2, - "collection": "order_histories", - "properties": { - "id_order_state": 1, - "id_order": 2, - "id_order_history": 2, - "name": "Awaiting check payment", - "template": "cheque", - "date_add": "2023-12-20T22:56:49+0100", - "is_validated": false, - "is_delivered": false, - "is_shipped": false, - "is_paid": false, - "is_deleted": false, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100" - } - }, - { - "id": 3, - "collection": "order_histories", - "properties": { - "id_order_state": 1, - "id_order": 3, - "id_order_history": 3, - "name": "Awaiting check payment", - "template": "cheque", - "date_add": "2023-12-20T22:56:49+0100", - "is_validated": false, - "is_delivered": false, - "is_shipped": false, - "is_paid": false, - "is_deleted": false, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100" - } - }, - { - "id": 4, - "collection": "order_histories", - "properties": { - "id_order_state": 1, - "id_order": 4, - "id_order_history": 4, - "name": "Awaiting check payment", - "template": "cheque", - "date_add": "2023-12-20T22:56:49+0100", - "is_validated": false, - "is_delivered": false, - "is_shipped": false, - "is_paid": false, - "is_deleted": false, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100" - } - }, - { - "id": 5, - "collection": "order_histories", - "properties": { - "id_order_state": 10, - "id_order": 5, - "id_order_history": 5, - "name": "Awaiting bank wire payment", - "template": "bankwire", - "date_add": "2023-12-20T22:56:49+0100", - "is_validated": false, - "is_delivered": false, - "is_shipped": false, - "is_paid": false, - "is_deleted": false, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100" - } - }, - { - "id": 6, - "collection": "order_histories", - "properties": { - "id_order_state": 6, - "id_order": 1, - "id_order_history": 6, - "name": "Canceled", - "template": "order_canceled", - "date_add": "2023-12-20T22:56:49+0100", - "is_validated": false, - "is_delivered": false, - "is_shipped": false, - "is_paid": false, - "is_deleted": false, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100" - } - }, - { - "id": 7, - "collection": "order_histories", - "properties": { - "id_order_state": 8, - "id_order": 3, - "id_order_history": 7, - "name": "Payment error", - "template": "payment_error", - "date_add": "2023-12-20T22:56:49+0100", - "is_validated": false, - "is_delivered": false, - "is_shipped": false, - "is_paid": false, - "is_deleted": false, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100" - } - } -] diff --git a/e2e/src/fixtures/1.6/order_histories.json b/e2e/src/fixtures/1.7/order_status_history.json similarity index 91% rename from e2e/src/fixtures/1.6/order_histories.json rename to e2e/src/fixtures/1.7/order_status_history.json index 310f587e..80aa3b22 100644 --- a/e2e/src/fixtures/1.6/order_histories.json +++ b/e2e/src/fixtures/1.7/order_status_history.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/fixtures/8/product_bundles.json b/e2e/src/fixtures/8/bundles.json similarity index 83% rename from e2e/src/fixtures/8/product_bundles.json rename to e2e/src/fixtures/8/bundles.json index bca28be0..7438d673 100644 --- a/e2e/src/fixtures/8/product_bundles.json +++ b/e2e/src/fixtures/8/bundles.json @@ -1,7 +1,7 @@ [ { "id": 15, - "collection": "product_bundles", + "collection": "bundles", "properties": { "id_bundle": 15, "id_product": 5, @@ -12,7 +12,7 @@ }, { "id": 15, - "collection": "product_bundles", + "collection": "bundles", "properties": { "id_bundle": 15, "id_product": 7, diff --git a/e2e/src/fixtures/8/order_histories.json b/e2e/src/fixtures/8/order_status_history.json similarity index 91% rename from e2e/src/fixtures/8/order_histories.json rename to e2e/src/fixtures/8/order_status_history.json index 49223656..f5d6eac5 100644 --- a/e2e/src/fixtures/8/order_histories.json +++ b/e2e/src/fixtures/8/order_status_history.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/fixtures/9/product_bundles.json b/e2e/src/fixtures/9/bundles.json similarity index 83% rename from e2e/src/fixtures/9/product_bundles.json rename to e2e/src/fixtures/9/bundles.json index bca28be0..7438d673 100644 --- a/e2e/src/fixtures/9/product_bundles.json +++ b/e2e/src/fixtures/9/bundles.json @@ -1,7 +1,7 @@ [ { "id": 15, - "collection": "product_bundles", + "collection": "bundles", "properties": { "id_bundle": 15, "id_product": 5, @@ -12,7 +12,7 @@ }, { "id": 15, - "collection": "product_bundles", + "collection": "bundles", "properties": { "id_bundle": 15, "id_product": 7, diff --git a/e2e/src/fixtures/9/order_histories.json b/e2e/src/fixtures/9/order_status_history.json similarity index 91% rename from e2e/src/fixtures/9/order_histories.json rename to e2e/src/fixtures/9/order_status_history.json index b33a067c..05868d4b 100644 --- a/e2e/src/fixtures/9/order_histories.json +++ b/e2e/src/fixtures/9/order_status_history.json @@ -1,7 +1,7 @@ [ { "id": 1, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 1, @@ -20,7 +20,7 @@ }, { "id": 2, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 2, @@ -39,7 +39,7 @@ }, { "id": 3, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 3, @@ -58,7 +58,7 @@ }, { "id": 4, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 1, "id_order": 4, @@ -77,7 +77,7 @@ }, { "id": 5, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 10, "id_order": 5, @@ -96,7 +96,7 @@ }, { "id": 6, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 6, "id_order": 1, @@ -115,7 +115,7 @@ }, { "id": 7, - "collection": "order_histories", + "collection": "order_status_history", "properties": { "id_order_state": 8, "id_order": 3, diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index 465ee0ce..a654217c 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -1,6 +1,7 @@ import R from "ramda"; export const shopContentMapping = { + bundles: "bundles", carriers: "carriers", carrier_details: "carrier-details", carrier_taxes: "carrier-taxes", @@ -20,9 +21,8 @@ export const shopContentMapping = { orders: "orders", order_cart_rules: "order-cart-rules", order_details: "order-details", - order_histories: "order-histories", + order_status_history: "order-status-history", products: "products", - product_bundles: "product-bundles", product_suppliers: "product-suppliers", shops: "shops", specific_prices: "specific-prices", diff --git a/e2e/src/type/bundles.ts b/e2e/src/type/bundles.ts index 85e40e88..eb4f660c 100644 --- a/e2e/src/type/bundles.ts +++ b/e2e/src/type/bundles.ts @@ -1,4 +1,4 @@ -import fixture from "../fixtures/latest/product_bundles.json"; +import fixture from "../fixtures/latest/bundles.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/e2e/src/type/order-histories.ts b/e2e/src/type/order-status-history.ts similarity index 75% rename from e2e/src/type/order-histories.ts rename to e2e/src/type/order-status-history.ts index 4dac7526..c1b8b112 100644 --- a/e2e/src/type/order-histories.ts +++ b/e2e/src/type/order-status-history.ts @@ -1,10 +1,10 @@ -import fixture from "../fixtures/latest/order_histories.json"; +import fixture from "../fixtures/latest/order_status_histories.json"; // test type // eslint-disable-next-line @typescript-eslint/no-unused-vars -const t: OrderHistories[] = fixture; +const t: OrderStatusHistory[] = fixture; -export type OrderHistories = { +export type OrderStatusHistory = { id: number; collection: string; properties: { diff --git a/src/Config/Config.php b/src/Config/Config.php index 8d8e1e42..dd32fe2b 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -60,6 +60,7 @@ class Config self::PS_ACCOUNTS_NOT_INSTALLED => 'PsAccounts not installed', ]; + const COLLECTION_BUNDLES = 'bundles'; const COLLECTION_CARRIERS = 'carriers'; const COLLECTION_CARRIER_DETAILS = 'carrier_details'; const COLLECTION_CARRIER_TAXES = 'carrier_taxes'; @@ -80,9 +81,8 @@ class Config const COLLECTION_ORDERS = 'orders'; const COLLECTION_ORDER_CART_RULES = 'order_cart_rules'; const COLLECTION_ORDER_DETAILS = 'order_details'; - const COLLECTION_ORDER_HISTORIES = 'order_histories'; + const COLLECTION_ORDER_STATUS_HISTORY = 'order_status_history'; const COLLECTION_PRODUCTS = 'products'; - const COLLECTION_PRODUCT_BUNDLES = 'product_bundles'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; const COLLECTION_SHOPS = 'shops'; const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; @@ -97,6 +97,7 @@ class Config const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; const SHOP_CONTENTS = [ + self::COLLECTION_BUNDLES, self::COLLECTION_CARRIERS, self::COLLECTION_CARRIER_DETAILS, self::COLLECTION_CARRIER_TAXES, @@ -116,9 +117,8 @@ class Config self::COLLECTION_ORDERS, self::COLLECTION_ORDER_CART_RULES, self::COLLECTION_ORDER_DETAILS, - self::COLLECTION_ORDER_HISTORIES, + self::COLLECTION_ORDER_STATUS_HISTORY, self::COLLECTION_PRODUCTS, - self::COLLECTION_PRODUCT_BUNDLES, self::COLLECTION_CUSTOM_PRODUCT_CARRIERS, self::COLLECTION_PRODUCT_SUPPLIERS, self::COLLECTION_SHOPS, diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index e5041568..b12281ef 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -111,6 +111,8 @@ protected function getShopContext() } /** + * @param string $query + * * @return array|bool|\mysqli_result|\PDOStatement|resource|null * * @throws \PrestaShopException diff --git a/src/Repository/ProductBundleRepository.php b/src/Repository/BundleRepository.php similarity index 97% rename from src/Repository/ProductBundleRepository.php rename to src/Repository/BundleRepository.php index 216cd3fb..33f9b987 100644 --- a/src/Repository/ProductBundleRepository.php +++ b/src/Repository/BundleRepository.php @@ -30,7 +30,7 @@ exit; } -class ProductBundleRepository extends AbstractRepository implements RepositoryInterface +class BundleRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'pack'; diff --git a/src/Repository/OrderHistoryRepository.php b/src/Repository/OrderStatusHistoryRepository.php similarity index 96% rename from src/Repository/OrderHistoryRepository.php rename to src/Repository/OrderStatusHistoryRepository.php index 07a74cfb..ca7c4b9b 100644 --- a/src/Repository/OrderHistoryRepository.php +++ b/src/Repository/OrderStatusHistoryRepository.php @@ -30,7 +30,7 @@ exit; } -class OrderHistoryRepository extends AbstractRepository implements RepositoryInterface +class OrderStatusHistoryRepository extends AbstractRepository implements RepositoryInterface { const TABLE_NAME = 'order_history'; @@ -140,7 +140,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) * * @throws \PrestaShopDatabaseException */ - public function getOrderHistoryIdsByOrderIds($orderIds, $langIso) + public function getOrderStatusHistoriesByOrderIds($orderIds, $langIso) { if (!$orderIds) { return []; diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 74cdee52..465fdc91 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -118,7 +118,7 @@ public function countFullSyncContentLeft($offset, $limit, $langIso) { // this table doesn't exist in the database before 1.7 if (empty(parent::checkIfTableExist('%translation'))) { - return []; + return 0; } $this->generateFullQuery($langIso, false); diff --git a/src/Service/ShopContent/ProductBundlesService.php b/src/Service/ShopContent/BundlesService.php similarity index 62% rename from src/Service/ShopContent/ProductBundlesService.php rename to src/Service/ShopContent/BundlesService.php index ec025754..c9bbad35 100644 --- a/src/Service/ShopContent/ProductBundlesService.php +++ b/src/Service/ShopContent/BundlesService.php @@ -27,20 +27,20 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\ProductBundleRepository; +use PrestaShop\Module\PsEventbus\Repository\BundleRepository; if (!defined('_PS_VERSION_')) { exit; } -class ProductBundlesService implements ShopContentServiceInterface +class BundlesService implements ShopContentServiceInterface { - /** @var ProductBundleRepository */ - private $productBundleRepository; + /** @var BundleRepository */ + private $bundleRepository; - public function __construct(ProductBundleRepository $productBundleRepository) + public function __construct(BundleRepository $bundleRepository) { - $this->productBundleRepository = $productBundleRepository; + $this->bundleRepository = $bundleRepository; } /** @@ -52,18 +52,18 @@ public function __construct(ProductBundleRepository $productBundleRepository) */ public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->productBundleRepository->retrieveContentsForFull($offset, $limit, $langIso); + $result = $this->bundleRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; } - $this->castProductsBundles($result, $langIso); + $this->castBundles($result, $langIso); return array_map(function ($item) { return [ 'id' => $item['id_bundle'], - 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, + 'collection' => Config::COLLECTION_BUNDLES, 'properties' => $item, ]; }, $result); @@ -78,18 +78,18 @@ public function getContentsForFull($offset, $limit, $langIso) */ public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->productBundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->bundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; } - $this->castProductsBundles($result, $langIso); + $this->castBundles($result, $langIso); return array_map(function ($item) { return [ 'id' => $item['id_bundle'], - 'collection' => Config::COLLECTION_PRODUCT_BUNDLES, + 'collection' => Config::COLLECTION_BUNDLES, 'properties' => $item, ]; }, $result); @@ -104,24 +104,24 @@ public function getContentsForIncremental($limit, $contentIds, $langIso) */ public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->productBundleRepository->countFullSyncContentLeft($offset, $limit, $langIso); + return $this->bundleRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** - * @param array $productBundles + * @param array $bundles * @param string $langIso * * @return void */ - private function castProductsBundles(&$productBundles, $langIso) + private function castBundles(&$bundles, $langIso) { - foreach ($productBundles as &$productBundle) { - $productBundle['id_product'] = $productBundle['id_product_item']; - $productBundle['unique_product_id'] = "{$productBundle['id_bundle']}-{$productBundle['product_id_attribute']}-{$langIso}"; + foreach ($bundles as &$bundle) { + $bundle['id_product'] = $bundle['id_product_item']; + $bundle['unique_product_id'] = "{$bundle['id_bundle']}-{$bundle['product_id_attribute']}-{$langIso}"; - unset($productBundle['product_id_attribute']); - unset($productBundle['id_product_item']); - unset($productBundle['id_product_attribute_item']); + unset($bundle['product_id_attribute']); + unset($bundle['id_product_item']); + unset($bundle['id_product_attribute_item']); } } } diff --git a/src/Service/ShopContent/OrderHistoriesService.php b/src/Service/ShopContent/OrderStatusHistoryService.php similarity index 52% rename from src/Service/ShopContent/OrderHistoriesService.php rename to src/Service/ShopContent/OrderStatusHistoryService.php index 868c9e37..1f7aacf5 100644 --- a/src/Service/ShopContent/OrderHistoriesService.php +++ b/src/Service/ShopContent/OrderStatusHistoryService.php @@ -27,20 +27,20 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderStatusHistoryRepository; if (!defined('_PS_VERSION_')) { exit; } -class OrderHistoriesService implements ShopContentServiceInterface +class OrderStatusHistoryService implements ShopContentServiceInterface { - /** @var OrderHistoryRepository */ - private $orderHistoryRepository; + /** @var OrderStatusHistoryRepository */ + private $orderStatusHistoryRepository; - public function __construct(OrderHistoryRepository $orderHistoryRepository) + public function __construct(OrderStatusHistoryRepository $orderStatusHistoryRepository) { - $this->orderHistoryRepository = $orderHistoryRepository; + $this->orderStatusHistoryRepository = $orderStatusHistoryRepository; } /** @@ -52,18 +52,18 @@ public function __construct(OrderHistoryRepository $orderHistoryRepository) */ public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->orderHistoryRepository->retrieveContentsForFull($offset, $limit, $langIso); + $result = $this->orderStatusHistoryRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; } - $this->castOrderHistories($result); + $this->castOrderStatusHistories($result); return array_map(function ($item) { return [ 'id' => $item['id_order_history'], - 'collection' => Config::COLLECTION_ORDER_HISTORIES, + 'collection' => Config::COLLECTION_ORDER_STATUS_HISTORY, 'properties' => $item, ]; }, $result); @@ -78,18 +78,18 @@ public function getContentsForFull($offset, $limit, $langIso) */ public function getContentsForIncremental($limit, $contentIds, $langIso) { - $result = $this->orderHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->orderStatusHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); if (empty($result)) { return []; } - $this->castOrderHistories($result); + $this->castOrderStatusHistories($result); return array_map(function ($item) { return [ 'id' => $item['id_order_history'], - 'collection' => Config::COLLECTION_ORDER_HISTORIES, + 'collection' => Config::COLLECTION_ORDER_STATUS_HISTORY, 'properties' => $item, ]; }, $result); @@ -104,29 +104,29 @@ public function getContentsForIncremental($limit, $contentIds, $langIso) */ public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->orderHistoryRepository->countFullSyncContentLeft($offset, $limit, $langIso); + return $this->orderStatusHistoryRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** - * @param array $orderHistories + * @param array $orderStatusHistories * * @return void */ - private function castOrderHistories(&$orderHistories) + private function castOrderStatusHistories(&$orderStatusHistories) { - foreach ($orderHistories as &$orderHistory) { - $orderHistory['id_order_state'] = (int) $orderHistory['id_order_state']; - $orderHistory['id_order'] = (int) $orderHistory['id_order']; - $orderHistory['id_order_history'] = (int) $orderHistory['id_order_history']; - $orderHistory['name'] = (string) $orderHistory['name']; - $orderHistory['template'] = (string) $orderHistory['template']; - $orderHistory['is_validated'] = (bool) $orderHistory['is_validated']; - $orderHistory['is_delivered'] = (bool) $orderHistory['is_delivered']; - $orderHistory['is_shipped'] = (bool) $orderHistory['is_shipped']; - $orderHistory['is_paid'] = (bool) $orderHistory['is_paid']; - $orderHistory['is_deleted'] = (bool) $orderHistory['is_deleted']; - $orderHistory['created_at'] = $orderHistory['date_add']; - $orderHistory['updated_at'] = $orderHistory['date_add']; + foreach ($orderStatusHistories as &$orderStatusHistory) { + $orderStatusHistory['id_order_state'] = (int) $orderStatusHistory['id_order_state']; + $orderStatusHistory['id_order'] = (int) $orderStatusHistory['id_order']; + $orderStatusHistory['id_order_history'] = (int) $orderStatusHistory['id_order_history']; + $orderStatusHistory['name'] = (string) $orderStatusHistory['name']; + $orderStatusHistory['template'] = (string) $orderStatusHistory['template']; + $orderStatusHistory['is_validated'] = (bool) $orderStatusHistory['is_validated']; + $orderStatusHistory['is_delivered'] = (bool) $orderStatusHistory['is_delivered']; + $orderStatusHistory['is_shipped'] = (bool) $orderStatusHistory['is_shipped']; + $orderStatusHistory['is_paid'] = (bool) $orderStatusHistory['is_paid']; + $orderStatusHistory['is_deleted'] = (bool) $orderStatusHistory['is_deleted']; + $orderStatusHistory['created_at'] = $orderStatusHistory['date_add']; + $orderStatusHistory['updated_at'] = $orderStatusHistory['date_add']; } } } diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 98d1edc9..836f764b 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -28,8 +28,8 @@ use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Formatter\ArrayFormatter; -use PrestaShop\Module\PsEventbus\Repository\OrderHistoryRepository; use PrestaShop\Module\PsEventbus\Repository\OrderRepository; +use PrestaShop\Module\PsEventbus\Repository\OrderStatusHistoryRepository; if (!defined('_PS_VERSION_')) { exit; @@ -40,19 +40,19 @@ class OrdersService implements ShopContentServiceInterface /** @var OrderRepository */ private $orderRepository; - /** @var OrderHistoryRepository */ - private $orderHistoryRepository; + /** @var OrderStatusHistoryRepository */ + private $orderStatusHistoryRepository; /** @var ArrayFormatter */ private $arrayFormatter; public function __construct( OrderRepository $orderRepository, - OrderHistoryRepository $orderHistoryRepository, + OrderStatusHistoryRepository $orderStatusHistoryRepository, ArrayFormatter $arrayFormatter ) { $this->orderRepository = $orderRepository; - $this->orderHistoryRepository = $orderHistoryRepository; + $this->orderStatusHistoryRepository = $orderStatusHistoryRepository; $this->arrayFormatter = $arrayFormatter; } @@ -188,13 +188,13 @@ private function castIsPaidValue($orders, $order, $langIso) { $isPaid = $dateAdd = 0; $orderIds = $this->arrayFormatter->formatValueArray($orders, 'id_order'); - /** @var array $orderHistoryStatuss */ - $orderHistoryStatuss = $this->orderHistoryRepository->getOrderHistoryIdsByOrderIds($orderIds, $langIso); + /** @var array $orderStatusHistories */ + $orderStatusHistories = $this->orderStatusHistoryRepository->getOrderStatusHistoriesByOrderIds($orderIds, $langIso); - foreach ($orderHistoryStatuss as &$orderHistoryStatus) { - if ($order['id_order'] == $orderHistoryStatus['id_order'] && $dateAdd < $orderHistoryStatus['date_add']) { - $isPaid = (bool) $orderHistoryStatus['is_paid']; - $dateAdd = $orderHistoryStatus['date_add']; + foreach ($orderStatusHistories as &$orderStatusHistory) { + if ($order['id_order'] == $orderStatusHistory['id_order'] && $dateAdd < $orderStatusHistory['date_add']) { + $isPaid = (bool) $orderStatusHistory['is_paid']; + $dateAdd = $orderStatusHistory['date_add']; } } From 47e94067faa7463502be87fd8482254af4970ac4 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:20:28 +0100 Subject: [PATCH 144/162] fix: deleted object v4 (#387) Co-authored-by: Guillaume Lepoetre --- README.md | 4 +- .../cloudsync-mock/src/lib/collector-api.ts | 19 +- e2e/package.json | 1 + e2e/pnpm-lock.yaml | 8 + e2e/src/fixtures/1.6/carrier_details.json | 4 +- e2e/src/fixtures/1.6/carriers.json | 4 +- e2e/src/fixtures/1.6/cart_products.json | 30 +-- e2e/src/fixtures/1.6/carts.json | 10 +- e2e/src/fixtures/1.6/categories.json | 22 +- e2e/src/fixtures/1.6/currencies.json | 4 +- e2e/src/fixtures/1.6/customers.json | 2 +- e2e/src/fixtures/1.6/employees.json | 2 +- e2e/src/fixtures/1.6/image_types.json | 18 +- e2e/src/fixtures/1.6/images.json | 46 ++-- e2e/src/fixtures/1.6/languages.json | 2 +- e2e/src/fixtures/1.6/manufacturers.json | 2 +- e2e/src/fixtures/1.6/modules.json | 138 ++++++------ e2e/src/fixtures/1.6/order_details.json | 30 +-- .../fixtures/1.6/order_status_history.json | 14 +- e2e/src/fixtures/1.6/orders.json | 10 +- e2e/src/fixtures/1.6/product_suppliers.json | 14 +- e2e/src/fixtures/1.6/products.json | 90 ++++---- e2e/src/fixtures/1.6/shops.json | 2 +- e2e/src/fixtures/1.6/specific_prices.json | 4 +- e2e/src/fixtures/1.6/stocks.json | 104 ++++----- e2e/src/fixtures/1.6/stores.json | 10 +- e2e/src/fixtures/1.6/suppliers.json | 2 +- e2e/src/fixtures/1.6/themes.json | 2 +- e2e/src/fixtures/1.7/bundles.json | 4 +- e2e/src/fixtures/1.7/carrier_details.json | 28 +-- e2e/src/fixtures/1.7/carriers.json | 8 +- e2e/src/fixtures/1.7/cart_products.json | 14 +- e2e/src/fixtures/1.7/carts.json | 10 +- e2e/src/fixtures/1.7/categories.json | 18 +- e2e/src/fixtures/1.7/currencies.json | 4 +- e2e/src/fixtures/1.7/customers.json | 4 +- e2e/src/fixtures/1.7/employees.json | 2 +- e2e/src/fixtures/1.7/image_types.json | 14 +- e2e/src/fixtures/1.7/images.json | 46 ++-- e2e/src/fixtures/1.7/languages.json | 2 +- e2e/src/fixtures/1.7/manufacturers.json | 4 +- e2e/src/fixtures/1.7/modules.json | 126 +++++------ e2e/src/fixtures/1.7/order_details.json | 14 +- .../fixtures/1.7/order_status_history.json | 14 +- e2e/src/fixtures/1.7/orders.json | 10 +- e2e/src/fixtures/1.7/product_suppliers.json | 140 ++++++------ e2e/src/fixtures/1.7/products.json | 94 ++++---- e2e/src/fixtures/1.7/shops.json | 2 +- e2e/src/fixtures/1.7/specific_prices.json | 4 +- e2e/src/fixtures/1.7/stocks.json | 116 +++++----- e2e/src/fixtures/1.7/stores.json | 10 +- e2e/src/fixtures/1.7/suppliers.json | 4 +- e2e/src/fixtures/1.7/themes.json | 2 +- e2e/src/fixtures/8/bundles.json | 20 +- e2e/src/fixtures/8/carrier_details.json | 120 +++++----- e2e/src/fixtures/8/carriers.json | 112 ++++++---- e2e/src/fixtures/8/cart_products.json | 14 +- e2e/src/fixtures/8/carts.json | 10 +- e2e/src/fixtures/8/categories.json | 18 +- e2e/src/fixtures/8/currencies.json | 4 +- e2e/src/fixtures/8/customers.json | 4 +- e2e/src/fixtures/8/employees.json | 2 +- e2e/src/fixtures/8/image_types.json | 14 +- e2e/src/fixtures/8/images.json | 46 ++-- e2e/src/fixtures/8/languages.json | 2 +- e2e/src/fixtures/8/manufacturers.json | 4 +- e2e/src/fixtures/8/modules.json | 136 ++++++------ e2e/src/fixtures/8/order_details.json | 14 +- e2e/src/fixtures/8/order_status_history.json | 14 +- e2e/src/fixtures/8/orders.json | 210 ++++++++++++++---- e2e/src/fixtures/8/product_suppliers.json | 146 ++++++------ e2e/src/fixtures/8/products.json | 188 ++++++++-------- e2e/src/fixtures/8/shops.json | 2 +- e2e/src/fixtures/8/specific_prices.json | 4 +- e2e/src/fixtures/8/stocks.json | 116 +++++----- e2e/src/fixtures/8/stores.json | 10 +- e2e/src/fixtures/8/suppliers.json | 4 +- e2e/src/fixtures/8/themes.json | 2 +- e2e/src/fixtures/9/bundles.json | 4 +- e2e/src/fixtures/9/carrier_details.json | 41 ++-- e2e/src/fixtures/9/carriers.json | 12 +- e2e/src/fixtures/9/cart_products.json | 14 +- e2e/src/fixtures/9/carts.json | 10 +- e2e/src/fixtures/9/categories.json | 18 +- e2e/src/fixtures/9/currencies.json | 4 +- e2e/src/fixtures/9/customers.json | 4 +- e2e/src/fixtures/9/employees.json | 2 +- e2e/src/fixtures/9/image_types.json | 14 +- e2e/src/fixtures/9/images.json | 46 ++-- e2e/src/fixtures/9/languages.json | 2 +- e2e/src/fixtures/9/manufacturers.json | 4 +- e2e/src/fixtures/9/modules.json | 138 ++++++------ e2e/src/fixtures/9/order_details.json | 14 +- e2e/src/fixtures/9/order_status_history.json | 14 +- e2e/src/fixtures/9/orders.json | 20 +- e2e/src/fixtures/9/product_suppliers.json | 146 ++++++------ e2e/src/fixtures/9/products.json | 94 ++++---- e2e/src/fixtures/9/shops.json | 2 +- e2e/src/fixtures/9/specific_prices.json | 4 +- e2e/src/fixtures/9/stocks.json | 116 +++++----- e2e/src/fixtures/9/stores.json | 10 +- e2e/src/fixtures/9/suppliers.json | 4 +- e2e/src/fixtures/9/themes.json | 4 +- e2e/src/full-sync.spec.ts | 39 ++-- e2e/src/helpers/data-helper.ts | 29 +-- e2e/src/helpers/log-helper.ts | 7 +- src/Api/LiveSyncApiClient.php | 5 +- src/Config/Config.php | 4 +- src/Repository/AbstractRepository.php | 12 +- src/Repository/BundleRepository.php | 4 + src/Repository/CarrierRepository.php | 4 + src/Repository/CartProductRepository.php | 4 + src/Repository/CartRepository.php | 4 + src/Repository/CartRuleRepository.php | 4 + src/Repository/CategoryRepository.php | 4 + src/Repository/CountryRepository.php | 40 ++-- src/Repository/CurrencyRepository.php | 4 + .../CustomProductCarrierRepository.php | 4 + src/Repository/CustomerRepository.php | 4 + src/Repository/EmployeeRepository.php | 4 + src/Repository/ImageRepository.php | 4 + src/Repository/ImageTypeRepository.php | 4 + src/Repository/IncrementalSyncRepository.php | 22 +- src/Repository/LanguageRepository.php | 4 + src/Repository/ManufacturerRepository.php | 4 + src/Repository/ModuleRepository.php | 4 + src/Repository/OrderCartRuleRepository.php | 4 + src/Repository/OrderDetailRepository.php | 4 + src/Repository/OrderRepository.php | 4 + .../OrderStatusHistoryRepository.php | 4 + src/Repository/ProductRepository.php | 4 + src/Repository/ProductSupplierRepository.php | 4 + src/Repository/SpecificPriceRepository.php | 4 + src/Repository/StateRepository.php | 32 +-- src/Repository/StockMovementRepository.php | 4 + src/Repository/StockRepository.php | 4 + src/Repository/StoreRepository.php | 4 + src/Repository/SupplierRepository.php | 4 + src/Repository/TaxeRepository.php | 57 ++--- src/Repository/TaxonomyRepository.php | 4 + src/Repository/TranslationRepository.php | 4 + src/Repository/WishlistProductRepository.php | 4 + src/Repository/WishlistRepository.php | 4 + src/Service/CommonService.php | 4 +- src/Service/ShopContent/BundlesService.php | 25 +-- .../ShopContent/CarrierDetailsService.php | 35 ++- .../ShopContent/CarrierTaxesService.php | 33 ++- src/Service/ShopContent/CarriersService.php | 25 +-- .../ShopContent/CartProductsService.php | 25 +-- src/Service/ShopContent/CartRulesService.php | 25 +-- src/Service/ShopContent/CartsService.php | 25 +-- src/Service/ShopContent/CategoriesService.php | 25 +-- src/Service/ShopContent/CurrenciesService.php | 25 +-- .../CustomProductCarriersService.php | 23 +- src/Service/ShopContent/CustomersService.php | 25 +-- src/Service/ShopContent/EmployeesService.php | 25 +-- src/Service/ShopContent/ImageTypesService.php | 25 +-- src/Service/ShopContent/ImagesService.php | 25 +-- src/Service/ShopContent/LanguagesService.php | 25 +-- .../ShopContent/ManufacturersService.php | 25 +-- src/Service/ShopContent/ModulesService.php | 25 +-- .../ShopContent/OrderCartRulesService.php | 25 +-- .../ShopContent/OrderDetailsService.php | 25 +-- .../ShopContent/OrderStatusHistoryService.php | 25 +-- src/Service/ShopContent/OrdersService.php | 25 +-- .../ShopContent/ProductSuppliersService.php | 25 +-- src/Service/ShopContent/ProductsService.php | 27 +-- .../ShopContentAbstractService.php | 68 ++++++ .../ShopContentServiceInterface.php | 5 +- src/Service/ShopContent/ShopsService.php | 9 +- .../ShopContent/SpecificPricesService.php | 25 +-- .../ShopContent/StockMovementsService.php | 25 +-- src/Service/ShopContent/StocksService.php | 25 +-- src/Service/ShopContent/StoresService.php | 25 +-- src/Service/ShopContent/SuppliersService.php | 25 +-- src/Service/ShopContent/TaxonomiesService.php | 25 +-- src/Service/ShopContent/ThemesService.php | 25 +-- .../ShopContent/TranslationsService.php | 25 +-- .../ShopContent/WishlistProductsService.php | 25 +-- src/Service/ShopContent/WishlistsService.php | 25 +-- src/Service/SynchronizationService.php | 34 ++- src/Traits/UseHooks.php | 90 ++++---- 182 files changed, 2365 insertions(+), 2304 deletions(-) create mode 100644 src/Service/ShopContent/ShopContentAbstractService.php diff --git a/README.md b/README.md index cc0ad59b..4de99d30 100644 --- a/README.md +++ b/README.md @@ -118,9 +118,9 @@ const SHOP_CONTENTS = [ ]; ``` -Create a service "planesService.php" (in plural) in the [shop content services folder](src/Service/ShopContent/) that implements the [ShopContentServiceInterface.php](src/Service/ShopContent/ShopContentServiceInterface.php) interface. For the method structure, use the existing base on all other shop content services to maintain consistency. +Create a service "planesService.php" (in plural) in the [shop content services folder](src/Service/ShopContent/) that extends the [ShopContentAbstractService](src/Service/ShopContent/ShopContentAbstractService.php) and implements the [ShopContentServiceInterface.php](src/Service/ShopContent/ShopContentServiceInterface.php) interface. For the method structure, use the existing base on all other shop content services to maintain consistency. ```PHP -class PlanesService implements ShopContentServiceInterface +class PlanesService extends ShopContentAbstractService implements ShopContentServiceInterface { ... } diff --git a/e2e-env/cloudsync-mock/src/lib/collector-api.ts b/e2e-env/cloudsync-mock/src/lib/collector-api.ts index 37833eb5..842d8b7d 100644 --- a/e2e-env/cloudsync-mock/src/lib/collector-api.ts +++ b/e2e-env/cloudsync-mock/src/lib/collector-api.ts @@ -1,25 +1,26 @@ import { Server } from "./server"; -import {WsServer} from "./ws-server"; +import { WsServer } from "./ws-server"; // @ts-expect-error we don't care about packaging here import multer from "multer"; -const storage = multer.memoryStorage() -const upload = multer({ storage }) +const storage = multer.memoryStorage(); +const upload = multer({ storage }); export class CollectorApiServer extends Server { - public constructor( probe: WsServer) { - super( probe); + public constructor(probe: WsServer) { + super(probe); this.api.get("/", (_req, res) => { res.status(200).end(); }); - this.api.post("/upload/:jobid", upload.single('file'), (req, res) => { + this.api.post("/upload/:jobid", upload.single("file"), (req, res) => { const jobId = req.params.jobid; if (jobId.startsWith("valid-job-")) { - req.body.file = req.file.buffer.toString() - .split('\n') - .map(line => JSON.parse(line.trim())) + req.body.file = req.file.buffer + .toString() + .split("\n") + .map((line) => JSON.parse(line.trim())); res.status(201).end(); } else { res.status(500).end(); diff --git a/e2e/package.json b/e2e/package.json index 04cfaec6..b9e278a1 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -27,6 +27,7 @@ "jest-expect-message": "^1.1.3", "jest-extended": "^4.0.2", "jest-mock-extended": "^3.0.7", + "object-hash": "3.0.0", "prettier": "^3.3.3", "ramda": "^0.30.1", "rxjs": "^7.8.1", diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 46ec728f..ae54ab75 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -52,6 +52,9 @@ devDependencies: jest-mock-extended: specifier: ^3.0.7 version: 3.0.7(jest@29.7.0)(typescript@5.6.2) + object-hash: + specifier: 3.0.0 + version: 3.0.0 prettier: specifier: ^3.3.3 version: 3.3.3 @@ -2613,6 +2616,11 @@ packages: path-key: 3.1.1 dev: true + /object-hash@3.0.0: + resolution: {integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==} + engines: {node: '>= 6'} + dev: true + /once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: diff --git a/e2e/src/fixtures/1.6/carrier_details.json b/e2e/src/fixtures/1.6/carrier_details.json index 02be9cbf..b18a4766 100644 --- a/e2e/src/fixtures/1.6/carrier_details.json +++ b/e2e/src/fixtures/1.6/carrier_details.json @@ -1,6 +1,6 @@ [ { - "id": "2-1-range_weight-1", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "2", @@ -16,7 +16,7 @@ } }, { - "id": "2-2-range_weight-1", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "2", diff --git a/e2e/src/fixtures/1.6/carriers.json b/e2e/src/fixtures/1.6/carriers.json index eeccf889..25fa1229 100644 --- a/e2e/src/fixtures/1.6/carriers.json +++ b/e2e/src/fixtures/1.6/carriers.json @@ -1,7 +1,7 @@ [ { + "action": "upsert", "collection": "carriers", - "id": "1", "properties": { "id_carrier": "1", "id_reference": "1", @@ -30,8 +30,8 @@ } }, { + "action": "upsert", "collection": "carriers", - "id": "2", "properties": { "id_carrier": "2", "id_reference": "2", diff --git a/e2e/src/fixtures/1.6/cart_products.json b/e2e/src/fixtures/1.6/cart_products.json index 60efc442..d3505fa0 100644 --- a/e2e/src/fixtures/1.6/cart_products.json +++ b/e2e/src/fixtures/1.6/cart_products.json @@ -1,6 +1,6 @@ [ { - "id": "1-2-10", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -12,7 +12,7 @@ } }, { - "id": "1-3-13", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -24,7 +24,7 @@ } }, { - "id": "2-2-10", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -36,7 +36,7 @@ } }, { - "id": "2-6-32", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -48,7 +48,7 @@ } }, { - "id": "2-7-34", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -60,7 +60,7 @@ } }, { - "id": "3-1-1", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "3", @@ -72,7 +72,7 @@ } }, { - "id": "3-2-10", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "3", @@ -84,7 +84,7 @@ } }, { - "id": "3-6-32", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "3", @@ -96,7 +96,7 @@ } }, { - "id": "4-1-1", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "4", @@ -108,7 +108,7 @@ } }, { - "id": "4-3-13", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "4", @@ -120,7 +120,7 @@ } }, { - "id": "4-5-19", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "4", @@ -132,7 +132,7 @@ } }, { - "id": "4-7-34", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "4", @@ -144,7 +144,7 @@ } }, { - "id": "5-1-1", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "5", @@ -156,7 +156,7 @@ } }, { - "id": "5-2-7", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "5", @@ -168,7 +168,7 @@ } }, { - "id": "5-3-13", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/1.6/carts.json b/e2e/src/fixtures/1.6/carts.json index ee7855aa..a49c2f9b 100644 --- a/e2e/src/fixtures/1.6/carts.json +++ b/e2e/src/fixtures/1.6/carts.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "1", @@ -9,7 +9,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "2", @@ -18,7 +18,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "3", @@ -27,7 +27,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "4", @@ -36,7 +36,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/1.6/categories.json b/e2e/src/fixtures/1.6/categories.json index 03b193f6..c3126624 100644 --- a/e2e/src/fixtures/1.6/categories.json +++ b/e2e/src/fixtures/1.6/categories.json @@ -1,6 +1,6 @@ [ { - "id": "1-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "1-en", @@ -18,7 +18,7 @@ } }, { - "id": "2-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "2-en", @@ -36,7 +36,7 @@ } }, { - "id": "3-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "3-en", @@ -54,7 +54,7 @@ } }, { - "id": "4-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "4-en", @@ -72,7 +72,7 @@ } }, { - "id": "5-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "5-en", @@ -90,7 +90,7 @@ } }, { - "id": "6-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "6-en", @@ -108,7 +108,7 @@ } }, { - "id": "7-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "7-en", @@ -126,7 +126,7 @@ } }, { - "id": "8-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "8-en", @@ -144,7 +144,7 @@ } }, { - "id": "9-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "9-en", @@ -162,7 +162,7 @@ } }, { - "id": "10-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "10-en", @@ -180,7 +180,7 @@ } }, { - "id": "11-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "11-en", diff --git a/e2e/src/fixtures/1.6/currencies.json b/e2e/src/fixtures/1.6/currencies.json index c1a1734b..ace7f805 100644 --- a/e2e/src/fixtures/1.6/currencies.json +++ b/e2e/src/fixtures/1.6/currencies.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 1, @@ -12,7 +12,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 2, diff --git a/e2e/src/fixtures/1.6/customers.json b/e2e/src/fixtures/1.6/customers.json index 42524418..2a73e994 100644 --- a/e2e/src/fixtures/1.6/customers.json +++ b/e2e/src/fixtures/1.6/customers.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "customers", "properties": { "id_customer": 1, diff --git a/e2e/src/fixtures/1.6/employees.json b/e2e/src/fixtures/1.6/employees.json index c7627627..0a7bafcd 100644 --- a/e2e/src/fixtures/1.6/employees.json +++ b/e2e/src/fixtures/1.6/employees.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "employees", "properties": { "id_employee": 1, diff --git a/e2e/src/fixtures/1.6/image_types.json b/e2e/src/fixtures/1.6/image_types.json index 13fbb204..d26aea1f 100644 --- a/e2e/src/fixtures/1.6/image_types.json +++ b/e2e/src/fixtures/1.6/image_types.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 1, @@ -15,7 +15,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 2, @@ -30,7 +30,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 3, @@ -45,7 +45,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 4, @@ -60,7 +60,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 5, @@ -75,7 +75,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 6, @@ -90,7 +90,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 7, @@ -105,7 +105,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 8, @@ -120,7 +120,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 9, diff --git a/e2e/src/fixtures/1.6/images.json b/e2e/src/fixtures/1.6/images.json index baaab889..063a1ae7 100644 --- a/e2e/src/fixtures/1.6/images.json +++ b/e2e/src/fixtures/1.6/images.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "images", "properties": { "id_image": 1, @@ -13,7 +13,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "images", "properties": { "id_image": 2, @@ -26,7 +26,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "images", "properties": { "id_image": 3, @@ -39,7 +39,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "images", "properties": { "id_image": 4, @@ -52,7 +52,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "images", "properties": { "id_image": 5, @@ -65,7 +65,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "images", "properties": { "id_image": 6, @@ -78,7 +78,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "images", "properties": { "id_image": 7, @@ -91,7 +91,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "images", "properties": { "id_image": 8, @@ -104,7 +104,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "images", "properties": { "id_image": 9, @@ -117,7 +117,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "images", "properties": { "id_image": 10, @@ -130,7 +130,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "images", "properties": { "id_image": 11, @@ -143,7 +143,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "images", "properties": { "id_image": 12, @@ -156,7 +156,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "images", "properties": { "id_image": 13, @@ -169,7 +169,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "images", "properties": { "id_image": 14, @@ -182,7 +182,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "images", "properties": { "id_image": 15, @@ -195,7 +195,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "images", "properties": { "id_image": 16, @@ -208,7 +208,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "images", "properties": { "id_image": 17, @@ -221,7 +221,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "images", "properties": { "id_image": 18, @@ -234,7 +234,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "images", "properties": { "id_image": 19, @@ -247,7 +247,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "images", "properties": { "id_image": 20, @@ -260,7 +260,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "images", "properties": { "id_image": 21, @@ -273,7 +273,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "images", "properties": { "id_image": 22, @@ -286,7 +286,7 @@ } }, { - "id": "23", + "action": "upsert", "collection": "images", "properties": { "id_image": 23, diff --git a/e2e/src/fixtures/1.6/languages.json b/e2e/src/fixtures/1.6/languages.json index 983adf8c..e18b1806 100644 --- a/e2e/src/fixtures/1.6/languages.json +++ b/e2e/src/fixtures/1.6/languages.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "languages", "properties": { "id_lang": 1, diff --git a/e2e/src/fixtures/1.6/manufacturers.json b/e2e/src/fixtures/1.6/manufacturers.json index 68a27430..3572111d 100644 --- a/e2e/src/fixtures/1.6/manufacturers.json +++ b/e2e/src/fixtures/1.6/manufacturers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "manufacturers", "properties": { "id_manufacturer": 1, diff --git a/e2e/src/fixtures/1.6/modules.json b/e2e/src/fixtures/1.6/modules.json index 2c75976b..33c40bb5 100644 --- a/e2e/src/fixtures/1.6/modules.json +++ b/e2e/src/fixtures/1.6/modules.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "modules", "properties": { "module_id": "1", @@ -12,7 +12,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "modules", "properties": { "module_id": "2", @@ -24,7 +24,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "modules", "properties": { "module_id": "3", @@ -36,7 +36,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "modules", "properties": { "module_id": "4", @@ -48,7 +48,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "modules", "properties": { "module_id": "5", @@ -60,7 +60,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "modules", "properties": { "module_id": "6", @@ -72,7 +72,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "modules", "properties": { "module_id": "7", @@ -84,7 +84,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "modules", "properties": { "module_id": "8", @@ -96,7 +96,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "modules", "properties": { "module_id": "9", @@ -108,7 +108,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "modules", "properties": { "module_id": "10", @@ -120,7 +120,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "modules", "properties": { "module_id": "11", @@ -132,7 +132,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "modules", "properties": { "module_id": "12", @@ -144,7 +144,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "modules", "properties": { "module_id": "13", @@ -156,7 +156,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "modules", "properties": { "module_id": "14", @@ -168,7 +168,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "modules", "properties": { "module_id": "15", @@ -180,7 +180,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "modules", "properties": { "module_id": "16", @@ -192,7 +192,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "modules", "properties": { "module_id": "17", @@ -204,7 +204,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "modules", "properties": { "module_id": "18", @@ -216,7 +216,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "modules", "properties": { "module_id": "19", @@ -228,7 +228,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "modules", "properties": { "module_id": "20", @@ -240,7 +240,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "modules", "properties": { "module_id": "21", @@ -252,7 +252,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "modules", "properties": { "module_id": "22", @@ -264,7 +264,7 @@ } }, { - "id": "23", + "action": "upsert", "collection": "modules", "properties": { "module_id": "23", @@ -276,7 +276,7 @@ } }, { - "id": "24", + "action": "upsert", "collection": "modules", "properties": { "module_id": "24", @@ -288,7 +288,7 @@ } }, { - "id": "25", + "action": "upsert", "collection": "modules", "properties": { "module_id": "25", @@ -300,7 +300,7 @@ } }, { - "id": "26", + "action": "upsert", "collection": "modules", "properties": { "module_id": "26", @@ -312,7 +312,7 @@ } }, { - "id": "27", + "action": "upsert", "collection": "modules", "properties": { "module_id": "27", @@ -324,7 +324,7 @@ } }, { - "id": "28", + "action": "upsert", "collection": "modules", "properties": { "module_id": "28", @@ -336,7 +336,7 @@ } }, { - "id": "29", + "action": "upsert", "collection": "modules", "properties": { "module_id": "29", @@ -348,7 +348,7 @@ } }, { - "id": "30", + "action": "upsert", "collection": "modules", "properties": { "module_id": "30", @@ -360,7 +360,7 @@ } }, { - "id": "31", + "action": "upsert", "collection": "modules", "properties": { "module_id": "31", @@ -372,7 +372,7 @@ } }, { - "id": "32", + "action": "upsert", "collection": "modules", "properties": { "module_id": "32", @@ -384,7 +384,7 @@ } }, { - "id": "33", + "action": "upsert", "collection": "modules", "properties": { "module_id": "33", @@ -396,7 +396,7 @@ } }, { - "id": "34", + "action": "upsert", "collection": "modules", "properties": { "module_id": "34", @@ -408,7 +408,7 @@ } }, { - "id": "35", + "action": "upsert", "collection": "modules", "properties": { "module_id": "35", @@ -420,7 +420,7 @@ } }, { - "id": "36", + "action": "upsert", "collection": "modules", "properties": { "module_id": "36", @@ -432,7 +432,7 @@ } }, { - "id": "37", + "action": "upsert", "collection": "modules", "properties": { "module_id": "37", @@ -444,7 +444,7 @@ } }, { - "id": "38", + "action": "upsert", "collection": "modules", "properties": { "module_id": "38", @@ -456,7 +456,7 @@ } }, { - "id": "39", + "action": "upsert", "collection": "modules", "properties": { "module_id": "39", @@ -468,7 +468,7 @@ } }, { - "id": "40", + "action": "upsert", "collection": "modules", "properties": { "module_id": "40", @@ -480,7 +480,7 @@ } }, { - "id": "41", + "action": "upsert", "collection": "modules", "properties": { "module_id": "41", @@ -492,7 +492,7 @@ } }, { - "id": "42", + "action": "upsert", "collection": "modules", "properties": { "module_id": "42", @@ -504,7 +504,7 @@ } }, { - "id": "43", + "action": "upsert", "collection": "modules", "properties": { "module_id": "43", @@ -516,7 +516,7 @@ } }, { - "id": "44", + "action": "upsert", "collection": "modules", "properties": { "module_id": "44", @@ -528,7 +528,7 @@ } }, { - "id": "45", + "action": "upsert", "collection": "modules", "properties": { "module_id": "45", @@ -540,7 +540,7 @@ } }, { - "id": "46", + "action": "upsert", "collection": "modules", "properties": { "module_id": "46", @@ -552,7 +552,7 @@ } }, { - "id": "47", + "action": "upsert", "collection": "modules", "properties": { "module_id": "47", @@ -564,7 +564,7 @@ } }, { - "id": "48", + "action": "upsert", "collection": "modules", "properties": { "module_id": "48", @@ -576,7 +576,7 @@ } }, { - "id": "49", + "action": "upsert", "collection": "modules", "properties": { "module_id": "49", @@ -588,7 +588,7 @@ } }, { - "id": "50", + "action": "upsert", "collection": "modules", "properties": { "module_id": "50", @@ -600,7 +600,7 @@ } }, { - "id": "51", + "action": "upsert", "collection": "modules", "properties": { "module_id": "51", @@ -612,7 +612,7 @@ } }, { - "id": "52", + "action": "upsert", "collection": "modules", "properties": { "module_id": "52", @@ -624,7 +624,7 @@ } }, { - "id": "53", + "action": "upsert", "collection": "modules", "properties": { "module_id": "53", @@ -636,7 +636,7 @@ } }, { - "id": "54", + "action": "upsert", "collection": "modules", "properties": { "module_id": "54", @@ -648,7 +648,7 @@ } }, { - "id": "55", + "action": "upsert", "collection": "modules", "properties": { "module_id": "55", @@ -660,7 +660,7 @@ } }, { - "id": "56", + "action": "upsert", "collection": "modules", "properties": { "module_id": "56", @@ -672,7 +672,7 @@ } }, { - "id": "57", + "action": "upsert", "collection": "modules", "properties": { "module_id": "57", @@ -684,7 +684,7 @@ } }, { - "id": "58", + "action": "upsert", "collection": "modules", "properties": { "module_id": "58", @@ -696,7 +696,7 @@ } }, { - "id": "59", + "action": "upsert", "collection": "modules", "properties": { "module_id": "59", @@ -708,7 +708,7 @@ } }, { - "id": "60", + "action": "upsert", "collection": "modules", "properties": { "module_id": "60", @@ -720,7 +720,7 @@ } }, { - "id": "61", + "action": "upsert", "collection": "modules", "properties": { "module_id": "61", @@ -732,7 +732,7 @@ } }, { - "id": "62", + "action": "upsert", "collection": "modules", "properties": { "module_id": "62", @@ -744,7 +744,7 @@ } }, { - "id": "63", + "action": "upsert", "collection": "modules", "properties": { "module_id": "63", @@ -756,7 +756,7 @@ } }, { - "id": "64", + "action": "upsert", "collection": "modules", "properties": { "module_id": "64", @@ -768,7 +768,7 @@ } }, { - "id": "65", + "action": "upsert", "collection": "modules", "properties": { "module_id": "65", @@ -780,7 +780,7 @@ } }, { - "id": "66", + "action": "upsert", "collection": "modules", "properties": { "module_id": "66", @@ -792,7 +792,7 @@ } }, { - "id": "67", + "action": "upsert", "collection": "modules", "properties": { "module_id": "67", @@ -804,7 +804,7 @@ } }, { - "id": "68", + "action": "upsert", "collection": "modules", "properties": { "module_id": "68", @@ -816,7 +816,7 @@ } }, { - "id": "69", + "action": "upsert", "collection": "modules", "properties": { "module_id": "69", diff --git a/e2e/src/fixtures/1.6/order_details.json b/e2e/src/fixtures/1.6/order_details.json index 43771458..619ec48b 100644 --- a/e2e/src/fixtures/1.6/order_details.json +++ b/e2e/src/fixtures/1.6/order_details.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 1, @@ -20,7 +20,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 2, @@ -40,7 +40,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 3, @@ -60,7 +60,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 4, @@ -80,7 +80,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 5, @@ -100,7 +100,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 6, @@ -120,7 +120,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 7, @@ -140,7 +140,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 8, @@ -160,7 +160,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 9, @@ -180,7 +180,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 10, @@ -200,7 +200,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 11, @@ -220,7 +220,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 12, @@ -240,7 +240,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 13, @@ -260,7 +260,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 14, @@ -280,7 +280,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 15, diff --git a/e2e/src/fixtures/1.6/order_status_history.json b/e2e/src/fixtures/1.6/order_status_history.json index e39bdde7..5f92b609 100644 --- a/e2e/src/fixtures/1.6/order_status_history.json +++ b/e2e/src/fixtures/1.6/order_status_history.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -19,7 +19,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -38,7 +38,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -57,7 +57,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -76,7 +76,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 10, @@ -95,7 +95,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 6, @@ -114,7 +114,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 8, diff --git a/e2e/src/fixtures/1.6/orders.json b/e2e/src/fixtures/1.6/orders.json index 1cb964f1..346878e8 100644 --- a/e2e/src/fixtures/1.6/orders.json +++ b/e2e/src/fixtures/1.6/orders.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "orders", "properties": { "id_order": 1, @@ -33,7 +33,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "orders", "properties": { "id_order": 2, @@ -66,7 +66,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "orders", "properties": { "id_order": 3, @@ -99,7 +99,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "orders", "properties": { "id_order": 4, @@ -132,7 +132,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "orders", "properties": { "id_order": 5, diff --git a/e2e/src/fixtures/1.6/product_suppliers.json b/e2e/src/fixtures/1.6/product_suppliers.json index a26e26e2..a25e97e3 100644 --- a/e2e/src/fixtures/1.6/product_suppliers.json +++ b/e2e/src/fixtures/1.6/product_suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 1, @@ -13,7 +13,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 2, @@ -26,7 +26,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 3, @@ -39,7 +39,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 4, @@ -52,7 +52,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 5, @@ -65,7 +65,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 6, @@ -78,7 +78,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 7, diff --git a/e2e/src/fixtures/1.6/products.json b/e2e/src/fixtures/1.6/products.json index a75b1c85..6f2c6a5a 100644 --- a/e2e/src/fixtures/1.6/products.json +++ b/e2e/src/fixtures/1.6/products.json @@ -1,6 +1,6 @@ [ { - "id": "1-2-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -61,7 +61,7 @@ } }, { - "id": "1-3-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -122,7 +122,7 @@ } }, { - "id": "1-4-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -183,7 +183,7 @@ } }, { - "id": "1-5-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -244,7 +244,7 @@ } }, { - "id": "1-6-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -305,7 +305,7 @@ } }, { - "id": "1-1-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -366,7 +366,7 @@ } }, { - "id": "2-8-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -427,7 +427,7 @@ } }, { - "id": "2-9-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -488,7 +488,7 @@ } }, { - "id": "2-10-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -549,7 +549,7 @@ } }, { - "id": "2-11-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -610,7 +610,7 @@ } }, { - "id": "2-12-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -671,7 +671,7 @@ } }, { - "id": "2-7-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -732,7 +732,7 @@ } }, { - "id": "3-14-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -793,7 +793,7 @@ } }, { - "id": "3-15-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -854,7 +854,7 @@ } }, { - "id": "3-13-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -915,7 +915,7 @@ } }, { - "id": "4-17-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -976,7 +976,7 @@ } }, { - "id": "4-18-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1037,7 +1037,7 @@ } }, { - "id": "4-43-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1098,7 +1098,7 @@ } }, { - "id": "4-44-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1159,7 +1159,7 @@ } }, { - "id": "4-45-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1220,7 +1220,7 @@ } }, { - "id": "4-16-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1281,7 +1281,7 @@ } }, { - "id": "5-20-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1342,7 +1342,7 @@ } }, { - "id": "5-21-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1403,7 +1403,7 @@ } }, { - "id": "5-22-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1464,7 +1464,7 @@ } }, { - "id": "5-23-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1525,7 +1525,7 @@ } }, { - "id": "5-24-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1586,7 +1586,7 @@ } }, { - "id": "5-25-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1647,7 +1647,7 @@ } }, { - "id": "5-26-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1708,7 +1708,7 @@ } }, { - "id": "5-27-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1769,7 +1769,7 @@ } }, { - "id": "5-28-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1830,7 +1830,7 @@ } }, { - "id": "5-29-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1891,7 +1891,7 @@ } }, { - "id": "5-30-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1952,7 +1952,7 @@ } }, { - "id": "5-19-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -2013,7 +2013,7 @@ } }, { - "id": "6-32-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -2074,7 +2074,7 @@ } }, { - "id": "6-33-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -2135,7 +2135,7 @@ } }, { - "id": "6-40-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -2196,7 +2196,7 @@ } }, { - "id": "6-41-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -2257,7 +2257,7 @@ } }, { - "id": "6-42-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -2318,7 +2318,7 @@ } }, { - "id": "6-31-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -2379,7 +2379,7 @@ } }, { - "id": "7-35-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -2440,7 +2440,7 @@ } }, { - "id": "7-36-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -2501,7 +2501,7 @@ } }, { - "id": "7-37-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -2562,7 +2562,7 @@ } }, { - "id": "7-38-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -2623,7 +2623,7 @@ } }, { - "id": "7-39-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -2684,7 +2684,7 @@ } }, { - "id": "7-34-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, diff --git a/e2e/src/fixtures/1.6/shops.json b/e2e/src/fixtures/1.6/shops.json index 5ccb60ce..430926cd 100644 --- a/e2e/src/fixtures/1.6/shops.json +++ b/e2e/src/fixtures/1.6/shops.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "shops", "properties": { "created_at": "2024-07-16 15:33:52", diff --git a/e2e/src/fixtures/1.6/specific_prices.json b/e2e/src/fixtures/1.6/specific_prices.json index 66bd33b4..6a9a3b49 100644 --- a/e2e/src/fixtures/1.6/specific_prices.json +++ b/e2e/src/fixtures/1.6/specific_prices.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 1, @@ -31,7 +31,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 2, diff --git a/e2e/src/fixtures/1.6/stocks.json b/e2e/src/fixtures/1.6/stocks.json index d58cf9b3..2d08f970 100644 --- a/e2e/src/fixtures/1.6/stocks.json +++ b/e2e/src/fixtures/1.6/stocks.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 1, @@ -14,7 +14,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 2, @@ -28,7 +28,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 3, @@ -42,7 +42,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 4, @@ -56,7 +56,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 5, @@ -70,7 +70,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 6, @@ -84,7 +84,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 7, @@ -98,7 +98,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 8, @@ -112,7 +112,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 9, @@ -126,7 +126,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 10, @@ -140,7 +140,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 11, @@ -154,7 +154,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 12, @@ -168,7 +168,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 13, @@ -182,7 +182,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 14, @@ -196,7 +196,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 15, @@ -210,7 +210,7 @@ } }, { - "id": 16, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 16, @@ -224,7 +224,7 @@ } }, { - "id": 17, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 17, @@ -238,7 +238,7 @@ } }, { - "id": 18, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 18, @@ -252,7 +252,7 @@ } }, { - "id": 19, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 19, @@ -266,7 +266,7 @@ } }, { - "id": 20, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 20, @@ -280,7 +280,7 @@ } }, { - "id": 21, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 21, @@ -294,7 +294,7 @@ } }, { - "id": 22, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 22, @@ -308,7 +308,7 @@ } }, { - "id": 23, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 23, @@ -322,7 +322,7 @@ } }, { - "id": 24, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 24, @@ -336,7 +336,7 @@ } }, { - "id": 25, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 25, @@ -350,7 +350,7 @@ } }, { - "id": 26, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 26, @@ -364,7 +364,7 @@ } }, { - "id": 27, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 27, @@ -378,7 +378,7 @@ } }, { - "id": 28, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 28, @@ -392,7 +392,7 @@ } }, { - "id": 29, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 29, @@ -406,7 +406,7 @@ } }, { - "id": 30, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 30, @@ -420,7 +420,7 @@ } }, { - "id": 31, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 31, @@ -434,7 +434,7 @@ } }, { - "id": 32, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 32, @@ -448,7 +448,7 @@ } }, { - "id": 33, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 33, @@ -462,7 +462,7 @@ } }, { - "id": 34, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 34, @@ -476,7 +476,7 @@ } }, { - "id": 35, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 35, @@ -490,7 +490,7 @@ } }, { - "id": 36, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 36, @@ -504,7 +504,7 @@ } }, { - "id": 37, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 37, @@ -518,7 +518,7 @@ } }, { - "id": 38, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 38, @@ -532,7 +532,7 @@ } }, { - "id": 39, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 39, @@ -546,7 +546,7 @@ } }, { - "id": 40, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 40, @@ -560,7 +560,7 @@ } }, { - "id": 41, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 41, @@ -574,7 +574,7 @@ } }, { - "id": 42, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 42, @@ -588,7 +588,7 @@ } }, { - "id": 43, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 43, @@ -602,7 +602,7 @@ } }, { - "id": 44, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 44, @@ -616,7 +616,7 @@ } }, { - "id": 45, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 45, @@ -630,7 +630,7 @@ } }, { - "id": 46, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 46, @@ -644,7 +644,7 @@ } }, { - "id": 47, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 47, @@ -658,7 +658,7 @@ } }, { - "id": 48, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 48, @@ -672,7 +672,7 @@ } }, { - "id": 49, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 49, @@ -686,7 +686,7 @@ } }, { - "id": 50, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 50, @@ -700,7 +700,7 @@ } }, { - "id": 51, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 51, @@ -714,7 +714,7 @@ } }, { - "id": 52, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 52, diff --git a/e2e/src/fixtures/1.6/stores.json b/e2e/src/fixtures/1.6/stores.json index 0bd37217..df1501ed 100644 --- a/e2e/src/fixtures/1.6/stores.json +++ b/e2e/src/fixtures/1.6/stores.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stores", "properties": { "id_store": 1, @@ -18,7 +18,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stores", "properties": { "id_store": 2, @@ -36,7 +36,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stores", "properties": { "id_store": 3, @@ -54,7 +54,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stores", "properties": { "id_store": 4, @@ -72,7 +72,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stores", "properties": { "id_store": 5, diff --git a/e2e/src/fixtures/1.6/suppliers.json b/e2e/src/fixtures/1.6/suppliers.json index 9a577579..d1dff472 100644 --- a/e2e/src/fixtures/1.6/suppliers.json +++ b/e2e/src/fixtures/1.6/suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "suppliers", "properties": { "id_supplier": 1, diff --git a/e2e/src/fixtures/1.6/themes.json b/e2e/src/fixtures/1.6/themes.json index 737943a7..b6d055ee 100644 --- a/e2e/src/fixtures/1.6/themes.json +++ b/e2e/src/fixtures/1.6/themes.json @@ -1,6 +1,6 @@ [ { - "id": "f3e39421159095f9fb628aea58bd1907", + "action": "upsert", "collection": "themes", "properties": { "theme_id": "f3e39421159095f9fb628aea58bd1907", diff --git a/e2e/src/fixtures/1.7/bundles.json b/e2e/src/fixtures/1.7/bundles.json index 7fced11c..fac3dce8 100644 --- a/e2e/src/fixtures/1.7/bundles.json +++ b/e2e/src/fixtures/1.7/bundles.json @@ -1,6 +1,6 @@ [ { - "id": "15", + "action": "upsert", "collection": "bundles", "properties": { "id_bundle": "15", @@ -11,7 +11,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "bundles", "properties": { "id_bundle": "15", diff --git a/e2e/src/fixtures/1.7/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json index e5081835..502f304c 100644 --- a/e2e/src/fixtures/1.7/carrier_details.json +++ b/e2e/src/fixtures/1.7/carrier_details.json @@ -1,6 +1,6 @@ [ { - "id": "2-1-range_weight-1", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "2", @@ -16,7 +16,7 @@ } }, { - "id": "2-2-range_weight-1", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "2", @@ -32,7 +32,7 @@ } }, { - "id": "3-2-range_price-2", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "3", @@ -48,7 +48,7 @@ } }, { - "id": "3-1-range_price-2", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "3", @@ -64,7 +64,7 @@ } }, { - "id": "3-2-range_price-3", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "3", @@ -80,7 +80,7 @@ } }, { - "id": "3-1-range_price-3", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "3", @@ -96,7 +96,7 @@ } }, { - "id": "3-2-range_price-4", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "3", @@ -112,7 +112,7 @@ } }, { - "id": "3-1-range_price-4", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "3", @@ -128,7 +128,7 @@ } }, { - "id": "4-2-range_weight-2", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "4", @@ -144,7 +144,7 @@ } }, { - "id": "4-1-range_weight-2", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "4", @@ -160,7 +160,7 @@ } }, { - "id": "4-2-range_weight-3", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "4", @@ -176,7 +176,7 @@ } }, { - "id": "4-1-range_weight-3", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "4", @@ -192,7 +192,7 @@ } }, { - "id": "4-2-range_weight-4", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "4", @@ -208,7 +208,7 @@ } }, { - "id": "4-1-range_weight-4", + "action": "upsert", "collection": "carrier_details", "properties": { "id_reference": "4", diff --git a/e2e/src/fixtures/1.7/carriers.json b/e2e/src/fixtures/1.7/carriers.json index bef1dd4a..edb2df8d 100644 --- a/e2e/src/fixtures/1.7/carriers.json +++ b/e2e/src/fixtures/1.7/carriers.json @@ -1,7 +1,7 @@ [ { + "action": "upsert", "collection": "carriers", - "id": "3", "properties": { "id_carrier": "3", "id_reference": "3", @@ -30,8 +30,8 @@ } }, { + "action": "upsert", "collection": "carriers", - "id": "4", "properties": { "id_carrier": "4", "id_reference": "4", @@ -60,8 +60,8 @@ } }, { + "action": "upsert", "collection": "carriers", - "id": "1", "properties": { "id_carrier": "1", "id_reference": "1", @@ -90,8 +90,8 @@ } }, { + "action": "upsert", "collection": "carriers", - "id": "2", "properties": { "id_carrier": "2", "id_reference": "2", diff --git a/e2e/src/fixtures/1.7/cart_products.json b/e2e/src/fixtures/1.7/cart_products.json index c4af221f..2d245056 100644 --- a/e2e/src/fixtures/1.7/cart_products.json +++ b/e2e/src/fixtures/1.7/cart_products.json @@ -1,6 +1,6 @@ [ { - "id": "1-1-1", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -12,7 +12,7 @@ } }, { - "id": "1-2-9", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -24,7 +24,7 @@ } }, { - "id": "2-4-18", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -36,7 +36,7 @@ } }, { - "id": "2-8-0", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -48,7 +48,7 @@ } }, { - "id": "3-16-28", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "3", @@ -60,7 +60,7 @@ } }, { - "id": "4-16-29", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "4", @@ -72,7 +72,7 @@ } }, { - "id": "5-10-25", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/1.7/carts.json b/e2e/src/fixtures/1.7/carts.json index f0d08485..64a6a70d 100644 --- a/e2e/src/fixtures/1.7/carts.json +++ b/e2e/src/fixtures/1.7/carts.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "1", @@ -9,7 +9,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "2", @@ -18,7 +18,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "3", @@ -27,7 +27,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "4", @@ -36,7 +36,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/1.7/categories.json b/e2e/src/fixtures/1.7/categories.json index e1afb9d0..92cfea7b 100644 --- a/e2e/src/fixtures/1.7/categories.json +++ b/e2e/src/fixtures/1.7/categories.json @@ -1,6 +1,6 @@ [ { - "id": "1-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "1-en", @@ -18,7 +18,7 @@ } }, { - "id": "2-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "2-en", @@ -36,7 +36,7 @@ } }, { - "id": "3-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "3-en", @@ -54,7 +54,7 @@ } }, { - "id": "4-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "4-en", @@ -72,7 +72,7 @@ } }, { - "id": "5-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "5-en", @@ -90,7 +90,7 @@ } }, { - "id": "6-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "6-en", @@ -108,7 +108,7 @@ } }, { - "id": "7-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "7-en", @@ -126,7 +126,7 @@ } }, { - "id": "8-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "8-en", @@ -144,7 +144,7 @@ } }, { - "id": "9-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "9-en", diff --git a/e2e/src/fixtures/1.7/currencies.json b/e2e/src/fixtures/1.7/currencies.json index 877caf69..780dc095 100644 --- a/e2e/src/fixtures/1.7/currencies.json +++ b/e2e/src/fixtures/1.7/currencies.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 1, @@ -13,7 +13,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 2, diff --git a/e2e/src/fixtures/1.7/customers.json b/e2e/src/fixtures/1.7/customers.json index 2260f3a9..06a16dca 100644 --- a/e2e/src/fixtures/1.7/customers.json +++ b/e2e/src/fixtures/1.7/customers.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "customers", "properties": { "id_customer": 1, @@ -17,7 +17,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "customers", "properties": { "id_customer": 2, diff --git a/e2e/src/fixtures/1.7/employees.json b/e2e/src/fixtures/1.7/employees.json index 747c86b6..cb046d42 100644 --- a/e2e/src/fixtures/1.7/employees.json +++ b/e2e/src/fixtures/1.7/employees.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "employees", "properties": { "id_employee": 1, diff --git a/e2e/src/fixtures/1.7/image_types.json b/e2e/src/fixtures/1.7/image_types.json index b8cbf800..7d0cba7f 100644 --- a/e2e/src/fixtures/1.7/image_types.json +++ b/e2e/src/fixtures/1.7/image_types.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 1, @@ -15,7 +15,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 2, @@ -30,7 +30,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 3, @@ -45,7 +45,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 4, @@ -60,7 +60,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 5, @@ -75,7 +75,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 6, @@ -90,7 +90,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 7, diff --git a/e2e/src/fixtures/1.7/images.json b/e2e/src/fixtures/1.7/images.json index 9927ccb0..8dea38a2 100644 --- a/e2e/src/fixtures/1.7/images.json +++ b/e2e/src/fixtures/1.7/images.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "images", "properties": { "id_image": 1, @@ -13,7 +13,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "images", "properties": { "id_image": 2, @@ -26,7 +26,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "images", "properties": { "id_image": 3, @@ -39,7 +39,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "images", "properties": { "id_image": 4, @@ -52,7 +52,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "images", "properties": { "id_image": 5, @@ -65,7 +65,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "images", "properties": { "id_image": 6, @@ -78,7 +78,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "images", "properties": { "id_image": 7, @@ -91,7 +91,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "images", "properties": { "id_image": 8, @@ -104,7 +104,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "images", "properties": { "id_image": 9, @@ -117,7 +117,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "images", "properties": { "id_image": 10, @@ -130,7 +130,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "images", "properties": { "id_image": 11, @@ -143,7 +143,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "images", "properties": { "id_image": 12, @@ -156,7 +156,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "images", "properties": { "id_image": 13, @@ -169,7 +169,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "images", "properties": { "id_image": 14, @@ -182,7 +182,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "images", "properties": { "id_image": 15, @@ -195,7 +195,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "images", "properties": { "id_image": 16, @@ -208,7 +208,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "images", "properties": { "id_image": 17, @@ -221,7 +221,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "images", "properties": { "id_image": 18, @@ -234,7 +234,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "images", "properties": { "id_image": 19, @@ -247,7 +247,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "images", "properties": { "id_image": 20, @@ -260,7 +260,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "images", "properties": { "id_image": 21, @@ -273,7 +273,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "images", "properties": { "id_image": 22, @@ -286,7 +286,7 @@ } }, { - "id": "23", + "action": "upsert", "collection": "images", "properties": { "id_image": 23, diff --git a/e2e/src/fixtures/1.7/languages.json b/e2e/src/fixtures/1.7/languages.json index 8c0b6eb5..7f08db6e 100644 --- a/e2e/src/fixtures/1.7/languages.json +++ b/e2e/src/fixtures/1.7/languages.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "languages", "properties": { "id_lang": 1, diff --git a/e2e/src/fixtures/1.7/manufacturers.json b/e2e/src/fixtures/1.7/manufacturers.json index fbb33521..aa9bdb73 100644 --- a/e2e/src/fixtures/1.7/manufacturers.json +++ b/e2e/src/fixtures/1.7/manufacturers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "manufacturers", "properties": { "id_manufacturer": 1, @@ -18,7 +18,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "manufacturers", "properties": { "id_manufacturer": 2, diff --git a/e2e/src/fixtures/1.7/modules.json b/e2e/src/fixtures/1.7/modules.json index b2ca101a..fdbb20db 100644 --- a/e2e/src/fixtures/1.7/modules.json +++ b/e2e/src/fixtures/1.7/modules.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "modules", "properties": { "module_id": "1", @@ -12,7 +12,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "modules", "properties": { "module_id": "2", @@ -24,7 +24,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "modules", "properties": { "module_id": "3", @@ -36,7 +36,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "modules", "properties": { "module_id": "4", @@ -48,7 +48,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "modules", "properties": { "module_id": "5", @@ -60,7 +60,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "modules", "properties": { "module_id": "6", @@ -72,7 +72,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "modules", "properties": { "module_id": "7", @@ -84,7 +84,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "modules", "properties": { "module_id": "8", @@ -96,7 +96,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "modules", "properties": { "module_id": "9", @@ -108,7 +108,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "modules", "properties": { "module_id": "10", @@ -120,7 +120,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "modules", "properties": { "module_id": "11", @@ -132,7 +132,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "modules", "properties": { "module_id": "12", @@ -144,7 +144,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "modules", "properties": { "module_id": "13", @@ -156,7 +156,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "modules", "properties": { "module_id": "14", @@ -168,7 +168,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "modules", "properties": { "module_id": "15", @@ -180,7 +180,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "modules", "properties": { "module_id": "16", @@ -192,7 +192,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "modules", "properties": { "module_id": "17", @@ -204,7 +204,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "modules", "properties": { "module_id": "18", @@ -216,7 +216,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "modules", "properties": { "module_id": "19", @@ -228,7 +228,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "modules", "properties": { "module_id": "20", @@ -240,7 +240,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "modules", "properties": { "module_id": "21", @@ -252,7 +252,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "modules", "properties": { "module_id": "22", @@ -264,7 +264,7 @@ } }, { - "id": "24", + "action": "upsert", "collection": "modules", "properties": { "module_id": "24", @@ -276,7 +276,7 @@ } }, { - "id": "25", + "action": "upsert", "collection": "modules", "properties": { "module_id": "25", @@ -288,7 +288,7 @@ } }, { - "id": "26", + "action": "upsert", "collection": "modules", "properties": { "module_id": "26", @@ -300,7 +300,7 @@ } }, { - "id": "27", + "action": "upsert", "collection": "modules", "properties": { "module_id": "27", @@ -312,7 +312,7 @@ } }, { - "id": "28", + "action": "upsert", "collection": "modules", "properties": { "module_id": "28", @@ -324,7 +324,7 @@ } }, { - "id": "29", + "action": "upsert", "collection": "modules", "properties": { "module_id": "29", @@ -336,7 +336,7 @@ } }, { - "id": "30", + "action": "upsert", "collection": "modules", "properties": { "module_id": "30", @@ -348,7 +348,7 @@ } }, { - "id": "31", + "action": "upsert", "collection": "modules", "properties": { "module_id": "31", @@ -360,7 +360,7 @@ } }, { - "id": "32", + "action": "upsert", "collection": "modules", "properties": { "module_id": "32", @@ -372,7 +372,7 @@ } }, { - "id": "33", + "action": "upsert", "collection": "modules", "properties": { "module_id": "33", @@ -384,7 +384,7 @@ } }, { - "id": "34", + "action": "upsert", "collection": "modules", "properties": { "module_id": "34", @@ -396,7 +396,7 @@ } }, { - "id": "35", + "action": "upsert", "collection": "modules", "properties": { "module_id": "35", @@ -408,7 +408,7 @@ } }, { - "id": "36", + "action": "upsert", "collection": "modules", "properties": { "module_id": "36", @@ -420,7 +420,7 @@ } }, { - "id": "37", + "action": "upsert", "collection": "modules", "properties": { "module_id": "37", @@ -432,7 +432,7 @@ } }, { - "id": "38", + "action": "upsert", "collection": "modules", "properties": { "module_id": "38", @@ -444,7 +444,7 @@ } }, { - "id": "39", + "action": "upsert", "collection": "modules", "properties": { "module_id": "39", @@ -456,7 +456,7 @@ } }, { - "id": "40", + "action": "upsert", "collection": "modules", "properties": { "module_id": "40", @@ -468,7 +468,7 @@ } }, { - "id": "41", + "action": "upsert", "collection": "modules", "properties": { "module_id": "41", @@ -480,7 +480,7 @@ } }, { - "id": "42", + "action": "upsert", "collection": "modules", "properties": { "module_id": "42", @@ -492,7 +492,7 @@ } }, { - "id": "43", + "action": "upsert", "collection": "modules", "properties": { "module_id": "43", @@ -504,7 +504,7 @@ } }, { - "id": "44", + "action": "upsert", "collection": "modules", "properties": { "module_id": "44", @@ -516,7 +516,7 @@ } }, { - "id": "45", + "action": "upsert", "collection": "modules", "properties": { "module_id": "45", @@ -528,7 +528,7 @@ } }, { - "id": "46", + "action": "upsert", "collection": "modules", "properties": { "module_id": "46", @@ -540,7 +540,7 @@ } }, { - "id": "47", + "action": "upsert", "collection": "modules", "properties": { "module_id": "47", @@ -552,7 +552,7 @@ } }, { - "id": "48", + "action": "upsert", "collection": "modules", "properties": { "module_id": "48", @@ -564,7 +564,7 @@ } }, { - "id": "49", + "action": "upsert", "collection": "modules", "properties": { "module_id": "49", @@ -576,7 +576,7 @@ } }, { - "id": "50", + "action": "upsert", "collection": "modules", "properties": { "module_id": "50", @@ -588,7 +588,7 @@ } }, { - "id": "51", + "action": "upsert", "collection": "modules", "properties": { "module_id": "51", @@ -600,7 +600,7 @@ } }, { - "id": "52", + "action": "upsert", "collection": "modules", "properties": { "module_id": "52", @@ -612,7 +612,7 @@ } }, { - "id": "53", + "action": "upsert", "collection": "modules", "properties": { "module_id": "53", @@ -624,7 +624,7 @@ } }, { - "id": "54", + "action": "upsert", "collection": "modules", "properties": { "module_id": "54", @@ -636,7 +636,7 @@ } }, { - "id": "55", + "action": "upsert", "collection": "modules", "properties": { "module_id": "55", @@ -648,7 +648,7 @@ } }, { - "id": "56", + "action": "upsert", "collection": "modules", "properties": { "module_id": "56", @@ -660,7 +660,7 @@ } }, { - "id": "57", + "action": "upsert", "collection": "modules", "properties": { "module_id": "57", @@ -672,7 +672,7 @@ } }, { - "id": "58", + "action": "upsert", "collection": "modules", "properties": { "module_id": "58", @@ -684,7 +684,7 @@ } }, { - "id": "59", + "action": "upsert", "collection": "modules", "properties": { "module_id": "59", @@ -696,7 +696,7 @@ } }, { - "id": "60", + "action": "upsert", "collection": "modules", "properties": { "module_id": "60", @@ -708,7 +708,7 @@ } }, { - "id": "61", + "action": "upsert", "collection": "modules", "properties": { "module_id": "61", @@ -720,7 +720,7 @@ } }, { - "id": "62", + "action": "upsert", "collection": "modules", "properties": { "module_id": "62", @@ -732,7 +732,7 @@ } }, { - "id": "63", + "action": "upsert", "collection": "modules", "properties": { "module_id": "63", @@ -744,7 +744,7 @@ } }, { - "id": "64", + "action": "upsert", "collection": "modules", "properties": { "module_id": "64", diff --git a/e2e/src/fixtures/1.7/order_details.json b/e2e/src/fixtures/1.7/order_details.json index 9f313260..36a44a9b 100644 --- a/e2e/src/fixtures/1.7/order_details.json +++ b/e2e/src/fixtures/1.7/order_details.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 1, @@ -20,7 +20,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 2, @@ -40,7 +40,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 3, @@ -60,7 +60,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 4, @@ -80,7 +80,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 5, @@ -100,7 +100,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 6, @@ -120,7 +120,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 7, diff --git a/e2e/src/fixtures/1.7/order_status_history.json b/e2e/src/fixtures/1.7/order_status_history.json index 80aa3b22..3039affb 100644 --- a/e2e/src/fixtures/1.7/order_status_history.json +++ b/e2e/src/fixtures/1.7/order_status_history.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -19,7 +19,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -38,7 +38,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -57,7 +57,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -76,7 +76,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 10, @@ -95,7 +95,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 6, @@ -114,7 +114,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 8, diff --git a/e2e/src/fixtures/1.7/orders.json b/e2e/src/fixtures/1.7/orders.json index aea28404..e1cf8c9a 100644 --- a/e2e/src/fixtures/1.7/orders.json +++ b/e2e/src/fixtures/1.7/orders.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "orders", "properties": { "id_order": 1, @@ -33,7 +33,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "orders", "properties": { "id_order": 2, @@ -66,7 +66,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "orders", "properties": { "id_order": 3, @@ -99,7 +99,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "orders", "properties": { "id_order": 4, @@ -132,7 +132,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "orders", "properties": { "id_order": 5, diff --git a/e2e/src/fixtures/1.7/product_suppliers.json b/e2e/src/fixtures/1.7/product_suppliers.json index 17a9024f..f180aff8 100644 --- a/e2e/src/fixtures/1.7/product_suppliers.json +++ b/e2e/src/fixtures/1.7/product_suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 1, @@ -13,7 +13,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 2, @@ -26,7 +26,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 3, @@ -39,7 +39,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 4, @@ -52,7 +52,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 5, @@ -65,7 +65,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 6, @@ -78,7 +78,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 7, @@ -91,7 +91,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 8, @@ -104,7 +104,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 9, @@ -117,7 +117,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 10, @@ -130,7 +130,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 11, @@ -143,7 +143,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 12, @@ -156,7 +156,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 13, @@ -169,7 +169,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 14, @@ -182,7 +182,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 15, @@ -195,7 +195,7 @@ } }, { - "id": 16, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 16, @@ -208,7 +208,7 @@ } }, { - "id": 17, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 17, @@ -221,7 +221,7 @@ } }, { - "id": 18, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 18, @@ -234,7 +234,7 @@ } }, { - "id": 19, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 19, @@ -247,7 +247,7 @@ } }, { - "id": 20, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 20, @@ -260,7 +260,7 @@ } }, { - "id": 21, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 21, @@ -273,7 +273,7 @@ } }, { - "id": 22, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 22, @@ -286,7 +286,7 @@ } }, { - "id": 23, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 23, @@ -299,7 +299,7 @@ } }, { - "id": 24, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 24, @@ -312,7 +312,7 @@ } }, { - "id": 25, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 25, @@ -325,7 +325,7 @@ } }, { - "id": 26, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 26, @@ -338,7 +338,7 @@ } }, { - "id": 27, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 27, @@ -351,7 +351,7 @@ } }, { - "id": 28, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 28, @@ -364,7 +364,7 @@ } }, { - "id": 29, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 29, @@ -377,7 +377,7 @@ } }, { - "id": 30, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 30, @@ -390,7 +390,7 @@ } }, { - "id": 31, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 31, @@ -403,7 +403,7 @@ } }, { - "id": 32, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 32, @@ -416,7 +416,7 @@ } }, { - "id": 33, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 33, @@ -429,7 +429,7 @@ } }, { - "id": 34, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 34, @@ -442,7 +442,7 @@ } }, { - "id": 35, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 35, @@ -455,7 +455,7 @@ } }, { - "id": 36, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 36, @@ -468,7 +468,7 @@ } }, { - "id": 37, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 37, @@ -481,7 +481,7 @@ } }, { - "id": 38, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 38, @@ -494,7 +494,7 @@ } }, { - "id": 39, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 39, @@ -507,7 +507,7 @@ } }, { - "id": 40, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 40, @@ -520,7 +520,7 @@ } }, { - "id": 41, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 41, @@ -533,7 +533,7 @@ } }, { - "id": 42, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 42, @@ -546,7 +546,7 @@ } }, { - "id": 43, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 43, @@ -559,7 +559,7 @@ } }, { - "id": 44, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 44, @@ -572,7 +572,7 @@ } }, { - "id": 45, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 45, @@ -585,7 +585,7 @@ } }, { - "id": 46, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 46, @@ -598,7 +598,7 @@ } }, { - "id": 47, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 47, @@ -611,7 +611,7 @@ } }, { - "id": 48, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 48, @@ -624,7 +624,7 @@ } }, { - "id": 49, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 49, @@ -637,7 +637,7 @@ } }, { - "id": 50, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 50, @@ -650,7 +650,7 @@ } }, { - "id": 51, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 51, @@ -663,7 +663,7 @@ } }, { - "id": 52, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 52, @@ -676,7 +676,7 @@ } }, { - "id": 53, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 53, @@ -689,7 +689,7 @@ } }, { - "id": 54, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 54, @@ -702,7 +702,7 @@ } }, { - "id": 55, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 55, @@ -715,7 +715,7 @@ } }, { - "id": 56, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 56, @@ -728,7 +728,7 @@ } }, { - "id": 57, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 57, @@ -741,7 +741,7 @@ } }, { - "id": 58, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 58, @@ -754,7 +754,7 @@ } }, { - "id": 59, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 59, @@ -767,7 +767,7 @@ } }, { - "id": 60, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 60, @@ -780,7 +780,7 @@ } }, { - "id": 61, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 61, @@ -793,7 +793,7 @@ } }, { - "id": 62, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 62, @@ -806,7 +806,7 @@ } }, { - "id": 63, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 63, @@ -819,7 +819,7 @@ } }, { - "id": 64, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 64, @@ -832,7 +832,7 @@ } }, { - "id": 65, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 65, @@ -845,7 +845,7 @@ } }, { - "id": 66, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 66, @@ -858,7 +858,7 @@ } }, { - "id": 67, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 67, @@ -871,7 +871,7 @@ } }, { - "id": 68, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 68, @@ -884,7 +884,7 @@ } }, { - "id": 69, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 69, @@ -897,7 +897,7 @@ } }, { - "id": 70, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 70, diff --git a/e2e/src/fixtures/1.7/products.json b/e2e/src/fixtures/1.7/products.json index b6ae4bc3..ba544a20 100644 --- a/e2e/src/fixtures/1.7/products.json +++ b/e2e/src/fixtures/1.7/products.json @@ -1,6 +1,6 @@ [ { - "id": "1-2-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -63,7 +63,7 @@ } }, { - "id": "1-3-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -126,7 +126,7 @@ } }, { - "id": "1-4-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -189,7 +189,7 @@ } }, { - "id": "1-5-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -252,7 +252,7 @@ } }, { - "id": "1-6-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -315,7 +315,7 @@ } }, { - "id": "1-7-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -378,7 +378,7 @@ } }, { - "id": "1-8-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -441,7 +441,7 @@ } }, { - "id": "1-1-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -504,7 +504,7 @@ } }, { - "id": "2-10-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -566,7 +566,7 @@ } }, { - "id": "2-11-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -628,7 +628,7 @@ } }, { - "id": "2-12-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -690,7 +690,7 @@ } }, { - "id": "2-9-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -752,7 +752,7 @@ } }, { - "id": "3-14-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -813,7 +813,7 @@ } }, { - "id": "3-15-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -874,7 +874,7 @@ } }, { - "id": "3-13-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -935,7 +935,7 @@ } }, { - "id": "4-17-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -996,7 +996,7 @@ } }, { - "id": "4-18-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1057,7 +1057,7 @@ } }, { - "id": "4-16-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1118,7 +1118,7 @@ } }, { - "id": "5-20-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1179,7 +1179,7 @@ } }, { - "id": "5-21-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1240,7 +1240,7 @@ } }, { - "id": "5-19-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1301,7 +1301,7 @@ } }, { - "id": "6-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -1360,7 +1360,7 @@ } }, { - "id": "7-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -1419,7 +1419,7 @@ } }, { - "id": "8-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 8, @@ -1478,7 +1478,7 @@ } }, { - "id": "9-23-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 9, @@ -1540,7 +1540,7 @@ } }, { - "id": "9-22-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 9, @@ -1602,7 +1602,7 @@ } }, { - "id": "10-25-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 10, @@ -1664,7 +1664,7 @@ } }, { - "id": "10-24-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 10, @@ -1726,7 +1726,7 @@ } }, { - "id": "11-27-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 11, @@ -1788,7 +1788,7 @@ } }, { - "id": "11-26-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 11, @@ -1850,7 +1850,7 @@ } }, { - "id": "12-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 12, @@ -1907,7 +1907,7 @@ } }, { - "id": "13-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 13, @@ -1964,7 +1964,7 @@ } }, { - "id": "14-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 14, @@ -2021,7 +2021,7 @@ } }, { - "id": "15-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 15, @@ -2078,7 +2078,7 @@ } }, { - "id": "16-29-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2140,7 +2140,7 @@ } }, { - "id": "16-30-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2202,7 +2202,7 @@ } }, { - "id": "16-31-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2264,7 +2264,7 @@ } }, { - "id": "16-28-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2326,7 +2326,7 @@ } }, { - "id": "17-33-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2388,7 +2388,7 @@ } }, { - "id": "17-34-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2450,7 +2450,7 @@ } }, { - "id": "17-35-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2512,7 +2512,7 @@ } }, { - "id": "17-32-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2574,7 +2574,7 @@ } }, { - "id": "18-37-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2636,7 +2636,7 @@ } }, { - "id": "18-38-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2698,7 +2698,7 @@ } }, { - "id": "18-39-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2760,7 +2760,7 @@ } }, { - "id": "18-36-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2822,7 +2822,7 @@ } }, { - "id": "19-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 19, diff --git a/e2e/src/fixtures/1.7/shops.json b/e2e/src/fixtures/1.7/shops.json index b29741e3..854c0275 100644 --- a/e2e/src/fixtures/1.7/shops.json +++ b/e2e/src/fixtures/1.7/shops.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "shops", "properties": { "created_at": "2023-12-20 22:56:03", diff --git a/e2e/src/fixtures/1.7/specific_prices.json b/e2e/src/fixtures/1.7/specific_prices.json index f179c309..222d03f4 100644 --- a/e2e/src/fixtures/1.7/specific_prices.json +++ b/e2e/src/fixtures/1.7/specific_prices.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 1, @@ -31,7 +31,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 2, diff --git a/e2e/src/fixtures/1.7/stocks.json b/e2e/src/fixtures/1.7/stocks.json index b95df9a4..12efb5ae 100644 --- a/e2e/src/fixtures/1.7/stocks.json +++ b/e2e/src/fixtures/1.7/stocks.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 1, @@ -17,7 +17,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 2, @@ -34,7 +34,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 3, @@ -51,7 +51,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 4, @@ -68,7 +68,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 5, @@ -85,7 +85,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 6, @@ -102,7 +102,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 7, @@ -119,7 +119,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 8, @@ -136,7 +136,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 9, @@ -153,7 +153,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 10, @@ -170,7 +170,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 11, @@ -187,7 +187,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 12, @@ -204,7 +204,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 13, @@ -221,7 +221,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 14, @@ -238,7 +238,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 15, @@ -255,7 +255,7 @@ } }, { - "id": 16, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 16, @@ -272,7 +272,7 @@ } }, { - "id": 17, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 17, @@ -289,7 +289,7 @@ } }, { - "id": 18, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 18, @@ -306,7 +306,7 @@ } }, { - "id": 19, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 19, @@ -323,7 +323,7 @@ } }, { - "id": 20, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 20, @@ -340,7 +340,7 @@ } }, { - "id": 21, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 21, @@ -357,7 +357,7 @@ } }, { - "id": 22, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 22, @@ -374,7 +374,7 @@ } }, { - "id": 23, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 23, @@ -391,7 +391,7 @@ } }, { - "id": 24, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 24, @@ -408,7 +408,7 @@ } }, { - "id": 25, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 25, @@ -425,7 +425,7 @@ } }, { - "id": 26, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 26, @@ -442,7 +442,7 @@ } }, { - "id": 27, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 27, @@ -459,7 +459,7 @@ } }, { - "id": 28, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 28, @@ -476,7 +476,7 @@ } }, { - "id": 29, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 29, @@ -493,7 +493,7 @@ } }, { - "id": 30, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 30, @@ -510,7 +510,7 @@ } }, { - "id": 31, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 31, @@ -527,7 +527,7 @@ } }, { - "id": 32, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 32, @@ -544,7 +544,7 @@ } }, { - "id": 33, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 33, @@ -561,7 +561,7 @@ } }, { - "id": 34, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 34, @@ -578,7 +578,7 @@ } }, { - "id": 35, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 35, @@ -595,7 +595,7 @@ } }, { - "id": 36, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 36, @@ -612,7 +612,7 @@ } }, { - "id": 37, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 37, @@ -629,7 +629,7 @@ } }, { - "id": 38, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 38, @@ -646,7 +646,7 @@ } }, { - "id": 39, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 39, @@ -663,7 +663,7 @@ } }, { - "id": 40, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 40, @@ -680,7 +680,7 @@ } }, { - "id": 41, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 41, @@ -697,7 +697,7 @@ } }, { - "id": 42, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 42, @@ -714,7 +714,7 @@ } }, { - "id": 43, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 43, @@ -731,7 +731,7 @@ } }, { - "id": 44, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 44, @@ -748,7 +748,7 @@ } }, { - "id": 45, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 45, @@ -765,7 +765,7 @@ } }, { - "id": 46, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 46, @@ -782,7 +782,7 @@ } }, { - "id": 47, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 47, @@ -799,7 +799,7 @@ } }, { - "id": 48, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 48, @@ -816,7 +816,7 @@ } }, { - "id": 49, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 49, @@ -833,7 +833,7 @@ } }, { - "id": 50, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 50, @@ -850,7 +850,7 @@ } }, { - "id": 51, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 51, @@ -867,7 +867,7 @@ } }, { - "id": 52, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 52, @@ -884,7 +884,7 @@ } }, { - "id": 53, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 53, @@ -901,7 +901,7 @@ } }, { - "id": 54, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 54, @@ -918,7 +918,7 @@ } }, { - "id": 55, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 55, @@ -935,7 +935,7 @@ } }, { - "id": 56, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 56, @@ -952,7 +952,7 @@ } }, { - "id": 57, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 57, @@ -969,7 +969,7 @@ } }, { - "id": 58, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 58, diff --git a/e2e/src/fixtures/1.7/stores.json b/e2e/src/fixtures/1.7/stores.json index 893436bb..d4f07ffc 100644 --- a/e2e/src/fixtures/1.7/stores.json +++ b/e2e/src/fixtures/1.7/stores.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stores", "properties": { "id_store": 1, @@ -20,7 +20,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stores", "properties": { "id_store": 2, @@ -40,7 +40,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stores", "properties": { "id_store": 3, @@ -60,7 +60,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stores", "properties": { "id_store": 4, @@ -80,7 +80,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stores", "properties": { "id_store": 5, diff --git a/e2e/src/fixtures/1.7/suppliers.json b/e2e/src/fixtures/1.7/suppliers.json index 33b27dad..0d869afe 100644 --- a/e2e/src/fixtures/1.7/suppliers.json +++ b/e2e/src/fixtures/1.7/suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "suppliers", "properties": { "id_supplier": 1, @@ -17,7 +17,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "suppliers", "properties": { "id_supplier": 2, diff --git a/e2e/src/fixtures/1.7/themes.json b/e2e/src/fixtures/1.7/themes.json index d50b15de..15884f3e 100644 --- a/e2e/src/fixtures/1.7/themes.json +++ b/e2e/src/fixtures/1.7/themes.json @@ -1,6 +1,6 @@ [ { - "id": "f3d64714d1f6e7f71558d4252e84ab58", + "action": "upsert", "collection": "themes", "properties": { "theme_id": "f3d64714d1f6e7f71558d4252e84ab58", diff --git a/e2e/src/fixtures/8/bundles.json b/e2e/src/fixtures/8/bundles.json index 7438d673..fac3dce8 100644 --- a/e2e/src/fixtures/8/bundles.json +++ b/e2e/src/fixtures/8/bundles.json @@ -1,24 +1,24 @@ [ { - "id": 15, + "action": "upsert", "collection": "bundles", "properties": { - "id_bundle": 15, - "id_product": 5, - "id_product_attribute": 19, + "id_bundle": "15", + "id_product": "5", + "id_product_attribute": "19", "unique_product_id": "15-0-en", - "quantity": 5 + "quantity": "5" } }, { - "id": 15, + "action": "upsert", "collection": "bundles", "properties": { - "id_bundle": 15, - "id_product": 7, - "id_product_attribute": 0, + "id_bundle": "15", + "id_product": "7", + "id_product_attribute": "0", "unique_product_id": "15-0-en", - "quantity": 5 + "quantity": "5" } } ] diff --git a/e2e/src/fixtures/8/carrier_details.json b/e2e/src/fixtures/8/carrier_details.json index fe34c614..68f95f5e 100644 --- a/e2e/src/fixtures/8/carrier_details.json +++ b/e2e/src/fixtures/8/carrier_details.json @@ -1,7 +1,39 @@ [ { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "1", + "id_range": "1", + "id_carrier_detail": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "FR", + "state_ids": "", + "price": 5 + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "2", + "id_range": "1", + "id_carrier_detail": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "US", + "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", + "price": 5 + } + }, + { + "action": "upsert", "collection": "carrier_details", - "id": "3-1-range_price-2", "properties": { "id_reference": "3", "id_zone": "1", @@ -16,8 +48,8 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-2-range_price-2", "properties": { "id_reference": "3", "id_zone": "2", @@ -32,40 +64,40 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-2-range_price-3", "properties": { "id_reference": "3", - "id_zone": "2", + "id_zone": "1", "id_range": "3", "id_carrier_detail": "3", "shipping_method": "range_price", "delimiter1": 50, "delimiter2": 100, - "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 2 + "country_ids": "FR", + "state_ids": "", + "price": 1 } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-1-range_price-3", "properties": { "id_reference": "3", - "id_zone": "1", + "id_zone": "2", "id_range": "3", "id_carrier_detail": "3", "shipping_method": "range_price", "delimiter1": 50, "delimiter2": 100, - "country_ids": "FR", - "state_ids": "", - "price": 1 + "country_ids": "US", + "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", + "price": 2 } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-1-range_price-4", "properties": { "id_reference": "3", "id_zone": "1", @@ -80,8 +112,8 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-2-range_price-4", "properties": { "id_reference": "3", "id_zone": "2", @@ -96,8 +128,8 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-1-range_weight-2", "properties": { "id_reference": "4", "id_zone": "1", @@ -112,8 +144,8 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-2-range_weight-2", "properties": { "id_reference": "4", "id_zone": "2", @@ -128,40 +160,40 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-2-range_weight-3", "properties": { "id_reference": "4", - "id_zone": "2", + "id_zone": "1", "id_range": "3", "id_carrier_detail": "3", "shipping_method": "range_weight", "delimiter1": 1, "delimiter2": 3, - "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 3 + "country_ids": "FR", + "state_ids": "", + "price": 2 } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-1-range_weight-3", "properties": { "id_reference": "4", - "id_zone": "1", + "id_zone": "2", "id_range": "3", "id_carrier_detail": "3", "shipping_method": "range_weight", "delimiter1": 1, "delimiter2": 3, - "country_ids": "FR", - "state_ids": "", - "price": 2 + "country_ids": "US", + "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", + "price": 3 } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-1-range_weight-4", "properties": { "id_reference": "4", "id_zone": "1", @@ -176,8 +208,8 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-2-range_weight-4", "properties": { "id_reference": "4", "id_zone": "2", @@ -190,37 +222,5 @@ "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", "price": 6 } - }, - { - "collection": "carrier_details", - "id": "2-1-range_weight-1", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "id_carrier_detail": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5 - } - }, - { - "collection": "carrier_details", - "id": "2-2-range_weight-1", - "properties": { - "id_reference": "2", - "id_zone": "2", - "id_range": "1", - "id_carrier_detail": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 5 - } } ] diff --git a/e2e/src/fixtures/8/carriers.json b/e2e/src/fixtures/8/carriers.json index 0caae8c7..2315ed6b 100644 --- a/e2e/src/fixtures/8/carriers.json +++ b/e2e/src/fixtures/8/carriers.json @@ -1,122 +1,138 @@ [ { + "action": "upsert", "collection": "carriers", - "id": "3", "properties": { - "id_carrier": "3", - "id_reference": "3", - "name": "My cheap carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "1", + "id_reference": "1", + "name": "Click and collect", "url": "", - "active": false, + "active": true, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, + "shipping_handling": 0, + "range_behavior": "0", "is_module": false, - "is_free": false, + "is_free": true, "shipping_external": false, "need_range": false, "external_module_name": "", + "shipping_method": "0", + "position": "0", "max_width": 0, "max_height": 0, "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Buy more to pay less!", + "delay": "Pick up in-store", + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, + "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - } + }, + "action": "upsert" }, { + "action": "upsert", "collection": "carriers", - "id": "4", "properties": { - "id_carrier": "4", - "id_reference": "4", - "name": "My light carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "2", + "id_reference": "2", + "name": "My carrier", "url": "", - "active": false, + "active": true, "deleted": false, "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, + "range_behavior": "0", "is_module": false, "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", + "shipping_method": "0", + "position": "1", "max_width": 0, "max_height": 0, "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "The lighter the cheaper!", + "delay": "Delivery next day!", + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, + "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - } + }, + "action": "upsert" }, { + "action": "upsert", "collection": "carriers", - "id": "1", "properties": { - "id_carrier": "1", - "id_reference": "1", - "name": "Click and collect", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "3", + "id_reference": "3", + "name": "My cheap carrier", "url": "", - "active": true, + "active": false, "deleted": false, - "shipping_handling": 0, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, + "shipping_handling": 2, + "range_behavior": "0", "is_module": false, - "is_free": true, + "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", + "shipping_method": "2", + "position": "2", "max_width": 0, "max_height": 0, "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Pick up in-store", + "delay": "Buy more to pay less!", + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, + "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - } + }, + "action": "upsert" }, { + "action": "upsert", "collection": "carriers", - "id": "2", "properties": { - "id_carrier": "2", - "id_reference": "2", - "name": "My carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "4", + "id_reference": "4", + "name": "My light carrier", "url": "", - "active": true, + "active": false, "deleted": false, "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, + "range_behavior": "0", "is_module": false, "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", + "shipping_method": "1", + "position": "3", "max_width": 0, "max_height": 0, "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Delivery next day!", + "delay": "The lighter the cheaper!", + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, + "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - } + }, + "action": "upsert" } ] diff --git a/e2e/src/fixtures/8/cart_products.json b/e2e/src/fixtures/8/cart_products.json index c4af221f..2d245056 100644 --- a/e2e/src/fixtures/8/cart_products.json +++ b/e2e/src/fixtures/8/cart_products.json @@ -1,6 +1,6 @@ [ { - "id": "1-1-1", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -12,7 +12,7 @@ } }, { - "id": "1-2-9", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -24,7 +24,7 @@ } }, { - "id": "2-4-18", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -36,7 +36,7 @@ } }, { - "id": "2-8-0", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -48,7 +48,7 @@ } }, { - "id": "3-16-28", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "3", @@ -60,7 +60,7 @@ } }, { - "id": "4-16-29", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "4", @@ -72,7 +72,7 @@ } }, { - "id": "5-10-25", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/8/carts.json b/e2e/src/fixtures/8/carts.json index 1e1bce2b..97934640 100644 --- a/e2e/src/fixtures/8/carts.json +++ b/e2e/src/fixtures/8/carts.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "1", @@ -9,7 +9,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "2", @@ -18,7 +18,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "3", @@ -27,7 +27,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "4", @@ -36,7 +36,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/8/categories.json b/e2e/src/fixtures/8/categories.json index c1f796f6..014a4830 100644 --- a/e2e/src/fixtures/8/categories.json +++ b/e2e/src/fixtures/8/categories.json @@ -1,6 +1,6 @@ [ { - "id": "1-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "1-en", @@ -18,7 +18,7 @@ } }, { - "id": "2-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "2-en", @@ -36,7 +36,7 @@ } }, { - "id": "3-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "3-en", @@ -54,7 +54,7 @@ } }, { - "id": "4-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "4-en", @@ -72,7 +72,7 @@ } }, { - "id": "5-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "5-en", @@ -90,7 +90,7 @@ } }, { - "id": "6-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "6-en", @@ -108,7 +108,7 @@ } }, { - "id": "7-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "7-en", @@ -126,7 +126,7 @@ } }, { - "id": "8-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "8-en", @@ -144,7 +144,7 @@ } }, { - "id": "9-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "9-en", diff --git a/e2e/src/fixtures/8/currencies.json b/e2e/src/fixtures/8/currencies.json index 1955a57d..c936a1f2 100644 --- a/e2e/src/fixtures/8/currencies.json +++ b/e2e/src/fixtures/8/currencies.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 1, @@ -13,7 +13,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 2, diff --git a/e2e/src/fixtures/8/customers.json b/e2e/src/fixtures/8/customers.json index 9ab76e48..fdaac1b6 100644 --- a/e2e/src/fixtures/8/customers.json +++ b/e2e/src/fixtures/8/customers.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "customers", "properties": { "id_customer": 1, @@ -17,7 +17,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "customers", "properties": { "id_customer": 2, diff --git a/e2e/src/fixtures/8/employees.json b/e2e/src/fixtures/8/employees.json index 747c86b6..cb046d42 100644 --- a/e2e/src/fixtures/8/employees.json +++ b/e2e/src/fixtures/8/employees.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "employees", "properties": { "id_employee": 1, diff --git a/e2e/src/fixtures/8/image_types.json b/e2e/src/fixtures/8/image_types.json index b8cbf800..7d0cba7f 100644 --- a/e2e/src/fixtures/8/image_types.json +++ b/e2e/src/fixtures/8/image_types.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 1, @@ -15,7 +15,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 2, @@ -30,7 +30,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 3, @@ -45,7 +45,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 4, @@ -60,7 +60,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 5, @@ -75,7 +75,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 6, @@ -90,7 +90,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 7, diff --git a/e2e/src/fixtures/8/images.json b/e2e/src/fixtures/8/images.json index 9927ccb0..8dea38a2 100644 --- a/e2e/src/fixtures/8/images.json +++ b/e2e/src/fixtures/8/images.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "images", "properties": { "id_image": 1, @@ -13,7 +13,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "images", "properties": { "id_image": 2, @@ -26,7 +26,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "images", "properties": { "id_image": 3, @@ -39,7 +39,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "images", "properties": { "id_image": 4, @@ -52,7 +52,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "images", "properties": { "id_image": 5, @@ -65,7 +65,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "images", "properties": { "id_image": 6, @@ -78,7 +78,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "images", "properties": { "id_image": 7, @@ -91,7 +91,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "images", "properties": { "id_image": 8, @@ -104,7 +104,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "images", "properties": { "id_image": 9, @@ -117,7 +117,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "images", "properties": { "id_image": 10, @@ -130,7 +130,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "images", "properties": { "id_image": 11, @@ -143,7 +143,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "images", "properties": { "id_image": 12, @@ -156,7 +156,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "images", "properties": { "id_image": 13, @@ -169,7 +169,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "images", "properties": { "id_image": 14, @@ -182,7 +182,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "images", "properties": { "id_image": 15, @@ -195,7 +195,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "images", "properties": { "id_image": 16, @@ -208,7 +208,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "images", "properties": { "id_image": 17, @@ -221,7 +221,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "images", "properties": { "id_image": 18, @@ -234,7 +234,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "images", "properties": { "id_image": 19, @@ -247,7 +247,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "images", "properties": { "id_image": 20, @@ -260,7 +260,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "images", "properties": { "id_image": 21, @@ -273,7 +273,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "images", "properties": { "id_image": 22, @@ -286,7 +286,7 @@ } }, { - "id": "23", + "action": "upsert", "collection": "images", "properties": { "id_image": 23, diff --git a/e2e/src/fixtures/8/languages.json b/e2e/src/fixtures/8/languages.json index 8c0b6eb5..7f08db6e 100644 --- a/e2e/src/fixtures/8/languages.json +++ b/e2e/src/fixtures/8/languages.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "languages", "properties": { "id_lang": 1, diff --git a/e2e/src/fixtures/8/manufacturers.json b/e2e/src/fixtures/8/manufacturers.json index 3940f5b3..7a5409ec 100644 --- a/e2e/src/fixtures/8/manufacturers.json +++ b/e2e/src/fixtures/8/manufacturers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "manufacturers", "properties": { "id_manufacturer": 1, @@ -18,7 +18,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "manufacturers", "properties": { "id_manufacturer": 2, diff --git a/e2e/src/fixtures/8/modules.json b/e2e/src/fixtures/8/modules.json index 621bf62c..8b07c229 100644 --- a/e2e/src/fixtures/8/modules.json +++ b/e2e/src/fixtures/8/modules.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "modules", "properties": { "module_id": "1", @@ -12,7 +12,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "modules", "properties": { "module_id": "2", @@ -24,7 +24,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "modules", "properties": { "module_id": "3", @@ -36,7 +36,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "modules", "properties": { "module_id": "4", @@ -48,7 +48,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "modules", "properties": { "module_id": "5", @@ -60,7 +60,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "modules", "properties": { "module_id": "6", @@ -72,7 +72,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "modules", "properties": { "module_id": "7", @@ -84,7 +84,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "modules", "properties": { "module_id": "8", @@ -96,7 +96,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "modules", "properties": { "module_id": "9", @@ -108,7 +108,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "modules", "properties": { "module_id": "10", @@ -120,7 +120,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "modules", "properties": { "module_id": "11", @@ -132,7 +132,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "modules", "properties": { "module_id": "12", @@ -144,7 +144,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "modules", "properties": { "module_id": "13", @@ -156,7 +156,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "modules", "properties": { "module_id": "14", @@ -168,7 +168,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "modules", "properties": { "module_id": "15", @@ -180,7 +180,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "modules", "properties": { "module_id": "16", @@ -192,7 +192,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "modules", "properties": { "module_id": "17", @@ -204,7 +204,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "modules", "properties": { "module_id": "18", @@ -216,7 +216,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "modules", "properties": { "module_id": "19", @@ -228,7 +228,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "modules", "properties": { "module_id": "20", @@ -240,7 +240,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "modules", "properties": { "module_id": "21", @@ -252,7 +252,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "modules", "properties": { "module_id": "22", @@ -264,7 +264,7 @@ } }, { - "id": "23", + "action": "upsert", "collection": "modules", "properties": { "module_id": "23", @@ -276,7 +276,7 @@ } }, { - "id": "25", + "action": "upsert", "collection": "modules", "properties": { "module_id": "25", @@ -288,7 +288,7 @@ } }, { - "id": "26", + "action": "upsert", "collection": "modules", "properties": { "module_id": "26", @@ -300,7 +300,7 @@ } }, { - "id": "27", + "action": "upsert", "collection": "modules", "properties": { "module_id": "27", @@ -312,7 +312,7 @@ } }, { - "id": "28", + "action": "upsert", "collection": "modules", "properties": { "module_id": "28", @@ -324,7 +324,7 @@ } }, { - "id": "29", + "action": "upsert", "collection": "modules", "properties": { "module_id": "29", @@ -336,7 +336,7 @@ } }, { - "id": "30", + "action": "upsert", "collection": "modules", "properties": { "module_id": "30", @@ -348,7 +348,7 @@ } }, { - "id": "31", + "action": "upsert", "collection": "modules", "properties": { "module_id": "31", @@ -360,7 +360,7 @@ } }, { - "id": "32", + "action": "upsert", "collection": "modules", "properties": { "module_id": "32", @@ -372,7 +372,7 @@ } }, { - "id": "33", + "action": "upsert", "collection": "modules", "properties": { "module_id": "33", @@ -384,7 +384,7 @@ } }, { - "id": "34", + "action": "upsert", "collection": "modules", "properties": { "module_id": "34", @@ -396,7 +396,7 @@ } }, { - "id": "35", + "action": "upsert", "collection": "modules", "properties": { "module_id": "35", @@ -408,7 +408,7 @@ } }, { - "id": "36", + "action": "upsert", "collection": "modules", "properties": { "module_id": "36", @@ -420,7 +420,7 @@ } }, { - "id": "37", + "action": "upsert", "collection": "modules", "properties": { "module_id": "37", @@ -432,7 +432,7 @@ } }, { - "id": "38", + "action": "upsert", "collection": "modules", "properties": { "module_id": "38", @@ -444,7 +444,7 @@ } }, { - "id": "39", + "action": "upsert", "collection": "modules", "properties": { "module_id": "39", @@ -456,7 +456,7 @@ } }, { - "id": "40", + "action": "upsert", "collection": "modules", "properties": { "module_id": "40", @@ -468,7 +468,7 @@ } }, { - "id": "41", + "action": "upsert", "collection": "modules", "properties": { "module_id": "41", @@ -480,7 +480,7 @@ } }, { - "id": "42", + "action": "upsert", "collection": "modules", "properties": { "module_id": "42", @@ -492,7 +492,7 @@ } }, { - "id": "43", + "action": "upsert", "collection": "modules", "properties": { "module_id": "43", @@ -504,7 +504,7 @@ } }, { - "id": "44", + "action": "upsert", "collection": "modules", "properties": { "module_id": "44", @@ -516,7 +516,7 @@ } }, { - "id": "45", + "action": "upsert", "collection": "modules", "properties": { "module_id": "45", @@ -528,7 +528,7 @@ } }, { - "id": "46", + "action": "upsert", "collection": "modules", "properties": { "module_id": "46", @@ -540,7 +540,7 @@ } }, { - "id": "47", + "action": "upsert", "collection": "modules", "properties": { "module_id": "47", @@ -552,7 +552,7 @@ } }, { - "id": "48", + "action": "upsert", "collection": "modules", "properties": { "module_id": "48", @@ -564,7 +564,7 @@ } }, { - "id": "49", + "action": "upsert", "collection": "modules", "properties": { "module_id": "49", @@ -576,7 +576,7 @@ } }, { - "id": "50", + "action": "upsert", "collection": "modules", "properties": { "module_id": "50", @@ -588,7 +588,7 @@ } }, { - "id": "51", + "action": "upsert", "collection": "modules", "properties": { "module_id": "51", @@ -600,7 +600,7 @@ } }, { - "id": "52", + "action": "upsert", "collection": "modules", "properties": { "module_id": "52", @@ -612,7 +612,7 @@ } }, { - "id": "53", + "action": "upsert", "collection": "modules", "properties": { "module_id": "53", @@ -624,7 +624,7 @@ } }, { - "id": "54", + "action": "upsert", "collection": "modules", "properties": { "module_id": "54", @@ -636,7 +636,7 @@ } }, { - "id": "55", + "action": "upsert", "collection": "modules", "properties": { "module_id": "55", @@ -648,7 +648,7 @@ } }, { - "id": "56", + "action": "upsert", "collection": "modules", "properties": { "module_id": "56", @@ -660,7 +660,7 @@ } }, { - "id": "57", + "action": "upsert", "collection": "modules", "properties": { "module_id": "57", @@ -672,7 +672,7 @@ } }, { - "id": "58", + "action": "upsert", "collection": "modules", "properties": { "module_id": "58", @@ -684,7 +684,7 @@ } }, { - "id": "59", + "action": "upsert", "collection": "modules", "properties": { "module_id": "59", @@ -696,7 +696,7 @@ } }, { - "id": "60", + "action": "upsert", "collection": "modules", "properties": { "module_id": "60", @@ -708,7 +708,7 @@ } }, { - "id": "61", + "action": "upsert", "collection": "modules", "properties": { "module_id": "61", @@ -720,7 +720,7 @@ } }, { - "id": "62", + "action": "upsert", "collection": "modules", "properties": { "module_id": "62", @@ -732,7 +732,7 @@ } }, { - "id": "63", + "action": "upsert", "collection": "modules", "properties": { "module_id": "63", @@ -744,7 +744,7 @@ } }, { - "id": "64", + "action": "upsert", "collection": "modules", "properties": { "module_id": "64", @@ -756,7 +756,7 @@ } }, { - "id": "65", + "action": "upsert", "collection": "modules", "properties": { "module_id": "65", @@ -768,7 +768,7 @@ } }, { - "id": "66", + "action": "upsert", "collection": "modules", "properties": { "module_id": "66", @@ -780,7 +780,7 @@ } }, { - "id": "67", + "action": "upsert", "collection": "modules", "properties": { "module_id": "67", @@ -792,7 +792,7 @@ } }, { - "id": "68", + "action": "upsert", "collection": "modules", "properties": { "module_id": "68", @@ -804,7 +804,7 @@ } }, { - "id": "69", + "action": "upsert", "collection": "modules", "properties": { "module_id": "69", diff --git a/e2e/src/fixtures/8/order_details.json b/e2e/src/fixtures/8/order_details.json index 9f313260..36a44a9b 100644 --- a/e2e/src/fixtures/8/order_details.json +++ b/e2e/src/fixtures/8/order_details.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 1, @@ -20,7 +20,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 2, @@ -40,7 +40,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 3, @@ -60,7 +60,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 4, @@ -80,7 +80,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 5, @@ -100,7 +100,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 6, @@ -120,7 +120,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 7, diff --git a/e2e/src/fixtures/8/order_status_history.json b/e2e/src/fixtures/8/order_status_history.json index f5d6eac5..60575de7 100644 --- a/e2e/src/fixtures/8/order_status_history.json +++ b/e2e/src/fixtures/8/order_status_history.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -19,7 +19,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -38,7 +38,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -57,7 +57,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -76,7 +76,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 10, @@ -95,7 +95,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 6, @@ -114,7 +114,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 8, diff --git a/e2e/src/fixtures/8/orders.json b/e2e/src/fixtures/8/orders.json index cbad1720..09866d89 100644 --- a/e2e/src/fixtures/8/orders.json +++ b/e2e/src/fixtures/8/orders.json @@ -1,164 +1,284 @@ [ { - "id": 1, + "action": "upsert", "collection": "orders", "properties": { "id_order": 1, "reference": "XKBKNABJK", "id_customer": 2, - "id_cart": 1, + "id_cart": "1", "current_state": 6, "conversion_rate": 1, "total_paid_tax_excl": 66.8, "total_paid_tax_incl": 68.2, - "new_customer": true, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2024-02-06T20:24:53+0100", - "updated_at": "2024-02-06T20:24:53+0100", + "created_at": "2024-09-26T22:51:17+0200", + "updated_at": "2024-09-26T22:51:17+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", - "is_validated": 0, + "is_validated": "0", "is_paid": false, - "is_shipped": 0, + "is_shipped": "0", "status_label": "Canceled", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 59, + "total_products_wt": 59, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": true, "total_paid_tax": 1.4000000000000057, "delivery_country_code": "US", "invoice_country_code": "US" } }, { - "id": 2, + "action": "upsert", "collection": "orders", "properties": { "id_order": 2, "reference": "OHSATSERP", "id_customer": 2, - "id_cart": 2, + "id_cart": "2", "current_state": 1, "conversion_rate": 1, "total_paid_tax_excl": 169.9, "total_paid_tax_incl": 169.9, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 0, - "created_at": "2024-02-06T20:24:53+0100", - "updated_at": "2024-02-06T20:24:53+0100", + "created_at": "2024-09-26T22:51:17+0200", + "updated_at": "2024-09-26T22:51:17+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", - "is_validated": 0, + "is_validated": "0", "is_paid": false, - "is_shipped": 0, + "is_shipped": "0", "status_label": "Awaiting check payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 169, + "total_products_wt": 169, + "total_shipping_tax_incl": 0, + "total_shipping_tax_excl": 0, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 0, "delivery_country_code": "US", "invoice_country_code": "US" } }, { - "id": 3, + "action": "upsert", "collection": "orders", "properties": { "id_order": 3, "reference": "UOYEVOLI", "id_customer": 2, - "id_cart": 3, + "id_cart": "3", "current_state": 8, "conversion_rate": 1, "total_paid_tax_excl": 19.9, "total_paid_tax_incl": 21.3, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2024-02-06T20:24:53+0100", - "updated_at": "2024-02-06T20:24:53+0100", + "created_at": "2024-09-26T22:51:17+0200", + "updated_at": "2024-09-26T22:51:17+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", - "is_validated": 0, + "is_validated": "0", "is_paid": false, - "is_shipped": 0, + "is_shipped": "0", "status_label": "Payment error", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 12, + "total_products_wt": 12, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 1.4000000000000021, "delivery_country_code": "US", "invoice_country_code": "US" } }, { - "id": 4, + "action": "upsert", "collection": "orders", "properties": { "id_order": 4, "reference": "FFATNOMMJ", "id_customer": 2, - "id_cart": 4, + "id_cart": "4", "current_state": 1, "conversion_rate": 1, "total_paid_tax_excl": 19.9, "total_paid_tax_incl": 21.3, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2024-02-06T20:24:53+0100", - "updated_at": "2024-02-06T20:24:53+0100", + "created_at": "2024-09-26T22:51:17+0200", + "updated_at": "2024-09-26T22:51:17+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", - "is_validated": 0, + "is_validated": "0", "is_paid": false, - "is_shipped": 0, + "is_shipped": "0", "status_label": "Awaiting check payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 12, + "total_products_wt": 12, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 1.4000000000000021, "delivery_country_code": "US", "invoice_country_code": "US" } }, { - "id": 5, + "action": "upsert", "collection": "orders", "properties": { "id_order": 5, "reference": "KHWLILZLL", "id_customer": 2, - "id_cart": 5, + "id_cart": "5", "current_state": 10, "conversion_rate": 1, "total_paid_tax_excl": 25.9, "total_paid_tax_incl": 27.3, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_wirepayment", "payment_mode": "Bank wire", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2024-02-06T20:24:53+0100", - "updated_at": "2024-02-06T20:24:53+0100", + "created_at": "2024-09-26T22:51:17+0200", + "updated_at": "2024-09-26T22:51:17+0200", "id_carrier": 2, "payment_name": "ps_wirepayment", - "is_validated": 0, + "is_validated": "0", "is_paid": false, - "is_shipped": 0, + "is_shipped": "0", "status_label": "Awaiting bank wire payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 18, + "total_products_wt": 18, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 1.4000000000000021, "delivery_country_code": "US", "invoice_country_code": "US" diff --git a/e2e/src/fixtures/8/product_suppliers.json b/e2e/src/fixtures/8/product_suppliers.json index 365f801f..72ee278d 100644 --- a/e2e/src/fixtures/8/product_suppliers.json +++ b/e2e/src/fixtures/8/product_suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 1, @@ -13,7 +13,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 2, @@ -26,7 +26,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 3, @@ -39,7 +39,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 4, @@ -52,7 +52,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 5, @@ -65,7 +65,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 6, @@ -78,7 +78,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 7, @@ -91,7 +91,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 8, @@ -104,7 +104,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 9, @@ -117,7 +117,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 10, @@ -130,7 +130,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 11, @@ -143,7 +143,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 12, @@ -156,7 +156,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 13, @@ -169,7 +169,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 14, @@ -182,7 +182,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 15, @@ -195,7 +195,7 @@ } }, { - "id": 16, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 16, @@ -208,7 +208,7 @@ } }, { - "id": 17, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 17, @@ -221,7 +221,7 @@ } }, { - "id": 18, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 18, @@ -234,7 +234,7 @@ } }, { - "id": 19, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 19, @@ -247,7 +247,7 @@ } }, { - "id": 20, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 20, @@ -260,7 +260,7 @@ } }, { - "id": 21, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 21, @@ -273,7 +273,7 @@ } }, { - "id": 22, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 22, @@ -286,7 +286,7 @@ } }, { - "id": 23, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 23, @@ -299,7 +299,7 @@ } }, { - "id": 24, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 24, @@ -312,7 +312,7 @@ } }, { - "id": 25, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 25, @@ -325,7 +325,7 @@ } }, { - "id": 26, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 26, @@ -338,7 +338,7 @@ } }, { - "id": 27, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 27, @@ -351,7 +351,7 @@ } }, { - "id": 28, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 28, @@ -364,7 +364,7 @@ } }, { - "id": 29, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 29, @@ -377,7 +377,7 @@ } }, { - "id": 30, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 30, @@ -390,7 +390,7 @@ } }, { - "id": 31, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 31, @@ -403,7 +403,7 @@ } }, { - "id": 32, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 32, @@ -416,7 +416,7 @@ } }, { - "id": 33, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 33, @@ -429,7 +429,7 @@ } }, { - "id": 34, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 34, @@ -442,7 +442,7 @@ } }, { - "id": 35, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 35, @@ -455,7 +455,7 @@ } }, { - "id": 36, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 36, @@ -468,7 +468,7 @@ } }, { - "id": 37, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 37, @@ -481,7 +481,7 @@ } }, { - "id": 38, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 38, @@ -494,7 +494,7 @@ } }, { - "id": 39, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 39, @@ -507,7 +507,7 @@ } }, { - "id": 40, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 40, @@ -520,7 +520,7 @@ } }, { - "id": 41, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 41, @@ -533,7 +533,7 @@ } }, { - "id": 42, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 42, @@ -546,7 +546,7 @@ } }, { - "id": 43, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 43, @@ -559,7 +559,7 @@ } }, { - "id": 44, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 44, @@ -572,7 +572,7 @@ } }, { - "id": 45, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 45, @@ -585,7 +585,7 @@ } }, { - "id": 46, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 46, @@ -598,7 +598,7 @@ } }, { - "id": 47, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 47, @@ -611,7 +611,7 @@ } }, { - "id": 48, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 48, @@ -624,7 +624,7 @@ } }, { - "id": 49, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 49, @@ -637,7 +637,7 @@ } }, { - "id": 50, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 50, @@ -650,7 +650,7 @@ } }, { - "id": 51, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 51, @@ -663,7 +663,7 @@ } }, { - "id": 52, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 52, @@ -676,7 +676,7 @@ } }, { - "id": 53, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 53, @@ -689,7 +689,7 @@ } }, { - "id": 54, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 54, @@ -702,7 +702,7 @@ } }, { - "id": 55, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 55, @@ -715,7 +715,7 @@ } }, { - "id": 56, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 56, @@ -728,7 +728,7 @@ } }, { - "id": 57, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 57, @@ -741,7 +741,7 @@ } }, { - "id": 58, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 58, @@ -754,7 +754,7 @@ } }, { - "id": 59, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 59, @@ -767,7 +767,7 @@ } }, { - "id": 60, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 60, @@ -780,7 +780,7 @@ } }, { - "id": 61, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 61, @@ -793,7 +793,7 @@ } }, { - "id": 62, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 62, @@ -806,7 +806,7 @@ } }, { - "id": 63, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 63, @@ -819,7 +819,7 @@ } }, { - "id": 64, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 64, @@ -832,7 +832,7 @@ } }, { - "id": 65, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 65, @@ -845,7 +845,7 @@ } }, { - "id": 66, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 66, @@ -858,7 +858,7 @@ } }, { - "id": 67, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 67, @@ -871,7 +871,7 @@ } }, { - "id": 68, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 68, @@ -884,7 +884,7 @@ } }, { - "id": 69, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 69, @@ -897,7 +897,7 @@ } }, { - "id": 70, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 70, @@ -910,7 +910,7 @@ } }, { - "id": 71, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 71, @@ -923,7 +923,7 @@ } }, { - "id": 72, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 72, @@ -936,7 +936,7 @@ } }, { - "id": 73, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 73, diff --git a/e2e/src/fixtures/8/products.json b/e2e/src/fixtures/8/products.json index 41a26983..d6ee1349 100644 --- a/e2e/src/fixtures/8/products.json +++ b/e2e/src/fixtures/8/products.json @@ -1,6 +1,6 @@ [ { - "id": "1-2-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -34,7 +34,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -63,7 +63,7 @@ } }, { - "id": "1-3-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -97,7 +97,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -126,7 +126,7 @@ } }, { - "id": "1-4-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -160,7 +160,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -189,7 +189,7 @@ } }, { - "id": "1-5-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -223,7 +223,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -252,7 +252,7 @@ } }, { - "id": "1-6-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -286,7 +286,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -315,7 +315,7 @@ } }, { - "id": "1-7-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -349,7 +349,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -378,7 +378,7 @@ } }, { - "id": "1-8-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -412,7 +412,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -441,7 +441,7 @@ } }, { - "id": "1-1-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -475,7 +475,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -504,7 +504,7 @@ } }, { - "id": "2-10-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -538,7 +538,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -566,7 +566,7 @@ } }, { - "id": "2-11-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -600,7 +600,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -628,7 +628,7 @@ } }, { - "id": "2-12-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -662,7 +662,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -690,7 +690,7 @@ } }, { - "id": "2-9-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -724,7 +724,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -752,7 +752,7 @@ } }, { - "id": "3-14-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -786,7 +786,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -813,7 +813,7 @@ } }, { - "id": "3-15-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -847,7 +847,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -874,7 +874,7 @@ } }, { - "id": "3-13-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -908,7 +908,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -935,7 +935,7 @@ } }, { - "id": "4-17-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -969,7 +969,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -996,7 +996,7 @@ } }, { - "id": "4-18-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1030,7 +1030,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1057,7 +1057,7 @@ } }, { - "id": "4-16-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1091,7 +1091,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1118,7 +1118,7 @@ } }, { - "id": "5-20-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1152,7 +1152,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1179,7 +1179,7 @@ } }, { - "id": "5-21-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1213,7 +1213,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1240,7 +1240,7 @@ } }, { - "id": "5-19-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1274,7 +1274,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1301,7 +1301,7 @@ } }, { - "id": "6-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -1335,7 +1335,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1360,7 +1360,7 @@ } }, { - "id": "7-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -1394,7 +1394,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1419,7 +1419,7 @@ } }, { - "id": "8-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 8, @@ -1453,7 +1453,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1478,7 +1478,7 @@ } }, { - "id": "9-23-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 9, @@ -1512,7 +1512,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1540,7 +1540,7 @@ } }, { - "id": "9-22-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 9, @@ -1574,7 +1574,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1602,7 +1602,7 @@ } }, { - "id": "10-25-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 10, @@ -1636,7 +1636,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1664,7 +1664,7 @@ } }, { - "id": "10-24-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 10, @@ -1698,7 +1698,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1726,7 +1726,7 @@ } }, { - "id": "11-27-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 11, @@ -1760,7 +1760,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1788,7 +1788,7 @@ } }, { - "id": "11-26-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 11, @@ -1822,7 +1822,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1850,7 +1850,7 @@ } }, { - "id": "12-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 12, @@ -1884,7 +1884,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1907,7 +1907,7 @@ } }, { - "id": "13-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 13, @@ -1941,7 +1941,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -1964,7 +1964,7 @@ } }, { - "id": "14-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 14, @@ -1998,7 +1998,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2021,7 +2021,7 @@ } }, { - "id": "15-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 15, @@ -2055,7 +2055,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2078,7 +2078,7 @@ } }, { - "id": "16-29-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2112,7 +2112,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2140,7 +2140,7 @@ } }, { - "id": "16-30-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2174,7 +2174,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2202,7 +2202,7 @@ } }, { - "id": "16-31-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2236,7 +2236,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2264,7 +2264,7 @@ } }, { - "id": "16-28-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2298,7 +2298,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2326,7 +2326,7 @@ } }, { - "id": "17-33-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2360,7 +2360,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2388,7 +2388,7 @@ } }, { - "id": "17-34-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2422,7 +2422,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2450,7 +2450,7 @@ } }, { - "id": "17-35-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2484,7 +2484,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2512,7 +2512,7 @@ } }, { - "id": "17-32-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2546,7 +2546,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2574,7 +2574,7 @@ } }, { - "id": "18-37-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2608,7 +2608,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2636,7 +2636,7 @@ } }, { - "id": "18-38-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2670,7 +2670,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2698,7 +2698,7 @@ } }, { - "id": "18-39-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2732,7 +2732,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2760,7 +2760,7 @@ } }, { - "id": "18-36-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2794,7 +2794,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", @@ -2822,7 +2822,7 @@ } }, { - "id": "19-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 19, @@ -2856,7 +2856,7 @@ "width": "0.000000", "height": "0.000000", "depth": "0.000000", - "additional_delivery_times": 1, + "additional_delivery_times": "1", "additional_shipping_cost": "0.000000", "delivery_in_stock": "", "delivery_out_stock": "", diff --git a/e2e/src/fixtures/8/shops.json b/e2e/src/fixtures/8/shops.json index 66e78af4..8ee1c151 100644 --- a/e2e/src/fixtures/8/shops.json +++ b/e2e/src/fixtures/8/shops.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "shops", "properties": { "created_at": "2024-08-22T12:27:09+0200", diff --git a/e2e/src/fixtures/8/specific_prices.json b/e2e/src/fixtures/8/specific_prices.json index f179c309..222d03f4 100644 --- a/e2e/src/fixtures/8/specific_prices.json +++ b/e2e/src/fixtures/8/specific_prices.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 1, @@ -31,7 +31,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 2, diff --git a/e2e/src/fixtures/8/stocks.json b/e2e/src/fixtures/8/stocks.json index b95df9a4..12efb5ae 100644 --- a/e2e/src/fixtures/8/stocks.json +++ b/e2e/src/fixtures/8/stocks.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 1, @@ -17,7 +17,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 2, @@ -34,7 +34,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 3, @@ -51,7 +51,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 4, @@ -68,7 +68,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 5, @@ -85,7 +85,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 6, @@ -102,7 +102,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 7, @@ -119,7 +119,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 8, @@ -136,7 +136,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 9, @@ -153,7 +153,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 10, @@ -170,7 +170,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 11, @@ -187,7 +187,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 12, @@ -204,7 +204,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 13, @@ -221,7 +221,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 14, @@ -238,7 +238,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 15, @@ -255,7 +255,7 @@ } }, { - "id": 16, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 16, @@ -272,7 +272,7 @@ } }, { - "id": 17, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 17, @@ -289,7 +289,7 @@ } }, { - "id": 18, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 18, @@ -306,7 +306,7 @@ } }, { - "id": 19, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 19, @@ -323,7 +323,7 @@ } }, { - "id": 20, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 20, @@ -340,7 +340,7 @@ } }, { - "id": 21, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 21, @@ -357,7 +357,7 @@ } }, { - "id": 22, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 22, @@ -374,7 +374,7 @@ } }, { - "id": 23, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 23, @@ -391,7 +391,7 @@ } }, { - "id": 24, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 24, @@ -408,7 +408,7 @@ } }, { - "id": 25, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 25, @@ -425,7 +425,7 @@ } }, { - "id": 26, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 26, @@ -442,7 +442,7 @@ } }, { - "id": 27, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 27, @@ -459,7 +459,7 @@ } }, { - "id": 28, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 28, @@ -476,7 +476,7 @@ } }, { - "id": 29, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 29, @@ -493,7 +493,7 @@ } }, { - "id": 30, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 30, @@ -510,7 +510,7 @@ } }, { - "id": 31, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 31, @@ -527,7 +527,7 @@ } }, { - "id": 32, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 32, @@ -544,7 +544,7 @@ } }, { - "id": 33, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 33, @@ -561,7 +561,7 @@ } }, { - "id": 34, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 34, @@ -578,7 +578,7 @@ } }, { - "id": 35, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 35, @@ -595,7 +595,7 @@ } }, { - "id": 36, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 36, @@ -612,7 +612,7 @@ } }, { - "id": 37, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 37, @@ -629,7 +629,7 @@ } }, { - "id": 38, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 38, @@ -646,7 +646,7 @@ } }, { - "id": 39, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 39, @@ -663,7 +663,7 @@ } }, { - "id": 40, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 40, @@ -680,7 +680,7 @@ } }, { - "id": 41, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 41, @@ -697,7 +697,7 @@ } }, { - "id": 42, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 42, @@ -714,7 +714,7 @@ } }, { - "id": 43, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 43, @@ -731,7 +731,7 @@ } }, { - "id": 44, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 44, @@ -748,7 +748,7 @@ } }, { - "id": 45, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 45, @@ -765,7 +765,7 @@ } }, { - "id": 46, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 46, @@ -782,7 +782,7 @@ } }, { - "id": 47, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 47, @@ -799,7 +799,7 @@ } }, { - "id": 48, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 48, @@ -816,7 +816,7 @@ } }, { - "id": 49, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 49, @@ -833,7 +833,7 @@ } }, { - "id": 50, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 50, @@ -850,7 +850,7 @@ } }, { - "id": 51, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 51, @@ -867,7 +867,7 @@ } }, { - "id": 52, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 52, @@ -884,7 +884,7 @@ } }, { - "id": 53, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 53, @@ -901,7 +901,7 @@ } }, { - "id": 54, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 54, @@ -918,7 +918,7 @@ } }, { - "id": 55, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 55, @@ -935,7 +935,7 @@ } }, { - "id": 56, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 56, @@ -952,7 +952,7 @@ } }, { - "id": 57, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 57, @@ -969,7 +969,7 @@ } }, { - "id": 58, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 58, diff --git a/e2e/src/fixtures/8/stores.json b/e2e/src/fixtures/8/stores.json index 002bd9e8..15159b88 100644 --- a/e2e/src/fixtures/8/stores.json +++ b/e2e/src/fixtures/8/stores.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stores", "properties": { "id_store": 1, @@ -20,7 +20,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stores", "properties": { "id_store": 2, @@ -40,7 +40,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stores", "properties": { "id_store": 3, @@ -60,7 +60,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stores", "properties": { "id_store": 4, @@ -80,7 +80,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stores", "properties": { "id_store": 5, diff --git a/e2e/src/fixtures/8/suppliers.json b/e2e/src/fixtures/8/suppliers.json index 8475a828..8edfef88 100644 --- a/e2e/src/fixtures/8/suppliers.json +++ b/e2e/src/fixtures/8/suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "suppliers", "properties": { "id_supplier": 1, @@ -17,7 +17,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "suppliers", "properties": { "id_supplier": 2, diff --git a/e2e/src/fixtures/8/themes.json b/e2e/src/fixtures/8/themes.json index be7189af..dd4040cb 100644 --- a/e2e/src/fixtures/8/themes.json +++ b/e2e/src/fixtures/8/themes.json @@ -1,6 +1,6 @@ [ { - "id": "f3d64714d1f6e7f71558d4252e84ab58", + "action": "upsert", "collection": "themes", "properties": { "theme_id": "f3d64714d1f6e7f71558d4252e84ab58", diff --git a/e2e/src/fixtures/9/bundles.json b/e2e/src/fixtures/9/bundles.json index 7438d673..4ac3d9ad 100644 --- a/e2e/src/fixtures/9/bundles.json +++ b/e2e/src/fixtures/9/bundles.json @@ -1,6 +1,6 @@ [ { - "id": 15, + "action": "upsert", "collection": "bundles", "properties": { "id_bundle": 15, @@ -11,7 +11,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "bundles", "properties": { "id_bundle": 15, diff --git a/e2e/src/fixtures/9/carrier_details.json b/e2e/src/fixtures/9/carrier_details.json index 531f022a..2c206edd 100644 --- a/e2e/src/fixtures/9/carrier_details.json +++ b/e2e/src/fixtures/9/carrier_details.json @@ -1,7 +1,8 @@ [ { + "action": "upsert", "collection": "carrier_details", - "id": "3-2-range_price-2", + "properties": { "id_reference": "3", "id_zone": "2", @@ -16,8 +17,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-1-range_price-2", + "properties": { "id_reference": "3", "id_zone": "1", @@ -32,8 +34,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-2-range_price-3", + "properties": { "id_reference": "3", "id_zone": "2", @@ -48,8 +51,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-1-range_price-3", + "properties": { "id_reference": "3", "id_zone": "1", @@ -64,8 +68,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-1-range_price-4", + "properties": { "id_reference": "3", "id_zone": "1", @@ -80,8 +85,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "3-2-range_price-4", + "properties": { "id_reference": "3", "id_zone": "2", @@ -96,8 +102,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-2-range_weight-2", + "properties": { "id_reference": "4", "id_zone": "2", @@ -112,8 +119,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-1-range_weight-2", + "properties": { "id_reference": "4", "id_zone": "1", @@ -128,8 +136,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-2-range_weight-3", + "properties": { "id_reference": "4", "id_zone": "2", @@ -144,8 +153,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-1-range_weight-3", + "properties": { "id_reference": "4", "id_zone": "1", @@ -160,8 +170,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-1-range_weight-4", + "properties": { "id_reference": "4", "id_zone": "1", @@ -176,8 +187,8 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "4-2-range_weight-4", "properties": { "id_reference": "4", "id_zone": "2", @@ -192,8 +203,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "2-1-range_weight-1", + "properties": { "id_reference": "2", "id_zone": "1", @@ -208,8 +220,9 @@ } }, { + "action": "upsert", "collection": "carrier_details", - "id": "2-2-range_weight-1", + "properties": { "id_reference": "2", "id_zone": "2", diff --git a/e2e/src/fixtures/9/carriers.json b/e2e/src/fixtures/9/carriers.json index 0caae8c7..4332f5aa 100644 --- a/e2e/src/fixtures/9/carriers.json +++ b/e2e/src/fixtures/9/carriers.json @@ -1,7 +1,8 @@ [ { + "action": "upsert", "collection": "carriers", - "id": "3", + "properties": { "id_carrier": "3", "id_reference": "3", @@ -30,8 +31,9 @@ } }, { + "action": "upsert", "collection": "carriers", - "id": "4", + "properties": { "id_carrier": "4", "id_reference": "4", @@ -60,8 +62,9 @@ } }, { + "action": "upsert", "collection": "carriers", - "id": "1", + "properties": { "id_carrier": "1", "id_reference": "1", @@ -90,8 +93,9 @@ } }, { + "action": "upsert", "collection": "carriers", - "id": "2", + "properties": { "id_carrier": "2", "id_reference": "2", diff --git a/e2e/src/fixtures/9/cart_products.json b/e2e/src/fixtures/9/cart_products.json index c4af221f..2d245056 100644 --- a/e2e/src/fixtures/9/cart_products.json +++ b/e2e/src/fixtures/9/cart_products.json @@ -1,6 +1,6 @@ [ { - "id": "1-1-1", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -12,7 +12,7 @@ } }, { - "id": "1-2-9", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "1", @@ -24,7 +24,7 @@ } }, { - "id": "2-4-18", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -36,7 +36,7 @@ } }, { - "id": "2-8-0", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "2", @@ -48,7 +48,7 @@ } }, { - "id": "3-16-28", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "3", @@ -60,7 +60,7 @@ } }, { - "id": "4-16-29", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "4", @@ -72,7 +72,7 @@ } }, { - "id": "5-10-25", + "action": "upsert", "collection": "cart_products", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/9/carts.json b/e2e/src/fixtures/9/carts.json index 8f45075d..6e68aab8 100644 --- a/e2e/src/fixtures/9/carts.json +++ b/e2e/src/fixtures/9/carts.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "1", @@ -9,7 +9,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "2", @@ -18,7 +18,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "3", @@ -27,7 +27,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "4", @@ -36,7 +36,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "carts", "properties": { "id_cart": "5", diff --git a/e2e/src/fixtures/9/categories.json b/e2e/src/fixtures/9/categories.json index 00ad9528..80f587d5 100644 --- a/e2e/src/fixtures/9/categories.json +++ b/e2e/src/fixtures/9/categories.json @@ -1,6 +1,6 @@ [ { - "id": "1-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "1-en", @@ -18,7 +18,7 @@ } }, { - "id": "2-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "2-en", @@ -36,7 +36,7 @@ } }, { - "id": "3-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "3-en", @@ -54,7 +54,7 @@ } }, { - "id": "4-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "4-en", @@ -72,7 +72,7 @@ } }, { - "id": "5-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "5-en", @@ -90,7 +90,7 @@ } }, { - "id": "6-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "6-en", @@ -108,7 +108,7 @@ } }, { - "id": "7-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "7-en", @@ -126,7 +126,7 @@ } }, { - "id": "8-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "8-en", @@ -144,7 +144,7 @@ } }, { - "id": "9-en", + "action": "upsert", "collection": "categories", "properties": { "unique_category_id": "9-en", diff --git a/e2e/src/fixtures/9/currencies.json b/e2e/src/fixtures/9/currencies.json index 3e192200..7c488699 100644 --- a/e2e/src/fixtures/9/currencies.json +++ b/e2e/src/fixtures/9/currencies.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 1, @@ -13,7 +13,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "currencies", "properties": { "id_currency": 2, diff --git a/e2e/src/fixtures/9/customers.json b/e2e/src/fixtures/9/customers.json index 35648e61..a137a525 100644 --- a/e2e/src/fixtures/9/customers.json +++ b/e2e/src/fixtures/9/customers.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "customers", "properties": { "id_customer": 1, @@ -17,7 +17,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "customers", "properties": { "id_customer": 2, diff --git a/e2e/src/fixtures/9/employees.json b/e2e/src/fixtures/9/employees.json index b31c2177..07be19f2 100644 --- a/e2e/src/fixtures/9/employees.json +++ b/e2e/src/fixtures/9/employees.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "employees", "properties": { "id_employee": 1, diff --git a/e2e/src/fixtures/9/image_types.json b/e2e/src/fixtures/9/image_types.json index b8cbf800..7d0cba7f 100644 --- a/e2e/src/fixtures/9/image_types.json +++ b/e2e/src/fixtures/9/image_types.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 1, @@ -15,7 +15,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 2, @@ -30,7 +30,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 3, @@ -45,7 +45,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 4, @@ -60,7 +60,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 5, @@ -75,7 +75,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 6, @@ -90,7 +90,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "image_types", "properties": { "id_image_type": 7, diff --git a/e2e/src/fixtures/9/images.json b/e2e/src/fixtures/9/images.json index 9927ccb0..8dea38a2 100644 --- a/e2e/src/fixtures/9/images.json +++ b/e2e/src/fixtures/9/images.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "images", "properties": { "id_image": 1, @@ -13,7 +13,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "images", "properties": { "id_image": 2, @@ -26,7 +26,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "images", "properties": { "id_image": 3, @@ -39,7 +39,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "images", "properties": { "id_image": 4, @@ -52,7 +52,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "images", "properties": { "id_image": 5, @@ -65,7 +65,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "images", "properties": { "id_image": 6, @@ -78,7 +78,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "images", "properties": { "id_image": 7, @@ -91,7 +91,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "images", "properties": { "id_image": 8, @@ -104,7 +104,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "images", "properties": { "id_image": 9, @@ -117,7 +117,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "images", "properties": { "id_image": 10, @@ -130,7 +130,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "images", "properties": { "id_image": 11, @@ -143,7 +143,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "images", "properties": { "id_image": 12, @@ -156,7 +156,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "images", "properties": { "id_image": 13, @@ -169,7 +169,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "images", "properties": { "id_image": 14, @@ -182,7 +182,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "images", "properties": { "id_image": 15, @@ -195,7 +195,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "images", "properties": { "id_image": 16, @@ -208,7 +208,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "images", "properties": { "id_image": 17, @@ -221,7 +221,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "images", "properties": { "id_image": 18, @@ -234,7 +234,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "images", "properties": { "id_image": 19, @@ -247,7 +247,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "images", "properties": { "id_image": 20, @@ -260,7 +260,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "images", "properties": { "id_image": 21, @@ -273,7 +273,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "images", "properties": { "id_image": 22, @@ -286,7 +286,7 @@ } }, { - "id": "23", + "action": "upsert", "collection": "images", "properties": { "id_image": 23, diff --git a/e2e/src/fixtures/9/languages.json b/e2e/src/fixtures/9/languages.json index 8c0b6eb5..7f08db6e 100644 --- a/e2e/src/fixtures/9/languages.json +++ b/e2e/src/fixtures/9/languages.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "languages", "properties": { "id_lang": 1, diff --git a/e2e/src/fixtures/9/manufacturers.json b/e2e/src/fixtures/9/manufacturers.json index 226c8d67..b1cffbfd 100644 --- a/e2e/src/fixtures/9/manufacturers.json +++ b/e2e/src/fixtures/9/manufacturers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "manufacturers", "properties": { "id_manufacturer": 1, @@ -18,7 +18,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "manufacturers", "properties": { "id_manufacturer": 2, diff --git a/e2e/src/fixtures/9/modules.json b/e2e/src/fixtures/9/modules.json index 4175cc83..e7b724d4 100644 --- a/e2e/src/fixtures/9/modules.json +++ b/e2e/src/fixtures/9/modules.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "modules", "properties": { "module_id": "1", @@ -12,7 +12,7 @@ } }, { - "id": "2", + "action": "upsert", "collection": "modules", "properties": { "module_id": "2", @@ -24,7 +24,7 @@ } }, { - "id": "3", + "action": "upsert", "collection": "modules", "properties": { "module_id": "3", @@ -36,7 +36,7 @@ } }, { - "id": "4", + "action": "upsert", "collection": "modules", "properties": { "module_id": "4", @@ -48,7 +48,7 @@ } }, { - "id": "5", + "action": "upsert", "collection": "modules", "properties": { "module_id": "5", @@ -60,7 +60,7 @@ } }, { - "id": "6", + "action": "upsert", "collection": "modules", "properties": { "module_id": "6", @@ -72,7 +72,7 @@ } }, { - "id": "7", + "action": "upsert", "collection": "modules", "properties": { "module_id": "7", @@ -84,7 +84,7 @@ } }, { - "id": "8", + "action": "upsert", "collection": "modules", "properties": { "module_id": "8", @@ -96,7 +96,7 @@ } }, { - "id": "9", + "action": "upsert", "collection": "modules", "properties": { "module_id": "9", @@ -108,7 +108,7 @@ } }, { - "id": "10", + "action": "upsert", "collection": "modules", "properties": { "module_id": "10", @@ -120,7 +120,7 @@ } }, { - "id": "11", + "action": "upsert", "collection": "modules", "properties": { "module_id": "11", @@ -132,7 +132,7 @@ } }, { - "id": "12", + "action": "upsert", "collection": "modules", "properties": { "module_id": "12", @@ -144,7 +144,7 @@ } }, { - "id": "13", + "action": "upsert", "collection": "modules", "properties": { "module_id": "13", @@ -156,7 +156,7 @@ } }, { - "id": "14", + "action": "upsert", "collection": "modules", "properties": { "module_id": "14", @@ -168,7 +168,7 @@ } }, { - "id": "15", + "action": "upsert", "collection": "modules", "properties": { "module_id": "15", @@ -180,7 +180,7 @@ } }, { - "id": "16", + "action": "upsert", "collection": "modules", "properties": { "module_id": "16", @@ -192,7 +192,7 @@ } }, { - "id": "17", + "action": "upsert", "collection": "modules", "properties": { "module_id": "17", @@ -204,7 +204,7 @@ } }, { - "id": "18", + "action": "upsert", "collection": "modules", "properties": { "module_id": "18", @@ -216,7 +216,7 @@ } }, { - "id": "19", + "action": "upsert", "collection": "modules", "properties": { "module_id": "19", @@ -228,7 +228,7 @@ } }, { - "id": "20", + "action": "upsert", "collection": "modules", "properties": { "module_id": "20", @@ -240,7 +240,7 @@ } }, { - "id": "21", + "action": "upsert", "collection": "modules", "properties": { "module_id": "21", @@ -252,7 +252,7 @@ } }, { - "id": "22", + "action": "upsert", "collection": "modules", "properties": { "module_id": "22", @@ -264,7 +264,7 @@ } }, { - "id": "23", + "action": "upsert", "collection": "modules", "properties": { "module_id": "23", @@ -276,7 +276,7 @@ } }, { - "id": "25", + "action": "upsert", "collection": "modules", "properties": { "module_id": "25", @@ -288,7 +288,7 @@ } }, { - "id": "26", + "action": "upsert", "collection": "modules", "properties": { "module_id": "26", @@ -300,7 +300,7 @@ } }, { - "id": "27", + "action": "upsert", "collection": "modules", "properties": { "module_id": "27", @@ -312,7 +312,7 @@ } }, { - "id": "28", + "action": "upsert", "collection": "modules", "properties": { "module_id": "28", @@ -324,7 +324,7 @@ } }, { - "id": "29", + "action": "upsert", "collection": "modules", "properties": { "module_id": "29", @@ -336,7 +336,7 @@ } }, { - "id": "30", + "action": "upsert", "collection": "modules", "properties": { "module_id": "30", @@ -348,7 +348,7 @@ } }, { - "id": "31", + "action": "upsert", "collection": "modules", "properties": { "module_id": "31", @@ -360,7 +360,7 @@ } }, { - "id": "32", + "action": "upsert", "collection": "modules", "properties": { "module_id": "32", @@ -372,7 +372,7 @@ } }, { - "id": "33", + "action": "upsert", "collection": "modules", "properties": { "module_id": "33", @@ -384,7 +384,7 @@ } }, { - "id": "34", + "action": "upsert", "collection": "modules", "properties": { "module_id": "34", @@ -396,7 +396,7 @@ } }, { - "id": "35", + "action": "upsert", "collection": "modules", "properties": { "module_id": "35", @@ -408,7 +408,7 @@ } }, { - "id": "36", + "action": "upsert", "collection": "modules", "properties": { "module_id": "36", @@ -420,7 +420,7 @@ } }, { - "id": "37", + "action": "upsert", "collection": "modules", "properties": { "module_id": "37", @@ -432,7 +432,7 @@ } }, { - "id": "38", + "action": "upsert", "collection": "modules", "properties": { "module_id": "38", @@ -444,7 +444,7 @@ } }, { - "id": "39", + "action": "upsert", "collection": "modules", "properties": { "module_id": "39", @@ -456,7 +456,7 @@ } }, { - "id": "40", + "action": "upsert", "collection": "modules", "properties": { "module_id": "40", @@ -468,7 +468,7 @@ } }, { - "id": "41", + "action": "upsert", "collection": "modules", "properties": { "module_id": "41", @@ -480,7 +480,7 @@ } }, { - "id": "42", + "action": "upsert", "collection": "modules", "properties": { "module_id": "42", @@ -492,7 +492,7 @@ } }, { - "id": "43", + "action": "upsert", "collection": "modules", "properties": { "module_id": "43", @@ -504,7 +504,7 @@ } }, { - "id": "44", + "action": "upsert", "collection": "modules", "properties": { "module_id": "44", @@ -516,7 +516,7 @@ } }, { - "id": "45", + "action": "upsert", "collection": "modules", "properties": { "module_id": "45", @@ -528,7 +528,7 @@ } }, { - "id": "46", + "action": "upsert", "collection": "modules", "properties": { "module_id": "46", @@ -540,7 +540,7 @@ } }, { - "id": "47", + "action": "upsert", "collection": "modules", "properties": { "module_id": "47", @@ -552,7 +552,7 @@ } }, { - "id": "48", + "action": "upsert", "collection": "modules", "properties": { "module_id": "48", @@ -564,7 +564,7 @@ } }, { - "id": "49", + "action": "upsert", "collection": "modules", "properties": { "module_id": "49", @@ -576,7 +576,7 @@ } }, { - "id": "50", + "action": "upsert", "collection": "modules", "properties": { "module_id": "50", @@ -588,7 +588,7 @@ } }, { - "id": "51", + "action": "upsert", "collection": "modules", "properties": { "module_id": "51", @@ -600,7 +600,7 @@ } }, { - "id": "52", + "action": "upsert", "collection": "modules", "properties": { "module_id": "52", @@ -612,7 +612,7 @@ } }, { - "id": "53", + "action": "upsert", "collection": "modules", "properties": { "module_id": "53", @@ -624,7 +624,7 @@ } }, { - "id": "54", + "action": "upsert", "collection": "modules", "properties": { "module_id": "54", @@ -636,7 +636,7 @@ } }, { - "id": "55", + "action": "upsert", "collection": "modules", "properties": { "module_id": "55", @@ -648,7 +648,7 @@ } }, { - "id": "56", + "action": "upsert", "collection": "modules", "properties": { "module_id": "56", @@ -660,7 +660,7 @@ } }, { - "id": "57", + "action": "upsert", "collection": "modules", "properties": { "module_id": "57", @@ -672,7 +672,7 @@ } }, { - "id": "58", + "action": "upsert", "collection": "modules", "properties": { "module_id": "58", @@ -684,7 +684,7 @@ } }, { - "id": "59", + "action": "upsert", "collection": "modules", "properties": { "module_id": "59", @@ -696,7 +696,7 @@ } }, { - "id": "60", + "action": "upsert", "collection": "modules", "properties": { "module_id": "60", @@ -708,7 +708,7 @@ } }, { - "id": "61", + "action": "upsert", "collection": "modules", "properties": { "module_id": "61", @@ -720,7 +720,7 @@ } }, { - "id": "62", + "action": "upsert", "collection": "modules", "properties": { "module_id": "62", @@ -732,7 +732,7 @@ } }, { - "id": "63", + "action": "upsert", "collection": "modules", "properties": { "module_id": "63", @@ -744,7 +744,7 @@ } }, { - "id": "64", + "action": "upsert", "collection": "modules", "properties": { "module_id": "64", @@ -756,7 +756,7 @@ } }, { - "id": "65", + "action": "upsert", "collection": "modules", "properties": { "module_id": "65", @@ -768,7 +768,7 @@ } }, { - "id": "66", + "action": "upsert", "collection": "modules", "properties": { "module_id": "66", @@ -780,7 +780,7 @@ } }, { - "id": "67", + "action": "upsert", "collection": "modules", "properties": { "module_id": "67", @@ -792,7 +792,7 @@ } }, { - "id": "68", + "action": "upsert", "collection": "modules", "properties": { "module_id": "68", @@ -804,7 +804,7 @@ } }, { - "id": "69", + "action": "upsert", "collection": "modules", "properties": { "module_id": "69", @@ -816,7 +816,7 @@ } }, { - "id": "70", + "action": "upsert", "collection": "modules", "properties": { "module_id": "70", diff --git a/e2e/src/fixtures/9/order_details.json b/e2e/src/fixtures/9/order_details.json index 9f313260..36a44a9b 100644 --- a/e2e/src/fixtures/9/order_details.json +++ b/e2e/src/fixtures/9/order_details.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 1, @@ -20,7 +20,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 2, @@ -40,7 +40,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 3, @@ -60,7 +60,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 4, @@ -80,7 +80,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 5, @@ -100,7 +100,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 6, @@ -120,7 +120,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_details", "properties": { "id_order_detail": 7, diff --git a/e2e/src/fixtures/9/order_status_history.json b/e2e/src/fixtures/9/order_status_history.json index 05868d4b..c0257455 100644 --- a/e2e/src/fixtures/9/order_status_history.json +++ b/e2e/src/fixtures/9/order_status_history.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -19,7 +19,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -38,7 +38,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -57,7 +57,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 1, @@ -76,7 +76,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 10, @@ -95,7 +95,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 6, @@ -114,7 +114,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "order_status_history", "properties": { "id_order_state": 8, diff --git a/e2e/src/fixtures/9/orders.json b/e2e/src/fixtures/9/orders.json index c8400ea5..155414fb 100644 --- a/e2e/src/fixtures/9/orders.json +++ b/e2e/src/fixtures/9/orders.json @@ -1,12 +1,12 @@ [ { - "id": 1, + "action": "upsert", "collection": "orders", "properties": { "id_order": 1, "reference": "XKBKNABJK", "id_customer": 2, - "id_cart": 1, + "id_cart": "1", "current_state": 6, "conversion_rate": 1, "total_paid_tax_excl": 66.8, @@ -33,13 +33,13 @@ } }, { - "id": 2, + "action": "upsert", "collection": "orders", "properties": { "id_order": 2, "reference": "OHSATSERP", "id_customer": 2, - "id_cart": 2, + "id_cart": "2", "current_state": 1, "conversion_rate": 1, "total_paid_tax_excl": 169.9, @@ -66,13 +66,13 @@ } }, { - "id": 3, + "action": "upsert", "collection": "orders", "properties": { "id_order": 3, "reference": "UOYEVOLI", "id_customer": 2, - "id_cart": 3, + "id_cart": "3", "current_state": 8, "conversion_rate": 1, "total_paid_tax_excl": 19.9, @@ -99,13 +99,13 @@ } }, { - "id": 4, + "action": "upsert", "collection": "orders", "properties": { "id_order": 4, "reference": "FFATNOMMJ", "id_customer": 2, - "id_cart": 4, + "id_cart": "4", "current_state": 1, "conversion_rate": 1, "total_paid_tax_excl": 19.9, @@ -132,13 +132,13 @@ } }, { - "id": 5, + "action": "upsert", "collection": "orders", "properties": { "id_order": 5, "reference": "KHWLILZLL", "id_customer": 2, - "id_cart": 5, + "id_cart": "5", "current_state": 10, "conversion_rate": 1, "total_paid_tax_excl": 25.9, diff --git a/e2e/src/fixtures/9/product_suppliers.json b/e2e/src/fixtures/9/product_suppliers.json index 365f801f..72ee278d 100644 --- a/e2e/src/fixtures/9/product_suppliers.json +++ b/e2e/src/fixtures/9/product_suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 1, @@ -13,7 +13,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 2, @@ -26,7 +26,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 3, @@ -39,7 +39,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 4, @@ -52,7 +52,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 5, @@ -65,7 +65,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 6, @@ -78,7 +78,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 7, @@ -91,7 +91,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 8, @@ -104,7 +104,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 9, @@ -117,7 +117,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 10, @@ -130,7 +130,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 11, @@ -143,7 +143,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 12, @@ -156,7 +156,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 13, @@ -169,7 +169,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 14, @@ -182,7 +182,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 15, @@ -195,7 +195,7 @@ } }, { - "id": 16, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 16, @@ -208,7 +208,7 @@ } }, { - "id": 17, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 17, @@ -221,7 +221,7 @@ } }, { - "id": 18, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 18, @@ -234,7 +234,7 @@ } }, { - "id": 19, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 19, @@ -247,7 +247,7 @@ } }, { - "id": 20, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 20, @@ -260,7 +260,7 @@ } }, { - "id": 21, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 21, @@ -273,7 +273,7 @@ } }, { - "id": 22, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 22, @@ -286,7 +286,7 @@ } }, { - "id": 23, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 23, @@ -299,7 +299,7 @@ } }, { - "id": 24, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 24, @@ -312,7 +312,7 @@ } }, { - "id": 25, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 25, @@ -325,7 +325,7 @@ } }, { - "id": 26, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 26, @@ -338,7 +338,7 @@ } }, { - "id": 27, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 27, @@ -351,7 +351,7 @@ } }, { - "id": 28, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 28, @@ -364,7 +364,7 @@ } }, { - "id": 29, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 29, @@ -377,7 +377,7 @@ } }, { - "id": 30, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 30, @@ -390,7 +390,7 @@ } }, { - "id": 31, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 31, @@ -403,7 +403,7 @@ } }, { - "id": 32, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 32, @@ -416,7 +416,7 @@ } }, { - "id": 33, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 33, @@ -429,7 +429,7 @@ } }, { - "id": 34, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 34, @@ -442,7 +442,7 @@ } }, { - "id": 35, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 35, @@ -455,7 +455,7 @@ } }, { - "id": 36, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 36, @@ -468,7 +468,7 @@ } }, { - "id": 37, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 37, @@ -481,7 +481,7 @@ } }, { - "id": 38, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 38, @@ -494,7 +494,7 @@ } }, { - "id": 39, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 39, @@ -507,7 +507,7 @@ } }, { - "id": 40, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 40, @@ -520,7 +520,7 @@ } }, { - "id": 41, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 41, @@ -533,7 +533,7 @@ } }, { - "id": 42, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 42, @@ -546,7 +546,7 @@ } }, { - "id": 43, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 43, @@ -559,7 +559,7 @@ } }, { - "id": 44, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 44, @@ -572,7 +572,7 @@ } }, { - "id": 45, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 45, @@ -585,7 +585,7 @@ } }, { - "id": 46, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 46, @@ -598,7 +598,7 @@ } }, { - "id": 47, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 47, @@ -611,7 +611,7 @@ } }, { - "id": 48, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 48, @@ -624,7 +624,7 @@ } }, { - "id": 49, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 49, @@ -637,7 +637,7 @@ } }, { - "id": 50, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 50, @@ -650,7 +650,7 @@ } }, { - "id": 51, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 51, @@ -663,7 +663,7 @@ } }, { - "id": 52, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 52, @@ -676,7 +676,7 @@ } }, { - "id": 53, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 53, @@ -689,7 +689,7 @@ } }, { - "id": 54, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 54, @@ -702,7 +702,7 @@ } }, { - "id": 55, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 55, @@ -715,7 +715,7 @@ } }, { - "id": 56, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 56, @@ -728,7 +728,7 @@ } }, { - "id": 57, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 57, @@ -741,7 +741,7 @@ } }, { - "id": 58, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 58, @@ -754,7 +754,7 @@ } }, { - "id": 59, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 59, @@ -767,7 +767,7 @@ } }, { - "id": 60, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 60, @@ -780,7 +780,7 @@ } }, { - "id": 61, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 61, @@ -793,7 +793,7 @@ } }, { - "id": 62, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 62, @@ -806,7 +806,7 @@ } }, { - "id": 63, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 63, @@ -819,7 +819,7 @@ } }, { - "id": 64, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 64, @@ -832,7 +832,7 @@ } }, { - "id": 65, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 65, @@ -845,7 +845,7 @@ } }, { - "id": 66, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 66, @@ -858,7 +858,7 @@ } }, { - "id": 67, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 67, @@ -871,7 +871,7 @@ } }, { - "id": 68, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 68, @@ -884,7 +884,7 @@ } }, { - "id": 69, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 69, @@ -897,7 +897,7 @@ } }, { - "id": 70, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 70, @@ -910,7 +910,7 @@ } }, { - "id": 71, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 71, @@ -923,7 +923,7 @@ } }, { - "id": 72, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 72, @@ -936,7 +936,7 @@ } }, { - "id": 73, + "action": "upsert", "collection": "product_suppliers", "properties": { "id_product_supplier": 73, diff --git a/e2e/src/fixtures/9/products.json b/e2e/src/fixtures/9/products.json index 45936ceb..e9dca1b5 100644 --- a/e2e/src/fixtures/9/products.json +++ b/e2e/src/fixtures/9/products.json @@ -1,6 +1,6 @@ [ { - "id": "1-2-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -63,7 +63,7 @@ } }, { - "id": "1-3-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -126,7 +126,7 @@ } }, { - "id": "1-4-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -189,7 +189,7 @@ } }, { - "id": "1-5-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -252,7 +252,7 @@ } }, { - "id": "1-6-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -315,7 +315,7 @@ } }, { - "id": "1-7-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -378,7 +378,7 @@ } }, { - "id": "1-8-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -441,7 +441,7 @@ } }, { - "id": "1-1-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 1, @@ -504,7 +504,7 @@ } }, { - "id": "2-10-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -566,7 +566,7 @@ } }, { - "id": "2-11-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -628,7 +628,7 @@ } }, { - "id": "2-12-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -690,7 +690,7 @@ } }, { - "id": "2-9-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 2, @@ -752,7 +752,7 @@ } }, { - "id": "3-14-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -813,7 +813,7 @@ } }, { - "id": "3-15-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -874,7 +874,7 @@ } }, { - "id": "3-13-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 3, @@ -935,7 +935,7 @@ } }, { - "id": "4-17-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -996,7 +996,7 @@ } }, { - "id": "4-18-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1057,7 +1057,7 @@ } }, { - "id": "4-16-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 4, @@ -1118,7 +1118,7 @@ } }, { - "id": "5-20-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1179,7 +1179,7 @@ } }, { - "id": "5-21-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1240,7 +1240,7 @@ } }, { - "id": "5-19-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 5, @@ -1301,7 +1301,7 @@ } }, { - "id": "6-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 6, @@ -1360,7 +1360,7 @@ } }, { - "id": "7-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 7, @@ -1419,7 +1419,7 @@ } }, { - "id": "8-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 8, @@ -1478,7 +1478,7 @@ } }, { - "id": "9-23-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 9, @@ -1540,7 +1540,7 @@ } }, { - "id": "9-22-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 9, @@ -1602,7 +1602,7 @@ } }, { - "id": "10-25-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 10, @@ -1664,7 +1664,7 @@ } }, { - "id": "10-24-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 10, @@ -1726,7 +1726,7 @@ } }, { - "id": "11-27-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 11, @@ -1788,7 +1788,7 @@ } }, { - "id": "11-26-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 11, @@ -1850,7 +1850,7 @@ } }, { - "id": "12-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 12, @@ -1907,7 +1907,7 @@ } }, { - "id": "13-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 13, @@ -1964,7 +1964,7 @@ } }, { - "id": "14-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 14, @@ -2021,7 +2021,7 @@ } }, { - "id": "15-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 15, @@ -2078,7 +2078,7 @@ } }, { - "id": "16-29-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2140,7 +2140,7 @@ } }, { - "id": "16-30-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2202,7 +2202,7 @@ } }, { - "id": "16-31-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2264,7 +2264,7 @@ } }, { - "id": "16-28-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 16, @@ -2326,7 +2326,7 @@ } }, { - "id": "17-33-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2388,7 +2388,7 @@ } }, { - "id": "17-34-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2450,7 +2450,7 @@ } }, { - "id": "17-35-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2512,7 +2512,7 @@ } }, { - "id": "17-32-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 17, @@ -2574,7 +2574,7 @@ } }, { - "id": "18-37-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2636,7 +2636,7 @@ } }, { - "id": "18-38-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2698,7 +2698,7 @@ } }, { - "id": "18-39-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2760,7 +2760,7 @@ } }, { - "id": "18-36-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 18, @@ -2822,7 +2822,7 @@ } }, { - "id": "19-0-en", + "action": "upsert", "collection": "products", "properties": { "id_product": 19, diff --git a/e2e/src/fixtures/9/shops.json b/e2e/src/fixtures/9/shops.json index 49605475..08fd4f5d 100644 --- a/e2e/src/fixtures/9/shops.json +++ b/e2e/src/fixtures/9/shops.json @@ -1,6 +1,6 @@ [ { - "id": "1", + "action": "upsert", "collection": "shops", "properties": { "created_at": "2024-06-10 02:27:21", diff --git a/e2e/src/fixtures/9/specific_prices.json b/e2e/src/fixtures/9/specific_prices.json index f179c309..222d03f4 100644 --- a/e2e/src/fixtures/9/specific_prices.json +++ b/e2e/src/fixtures/9/specific_prices.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 1, @@ -31,7 +31,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "specific_prices", "properties": { "id_specific_price": 2, diff --git a/e2e/src/fixtures/9/stocks.json b/e2e/src/fixtures/9/stocks.json index b95df9a4..12efb5ae 100644 --- a/e2e/src/fixtures/9/stocks.json +++ b/e2e/src/fixtures/9/stocks.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 1, @@ -17,7 +17,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 2, @@ -34,7 +34,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 3, @@ -51,7 +51,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 4, @@ -68,7 +68,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 5, @@ -85,7 +85,7 @@ } }, { - "id": 6, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 6, @@ -102,7 +102,7 @@ } }, { - "id": 7, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 7, @@ -119,7 +119,7 @@ } }, { - "id": 8, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 8, @@ -136,7 +136,7 @@ } }, { - "id": 9, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 9, @@ -153,7 +153,7 @@ } }, { - "id": 10, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 10, @@ -170,7 +170,7 @@ } }, { - "id": 11, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 11, @@ -187,7 +187,7 @@ } }, { - "id": 12, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 12, @@ -204,7 +204,7 @@ } }, { - "id": 13, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 13, @@ -221,7 +221,7 @@ } }, { - "id": 14, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 14, @@ -238,7 +238,7 @@ } }, { - "id": 15, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 15, @@ -255,7 +255,7 @@ } }, { - "id": 16, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 16, @@ -272,7 +272,7 @@ } }, { - "id": 17, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 17, @@ -289,7 +289,7 @@ } }, { - "id": 18, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 18, @@ -306,7 +306,7 @@ } }, { - "id": 19, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 19, @@ -323,7 +323,7 @@ } }, { - "id": 20, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 20, @@ -340,7 +340,7 @@ } }, { - "id": 21, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 21, @@ -357,7 +357,7 @@ } }, { - "id": 22, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 22, @@ -374,7 +374,7 @@ } }, { - "id": 23, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 23, @@ -391,7 +391,7 @@ } }, { - "id": 24, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 24, @@ -408,7 +408,7 @@ } }, { - "id": 25, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 25, @@ -425,7 +425,7 @@ } }, { - "id": 26, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 26, @@ -442,7 +442,7 @@ } }, { - "id": 27, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 27, @@ -459,7 +459,7 @@ } }, { - "id": 28, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 28, @@ -476,7 +476,7 @@ } }, { - "id": 29, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 29, @@ -493,7 +493,7 @@ } }, { - "id": 30, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 30, @@ -510,7 +510,7 @@ } }, { - "id": 31, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 31, @@ -527,7 +527,7 @@ } }, { - "id": 32, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 32, @@ -544,7 +544,7 @@ } }, { - "id": 33, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 33, @@ -561,7 +561,7 @@ } }, { - "id": 34, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 34, @@ -578,7 +578,7 @@ } }, { - "id": 35, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 35, @@ -595,7 +595,7 @@ } }, { - "id": 36, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 36, @@ -612,7 +612,7 @@ } }, { - "id": 37, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 37, @@ -629,7 +629,7 @@ } }, { - "id": 38, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 38, @@ -646,7 +646,7 @@ } }, { - "id": 39, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 39, @@ -663,7 +663,7 @@ } }, { - "id": 40, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 40, @@ -680,7 +680,7 @@ } }, { - "id": 41, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 41, @@ -697,7 +697,7 @@ } }, { - "id": 42, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 42, @@ -714,7 +714,7 @@ } }, { - "id": 43, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 43, @@ -731,7 +731,7 @@ } }, { - "id": 44, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 44, @@ -748,7 +748,7 @@ } }, { - "id": 45, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 45, @@ -765,7 +765,7 @@ } }, { - "id": 46, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 46, @@ -782,7 +782,7 @@ } }, { - "id": 47, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 47, @@ -799,7 +799,7 @@ } }, { - "id": 48, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 48, @@ -816,7 +816,7 @@ } }, { - "id": 49, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 49, @@ -833,7 +833,7 @@ } }, { - "id": 50, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 50, @@ -850,7 +850,7 @@ } }, { - "id": 51, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 51, @@ -867,7 +867,7 @@ } }, { - "id": 52, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 52, @@ -884,7 +884,7 @@ } }, { - "id": 53, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 53, @@ -901,7 +901,7 @@ } }, { - "id": 54, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 54, @@ -918,7 +918,7 @@ } }, { - "id": 55, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 55, @@ -935,7 +935,7 @@ } }, { - "id": 56, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 56, @@ -952,7 +952,7 @@ } }, { - "id": 57, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 57, @@ -969,7 +969,7 @@ } }, { - "id": 58, + "action": "upsert", "collection": "stocks", "properties": { "id_stock_available": 58, diff --git a/e2e/src/fixtures/9/stores.json b/e2e/src/fixtures/9/stores.json index 29191752..65c3760d 100644 --- a/e2e/src/fixtures/9/stores.json +++ b/e2e/src/fixtures/9/stores.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "stores", "properties": { "id_store": 1, @@ -20,7 +20,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "stores", "properties": { "id_store": 2, @@ -40,7 +40,7 @@ } }, { - "id": 3, + "action": "upsert", "collection": "stores", "properties": { "id_store": 3, @@ -60,7 +60,7 @@ } }, { - "id": 4, + "action": "upsert", "collection": "stores", "properties": { "id_store": 4, @@ -80,7 +80,7 @@ } }, { - "id": 5, + "action": "upsert", "collection": "stores", "properties": { "id_store": 5, diff --git a/e2e/src/fixtures/9/suppliers.json b/e2e/src/fixtures/9/suppliers.json index 2cd693a8..b0060748 100644 --- a/e2e/src/fixtures/9/suppliers.json +++ b/e2e/src/fixtures/9/suppliers.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "action": "upsert", "collection": "suppliers", "properties": { "id_supplier": 1, @@ -17,7 +17,7 @@ } }, { - "id": 2, + "action": "upsert", "collection": "suppliers", "properties": { "id_supplier": 2, diff --git a/e2e/src/fixtures/9/themes.json b/e2e/src/fixtures/9/themes.json index d6821c78..411fcd30 100644 --- a/e2e/src/fixtures/9/themes.json +++ b/e2e/src/fixtures/9/themes.json @@ -1,6 +1,6 @@ [ { - "id": "28d58425ad1994a889cc596050bc52db", + "action": "upsert", "collection": "themes", "properties": { "theme_id": "28d58425ad1994a889cc596050bc52db", @@ -10,7 +10,7 @@ } }, { - "id": "f3d64714d1f6e7f71558d4252e84ab58", + "action": "upsert", "collection": "themes", "properties": { "theme_id": "f3d64714d1f6e7f71558d4252e84ab58", diff --git a/e2e/src/full-sync.spec.ts b/e2e/src/full-sync.spec.ts index 9bef6edc..9c58790f 100644 --- a/e2e/src/full-sync.spec.ts +++ b/e2e/src/full-sync.spec.ts @@ -5,12 +5,11 @@ import axios from "axios"; import { doFullSync, probe, PsEventbusSyncUpload } from "./helpers/mock-probe"; import { lastValueFrom, toArray, withLatestFrom } from "rxjs"; import { - generatePredictableModuleId, loadFixture, omitProperties, sortUploadData, } from "./helpers/data-helper"; -import { ShopContent, shopContentList } from "./helpers/shop-contents"; +import { shopContentList } from "./helpers/shop-contents"; expect.extend(matchers); @@ -26,6 +25,8 @@ const isBoolean = (val) => const specialFieldAssert: { [index: string]: (val) => void } = { created_at: isDateString, updated_at: isDateString, + delivery_date: isDateString, + invoice_date: isDateString, last_connection_date: isDateString, folder_created_at: isDateString, date_add: isDateString, @@ -100,38 +101,28 @@ describe("Full Sync", () => { ), ); - const syncedData: PsEventbusSyncUpload[] = messages.flat(); + let dataFromModule: PsEventbusSyncUpload[] = messages.flat(); + let fixtures = await loadFixture(shopContent); - // dump data for easier debugging or updating fixtures - let processedData = syncedData as PsEventbusSyncUpload[]; if (testConfig.dumpFullSyncData) { - await dumpUploadData(syncedData, shopContent); + await dumpUploadData(dataFromModule); } - const fixture = await loadFixture(shopContent); - - // we need to process fixtures and data returned from ps_eventbus to make them easier to compare - let processedFixture = fixture; - if (shopContent === ("modules" as ShopContent)) { - processedData = generatePredictableModuleId(processedData); - processedFixture = generatePredictableModuleId(processedFixture); - } - processedData = omitProperties( - processedData, - Object.keys(specialFieldAssert), - ); - processedData = sortUploadData(processedData); - processedFixture = omitProperties( - processedFixture, + dataFromModule = omitProperties( + dataFromModule, Object.keys(specialFieldAssert), ); - processedFixture = sortUploadData(processedFixture); + + fixtures = omitProperties(fixtures, Object.keys(specialFieldAssert)); + + dataFromModule = sortUploadData(dataFromModule); + fixtures = sortUploadData(fixtures); // assert - expect(processedData).toMatchObject(processedFixture); + expect(dataFromModule).toEqual(fixtures); // assert special field using custom matcher - for (const data of processedData) { + for (const data of dataFromModule) { for (const specialFieldName of Object.keys(specialFieldAssert)) { if (data.properties[specialFieldName] !== undefined) { specialFieldAssert[specialFieldName]( diff --git a/e2e/src/helpers/data-helper.ts b/e2e/src/helpers/data-helper.ts index 0556d045..48341b9b 100644 --- a/e2e/src/helpers/data-helper.ts +++ b/e2e/src/helpers/data-helper.ts @@ -6,30 +6,21 @@ import axios from "axios"; import testConfig from "./test.config"; import { HealthCheck } from "../type/health-check"; import semver from "semver"; - +import hash from "object-hash"; /** - * sort upload data by collection and id to allow easier comparison + * sort upload data by collection and hash to allow easier comparison + * The hash is calculated from the data object + * * @param data ps_eventbus upload data */ -export const sortUploadData: ( - data: PsEventbusSyncUpload[], -) => PsEventbusSyncUpload[] = R.pipe( - R.sortBy(R.prop("collection")), - R.sortBy(R.prop("id")), -); - -/** - * modules returned by ps_eventbus use their database it as their collection id, which makes it random. - * this function provides a way to generate a predictable replacement id. - * @param data - */ -export function generatePredictableModuleId( +export function sortUploadData( data: PsEventbusSyncUpload[], ): PsEventbusSyncUpload[] { - return data.map((it) => ({ - ...it, - id: `${(it.properties as { name: string }).name}`, - })); + data.forEach((item) => { + item["hash"] = hash(item); + }); + + return R.pipe(R.sortBy(R.prop("collection")), R.sortBy(R.prop("hash")))(data); } export function omitProperties( diff --git a/e2e/src/helpers/log-helper.ts b/e2e/src/helpers/log-helper.ts index 46beaa88..d211b04c 100644 --- a/e2e/src/helpers/log-helper.ts +++ b/e2e/src/helpers/log-helper.ts @@ -16,12 +16,9 @@ export function logAxiosError(err: Error) { } } -export async function dumpUploadData( - data: PsEventbusSyncUpload[], - filename: string, -) { +export async function dumpUploadData(data: PsEventbusSyncUpload[]) { const shopVersion = (await getShopHealthCheck()).prestashop_version; - const dir = `./dumps/${testConfig.testRunTime}/${shopVersion}/${filename}`; + const dir = `./dumps/${testConfig.testRunTime}/${shopVersion}`; await fs.promises.mkdir(dir, { recursive: true }); const groupedData = R.groupBy((el) => el.collection, data); diff --git a/src/Api/LiveSyncApiClient.php b/src/Api/LiveSyncApiClient.php index bdffc643..6e026698 100644 --- a/src/Api/LiveSyncApiClient.php +++ b/src/Api/LiveSyncApiClient.php @@ -103,9 +103,6 @@ public function liveSync($shopContent, $action) // shop content send to the API must be in kebab-case $kebabCasedShopContent = str_replace('_', '-', $shopContent); - // This parameter is purely useless, but it is required by the API - $uselessParameter = 0; - $response = $this->getClient(3)->sendRequest( new Request( 'POST', @@ -115,7 +112,7 @@ public function liveSync($shopContent, $action) 'Authorization' => 'Bearer ' . $this->jwt, 'User-Agent' => 'ps-eventbus/' . $this->module->version, 'Content-Type' => 'application/json', - ], // FIXME: Pass real array of shop contents. at the moment, only one shop content is sent to match CS rate limiter + ], '{"shopContents": ["' . $kebabCasedShopContent . '"], "action": "' . $action . '"}' ) ); diff --git a/src/Config/Config.php b/src/Config/Config.php index dd32fe2b..81a65c92 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -34,6 +34,7 @@ class Config { const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s'; + const INCREMENTAL_SYNC_TABLE_NAME = 'eventbus_incremental_sync'; const INCREMENTAL_SYNC_TABLE_SIZE_CHECK_MOD = 20; const INCREMENTAL_SYNC_MAX_TABLE_SIZE = 100000; @@ -134,8 +135,7 @@ class Config self::COLLECTION_WISHLIST_PRODUCTS, ]; - const INCREMENTAL_TYPE_ADD = 'add'; - const INCREMENTAL_TYPE_UPDATE = 'update'; + const INCREMENTAL_TYPE_UPSERT = 'upsert'; const INCREMENTAL_TYPE_DELETE = 'delete'; /** diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index b12281ef..8e5e066c 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -111,16 +111,16 @@ protected function getShopContext() } /** - * @param string $query + * @param string $tableName * * @return array|bool|\mysqli_result|\PDOStatement|resource|null * * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ - protected function checkIfTableExist($query) + protected function checkIfTableExist($tableName) { - $request = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'' . $query . '\' LIMIT 1;'; + $request = 'SELECT * FROM information_schema.tables WHERE table_name LIKE \'' . $tableName . '\' LIMIT 1;'; return $this->db->executeS($request); } @@ -135,6 +135,8 @@ protected function checkIfTableExist($query) */ protected function runQuery($disableCurrentExplain = null) { + $result = []; + $explainSql = false; if (defined('PS_EVENTBUS_EXPLAIN_SQL_ENABLED')) { @@ -145,9 +147,9 @@ protected function runQuery($disableCurrentExplain = null) $this->debugQuery(); } - $result = $this->db->executeS($this->query); + $result = (array) $this->db->executeS($this->query); - return is_array($result) ? $result : []; + return $result; } /** diff --git a/src/Repository/BundleRepository.php b/src/Repository/BundleRepository.php index 33f9b987..f8b60968 100644 --- a/src/Repository/BundleRepository.php +++ b/src/Repository/BundleRepository.php @@ -98,6 +98,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php index 974c67ef..3e970229 100644 --- a/src/Repository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -95,6 +95,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CartProductRepository.php b/src/Repository/CartProductRepository.php index 1ae56288..924871df 100644 --- a/src/Repository/CartProductRepository.php +++ b/src/Repository/CartProductRepository.php @@ -90,6 +90,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CartRepository.php b/src/Repository/CartRepository.php index 6136c9c9..111db8a7 100644 --- a/src/Repository/CartRepository.php +++ b/src/Repository/CartRepository.php @@ -88,6 +88,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CartRuleRepository.php b/src/Repository/CartRuleRepository.php index b9a76ff2..545a6e08 100644 --- a/src/Repository/CartRuleRepository.php +++ b/src/Repository/CartRuleRepository.php @@ -119,6 +119,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php index 42354496..083ff4e2 100644 --- a/src/Repository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -104,6 +104,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php index e5381906..e2bdd7b3 100644 --- a/src/Repository/CountryRepository.php +++ b/src/Repository/CountryRepository.php @@ -34,11 +34,6 @@ class CountryRepository extends AbstractRepository { const TABLE_NAME = 'country'; - /** - * @var array - */ - private $countryIsoCodeCache = []; - /** * @param int $zoneId * @param bool $active @@ -47,34 +42,29 @@ class CountryRepository extends AbstractRepository * * @throws \PrestaShopDatabaseException */ - public function getCountyIsoCodesByZoneId($zoneId, $active) + public function getCountryIsoCodesByZoneId($zoneId, $active) { - $cacheKey = $zoneId . '-' . (int) $active; $isoCodes = []; - if (!isset($this->countryIsoCodeCache[$cacheKey])) { - $this->generateMinimalQuery(self::TABLE_NAME, 'c'); - - $this->query - ->innerJoin('country_shop', 'cs', 'cs.id_country = c.id_country') - ->innerJoin('country_lang', 'cl', 'cl.id_country = c.id_country') - ->where('cs.id_shop = ' . (int) parent::getShopContext()->id) - ->where('cl.id_lang = ' . (int) parent::getLanguageContext()->id) - ->where('id_zone = ' . (int) $zoneId) - ->where('active = ' . (bool) $active) - ; + $this->generateMinimalQuery(self::TABLE_NAME, 'c'); - $this->query->select('iso_code'); + $this->query + ->innerJoin('country_shop', 'cs', 'cs.id_country = c.id_country') + ->innerJoin('country_lang', 'cl', 'cl.id_country = c.id_country') + ->where('cs.id_shop = ' . (int) parent::getShopContext()->id) + ->where('cl.id_lang = ' . (int) parent::getLanguageContext()->id) + ->where('id_zone = ' . (int) $zoneId) + ->where('active = ' . (bool) $active) + ; - $result = $this->runQuery(true); + $this->query->select('iso_code'); - foreach ($result as $country) { - $isoCodes[] = $country['iso_code']; - } + $result = $this->runQuery(true); - $this->countryIsoCodeCache[$cacheKey] = $isoCodes; + foreach ($result as $country) { + $isoCodes[] = $country['iso_code']; } - return $this->countryIsoCodeCache[$cacheKey]; + return $isoCodes; } } diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php index c8862d0d..31e2e5a0 100644 --- a/src/Repository/CurrencyRepository.php +++ b/src/Repository/CurrencyRepository.php @@ -103,6 +103,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CustomProductCarrierRepository.php b/src/Repository/CustomProductCarrierRepository.php index 7fdc75c2..5532b728 100644 --- a/src/Repository/CustomProductCarrierRepository.php +++ b/src/Repository/CustomProductCarrierRepository.php @@ -84,6 +84,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index 3e9b57ac..94e6eb83 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -96,6 +96,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/EmployeeRepository.php b/src/Repository/EmployeeRepository.php index 62e088ca..15b1a373 100644 --- a/src/Repository/EmployeeRepository.php +++ b/src/Repository/EmployeeRepository.php @@ -110,6 +110,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/ImageRepository.php b/src/Repository/ImageRepository.php index 7a23e839..4ebe7d65 100644 --- a/src/Repository/ImageRepository.php +++ b/src/Repository/ImageRepository.php @@ -94,6 +94,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/ImageTypeRepository.php b/src/Repository/ImageTypeRepository.php index 2b3f70c1..fbc872b4 100644 --- a/src/Repository/ImageTypeRepository.php +++ b/src/Repository/ImageTypeRepository.php @@ -92,6 +92,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/IncrementalSyncRepository.php b/src/Repository/IncrementalSyncRepository.php index 3d95d75c..cd629348 100644 --- a/src/Repository/IncrementalSyncRepository.php +++ b/src/Repository/IncrementalSyncRepository.php @@ -124,7 +124,7 @@ public function removeIncrementalSyncObjects($type, $objectIds, $langIso) } /** - * @param string $type + * @param string $shopContent * @param string $langIso * @param int $limit * @@ -132,28 +132,24 @@ public function removeIncrementalSyncObjects($type, $objectIds, $langIso) * * @throws \PrestaShopDatabaseException */ - public function getIncrementalSyncObjectIds($type, $langIso, $limit) + public function getIncrementalSyncObjects($shopContent, $langIso, $limit) { $this->generateMinimalQuery(self::TABLE_NAME, 'eis'); $this->query ->where('eis.lang_iso = "' . pSQL($langIso) . '"') ->where('eis.id_shop = "' . parent::getShopContext()->id . '"') - ->where('eis.type = "' . pSQL($type) . '"') + ->where('eis.type = "' . pSQL($shopContent) . '"') ->limit($limit) ; - $this->query->select('eis.id_object'); - - $result = $this->runQuery(true); - - if (!empty($result)) { - return array_map(function ($object) { - return $object['id_object']; - }, $result); - } + $this->query + ->select('eis.type') + ->select('eis.id_object as id') + ->select('eis.action') + ; - return []; + return $this->runQuery(true); } /** diff --git a/src/Repository/LanguageRepository.php b/src/Repository/LanguageRepository.php index eccc980f..ea0c8533 100644 --- a/src/Repository/LanguageRepository.php +++ b/src/Repository/LanguageRepository.php @@ -99,6 +99,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 19df7120..599a44c8 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -99,6 +99,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/ModuleRepository.php b/src/Repository/ModuleRepository.php index e2190669..41e4a41e 100644 --- a/src/Repository/ModuleRepository.php +++ b/src/Repository/ModuleRepository.php @@ -105,6 +105,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php index 6c256e57..07b4ad89 100644 --- a/src/Repository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -94,6 +94,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/OrderDetailRepository.php b/src/Repository/OrderDetailRepository.php index 5f203305..ee952c21 100644 --- a/src/Repository/OrderDetailRepository.php +++ b/src/Repository/OrderDetailRepository.php @@ -117,6 +117,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php index f7a374be..71352a86 100644 --- a/src/Repository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -147,6 +147,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/OrderStatusHistoryRepository.php b/src/Repository/OrderStatusHistoryRepository.php index ca7c4b9b..51ffcf49 100644 --- a/src/Repository/OrderStatusHistoryRepository.php +++ b/src/Repository/OrderStatusHistoryRepository.php @@ -101,6 +101,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index 05acb8f4..3dd81e73 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -166,6 +166,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php index 1f35e561..98e65f3c 100644 --- a/src/Repository/ProductSupplierRepository.php +++ b/src/Repository/ProductSupplierRepository.php @@ -90,6 +90,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/SpecificPriceRepository.php b/src/Repository/SpecificPriceRepository.php index c43110a5..ea95c292 100644 --- a/src/Repository/SpecificPriceRepository.php +++ b/src/Repository/SpecificPriceRepository.php @@ -108,6 +108,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php index 75d65855..e8663274 100644 --- a/src/Repository/StateRepository.php +++ b/src/Repository/StateRepository.php @@ -34,11 +34,6 @@ class StateRepository extends AbstractRepository { const TABLE_NAME = 'state'; - /** - * @var array - */ - private $stateIsoCodeCache = []; - /** * @param int $zoneId * @param bool $active @@ -49,29 +44,24 @@ class StateRepository extends AbstractRepository */ public function getStateIsoCodesByZoneId($zoneId, $active) { - $cacheKey = $zoneId . '-' . (int) $active; $isoCodes = []; - if (!isset($this->stateIsoCodeCache[$cacheKey])) { - $this->generateMinimalQuery(self::TABLE_NAME, 's'); - - $this->query->innerJoin('country', 'c', 'c.id_country = s.id_country') - ->where('s.id_zone = ' . (int) $zoneId) - ->where('s.active = ' . (bool) $active) - ->where('c.active = ' . (bool) $active) - ; + $this->generateMinimalQuery(self::TABLE_NAME, 's'); - $this->query->select('s.iso_code'); + $this->query->innerJoin('country', 'c', 'c.id_country = s.id_country') + ->where('s.id_zone = ' . (int) $zoneId) + ->where('s.active = ' . (bool) $active) + ->where('c.active = ' . (bool) $active) + ; - $result = $this->runQuery(true); + $this->query->select('s.iso_code'); - foreach ($result as $state) { - $isoCodes[] = $state['iso_code']; - } + $result = $this->runQuery(true); - $this->stateIsoCodeCache[$cacheKey] = $isoCodes; + foreach ($result as $state) { + $isoCodes[] = $state['iso_code']; } - return $this->stateIsoCodeCache[$cacheKey]; + return $isoCodes; } } diff --git a/src/Repository/StockMovementRepository.php b/src/Repository/StockMovementRepository.php index 921fed08..e7fb3ff4 100644 --- a/src/Repository/StockMovementRepository.php +++ b/src/Repository/StockMovementRepository.php @@ -105,6 +105,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index bedbd977..6ecbf753 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -106,6 +106,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/StoreRepository.php b/src/Repository/StoreRepository.php index b2834968..6be5d5b9 100644 --- a/src/Repository/StoreRepository.php +++ b/src/Repository/StoreRepository.php @@ -121,6 +121,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index 912b58cc..38a6b6ca 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -101,6 +101,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php index 535fd0b2..3d1064d0 100644 --- a/src/Repository/TaxeRepository.php +++ b/src/Repository/TaxeRepository.php @@ -34,11 +34,6 @@ class TaxeRepository extends AbstractRepository { const TABLE_NAME = 'tax'; - /** - * @var array - */ - private $countryIsoCodeCache = []; - /** * @param int $zoneId * @param int $taxRulesGroupId @@ -50,37 +45,31 @@ class TaxeRepository extends AbstractRepository */ public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active) { - $cacheKey = $zoneId . '-' . (int) $active; - - if (!isset($this->countryIsoCodeCache[$cacheKey])) { - $this->generateMinimalQuery(self::TABLE_NAME, 't'); - - $this->query - ->innerJoin('tax_rule', 'tr', 'tr.id_tax = t.id_tax') - ->innerJoin('tax_rules_group', 'trg', 'trg.id_tax_rules_group = tr.id_tax_rules_group') - ->innerJoin('tax_rules_group_shop', 'trgs', 'trgs.id_tax_rules_group = tr.id_tax_rules_group') - ->innerJoin('tax_lang', 'tl', 'tl.id_tax = t.id_tax') - ->leftJoin('country', 'c', 'c.id_country = tr.id_country') - ->leftJoin('state', 's', 's.id_state = tr.id_state') - ->where('tr.id_tax_rules_group = ' . (int) $taxRulesGroupId) - ->where('c.active = ' . (bool) $active) - ->where('s.active = ' . (bool) $active . ' OR s.active IS NULL') - ->where('t.active = ' . (bool) $active) - ->where('c.id_zone = ' . (int) $zoneId . ' OR s.id_zone = ' . (int) $zoneId) - ->where('c.iso_code IS NOT NULL') - ->where('trgs.id_shop = ' . parent::getShopContext()->id) - ->where('tl.id_lang = ' . (int) parent::getLanguageContext()->id) - ; + $this->generateMinimalQuery(self::TABLE_NAME, 't'); - $this->query - ->select('t.rate') - ->select('c.iso_code as country_iso_code') - ->select('GROUP_CONCAT(s.iso_code SEPARATOR ",") as state_iso_code') - ; + $this->query + ->innerJoin('tax_rule', 'tr', 'tr.id_tax = t.id_tax') + ->innerJoin('tax_rules_group', 'trg', 'trg.id_tax_rules_group = tr.id_tax_rules_group') + ->innerJoin('tax_rules_group_shop', 'trgs', 'trgs.id_tax_rules_group = tr.id_tax_rules_group') + ->innerJoin('tax_lang', 'tl', 'tl.id_tax = t.id_tax') + ->leftJoin('country', 'c', 'c.id_country = tr.id_country') + ->leftJoin('state', 's', 's.id_state = tr.id_state') + ->where('tr.id_tax_rules_group = ' . (int) $taxRulesGroupId) + ->where('c.active = ' . (bool) $active) + ->where('s.active = ' . (bool) $active . ' OR s.active IS NULL') + ->where('t.active = ' . (bool) $active) + ->where('c.id_zone = ' . (int) $zoneId . ' OR s.id_zone = ' . (int) $zoneId) + ->where('c.iso_code IS NOT NULL') + ->where('trgs.id_shop = ' . parent::getShopContext()->id) + ->where('tl.id_lang = ' . (int) parent::getLanguageContext()->id) + ; - $this->countryIsoCodeCache[$cacheKey] = $this->runQuery(true); - } + $this->query + ->select('t.rate') + ->select('c.iso_code as country_iso_code') + ->select('GROUP_CONCAT(s.iso_code SEPARATOR ",") as state_iso_code') + ; - return $this->countryIsoCodeCache[$cacheKey]; + return $this->runQuery(true); } } diff --git a/src/Repository/TaxonomyRepository.php b/src/Repository/TaxonomyRepository.php index 96153e87..edefb17e 100644 --- a/src/Repository/TaxonomyRepository.php +++ b/src/Repository/TaxonomyRepository.php @@ -92,6 +92,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/TranslationRepository.php b/src/Repository/TranslationRepository.php index 465fdc91..62cb6d2a 100644 --- a/src/Repository/TranslationRepository.php +++ b/src/Repository/TranslationRepository.php @@ -94,6 +94,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/WishlistProductRepository.php b/src/Repository/WishlistProductRepository.php index ef59c54f..f4a012aa 100644 --- a/src/Repository/WishlistProductRepository.php +++ b/src/Repository/WishlistProductRepository.php @@ -94,6 +94,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php index c6ddef26..f56fc089 100644 --- a/src/Repository/WishlistRepository.php +++ b/src/Repository/WishlistRepository.php @@ -100,6 +100,10 @@ public function retrieveContentsForFull($offset, $limit, $langIso) */ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) { + if ($contentIds == []) { + return []; + } + $this->generateFullQuery($langIso, true); $this->query diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index cfa09450..a838e452 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -75,13 +75,15 @@ public static function exitWithExceptionMessage(\Exception $exception) case $exception instanceof QueryParamsException: $code = Config::INVALID_URL_QUERY; break; + default: + $code = 500; } $response = [ 'object_type' => \Tools::getValue('shopContent'), 'status' => false, 'httpCode' => $code, - 'message' => $exception->getMessage(), + 'message' => $code == 500 ? 'Server error' : $exception->getMessage(), ]; self::dieWithResponse($response, (int) $code); diff --git a/src/Service/ShopContent/BundlesService.php b/src/Service/ShopContent/BundlesService.php index c9bbad35..512c86e7 100644 --- a/src/Service/ShopContent/BundlesService.php +++ b/src/Service/ShopContent/BundlesService.php @@ -33,7 +33,7 @@ exit; } -class BundlesService implements ShopContentServiceInterface +class BundlesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var BundleRepository */ private $bundleRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_bundle'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_BUNDLES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->bundleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->bundleRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castBundles($result, $langIso); } - $this->castBundles($result, $langIso); - - return array_map(function ($item) { - return [ - 'id' => $item['id_bundle'], - 'collection' => Config::COLLECTION_BUNDLES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_BUNDLES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index d3660397..8cdbb1ae 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -35,7 +35,7 @@ exit; } -class CarrierDetailsService implements ShopContentServiceInterface +class CarrierDetailsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CarrierRepository */ private $carrierRepository; @@ -70,7 +70,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['shipping_method'] . '-' . $item['id_range'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CARRIER_DETAILS, 'properties' => $item, ]; @@ -79,34 +79,27 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; - } + if (!empty($result)) { + $carrierDetails = []; - $carrierDetails = []; + foreach ($result as $carrierData) { + $carrierDetails = array_merge($carrierDetails, $this->buildCarrierDetails($carrierData)); + } - foreach ($result as $carrierData) { - $carrierDetails = array_merge($carrierDetails, $this->buildCarrierDetails($carrierData)); + $this->castCarrierDetails($carrierDetails); } - $this->castCarrierDetails($carrierDetails); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['shipping_method'] . '-' . $item['id_range'], - 'collection' => Config::COLLECTION_CARRIER_DETAILS, - 'properties' => $item, - ]; - }, $carrierDetails); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CARRIER_DETAILS, $result, $deletedContents); } /** @@ -182,7 +175,7 @@ private function buildCarrierDetails($carrierData) foreach ($deliveryPriceByRange['zones'] as $zone) { /** @var array $countryIsoCodes */ - $countryIsoCodes = $countryRepository->getCountyIsoCodesByZoneId($zone['id_zone'], true); + $countryIsoCodes = $countryRepository->getCountryIsoCodesByZoneId($zone['id_zone'], true); /** @var array $stateIsoCodes */ $stateIsoCodes = $stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index e2eea16b..6dcf534a 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -34,7 +34,7 @@ exit; } -class CarrierTaxesService implements ShopContentServiceInterface +class CarrierTaxesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CarrierRepository */ private $carrierRepository; @@ -69,7 +69,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['id_range'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CARRIER_TAXES, 'properties' => $item, ]; @@ -78,34 +78,27 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; - } + if (!empty($result)) { + $carrierTaxes = []; - $carrierTaxes = []; + foreach ($result as $carrierData) { + $carrierTaxes = array_merge($carrierTaxes, $this->buildCarrierTaxes($carrierData)); + } - foreach ($result as $carrierData) { - $carrierTaxes = array_merge($carrierTaxes, $this->buildCarrierTaxes($carrierData)); + $this->castCarrierTaxes($carrierTaxes); } - $this->castCarrierTaxes($carrierTaxes); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_reference'] . '-' . $item['id_zone'] . '-' . $item['id_range'], - 'collection' => Config::COLLECTION_CARRIER_TAXES, - 'properties' => $item, - ]; - }, $carrierTaxes); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CARRIER_TAXES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 12c3bc6f..129363a8 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -33,7 +33,7 @@ exit; } -class CarriersService implements ShopContentServiceInterface +class CarriersService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CarrierRepository */ private $carrierRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_reference'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CARRIERS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->carrierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCarriers($result); } - $this->castCarriers($result); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_reference'], - 'collection' => Config::COLLECTION_CARRIERS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CARRIERS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CartProductsService.php b/src/Service/ShopContent/CartProductsService.php index 82b95bef..7201debb 100644 --- a/src/Service/ShopContent/CartProductsService.php +++ b/src/Service/ShopContent/CartProductsService.php @@ -33,7 +33,7 @@ exit; } -class CartProductsService implements ShopContentServiceInterface +class CartProductsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CartProductRepository */ private $cartProductRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => "{$item['id_cart']}-{$item['id_product']}-{$item['id_product_attribute']}", + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CART_PRODUCTS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->cartProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->cartProductRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCartProducts($result); } - $this->castCartProducts($result); - - return array_map(function ($item) { - return [ - 'id' => "{$item['id_cart']}-{$item['id_product']}-{$item['id_product_attribute']}", - 'collection' => Config::COLLECTION_CART_PRODUCTS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CART_PRODUCTS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CartRulesService.php b/src/Service/ShopContent/CartRulesService.php index f55caff5..500f70b7 100644 --- a/src/Service/ShopContent/CartRulesService.php +++ b/src/Service/ShopContent/CartRulesService.php @@ -33,7 +33,7 @@ exit; } -class CartRulesService implements ShopContentServiceInterface +class CartRulesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CartRuleRepository */ private $cartRuleRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_cart_rule'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CART_RULES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->cartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->cartRuleRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCartRules($result); } - $this->castCartRules($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_cart_rule'], - 'collection' => Config::COLLECTION_CART_RULES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CART_RULES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CartsService.php b/src/Service/ShopContent/CartsService.php index 3b94c011..ec44a0d1 100644 --- a/src/Service/ShopContent/CartsService.php +++ b/src/Service/ShopContent/CartsService.php @@ -33,7 +33,7 @@ exit; } -class CartsService implements ShopContentServiceInterface +class CartsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CartRepository */ private $cartRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_cart'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CARTS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->cartRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->cartRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCarts($result); } - $this->castCarts($result); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_cart'], - 'collection' => Config::COLLECTION_CARTS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CARTS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CategoriesService.php b/src/Service/ShopContent/CategoriesService.php index c1d4cbbb..206534dd 100644 --- a/src/Service/ShopContent/CategoriesService.php +++ b/src/Service/ShopContent/CategoriesService.php @@ -33,7 +33,7 @@ exit; } -class CategoriesService implements ShopContentServiceInterface +class CategoriesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CategoryRepository */ private $categoryRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => "{$item['id_category']}-{$item['iso_code']}", + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CATEGORIES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->categoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->categoryRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCategories($result); } - $this->castCategories($result); - - return array_map(function ($item) { - return [ - 'id' => "{$item['id_category']}-{$item['iso_code']}", - 'collection' => Config::COLLECTION_CATEGORIES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CATEGORIES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CurrenciesService.php b/src/Service/ShopContent/CurrenciesService.php index 036ae967..8cdc4723 100644 --- a/src/Service/ShopContent/CurrenciesService.php +++ b/src/Service/ShopContent/CurrenciesService.php @@ -33,7 +33,7 @@ exit; } -class CurrenciesService implements ShopContentServiceInterface +class CurrenciesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CurrencyRepository */ private $currencyRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_currency'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CURRENCIES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->currencyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->currencyRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCurrencies($result); } - $this->castCurrencies($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_currency'], - 'collection' => Config::COLLECTION_CURRENCIES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CURRENCIES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CustomProductCarriersService.php b/src/Service/ShopContent/CustomProductCarriersService.php index b33a3828..4b4cb83d 100644 --- a/src/Service/ShopContent/CustomProductCarriersService.php +++ b/src/Service/ShopContent/CustomProductCarriersService.php @@ -33,7 +33,7 @@ exit; } -class CustomProductCarriersService implements ShopContentServiceInterface +class CustomProductCarriersService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CustomProductCarrierRepository */ private $customProductCarrierRepository; @@ -60,7 +60,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_product'] . '-' . $item['id_carrier_reference'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, 'properties' => $item, ]; @@ -69,26 +69,17 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->customProductCarrierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->customProductCarrierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; - } - - return array_map(function ($item) { - return [ - 'id' => $item['id_product'] . '-' . $item['id_carrier_reference'], - 'collection' => Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/CustomersService.php b/src/Service/ShopContent/CustomersService.php index d10f25cb..101d2b0f 100644 --- a/src/Service/ShopContent/CustomersService.php +++ b/src/Service/ShopContent/CustomersService.php @@ -33,7 +33,7 @@ exit; } -class CustomersService implements ShopContentServiceInterface +class CustomersService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CustomerRepository */ private $customerRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_customer'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_CUSTOMERS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->customerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->customerRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCustomers($result); } - $this->castCustomers($result); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_customer'], - 'collection' => Config::COLLECTION_CUSTOMERS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_CUSTOMERS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index dbc105b1..b3e879c2 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -33,7 +33,7 @@ exit; } -class EmployeesService implements ShopContentServiceInterface +class EmployeesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var EmployeeRepository */ private $employeeRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_employee'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_EMPLOYEES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->employeeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->employeeRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castEmployees($result); } - $this->castEmployees($result); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_employee'], - 'collection' => Config::COLLECTION_EMPLOYEES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_EMPLOYEES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ImageTypesService.php b/src/Service/ShopContent/ImageTypesService.php index deee446f..36df3956 100644 --- a/src/Service/ShopContent/ImageTypesService.php +++ b/src/Service/ShopContent/ImageTypesService.php @@ -33,7 +33,7 @@ exit; } -class ImageTypesService implements ShopContentServiceInterface +class ImageTypesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var ImageTypeRepository */ private $imageTypeRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_image_type'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_IMAGE_TYPES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->imageTypeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->imageTypeRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castImageTypes($result); } - $this->castImageTypes($result); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_image_type'], - 'collection' => Config::COLLECTION_IMAGE_TYPES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_IMAGE_TYPES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ImagesService.php b/src/Service/ShopContent/ImagesService.php index 5ccf147b..47a7fb42 100644 --- a/src/Service/ShopContent/ImagesService.php +++ b/src/Service/ShopContent/ImagesService.php @@ -33,7 +33,7 @@ exit; } -class ImagesService implements ShopContentServiceInterface +class ImagesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var ImageRepository */ private $imageRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['id_image'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_IMAGES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->imageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->imageRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castImages($result); } - $this->castImages($result); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['id_image'], - 'collection' => Config::COLLECTION_IMAGES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_IMAGES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/LanguagesService.php b/src/Service/ShopContent/LanguagesService.php index bb2600f2..596a676e 100644 --- a/src/Service/ShopContent/LanguagesService.php +++ b/src/Service/ShopContent/LanguagesService.php @@ -33,7 +33,7 @@ exit; } -class LanguagesService implements ShopContentServiceInterface +class LanguagesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var LanguageRepository */ private $languageRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_lang'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_LANGUAGES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->languageRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->languageRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castLanguages($result); } - $this->castLanguages($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_lang'], - 'collection' => Config::COLLECTION_LANGUAGES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_LANGUAGES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ManufacturersService.php b/src/Service/ShopContent/ManufacturersService.php index 08221d01..34666c09 100644 --- a/src/Service/ShopContent/ManufacturersService.php +++ b/src/Service/ShopContent/ManufacturersService.php @@ -33,7 +33,7 @@ exit; } -class ManufacturersService implements ShopContentServiceInterface +class ManufacturersService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var ManufacturerRepository */ private $manufacturerRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_manufacturer'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_MANUFACTURERS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->manufacturerRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->manufacturerRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castManufacturers($result); } - $this->castManufacturers($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_manufacturer'], - 'collection' => Config::COLLECTION_MANUFACTURERS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_MANUFACTURERS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ModulesService.php b/src/Service/ShopContent/ModulesService.php index 5414f1be..d07425fa 100644 --- a/src/Service/ShopContent/ModulesService.php +++ b/src/Service/ShopContent/ModulesService.php @@ -34,7 +34,7 @@ exit; } -class ModulesService implements ShopContentServiceInterface +class ModulesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var ModuleRepository */ private $moduleRepository; @@ -69,7 +69,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => (string) $item['module_id'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_MODULES, 'properties' => $item, ]; @@ -78,28 +78,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->moduleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->moduleRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castModules($result); } - $this->castModules($result); - - return array_map(function ($item) { - return [ - 'id' => (string) $item['module_id'], - 'collection' => Config::COLLECTION_MODULES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_MODULES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/OrderCartRulesService.php b/src/Service/ShopContent/OrderCartRulesService.php index 22c37bd2..044bca19 100644 --- a/src/Service/ShopContent/OrderCartRulesService.php +++ b/src/Service/ShopContent/OrderCartRulesService.php @@ -33,7 +33,7 @@ exit; } -class OrderCartRulesService implements ShopContentServiceInterface +class OrderCartRulesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var OrderCartRuleRepository */ private $orderCartRuleRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_order_cart_rule'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_ORDER_CART_RULES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->orderCartRuleRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->orderCartRuleRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castOrderCartRules($result); } - $this->castOrderCartRules($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_order_cart_rule'], - 'collection' => Config::COLLECTION_ORDER_CART_RULES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_ORDER_CART_RULES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/OrderDetailsService.php b/src/Service/ShopContent/OrderDetailsService.php index a83d441a..f1bab8ff 100644 --- a/src/Service/ShopContent/OrderDetailsService.php +++ b/src/Service/ShopContent/OrderDetailsService.php @@ -33,7 +33,7 @@ exit; } -class OrderDetailsService implements ShopContentServiceInterface +class OrderDetailsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var OrderDetailRepository */ private $orderDetailRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_order_detail'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_ORDER_DETAILS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $orderDetailIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $orderDetailIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->orderDetailRepository->retrieveContentsForIncremental($limit, $orderDetailIds, $langIso); + $result = $this->orderDetailRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castOrderDetails($result); } - $this->castOrderDetails($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_order_detail'], - 'collection' => Config::COLLECTION_ORDER_DETAILS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_ORDER_DETAILS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/OrderStatusHistoryService.php b/src/Service/ShopContent/OrderStatusHistoryService.php index 1f7aacf5..32435365 100644 --- a/src/Service/ShopContent/OrderStatusHistoryService.php +++ b/src/Service/ShopContent/OrderStatusHistoryService.php @@ -33,7 +33,7 @@ exit; } -class OrderStatusHistoryService implements ShopContentServiceInterface +class OrderStatusHistoryService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var OrderStatusHistoryRepository */ private $orderStatusHistoryRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_order_history'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_ORDER_STATUS_HISTORY, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->orderStatusHistoryRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->orderStatusHistoryRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castOrderStatusHistories($result); } - $this->castOrderStatusHistories($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_order_history'], - 'collection' => Config::COLLECTION_ORDER_STATUS_HISTORY, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_ORDER_STATUS_HISTORY, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index 836f764b..a6f70f39 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -35,7 +35,7 @@ exit; } -class OrdersService implements ShopContentServiceInterface +class OrdersService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var OrderRepository */ private $orderRepository; @@ -75,7 +75,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_order'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_ORDERS, 'properties' => $item, ]; @@ -84,28 +84,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->orderRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->orderRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castOrders($result, $langIso); } - $this->castOrders($result, $langIso); - - return array_map(function ($item) { - return [ - 'id' => $item['id_order'], - 'collection' => Config::COLLECTION_ORDERS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_ORDERS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ProductSuppliersService.php b/src/Service/ShopContent/ProductSuppliersService.php index 380c053a..25931ab1 100644 --- a/src/Service/ShopContent/ProductSuppliersService.php +++ b/src/Service/ShopContent/ProductSuppliersService.php @@ -33,7 +33,7 @@ exit; } -class ProductSuppliersService implements ShopContentServiceInterface +class ProductSuppliersService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var ProductSupplierRepository */ private $productSupplierRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_product_supplier'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_PRODUCT_SUPPLIERS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->productSupplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->productSupplierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castProductsSuppliers($result); } - $this->castProductsSuppliers($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_product_supplier'], - 'collection' => Config::COLLECTION_PRODUCT_SUPPLIERS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_PRODUCT_SUPPLIERS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index 707506e6..f082f179 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -34,7 +34,7 @@ exit; } -class ProductsService implements ShopContentServiceInterface +class ProductsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var ProductRepository */ private $productRepository; @@ -100,7 +100,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['unique_product_id'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_PRODUCTS, 'properties' => $item, ]; @@ -109,29 +109,22 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->productRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->productRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->decorateProducts($result, $langIso); + $this->castProducts($result); } - $this->decorateProducts($result, $langIso); - $this->castProducts($result); - - return array_map(function ($item) { - return [ - 'id' => $item['unique_product_id'], - 'collection' => Config::COLLECTION_PRODUCTS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_PRODUCTS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ShopContentAbstractService.php b/src/Service/ShopContent/ShopContentAbstractService.php new file mode 100644 index 00000000..7e427975 --- /dev/null +++ b/src/Service/ShopContent/ShopContentAbstractService.php @@ -0,0 +1,68 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; + +if (!defined('_PS_VERSION_')) { + exit; +} + +abstract class ShopContentAbstractService +{ + /** + * @param string $collection + * @param array $upsertedContents + * @param array $deletedList + * + * @return array + */ + protected function formatIncrementalSyncResponse($collection, $upsertedContents, $deletedList) + { + $data = []; + + foreach ($upsertedContents as $upsertedContent) { + $data[] = [ + 'action' => Config::INCREMENTAL_TYPE_UPSERT, + 'collection' => $collection, + 'properties' => $upsertedContent, + ]; + } + + foreach ($deletedList as $item) { + $data[] = [ + 'action' => Config::INCREMENTAL_TYPE_DELETE, + 'collection' => $collection, + 'properties' => [ + 'id' => $item['id'], + ], + ]; + } + + return $data; + } +} diff --git a/src/Service/ShopContent/ShopContentServiceInterface.php b/src/Service/ShopContent/ShopContentServiceInterface.php index 36e4212d..41bbc3fb 100644 --- a/src/Service/ShopContent/ShopContentServiceInterface.php +++ b/src/Service/ShopContent/ShopContentServiceInterface.php @@ -43,12 +43,13 @@ public function getContentsForFull($offset, $limit, $langIso); /** * @param int $limit - * @param mixed $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso); + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso); /** * @param int $offset diff --git a/src/Service/ShopContent/ShopsService.php b/src/Service/ShopContent/ShopsService.php index 24586972..8a574151 100644 --- a/src/Service/ShopContent/ShopsService.php +++ b/src/Service/ShopContent/ShopsService.php @@ -33,7 +33,7 @@ exit; } -class ShopsService implements ShopContentServiceInterface +class ShopsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var CurrenciesService */ private $currenciesService; @@ -93,7 +93,7 @@ public function getContentsForFull($offset, $limit, $langIso) return [ [ - 'id' => '1', + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_SHOPS, 'properties' => [ 'created_at' => $this->shopRepository->getCreatedAt(), @@ -125,12 +125,13 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { return []; } diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index c2f04811..45443d25 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -34,7 +34,7 @@ exit; } -class SpecificPricesService implements ShopContentServiceInterface +class SpecificPricesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var SpecificPriceRepository */ private $specificPriceRepository; @@ -69,7 +69,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_specific_price'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_SPECIFIC_PRICES, 'properties' => $item, ]; @@ -78,28 +78,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->specificPriceRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->specificPriceRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castCustomPrices($result); } - $this->castCustomPrices($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_specific_price'], - 'collection' => Config::COLLECTION_SPECIFIC_PRICES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_SPECIFIC_PRICES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/StockMovementsService.php b/src/Service/ShopContent/StockMovementsService.php index d42a419f..7d748e4d 100644 --- a/src/Service/ShopContent/StockMovementsService.php +++ b/src/Service/ShopContent/StockMovementsService.php @@ -33,7 +33,7 @@ exit; } -class StockMovementsService implements ShopContentServiceInterface +class StockMovementsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var StockMovementRepository */ private $stockMovementRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_stock_mvt'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_STOCK_MOVEMENTS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->stockMovementRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->stockMovementRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castStockMovements($result); } - $this->castStockMovements($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_stock_mvt'], - 'collection' => Config::COLLECTION_STOCK_MOVEMENTS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_STOCK_MOVEMENTS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/StocksService.php b/src/Service/ShopContent/StocksService.php index fa54127a..8bc83eae 100644 --- a/src/Service/ShopContent/StocksService.php +++ b/src/Service/ShopContent/StocksService.php @@ -33,7 +33,7 @@ exit; } -class StocksService implements ShopContentServiceInterface +class StocksService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var StockRepository */ private $stockRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_stock_available'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_STOCKS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->stockRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->stockRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castStocks($result, $langIso); } - $this->castStocks($result, $langIso); - - return array_map(function ($item) { - return [ - 'id' => $item['id_stock_available'], - 'collection' => Config::COLLECTION_STOCKS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_STOCKS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/StoresService.php b/src/Service/ShopContent/StoresService.php index effa9922..ace871fd 100644 --- a/src/Service/ShopContent/StoresService.php +++ b/src/Service/ShopContent/StoresService.php @@ -33,7 +33,7 @@ exit; } -class StoresService implements ShopContentServiceInterface +class StoresService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var StoreRepository */ private $storeRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_store'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_STORES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->storeRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->storeRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castStores($result); } - $this->castStores($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_store'], - 'collection' => Config::COLLECTION_STORES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_STORES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/SuppliersService.php b/src/Service/ShopContent/SuppliersService.php index b79da85a..50289157 100644 --- a/src/Service/ShopContent/SuppliersService.php +++ b/src/Service/ShopContent/SuppliersService.php @@ -33,7 +33,7 @@ exit; } -class SuppliersService implements ShopContentServiceInterface +class SuppliersService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var SupplierRepository */ private $supplierRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_supplier'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_SUPPLIERS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->supplierRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->supplierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castSuppliers($result); } - $this->castSuppliers($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_supplier'], - 'collection' => Config::COLLECTION_SUPPLIERS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_SUPPLIERS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/TaxonomiesService.php b/src/Service/ShopContent/TaxonomiesService.php index 2f8df63d..01f10a1a 100644 --- a/src/Service/ShopContent/TaxonomiesService.php +++ b/src/Service/ShopContent/TaxonomiesService.php @@ -33,7 +33,7 @@ exit; } -class TaxonomiesService implements ShopContentServiceInterface +class TaxonomiesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var TaxonomyRepository */ private $taxonomyRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['taxonomy_id'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_TAXONOMIES, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->taxonomyRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->taxonomyRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castTaxonomies($result); } - $this->castTaxonomies($result); - - return array_map(function ($item) { - return [ - 'id' => $item['taxonomy_id'], - 'collection' => Config::COLLECTION_TAXONOMIES, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_TAXONOMIES, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/ThemesService.php b/src/Service/ShopContent/ThemesService.php index d953b1d2..13b225d9 100644 --- a/src/Service/ShopContent/ThemesService.php +++ b/src/Service/ShopContent/ThemesService.php @@ -33,7 +33,7 @@ exit; } -class ThemesService implements ShopContentServiceInterface +class ThemesService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var \Context */ private $context; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['theme_id'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_THEMES, 'properties' => $item, ]; @@ -71,28 +71,23 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { $result = $this->getAllThemes(); - if (empty($result)) { - return []; - } + $themes = []; - $themes = $this->formatThemes($result); + if (!empty($result)) { + $themes = $this->formatThemes($result); + } - return array_map(function ($item) { - return [ - 'id' => $item['theme_id'], - 'collection' => Config::COLLECTION_THEMES, - 'properties' => $item, - ]; - }, $themes); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_THEMES, $themes, $deletedContents); } /** diff --git a/src/Service/ShopContent/TranslationsService.php b/src/Service/ShopContent/TranslationsService.php index a035fe01..39bdbf41 100644 --- a/src/Service/ShopContent/TranslationsService.php +++ b/src/Service/ShopContent/TranslationsService.php @@ -33,7 +33,7 @@ exit; } -class TranslationsService implements ShopContentServiceInterface +class TranslationsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var TranslationRepository */ private $translationRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_lang'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_TRANSLATIONS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->translationRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->translationRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castTranslations($result); } - $this->castTranslations($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_lang'], - 'collection' => Config::COLLECTION_TRANSLATIONS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_TRANSLATIONS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/WishlistProductsService.php b/src/Service/ShopContent/WishlistProductsService.php index 29edefe2..2e5d6ea5 100644 --- a/src/Service/ShopContent/WishlistProductsService.php +++ b/src/Service/ShopContent/WishlistProductsService.php @@ -33,7 +33,7 @@ exit; } -class WishlistProductsService implements ShopContentServiceInterface +class WishlistProductsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var WishlistProductRepository */ private $wishlistProductRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_wishlist_product'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_WISHLIST_PRODUCTS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->wishlistProductRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->wishlistProductRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castWishlistProducts($result); } - $this->castWishlistProducts($result); - - return array_map(function ($item) { - return [ - 'id' => $item['id_wishlist_product'], - 'collection' => Config::COLLECTION_WISHLIST_PRODUCTS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_WISHLIST_PRODUCTS, $result, $deletedContents); } /** diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index 0327dbd2..671bf1d8 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -33,7 +33,7 @@ exit; } -class WishlistsService implements ShopContentServiceInterface +class WishlistsService extends ShopContentAbstractService implements ShopContentServiceInterface { /** @var WishlistRepository */ private $wishlistRepository; @@ -62,7 +62,7 @@ public function getContentsForFull($offset, $limit, $langIso) return array_map(function ($item) { return [ - 'id' => $item['id_wishlist'], + 'action' => Config::INCREMENTAL_TYPE_UPSERT, 'collection' => Config::COLLECTION_WISHLISTS, 'properties' => $item, ]; @@ -71,28 +71,21 @@ public function getContentsForFull($offset, $limit, $langIso) /** * @param int $limit - * @param array $contentIds + * @param array $upsertedContents + * @param array $deletedContents * @param string $langIso * * @return array */ - public function getContentsForIncremental($limit, $contentIds, $langIso) + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, $contentIds, $langIso); + $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); - if (empty($result)) { - return []; + if (!empty($result)) { + $this->castWishlists($result, $langIso); } - $this->castWishlists($result, $langIso); - - return array_map(function ($item) { - return [ - 'id' => $item['id_wishlist'], - 'collection' => Config::COLLECTION_WISHLISTS, - 'properties' => $item, - ]; - }, $result); + return parent::formatIncrementalSyncResponse(Config::COLLECTION_WISHLISTS, $result, $deletedContents); } /** diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 34ba140a..239efce6 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -189,9 +189,9 @@ public function sendIncrementalSync( /** @var ShopContentServiceInterface $shopContentApiService */ $shopContentApiService = $module->getService($serviceId); - $contentIds = $this->incrementalSyncRepository->getIncrementalSyncObjectIds($shopContent, $langIso, $limit); + $contentsToSync = $this->incrementalSyncRepository->getIncrementalSyncObjects($shopContent, $langIso, $limit); - if (empty($contentIds)) { + if (empty($contentsToSync)) { return [ 'total_objects' => 0, 'has_remaining_objects' => false, @@ -199,7 +199,15 @@ public function sendIncrementalSync( ]; } - $data = $shopContentApiService->getContentsForIncremental($limit, $contentIds, $langIso); + $upsertedContents = array_filter($contentsToSync, function ($content) { + return $content['action'] == Config::INCREMENTAL_TYPE_UPSERT; + }); + + $deletedContents = array_filter($contentsToSync, function ($content) { + return $content['action'] == Config::INCREMENTAL_TYPE_DELETE; + }); + + $data = $shopContentApiService->getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso); CommonService::convertDateFormat($data); @@ -207,10 +215,10 @@ public function sendIncrementalSync( $response = $this->proxyService->upload($jobId, $data, $startTime, false); if ($response['httpCode'] == 201) { - $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, $contentIds, $langIso); + $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, array_column($contentsToSync, 'id'), $langIso); } } else { - $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, $contentIds, $langIso); + $this->incrementalSyncRepository->removeIncrementalSyncObjects($shopContent, array_column($contentsToSync, 'id'), $langIso); } $remainingObjects = $this->incrementalSyncRepository->getRemainingIncrementalObjects($shopContent, $langIso); @@ -394,21 +402,7 @@ private function returnSyncResponse($data, $syncResponse, $remainingObjects) 'total_objects' => count($data), 'has_remaining_objects' => $remainingObjects > 0, 'remaining_objects' => $remainingObjects, - 'md5' => $this->getPayloadMd5($data), + 'md5' => md5(serialize($data)), ], $syncResponse); } - - /** - * @param array $payload - * - * @return string - */ - private function getPayloadMd5($payload) - { - return md5( - implode(' ', array_map(function ($payloadItem) { - return $payloadItem['id']; - }, $payload)) - ); - } } diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 80e7cd26..1a06b9da 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -177,7 +177,7 @@ public function hookActionObjectImageAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -202,7 +202,7 @@ public function hookActionObjectImageUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_PRODUCTS => $image->id_product], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -252,7 +252,7 @@ public function hookActionObjectLanguageAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -277,7 +277,7 @@ public function hookActionObjectLanguageUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -327,7 +327,7 @@ public function hookActionObjectManufacturerAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -352,7 +352,7 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -402,7 +402,7 @@ public function hookActionObjectSupplierAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -427,7 +427,7 @@ public function hookActionObjectSupplierUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -501,7 +501,7 @@ public function hookActionObjectProductAddAfter($parameters) Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $customProductCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -549,7 +549,7 @@ public function hookActionObjectProductUpdateAfter($parameters) Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $customProductCarrierIds, Config::COLLECTION_STOCKS => $stockId, ], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -596,7 +596,7 @@ public function hookActionObjectWishlistAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -620,7 +620,7 @@ public function hookActionObjectWishlistUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -645,7 +645,7 @@ public function hookActionObjectStockAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -670,7 +670,7 @@ public function hookActionObjectStockUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -720,7 +720,7 @@ public function hookActionObjectStoreAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -745,7 +745,7 @@ public function hookActionObjectStoreUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -795,7 +795,7 @@ public function hookActionObjectCategoryAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -820,7 +820,7 @@ public function hookActionObjectCategoryUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -870,7 +870,7 @@ public function hookActionObjectCustomerAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -895,7 +895,7 @@ public function hookActionObjectCustomerUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -945,7 +945,7 @@ public function hookActionObjectCurrencyAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -970,7 +970,7 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -1019,7 +1019,7 @@ public function hookActionObjectCartAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CARTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARTS => $cart->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1043,7 +1043,7 @@ public function hookActionObjectCartUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CARTS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARTS => $cart->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1067,7 +1067,7 @@ public function hookActionObjectCartRuleAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1115,7 +1115,7 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1139,7 +1139,7 @@ public function hookActionObjectOrderAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_ORDERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ORDERS => $order->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1163,7 +1163,7 @@ public function hookActionObjectOrderUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_ORDERS, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ORDERS => $order->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1200,7 +1200,7 @@ public function hookActionObjectCarrierAddAfter($parameters) Config::COLLECTION_CARRIER_DETAILS => $carrier->id, Config::COLLECTION_CARRIER_TAXES => $carrier->id, ], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1237,7 +1237,7 @@ public function hookActionObjectCarrierUpdateAfter($parameters) Config::COLLECTION_CARRIER_DETAILS => $carrier->id, Config::COLLECTION_CARRIER_TAXES => $carrier->id, ], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1291,7 +1291,7 @@ public function hookActionObjectCountryAddAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1308,7 +1308,7 @@ public function hookActionObjectCountryUpdateAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1342,7 +1342,7 @@ public function hookActionObjectStateAddAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1359,7 +1359,7 @@ public function hookActionObjectStateUpdateAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1393,7 +1393,7 @@ public function hookActionObjectZoneAddAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1410,7 +1410,7 @@ public function hookActionObjectZoneUpdateAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1444,7 +1444,7 @@ public function hookActionObjectTaxAddAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1461,7 +1461,7 @@ public function hookActionObjectTaxUpdateAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1495,7 +1495,7 @@ public function hookActionObjectTaxRulesGroupAddAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1512,7 +1512,7 @@ public function hookActionObjectTaxRulesGroupUpdateAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1563,7 +1563,7 @@ public function hookActionObjectEmployeeAddAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1596,7 +1596,7 @@ public function hookActionObjectEmployeeUpdateAfter() $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1637,7 +1637,7 @@ public function hookActionDispatcherBefore($parameters) if ($route == 'api_translation_value_edit' || $route == 'api_translation_value_reset') { $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_TRANSLATIONS => 0], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1667,7 +1667,7 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], - Config::INCREMENTAL_TYPE_ADD, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1694,7 +1694,7 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], - Config::INCREMENTAL_TYPE_UPDATE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false From f3e851a25cf446081450aff92b98c2103fe3ecc5 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:05:27 +0100 Subject: [PATCH 145/162] fix: carrier details and taxes (#394) --- config/common/repository.yml | 36 ++-- config/front/services.yml | 10 +- e2e/src/fixtures/1.7/carrier_details.json | 162 ++++++++-------- e2e/src/fixtures/8/carrier_details.json | 138 ++++++------- e2e/src/fixtures/9/carrier_details.json | 181 ++++++++---------- src/Repository/AbstractRepository.php | 4 +- src/Repository/CarrierDetailRepository.php | 176 +++++++++++++++++ src/Repository/CarrierTaxeRepository.php | 154 +++++++++++++++ src/Repository/CountryRepository.php | 70 ------- src/Repository/StateRepository.php | 67 ------- ...sSyncRepository.php => SyncRepository.php} | 2 +- src/Repository/TaxeRepository.php | 75 -------- src/Service/ApiAuthorizationService.php | 14 +- src/Service/ApiShopContentService.php | 14 +- .../ShopContent/CarrierDetailsService.php | 102 ++-------- .../ShopContent/CarrierTaxesService.php | 103 ++-------- src/Service/ShopContent/CarriersService.php | 77 +------- src/Service/SynchronizationService.php | 16 +- 18 files changed, 641 insertions(+), 760 deletions(-) create mode 100644 src/Repository/CarrierDetailRepository.php create mode 100644 src/Repository/CarrierTaxeRepository.php delete mode 100644 src/Repository/CountryRepository.php delete mode 100644 src/Repository/StateRepository.php rename src/Repository/{EventbusSyncRepository.php => SyncRepository.php} (98%) delete mode 100644 src/Repository/TaxeRepository.php diff --git a/config/common/repository.yml b/config/common/repository.yml index 0188df65..3b475815 100644 --- a/config/common/repository.yml +++ b/config/common/repository.yml @@ -1,6 +1,6 @@ services: - PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository: - class: PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository + PrestaShop\Module\PsEventbus\Repository\SyncRepository: + class: PrestaShop\Module\PsEventbus\Repository\SyncRepository public: true arguments: - '@=service("ps_eventbus").getContext()' @@ -11,26 +11,6 @@ services: arguments: - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - PrestaShop\Module\PsEventbus\Repository\ShopRepository: - class: PrestaShop\Module\PsEventbus\Repository\ShopRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\CountryRepository: - class: PrestaShop\Module\PsEventbus\Repository\CountryRepository - public: true - arguments: - - '@=service("ps_eventbus").getContext()' - - PrestaShop\Module\PsEventbus\Repository\StateRepository: - class: PrestaShop\Module\PsEventbus\Repository\StateRepository - public: true - - PrestaShop\Module\PsEventbus\Repository\TaxeRepository: - class: PrestaShop\Module\PsEventbus\Repository\TaxeRepository - public: true - arguments: - - '@=service("ps_eventbus").getContext()' - PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository: class: PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository public: true @@ -47,6 +27,14 @@ services: class: PrestaShop\Module\PsEventbus\Repository\CarrierRepository public: true + PrestaShop\Module\PsEventbus\Repository\CarrierDetailRepository: + class: PrestaShop\Module\PsEventbus\Repository\CarrierDetailRepository + public: true + + PrestaShop\Module\PsEventbus\Repository\CarrierTaxeRepository: + class: PrestaShop\Module\PsEventbus\Repository\CarrierTaxeRepository + public: true + PrestaShop\Module\PsEventbus\Repository\CartRepository: class: PrestaShop\Module\PsEventbus\Repository\CartRepository public: true @@ -123,6 +111,10 @@ services: class: PrestaShop\Module\PsEventbus\Repository\ProductSupplierRepository public: true + PrestaShop\Module\PsEventbus\Repository\ShopRepository: + class: PrestaShop\Module\PsEventbus\Repository\ShopRepository + public: true + PrestaShop\Module\PsEventbus\Repository\StockRepository: class: PrestaShop\Module\PsEventbus\Repository\StockRepository public: true diff --git a/config/front/services.yml b/config/front/services.yml index 93eb94f4..4efb7643 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -8,7 +8,7 @@ services: class: PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' + - '@PrestaShop\Module\PsEventbus\Repository\SyncRepository' - '@PrestaShop\Module\PsEventbus\Api\SyncApiClient' - '@PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' @@ -18,7 +18,7 @@ services: public: true arguments: - '@PrestaShop\Module\PsEventbus\Api\LiveSyncApiClient' - - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' + - '@PrestaShop\Module\PsEventbus\Repository\SyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository' - '@PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository' - '@PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService' @@ -37,7 +37,7 @@ services: - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' - '@PrestaShop\Module\PsEventbus\Service\ApiAuthorizationService' - '@PrestaShop\Module\PsEventbus\Service\SynchronizationService' - - '@PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository' + - '@PrestaShop\Module\PsEventbus\Repository\SyncRepository' - '@PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler' PrestaShop\Module\PsEventbus\Service\ApiHealthCheckService: @@ -70,13 +70,13 @@ services: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierDetailsService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CarrierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CarrierDetailRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CarrierTaxesService public: true arguments: - - '@PrestaShop\Module\PsEventbus\Repository\CarrierRepository' + - '@PrestaShop\Module\PsEventbus\Repository\CarrierTaxeRepository' PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\CartsService diff --git a/e2e/src/fixtures/1.7/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json index 502f304c..309a9a16 100644 --- a/e2e/src/fixtures/1.7/carrier_details.json +++ b/e2e/src/fixtures/1.7/carrier_details.json @@ -6,13 +6,13 @@ "id_reference": "2", "id_zone": "1", "id_range": "1", - "id_carrier_detail": "1", "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 10000, - "country_ids": "", + "country_ids": "FR", "state_ids": "", - "price": 5 + "price": 5, + "id_carrier_detail": "1" } }, { @@ -22,13 +22,13 @@ "id_reference": "2", "id_zone": "2", "id_range": "1", - "id_carrier_detail": "1", "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 10000, - "country_ids": "", - "state_ids": "", - "price": 5 + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 5, + "id_carrier_detail": "1" } }, { @@ -36,15 +36,15 @@ "collection": "carrier_details", "properties": { "id_reference": "3", - "id_zone": "2", + "id_zone": "1", "id_range": "2", - "id_carrier_detail": "2", "shipping_method": "range_price", "delimiter1": 0, "delimiter2": 50, - "country_ids": "", + "country_ids": "FR", "state_ids": "", - "price": 4 + "price": 3, + "id_carrier_detail": "2" } }, { @@ -53,14 +53,14 @@ "properties": { "id_reference": "3", "id_zone": "1", - "id_range": "2", - "id_carrier_detail": "2", + "id_range": "3", "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "", + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "FR", "state_ids": "", - "price": 3 + "price": 1, + "id_carrier_detail": "3" } }, { @@ -68,15 +68,15 @@ "collection": "carrier_details", "properties": { "id_reference": "3", - "id_zone": "2", - "id_range": "3", - "id_carrier_detail": "3", + "id_zone": "1", + "id_range": "4", "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "", + "delimiter1": 100, + "delimiter2": 200, + "country_ids": "FR", "state_ids": "", - "price": 2 + "price": 0, + "id_carrier_detail": "4" } }, { @@ -84,15 +84,15 @@ "collection": "carrier_details", "properties": { "id_reference": "3", - "id_zone": "1", - "id_range": "3", - "id_carrier_detail": "3", + "id_zone": "2", + "id_range": "2", "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "", - "state_ids": "", - "price": 1 + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 4, + "id_carrier_detail": "2" } }, { @@ -101,14 +101,14 @@ "properties": { "id_reference": "3", "id_zone": "2", - "id_range": "4", - "id_carrier_detail": "4", + "id_range": "3", "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "", - "state_ids": "", - "price": 0 + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 2, + "id_carrier_detail": "3" } }, { @@ -116,15 +116,15 @@ "collection": "carrier_details", "properties": { "id_reference": "3", - "id_zone": "1", + "id_zone": "2", "id_range": "4", - "id_carrier_detail": "4", "shipping_method": "range_price", "delimiter1": 100, "delimiter2": 200, - "country_ids": "", - "state_ids": "", - "price": 0 + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "4" } }, { @@ -132,15 +132,15 @@ "collection": "carrier_details", "properties": { "id_reference": "4", - "id_zone": "2", + "id_zone": "1", "id_range": "2", - "id_carrier_detail": "2", "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 1, - "country_ids": "", + "country_ids": "FR", "state_ids": "", - "price": 0 + "price": 0, + "id_carrier_detail": "2" } }, { @@ -149,14 +149,14 @@ "properties": { "id_reference": "4", "id_zone": "1", - "id_range": "2", - "id_carrier_detail": "2", + "id_range": "3", "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "", + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "FR", "state_ids": "", - "price": 0 + "price": 2, + "id_carrier_detail": "3" } }, { @@ -164,15 +164,15 @@ "collection": "carrier_details", "properties": { "id_reference": "4", - "id_zone": "2", - "id_range": "3", - "id_carrier_detail": "3", + "id_zone": "1", + "id_range": "4", "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "", + "delimiter1": 3, + "delimiter2": 10000, + "country_ids": "FR", "state_ids": "", - "price": 3 + "price": 5, + "id_carrier_detail": "4" } }, { @@ -180,15 +180,15 @@ "collection": "carrier_details", "properties": { "id_reference": "4", - "id_zone": "1", - "id_range": "3", - "id_carrier_detail": "3", + "id_zone": "2", + "id_range": "2", "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "", - "state_ids": "", - "price": 2 + "delimiter1": 0, + "delimiter2": 1, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "2" } }, { @@ -197,14 +197,14 @@ "properties": { "id_reference": "4", "id_zone": "2", - "id_range": "4", - "id_carrier_detail": "4", + "id_range": "3", "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "", - "state_ids": "", - "price": 6 + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 3, + "id_carrier_detail": "3" } }, { @@ -212,15 +212,15 @@ "collection": "carrier_details", "properties": { "id_reference": "4", - "id_zone": "1", + "id_zone": "2", "id_range": "4", - "id_carrier_detail": "4", "shipping_method": "range_weight", "delimiter1": 3, "delimiter2": 10000, - "country_ids": "", - "state_ids": "", - "price": 5 + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "4" } } ] diff --git a/e2e/src/fixtures/8/carrier_details.json b/e2e/src/fixtures/8/carrier_details.json index 68f95f5e..309a9a16 100644 --- a/e2e/src/fixtures/8/carrier_details.json +++ b/e2e/src/fixtures/8/carrier_details.json @@ -6,13 +6,13 @@ "id_reference": "2", "id_zone": "1", "id_range": "1", - "id_carrier_detail": "1", "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 10000, "country_ids": "FR", "state_ids": "", - "price": 5 + "price": 5, + "id_carrier_detail": "1" } }, { @@ -22,13 +22,13 @@ "id_reference": "2", "id_zone": "2", "id_range": "1", - "id_carrier_detail": "1", "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 10000, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 5 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 5, + "id_carrier_detail": "1" } }, { @@ -38,13 +38,13 @@ "id_reference": "3", "id_zone": "1", "id_range": "2", - "id_carrier_detail": "2", "shipping_method": "range_price", "delimiter1": 0, "delimiter2": 50, "country_ids": "FR", "state_ids": "", - "price": 3 + "price": 3, + "id_carrier_detail": "2" } }, { @@ -52,15 +52,15 @@ "collection": "carrier_details", "properties": { "id_reference": "3", - "id_zone": "2", - "id_range": "2", - "id_carrier_detail": "2", + "id_zone": "1", + "id_range": "3", "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 4 + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "FR", + "state_ids": "", + "price": 1, + "id_carrier_detail": "3" } }, { @@ -69,14 +69,14 @@ "properties": { "id_reference": "3", "id_zone": "1", - "id_range": "3", - "id_carrier_detail": "3", + "id_range": "4", "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, + "delimiter1": 100, + "delimiter2": 200, "country_ids": "FR", "state_ids": "", - "price": 1 + "price": 0, + "id_carrier_detail": "4" } }, { @@ -85,14 +85,14 @@ "properties": { "id_reference": "3", "id_zone": "2", - "id_range": "3", - "id_carrier_detail": "3", + "id_range": "2", "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, + "delimiter1": 0, + "delimiter2": 50, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 2 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 4, + "id_carrier_detail": "2" } }, { @@ -100,15 +100,15 @@ "collection": "carrier_details", "properties": { "id_reference": "3", - "id_zone": "1", - "id_range": "4", - "id_carrier_detail": "4", + "id_zone": "2", + "id_range": "3", "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "FR", - "state_ids": "", - "price": 0 + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 2, + "id_carrier_detail": "3" } }, { @@ -118,13 +118,13 @@ "id_reference": "3", "id_zone": "2", "id_range": "4", - "id_carrier_detail": "4", "shipping_method": "range_price", "delimiter1": 100, "delimiter2": 200, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 0 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "4" } }, { @@ -134,13 +134,13 @@ "id_reference": "4", "id_zone": "1", "id_range": "2", - "id_carrier_detail": "2", "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 1, "country_ids": "FR", "state_ids": "", - "price": 0 + "price": 0, + "id_carrier_detail": "2" } }, { @@ -148,15 +148,15 @@ "collection": "carrier_details", "properties": { "id_reference": "4", - "id_zone": "2", - "id_range": "2", - "id_carrier_detail": "2", + "id_zone": "1", + "id_range": "3", "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 0 + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "FR", + "state_ids": "", + "price": 2, + "id_carrier_detail": "3" } }, { @@ -165,14 +165,14 @@ "properties": { "id_reference": "4", "id_zone": "1", - "id_range": "3", - "id_carrier_detail": "3", + "id_range": "4", "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, + "delimiter1": 3, + "delimiter2": 10000, "country_ids": "FR", "state_ids": "", - "price": 2 + "price": 5, + "id_carrier_detail": "4" } }, { @@ -181,14 +181,14 @@ "properties": { "id_reference": "4", "id_zone": "2", - "id_range": "3", - "id_carrier_detail": "3", + "id_range": "2", "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, + "delimiter1": 0, + "delimiter2": 1, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 3 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "2" } }, { @@ -196,15 +196,15 @@ "collection": "carrier_details", "properties": { "id_reference": "4", - "id_zone": "1", - "id_range": "4", - "id_carrier_detail": "4", + "id_zone": "2", + "id_range": "3", "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5 + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 3, + "id_carrier_detail": "3" } }, { @@ -214,13 +214,13 @@ "id_reference": "4", "id_zone": "2", "id_range": "4", - "id_carrier_detail": "4", "shipping_method": "range_weight", "delimiter1": 3, "delimiter2": 10000, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 6 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "4" } } ] diff --git a/e2e/src/fixtures/9/carrier_details.json b/e2e/src/fixtures/9/carrier_details.json index 2c206edd..309a9a16 100644 --- a/e2e/src/fixtures/9/carrier_details.json +++ b/e2e/src/fixtures/9/carrier_details.json @@ -2,188 +2,177 @@ { "action": "upsert", "collection": "carrier_details", - "properties": { - "id_reference": "3", + "id_reference": "2", + "id_zone": "1", + "id_range": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "FR", + "state_ids": "", + "price": 5, + "id_carrier_detail": "1" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", "id_zone": "2", - "id_range": "2", - "id_carrier_detail": "2", - "shipping_method": "range_price", + "id_range": "1", + "shipping_method": "range_weight", "delimiter1": 0, - "delimiter2": 50, + "delimiter2": 10000, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 4 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 5, + "id_carrier_detail": "1" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { "id_reference": "3", "id_zone": "1", "id_range": "2", - "id_carrier_detail": "2", "shipping_method": "range_price", "delimiter1": 0, "delimiter2": 50, "country_ids": "FR", "state_ids": "", - "price": 3 + "price": 3, + "id_carrier_detail": "2" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { "id_reference": "3", - "id_zone": "2", + "id_zone": "1", "id_range": "3", - "id_carrier_detail": "3", "shipping_method": "range_price", "delimiter1": 50, "delimiter2": 100, - "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 2 + "country_ids": "FR", + "state_ids": "", + "price": 1, + "id_carrier_detail": "3" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { "id_reference": "3", "id_zone": "1", - "id_range": "3", - "id_carrier_detail": "3", + "id_range": "4", "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, + "delimiter1": 100, + "delimiter2": 200, "country_ids": "FR", "state_ids": "", - "price": 1 + "price": 0, + "id_carrier_detail": "4" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { "id_reference": "3", - "id_zone": "1", - "id_range": "4", - "id_carrier_detail": "4", + "id_zone": "2", + "id_range": "2", "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "FR", - "state_ids": "", - "price": 0 + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 4, + "id_carrier_detail": "2" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { "id_reference": "3", "id_zone": "2", - "id_range": "4", - "id_carrier_detail": "4", + "id_range": "3", "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, + "delimiter1": 50, + "delimiter2": 100, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 0 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 2, + "id_carrier_detail": "3" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { - "id_reference": "4", + "id_reference": "3", "id_zone": "2", - "id_range": "2", - "id_carrier_detail": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, + "id_range": "4", + "shipping_method": "range_price", + "delimiter1": 100, + "delimiter2": 200, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 0 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "4" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { "id_reference": "4", "id_zone": "1", "id_range": "2", - "id_carrier_detail": "2", "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 1, "country_ids": "FR", "state_ids": "", - "price": 0 + "price": 0, + "id_carrier_detail": "2" } }, { "action": "upsert", "collection": "carrier_details", - - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "3", - "id_carrier_detail": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 3 - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { "id_reference": "4", "id_zone": "1", "id_range": "3", - "id_carrier_detail": "3", "shipping_method": "range_weight", "delimiter1": 1, "delimiter2": 3, "country_ids": "FR", "state_ids": "", - "price": 2 + "price": 2, + "id_carrier_detail": "3" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { "id_reference": "4", "id_zone": "1", "id_range": "4", - "id_carrier_detail": "4", "shipping_method": "range_weight", "delimiter1": 3, "delimiter2": 10000, "country_ids": "FR", "state_ids": "", - "price": 5 + "price": 5, + "id_carrier_detail": "4" } }, { @@ -192,48 +181,46 @@ "properties": { "id_reference": "4", "id_zone": "2", - "id_range": "4", - "id_carrier_detail": "4", + "id_range": "2", "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, + "delimiter1": 0, + "delimiter2": 1, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 6 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "2" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "id_carrier_detail": "1", + "id_reference": "4", + "id_zone": "2", + "id_range": "3", "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5 + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 3, + "id_carrier_detail": "3" } }, { "action": "upsert", "collection": "carrier_details", - "properties": { - "id_reference": "2", + "id_reference": "4", "id_zone": "2", - "id_range": "1", - "id_carrier_detail": "1", + "id_range": "4", "shipping_method": "range_weight", - "delimiter1": 0, + "delimiter1": 3, "delimiter2": 10000, "country_ids": "US", - "state_ids": "AA,AE,AP,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,PR,VI,DC", - "price": 5 + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "4" } } ] diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 8e5e066c..c9b07098 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -63,11 +63,11 @@ public function __construct() /** * @param string $tableName - * @param string $alias + * @param string|null $alias * * @return void */ - protected function generateMinimalQuery($tableName, $alias) + protected function generateMinimalQuery($tableName, $alias = null) { $this->query = new \DbQuery(); diff --git a/src/Repository/CarrierDetailRepository.php b/src/Repository/CarrierDetailRepository.php new file mode 100644 index 00000000..a44577e1 --- /dev/null +++ b/src/Repository/CarrierDetailRepository.php @@ -0,0 +1,176 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\Module\PsEventbus\Repository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class CarrierDetailRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'carrier'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'ca'); + + $this->query + ->innerJoin('delivery', 'd', 'ca.id_carrier = d.id_carrier AND d.id_zone IS NOT NULL') + ->leftJoin('range_weight', 'rw', 'ca.id_carrier = rw.id_carrier AND d.id_range_weight = rw.id_range_weight') + ->leftJoin('range_price', 'rp', 'ca.id_carrier = rp.id_carrier AND d.id_range_price = rp.id_range_price') + ->leftJoin('country', 'co', 'd.id_zone = co.id_zone AND co.iso_code IS NOT NULL AND co.active = 1') + ->leftJoin('state', 's', 'co.id_zone = s.id_zone AND co.id_country = s.id_country AND s.active = 1') + ->leftJoin('configuration', 'conf', 'conf.name = "PS_SHIPPING_METHOD"') + ; + + if ($withSelecParameters) { + $this->query + ->select('ca.id_reference') + ->select('d.id_zone') + ->select(' + CASE + WHEN d.id_range_weight IS NOT NULL AND d.id_range_weight != 0 THEN d.id_range_weight + WHEN d.id_range_price IS NOT NULL AND d.id_range_price != 0 THEN d.id_range_price + END AS id_range + ') + ->select(' + CASE + WHEN ca.is_free = 1 THEN "free_shipping" + WHEN ca.shipping_method = 0 AND conf.value IS NULL THEN "range_price" + WHEN ca.shipping_method = 0 AND conf.value IS NOT NULL THEN "range_weight" + WHEN ca.shipping_method = 1 THEN "range_weight" + WHEN ca.shipping_method = 2 THEN "range_price" + END AS shipping_method + ') + ->select(' + CASE + WHEN rw.delimiter1 IS NOT NULL THEN rw.delimiter1 + WHEN rp.delimiter1 IS NOT NULL THEN rp.delimiter1 + END AS delimiter1 + ') + ->select(' + CASE + WHEN rw.delimiter2 IS NOT NULL THEN rw.delimiter2 + WHEN rp.delimiter2 IS NOT NULL THEN rp.delimiter2 + END AS delimiter2 + ') + ->select(' + GROUP_CONCAT( + DISTINCT co.iso_code + ORDER BY co.iso_code ASC + SEPARATOR \',\' + ) AS country_ids + ') + ->select(' + GROUP_CONCAT( + DISTINCT + s.iso_code + ORDER BY s.iso_code ASC + SEPARATOR \',\' + ) AS state_ids + ') + ->select('d.price') + ; + + $this->query->groupBy('ca.id_reference, co.id_zone, id_range'); + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery(); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) + { + if ($contentIds == []) { + return []; + } + + $this->generateFullQuery($langIso, true); + + $this->query + ->where('ca.id_carrier IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit); + + return $this->runQuery(); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, true); + + $result = $this->db->executeS(' + SELECT (COUNT(*) - ' . (int) $offset . ') AS count + FROM (' . $this->query->build() . ') as subquery; + '); + + return is_array($result) ? $result[0]['count'] : []; + } +} diff --git a/src/Repository/CarrierTaxeRepository.php b/src/Repository/CarrierTaxeRepository.php new file mode 100644 index 00000000..485e58d4 --- /dev/null +++ b/src/Repository/CarrierTaxeRepository.php @@ -0,0 +1,154 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\Module\PsEventbus\Repository; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class CarrierTaxeRepository extends AbstractRepository implements RepositoryInterface +{ + const TABLE_NAME = 'carrier'; + + /** + * @param string $langIso + * @param bool $withSelecParameters + * + * @return mixed + * + * @throws \PrestaShopException + */ + public function generateFullQuery($langIso, $withSelecParameters) + { + $this->generateMinimalQuery(self::TABLE_NAME, 'ca'); + + $this->query + ->innerJoin('carrier_tax_rules_group_shop', 'ctrgs', 'ca.id_carrier = ctrgs.id_carrier') + ->innerJoin('tax_rule', 'tr', 'ctrgs.id_tax_rules_group = tr.id_tax_rules_group') + ->innerJoin('country', 'co', 'tr.id_country = co.id_country AND co.iso_code IS NOT NULL AND co.active = 1') + ->innerJoin('delivery', 'd', 'ca.id_carrier = d.id_carrier AND d.id_zone IS NOT NULL') + ->innerJoin('tax', 't', 'tr.id_tax = t.id_tax AND t.active = 1') + ->leftJoin('state', 's', 'tr.id_state = s.id_state AND s.active = 1') + ; + + $this->query + ->where('(co.id_zone = d.id_zone OR s.id_zone = d.id_zone)') + ; + + if ($withSelecParameters) { + $this->query + ->select('ca.id_reference') + ->select('co.id_zone') + ->select(' + CASE + WHEN d.id_range_weight IS NOT NULL AND d.id_range_weight != 0 THEN d.id_range_weight + WHEN d.id_range_price IS NOT NULL AND d.id_range_price != 0 THEN d.id_range_price + END AS id_range + ') + ->select('ctrgs.id_tax_rules_group AS id_carrier_tax') + ->select('co.iso_code as country_id') + ->select(' + GROUP_CONCAT( + DISTINCT + s.iso_code + ORDER BY s.iso_code ASC + SEPARATOR \',\' + ) AS state_ids + ') + ->select('t.rate AS tax_rate') + ; + + $this->query->groupBy('ca.id_reference, co.id_zone, id_range, country_id'); + } + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForFull($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, true); + + $this->query->limit((int) $limit, (int) $offset); + + return $this->runQuery(); + } + + /** + * @param int $limit + * @param array $contentIds + * @param string $langIso + * + * @return array + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function retrieveContentsForIncremental($limit, $contentIds, $langIso) + { + if ($contentIds == []) { + return []; + } + + $this->generateFullQuery($langIso, true); + + $this->query + ->where('ca.id_carrier IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->limit($limit); + + return $this->runQuery(); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + * + * @throws \PrestaShopException + * @throws \PrestaShopDatabaseException + */ + public function countFullSyncContentLeft($offset, $limit, $langIso) + { + $this->generateFullQuery($langIso, true); + + $result = $this->db->executeS(' + SELECT (COUNT(*) - ' . (int) $offset . ') AS count + FROM (' . $this->query->build() . ') as subquery; + '); + + return is_array($result) ? $result[0]['count'] : []; + } +} diff --git a/src/Repository/CountryRepository.php b/src/Repository/CountryRepository.php deleted file mode 100644 index e2bdd7b3..00000000 --- a/src/Repository/CountryRepository.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class CountryRepository extends AbstractRepository -{ - const TABLE_NAME = 'country'; - - /** - * @param int $zoneId - * @param bool $active - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getCountryIsoCodesByZoneId($zoneId, $active) - { - $isoCodes = []; - - $this->generateMinimalQuery(self::TABLE_NAME, 'c'); - - $this->query - ->innerJoin('country_shop', 'cs', 'cs.id_country = c.id_country') - ->innerJoin('country_lang', 'cl', 'cl.id_country = c.id_country') - ->where('cs.id_shop = ' . (int) parent::getShopContext()->id) - ->where('cl.id_lang = ' . (int) parent::getLanguageContext()->id) - ->where('id_zone = ' . (int) $zoneId) - ->where('active = ' . (bool) $active) - ; - - $this->query->select('iso_code'); - - $result = $this->runQuery(true); - - foreach ($result as $country) { - $isoCodes[] = $country['iso_code']; - } - - return $isoCodes; - } -} diff --git a/src/Repository/StateRepository.php b/src/Repository/StateRepository.php deleted file mode 100644 index e8663274..00000000 --- a/src/Repository/StateRepository.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class StateRepository extends AbstractRepository -{ - const TABLE_NAME = 'state'; - - /** - * @param int $zoneId - * @param bool $active - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getStateIsoCodesByZoneId($zoneId, $active) - { - $isoCodes = []; - - $this->generateMinimalQuery(self::TABLE_NAME, 's'); - - $this->query->innerJoin('country', 'c', 'c.id_country = s.id_country') - ->where('s.id_zone = ' . (int) $zoneId) - ->where('s.active = ' . (bool) $active) - ->where('c.active = ' . (bool) $active) - ; - - $this->query->select('s.iso_code'); - - $result = $this->runQuery(true); - - foreach ($result as $state) { - $isoCodes[] = $state['iso_code']; - } - - return $isoCodes; - } -} diff --git a/src/Repository/EventbusSyncRepository.php b/src/Repository/SyncRepository.php similarity index 98% rename from src/Repository/EventbusSyncRepository.php rename to src/Repository/SyncRepository.php index 7217ff87..d92491ee 100644 --- a/src/Repository/EventbusSyncRepository.php +++ b/src/Repository/SyncRepository.php @@ -30,7 +30,7 @@ exit; } -class EventbusSyncRepository extends AbstractRepository +class SyncRepository extends AbstractRepository { const TYPE_SYNC_TABLE_NAME = 'eventbus_type_sync'; const JOB_TABLE_NAME = 'eventbus_job'; diff --git a/src/Repository/TaxeRepository.php b/src/Repository/TaxeRepository.php deleted file mode 100644 index 3d1064d0..00000000 --- a/src/Repository/TaxeRepository.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\Module\PsEventbus\Repository; - -if (!defined('_PS_VERSION_')) { - exit; -} - -class TaxeRepository extends AbstractRepository -{ - const TABLE_NAME = 'tax'; - - /** - * @param int $zoneId - * @param int $taxRulesGroupId - * @param bool $active - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getCarrierTaxesByZone($zoneId, $taxRulesGroupId, $active) - { - $this->generateMinimalQuery(self::TABLE_NAME, 't'); - - $this->query - ->innerJoin('tax_rule', 'tr', 'tr.id_tax = t.id_tax') - ->innerJoin('tax_rules_group', 'trg', 'trg.id_tax_rules_group = tr.id_tax_rules_group') - ->innerJoin('tax_rules_group_shop', 'trgs', 'trgs.id_tax_rules_group = tr.id_tax_rules_group') - ->innerJoin('tax_lang', 'tl', 'tl.id_tax = t.id_tax') - ->leftJoin('country', 'c', 'c.id_country = tr.id_country') - ->leftJoin('state', 's', 's.id_state = tr.id_state') - ->where('tr.id_tax_rules_group = ' . (int) $taxRulesGroupId) - ->where('c.active = ' . (bool) $active) - ->where('s.active = ' . (bool) $active . ' OR s.active IS NULL') - ->where('t.active = ' . (bool) $active) - ->where('c.id_zone = ' . (int) $zoneId . ' OR s.id_zone = ' . (int) $zoneId) - ->where('c.iso_code IS NOT NULL') - ->where('trgs.id_shop = ' . parent::getShopContext()->id) - ->where('tl.id_lang = ' . (int) parent::getLanguageContext()->id) - ; - - $this->query - ->select('t.rate') - ->select('c.iso_code as country_iso_code') - ->select('GROUP_CONCAT(s.iso_code SEPARATOR ",") as state_iso_code') - ; - - return $this->runQuery(true); - } -} diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index dcf5ed5d..923975a6 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -30,7 +30,7 @@ use PrestaShop\Module\PsEventbus\Exception\EnvVarException; use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; -use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; +use PrestaShop\Module\PsEventbus\Repository\SyncRepository; if (!defined('_PS_VERSION_')) { exit; @@ -38,8 +38,8 @@ class ApiAuthorizationService { - /** @var EventbusSyncRepository */ - private $eventbusSyncRepository; + /** @var SyncRepository */ + private $syncRepository; /** @var SyncApiClient */ private $syncApiClient; @@ -51,12 +51,12 @@ class ApiAuthorizationService private $errorHandler; public function __construct( - EventbusSyncRepository $eventbusSyncRepository, + SyncRepository $syncRepository, SyncApiClient $syncApiClient, PsAccountsAdapterService $psAccountsAdapterService, ErrorHandler $errorHandler ) { - $this->eventbusSyncRepository = $eventbusSyncRepository; + $this->syncRepository = $syncRepository; $this->syncApiClient = $syncApiClient; $this->psAccountsAdapterService = $psAccountsAdapterService; $this->errorHandler = $errorHandler; @@ -118,7 +118,7 @@ public function authorize($jobId, $isHealthCheck) private function authorizeCall($jobId) { // Check if the job already exists - $job = $this->eventbusSyncRepository->findJobById($jobId); + $job = $this->syncRepository->findJobById($jobId); if ($job) { return true; @@ -132,6 +132,6 @@ private function authorizeCall($jobId) } // Cache the valid jobId - return $this->eventbusSyncRepository->insertJob($jobId, date(DATE_ATOM)); + return $this->syncRepository->insertJob($jobId, date(DATE_ATOM)); } } diff --git a/src/Service/ApiShopContentService.php b/src/Service/ApiShopContentService.php index 3cd78882..f4041e83 100644 --- a/src/Service/ApiShopContentService.php +++ b/src/Service/ApiShopContentService.php @@ -31,8 +31,8 @@ use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; -use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; +use PrestaShop\Module\PsEventbus\Repository\SyncRepository; use PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; @@ -48,8 +48,8 @@ class ApiShopContentService /** @var ApiAuthorizationService */ private $apiAuthorizationService; - /** @var EventbusSyncRepository */ - private $eventbusSyncRepository; + /** @var SyncRepository */ + private $syncRepository; /** @var SynchronizationService */ private $synchronizationService; @@ -65,7 +65,7 @@ public function __construct( ErrorHandler $errorHandler, ApiAuthorizationService $apiAuthorizationService, SynchronizationService $synchronizationService, - EventbusSyncRepository $eventbusSyncRepository + SyncRepository $syncRepository ) { $this->startTime = time(); @@ -73,7 +73,7 @@ public function __construct( $this->errorHandler = $errorHandler; $this->apiAuthorizationService = $apiAuthorizationService; $this->synchronizationService = $synchronizationService; - $this->eventbusSyncRepository = $eventbusSyncRepository; + $this->syncRepository = $syncRepository; } /** @@ -107,7 +107,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT); $langIso = $langIso ? $langIso : $languagesService->getDefaultLanguageIsoCode(); - $typeSync = $this->eventbusSyncRepository->findTypeSync($shopContent, $langIso); + $typeSync = $this->syncRepository->findTypeSync($shopContent, $langIso); // If no typesync exist, or if fullsync is requested by user if (!is_array($typeSync) || $fullSyncRequested) { @@ -121,7 +121,7 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $incrementalSyncRepository->removeIncrementaSyncObjectByType($shopContent); } - $this->eventbusSyncRepository->upsertTypeSync( + $this->syncRepository->upsertTypeSync( $shopContent, $offset, $dateNow, diff --git a/src/Service/ShopContent/CarrierDetailsService.php b/src/Service/ShopContent/CarrierDetailsService.php index 8cdbb1ae..b5b477f6 100644 --- a/src/Service/ShopContent/CarrierDetailsService.php +++ b/src/Service/ShopContent/CarrierDetailsService.php @@ -27,9 +27,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\CarrierRepository; -use PrestaShop\Module\PsEventbus\Repository\CountryRepository; -use PrestaShop\Module\PsEventbus\Repository\StateRepository; +use PrestaShop\Module\PsEventbus\Repository\CarrierDetailRepository; if (!defined('_PS_VERSION_')) { exit; @@ -37,12 +35,12 @@ class CarrierDetailsService extends ShopContentAbstractService implements ShopContentServiceInterface { - /** @var CarrierRepository */ - private $carrierRepository; + /** @var CarrierDetailRepository */ + private $carrierDetailRepository; - public function __construct(CarrierRepository $carrierRepository) + public function __construct(CarrierDetailRepository $carrierDetailRepository) { - $this->carrierRepository = $carrierRepository; + $this->carrierDetailRepository = $carrierDetailRepository; } /** @@ -54,19 +52,13 @@ public function __construct(CarrierRepository $carrierRepository) */ public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso); + $result = $this->carrierDetailRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; } - $carrierDetails = []; - - foreach ($result as $carrierData) { - $carrierDetails = array_merge($carrierDetails, $this->buildCarrierDetails($carrierData)); - } - - $this->castCarrierDetails($carrierDetails); + $this->castCarrierDetails($result); return array_map(function ($item) { return [ @@ -74,7 +66,7 @@ public function getContentsForFull($offset, $limit, $langIso) 'collection' => Config::COLLECTION_CARRIER_DETAILS, 'properties' => $item, ]; - }, $carrierDetails); + }, $result); } /** @@ -87,16 +79,10 @@ public function getContentsForFull($offset, $limit, $langIso) */ public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); + $result = $this->carrierDetailRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); if (!empty($result)) { - $carrierDetails = []; - - foreach ($result as $carrierData) { - $carrierDetails = array_merge($carrierDetails, $this->buildCarrierDetails($carrierData)); - } - - $this->castCarrierDetails($carrierDetails); + $this->castCarrierDetails($result); } return parent::formatIncrementalSyncResponse(Config::COLLECTION_CARRIER_DETAILS, $result, $deletedContents); @@ -111,7 +97,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon */ public function getFullSyncContentLeft($offset, $limit, $langIso) { - return $this->carrierRepository->countFullSyncContentLeft($offset, $limit, $langIso); + return $this->carrierDetailRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** @@ -125,7 +111,7 @@ private function castCarrierDetails(&$carrierDetails) $carrierDetail['id_reference'] = (string) $carrierDetail['id_reference']; $carrierDetail['id_zone'] = (string) $carrierDetail['id_zone']; $carrierDetail['id_range'] = (string) $carrierDetail['id_range']; - $carrierDetail['id_carrier_detail'] = (string) $carrierDetail['id_carrier_detail']; + $carrierDetail['id_carrier_detail'] = (string) $carrierDetail['id_range']; // same value as id_range $carrierDetail['shipping_method'] = (string) $carrierDetail['shipping_method']; $carrierDetail['delimiter1'] = (float) $carrierDetail['delimiter1']; $carrierDetail['delimiter2'] = (float) $carrierDetail['delimiter2']; @@ -134,68 +120,4 @@ private function castCarrierDetails(&$carrierDetails) $carrierDetail['price'] = (float) $carrierDetail['price']; } } - - /** - * Build a CarrierDetail from Carrier data - * - * @param array $carrierData - * - * @return array - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function buildCarrierDetails($carrierData) - { - /** @var \Ps_eventbus $module */ - $module = \Module::getInstanceByName('ps_eventbus'); - - /** @var CountryRepository $countryRepository */ - $countryRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\CountryRepository'); - - /** @var StateRepository $stateRepository */ - $stateRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\StateRepository'); - - $carrier = new \Carrier($carrierData['id_reference']); - - $deliveryPriceByRanges = CarriersService::getDeliveryPriceByRange($carrier); - - if (!$deliveryPriceByRanges) { - return []; - } - - $carrierDetails = []; - - foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { - $range = CarriersService::getCarrierRange($deliveryPriceByRange); - - if (!$range) { - continue; - } - - foreach ($deliveryPriceByRange['zones'] as $zone) { - /** @var array $countryIsoCodes */ - $countryIsoCodes = $countryRepository->getCountryIsoCodesByZoneId($zone['id_zone'], true); - - /** @var array $stateIsoCodes */ - $stateIsoCodes = $stateRepository->getStateIsoCodesByZoneId($zone['id_zone'], true); - - $carrierDetail = []; - $carrierDetail['id_reference'] = $carrier->id_reference; - $carrierDetail['id_zone'] = $zone['id_zone']; - $carrierDetail['id_range'] = $range->id; - $carrierDetail['id_carrier_detail'] = $range->id; - $carrierDetail['shipping_method'] = $carrier->getRangeTable(); - $carrierDetail['delimiter1'] = $range->delimiter1; - $carrierDetail['delimiter2'] = $range->delimiter2; - $carrierDetail['country_ids'] = implode(',', $countryIsoCodes); - $carrierDetail['state_ids'] = implode(',', $stateIsoCodes); - $carrierDetail['price'] = $zone['price']; - - array_push($carrierDetails, $carrierDetail); - } - } - - return $carrierDetails; - } } diff --git a/src/Service/ShopContent/CarrierTaxesService.php b/src/Service/ShopContent/CarrierTaxesService.php index 6dcf534a..97eecc20 100644 --- a/src/Service/ShopContent/CarrierTaxesService.php +++ b/src/Service/ShopContent/CarrierTaxesService.php @@ -27,8 +27,7 @@ namespace PrestaShop\Module\PsEventbus\Service\ShopContent; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Repository\CarrierRepository; -use PrestaShop\Module\PsEventbus\Repository\TaxeRepository; +use PrestaShop\Module\PsEventbus\Repository\CarrierTaxeRepository; if (!defined('_PS_VERSION_')) { exit; @@ -36,12 +35,12 @@ class CarrierTaxesService extends ShopContentAbstractService implements ShopContentServiceInterface { - /** @var CarrierRepository */ - private $carrierRepository; + /** @var CarrierTaxeRepository */ + private $carrierTaxeRepository; - public function __construct(CarrierRepository $carrierRepository) + public function __construct(CarrierTaxeRepository $carrierTaxeRepository) { - $this->carrierRepository = $carrierRepository; + $this->carrierTaxeRepository = $carrierTaxeRepository; } /** @@ -53,19 +52,13 @@ public function __construct(CarrierRepository $carrierRepository) */ public function getContentsForFull($offset, $limit, $langIso) { - $result = $this->carrierRepository->retrieveContentsForFull($offset, $limit, $langIso); + $result = $this->carrierTaxeRepository->retrieveContentsForFull($offset, $limit, $langIso); if (empty($result)) { return []; } - $carrierTaxes = []; - - foreach ($result as $carrierData) { - $carrierTaxes = array_merge($carrierTaxes, $this->buildCarrierTaxes($carrierData)); - } - - $this->castCarrierTaxes($carrierTaxes); + $this->castCarrierTaxes($result); return array_map(function ($item) { return [ @@ -73,7 +66,7 @@ public function getContentsForFull($offset, $limit, $langIso) 'collection' => Config::COLLECTION_CARRIER_TAXES, 'properties' => $item, ]; - }, $carrierTaxes); + }, $result); } /** @@ -86,16 +79,10 @@ public function getContentsForFull($offset, $limit, $langIso) */ public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) { - $result = $this->carrierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); + $result = $this->carrierTaxeRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); if (!empty($result)) { - $carrierTaxes = []; - - foreach ($result as $carrierData) { - $carrierTaxes = array_merge($carrierTaxes, $this->buildCarrierTaxes($carrierData)); - } - - $this->castCarrierTaxes($carrierTaxes); + $this->castCarrierTaxes($result); } return parent::formatIncrementalSyncResponse(Config::COLLECTION_CARRIER_TAXES, $result, $deletedContents); @@ -110,9 +97,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon */ public function getFullSyncContentLeft($offset, $limit, $langIso) { - $data = $this->getContentsForFull($offset, 50, $langIso); - - return count($data); + return $this->carrierTaxeRepository->countFullSyncContentLeft($offset, $limit, $langIso); } /** @@ -127,73 +112,9 @@ private function castCarrierTaxes(&$carrierTaxes) $carrierTaxe['id_zone'] = (string) $carrierTaxe['id_zone']; $carrierTaxe['id_range'] = (string) $carrierTaxe['id_range']; $carrierTaxe['id_carrier_tax'] = (string) $carrierTaxe['id_carrier_tax']; - $carrierTaxe['country_ids'] = (string) $carrierTaxe['country_ids']; + $carrierTaxe['country_id'] = (string) $carrierTaxe['country_id']; $carrierTaxe['state_ids'] = (string) $carrierTaxe['state_ids']; $carrierTaxe['tax_rate'] = (float) $carrierTaxe['tax_rate']; } } - - /** - * Build a CarrierTaxes from Carrier - * - * @param array $carrierData - * - * @return array - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function buildCarrierTaxes($carrierData) - { - /** @var \Ps_eventbus $module */ - $module = \Module::getInstanceByName('ps_eventbus'); - - /** @var TaxeRepository $taxeRepository */ - $taxeRepository = $module->getService('PrestaShop\Module\PsEventbus\Repository\TaxeRepository'); - - $carrier = new \Carrier($carrierData['id_reference']); - - $deliveryPriceByRanges = CarriersService::getDeliveryPriceByRange($carrier); - - if (!$deliveryPriceByRanges) { - return []; - } - - $carrierTaxes = []; - - foreach ($deliveryPriceByRanges as $deliveryPriceByRange) { - $range = CarriersService::getCarrierRange($deliveryPriceByRange); - - if (!$range) { - continue; - } - - foreach ($deliveryPriceByRange['zones'] as $zone) { - $taxRulesGroupId = (int) $carrier->getIdTaxRulesGroup(); - - /** @var array $carrierTaxesByZone */ - $carrierTaxesByZone = $taxeRepository->getCarrierTaxesByZone($zone['id_zone'], $taxRulesGroupId, true); - - if (!$carrierTaxesByZone[0]['country_iso_code']) { - continue; - } - - $carrierTaxesByZone = $carrierTaxesByZone[0]; - - $carrierTaxe = []; - - $carrierTaxe['id_reference'] = $carrier->id_reference; - $carrierTaxe['id_zone'] = $zone['id_zone']; - $carrierTaxe['id_range'] = $range->id; - $carrierTaxe['id_carrier_tax'] = $taxRulesGroupId; - $carrierTaxe['country_id'] = $carrierTaxesByZone['country_iso_code']; - $carrierTaxe['state_ids'] = $carrierTaxesByZone['state_iso_code']; - $carrierTaxe['tax_rate'] = $carrierTaxesByZone['rate']; - - array_push($carrierTaxes, $carrierTaxe); - } - } - - return $carrierTaxes; - } } diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index 129363a8..f59b7065 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -101,86 +101,27 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) } /** - * @param array $deliveryPriceByRange + * @param \Carrier $carrier + * @param array $delivery * * @return false|\RangeWeight|\RangePrice * * @throws \PrestaShopDatabaseException * @throws \PrestaShopException */ - public static function getCarrierRange($deliveryPriceByRange) + public static function generateRange($carrier, $delivery) { - if (isset($deliveryPriceByRange['id_range_weight'])) { - return new \RangeWeight($deliveryPriceByRange['id_range_weight']); - } - if (isset($deliveryPriceByRange['id_range_price'])) { - return new \RangePrice($deliveryPriceByRange['id_range_price']); - } - - return false; - } + $rangeTable = $carrier->getRangeTable(); - /** - * @param \Carrier $carrierObj - * - * @return array|false - */ - public static function getDeliveryPriceByRange(\Carrier $carrierObj) - { - $rangeTable = $carrierObj->getRangeTable(); - - switch ($rangeTable) { - case 'range_weight': - return CarriersService::getCarrierByWeightRange($carrierObj, 'range_weight'); - case 'range_price': - return CarriersService::getCarrierByPriceRange($carrierObj, 'range_price'); - default: - return false; + if ($rangeTable === 'range_weight') { + return new \RangeWeight($delivery['id_range_weight']); } - } - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - public static function getCarrierByWeightRange(\Carrier $carrierObj, $rangeTable) - { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_weight']]['id_range_weight'] = $range['id_range_weight']; - $filteredRanges[$range['id_range_weight']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_weight']]['zones'][$range['id_zone']]['price'] = $range['price']; - } - - return $filteredRanges; - } - - /** - * @param \Carrier $carrierObj - * @param string $rangeTable - * - * @return array - */ - public static function getCarrierByPriceRange(\Carrier $carrierObj, $rangeTable) - { - $deliveryPriceByRange = \Carrier::getDeliveryPriceByRanges($rangeTable, (int) $carrierObj->id); - - $filteredRanges = []; - - foreach ($deliveryPriceByRange as $range) { - $filteredRanges[$range['id_range_price']]['id_range_price'] = $range['id_range_price']; - $filteredRanges[$range['id_range_price']]['id_carrier'] = $range['id_carrier']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['id_zone'] = $range['id_zone']; - $filteredRanges[$range['id_range_price']]['zones'][$range['id_zone']]['price'] = $range['price']; + if ($rangeTable === 'range_price') { + return new \RangePrice($delivery['id_range_price']); } - return $filteredRanges; + return false; } /** diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 239efce6..5a275ba9 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -29,9 +29,9 @@ use PrestaShop\Module\PsEventbus\Api\LiveSyncApiClient; use PrestaShop\Module\PsEventbus\Config\Config; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; -use PrestaShop\Module\PsEventbus\Repository\EventbusSyncRepository; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\LiveSyncRepository; +use PrestaShop\Module\PsEventbus\Repository\SyncRepository; use PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService; use PrestaShop\Module\PsEventbus\Service\ShopContent\ShopContentServiceInterface; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; @@ -48,9 +48,9 @@ class SynchronizationService private $liveSyncApiClient; /** - * @var EventbusSyncRepository + * @var SyncRepository */ - private $eventbusSyncRepository; + private $syncRepository; /** * @var IncrementalSyncRepository @@ -79,7 +79,7 @@ class SynchronizationService public function __construct( LiveSyncApiClient $liveSyncApiClient, - EventbusSyncRepository $eventbusSyncRepository, + SyncRepository $syncRepository, IncrementalSyncRepository $incrementalSyncRepository, LiveSyncRepository $liveSyncRepository, LanguagesService $languagesService, @@ -87,7 +87,7 @@ public function __construct( ErrorHandler $errorHandler ) { $this->liveSyncApiClient = $liveSyncApiClient; - $this->eventbusSyncRepository = $eventbusSyncRepository; + $this->syncRepository = $syncRepository; $this->incrementalSyncRepository = $incrementalSyncRepository; $this->liveSyncRepository = $liveSyncRepository; $this->languagesService = $languagesService; @@ -151,7 +151,7 @@ public function sendFullSync( $offset = 0; } - $this->eventbusSyncRepository->upsertTypeSync($shopContent, $offset, $dateNow, $remainingObjects === 0, $langIso); + $this->syncRepository->upsertTypeSync($shopContent, $offset, $dateNow, $remainingObjects === 0, $langIso); return $this->returnSyncResponse($data, $response, $remainingObjects); } @@ -281,7 +281,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, $hasDeleted = $this->incrementalSyncRepository->removeIncrementaSyncObjectByType($contentType); if ($hasDeleted) { - $this->eventbusSyncRepository->upsertTypeSync( + $this->syncRepository->upsertTypeSync( $contentType, 0, $createdAt, @@ -386,7 +386,7 @@ private function debounceLiveSync($shopContentName) // @phpstan-ignore method.un */ private function isFullSyncDone($shopContent, $langIso) { - return $this->eventbusSyncRepository->isFullSyncDoneForThisTypeSync($shopContent, $langIso); + return $this->syncRepository->isFullSyncDoneForThisTypeSync($shopContent, $langIso); } /** From 9ee05e293ad8cb3ad3a510267147f74b5d9775ce Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:20:50 +0100 Subject: [PATCH 146/162] fix: carrier details and taxes (#395) --- src/Config/Config.php | 2 + src/Handler/ErrorHandler/ErrorHandler.php | 4 +- src/Repository/AbstractRepository.php | 6 +- src/Repository/CarrierDetailRepository.php | 4 +- src/Repository/CarrierTaxeRepository.php | 4 +- src/Repository/ProductRepository.php | 4 +- src/Service/ApiAuthorizationService.php | 2 + src/Service/ApiShopContentService.php | 11 - src/Service/CommonService.php | 2 - src/Service/PresenterService.php | 2 +- src/Service/PsAccountsAdapterService.php | 10 +- src/Service/ShopContent/EmployeesService.php | 1 - .../ShopContent/SpecificPricesService.php | 41 ++-- src/Service/ShopContent/StocksService.php | 7 +- src/Service/ShopContent/WishlistsService.php | 7 +- src/Service/SynchronizationService.php | 2 +- src/Traits/UseHooks.php | 192 +++++++++--------- upgrade/Upgrade-4.0.0.php | 7 +- 18 files changed, 136 insertions(+), 172 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 81a65c92..66a82087 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -138,6 +138,8 @@ class Config const INCREMENTAL_TYPE_UPSERT = 'upsert'; const INCREMENTAL_TYPE_DELETE = 'delete'; + const SYNC_SERVICE_NAME = 'PrestaShop\Module\PsEventbus\Service\SynchronizationService'; + /** * @param mixed $message * diff --git a/src/Handler/ErrorHandler/ErrorHandler.php b/src/Handler/ErrorHandler/ErrorHandler.php index 0b6329f7..41bf2988 100644 --- a/src/Handler/ErrorHandler/ErrorHandler.php +++ b/src/Handler/ErrorHandler/ErrorHandler.php @@ -102,7 +102,7 @@ public function handle($exception) $verboseEnabled = PS_EVENTBUS_VERBOSE_ENABLED; } - if ($logsEnabled == true) { + if ($logsEnabled) { \PrestaShopLogger::addLog( $exception->getMessage() . ' : ' . $exception->getFile() . ':' . $exception->getLine() . ' | ' . $exception->getTraceAsString(), 3, @@ -114,7 +114,7 @@ public function handle($exception) } // if debug mode enabled and verbose set to true, print error in front office - if (_PS_MODE_DEV_ == true && $verboseEnabled == true) { + if (_PS_MODE_DEV_ && $verboseEnabled) { throw $exception; } else { $this->client->captureException($exception); diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index c9b07098..f55ab60d 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -143,13 +143,11 @@ protected function runQuery($disableCurrentExplain = null) $explainSql = PS_EVENTBUS_EXPLAIN_SQL_ENABLED; } - if ($explainSql && $disableCurrentExplain == false) { + if ($explainSql && !$disableCurrentExplain) { $this->debugQuery(); } - $result = (array) $this->db->executeS($this->query); - - return $result; + return (array) $this->db->executeS($this->query); } /** diff --git a/src/Repository/CarrierDetailRepository.php b/src/Repository/CarrierDetailRepository.php index a44577e1..5a33b8ac 100644 --- a/src/Repository/CarrierDetailRepository.php +++ b/src/Repository/CarrierDetailRepository.php @@ -60,7 +60,7 @@ public function generateFullQuery($langIso, $withSelecParameters) ->select('ca.id_reference') ->select('d.id_zone') ->select(' - CASE + CASE WHEN d.id_range_weight IS NOT NULL AND d.id_range_weight != 0 THEN d.id_range_weight WHEN d.id_range_price IS NOT NULL AND d.id_range_price != 0 THEN d.id_range_price END AS id_range @@ -95,7 +95,7 @@ public function generateFullQuery($langIso, $withSelecParameters) ') ->select(' GROUP_CONCAT( - DISTINCT + DISTINCT s.iso_code ORDER BY s.iso_code ASC SEPARATOR \',\' diff --git a/src/Repository/CarrierTaxeRepository.php b/src/Repository/CarrierTaxeRepository.php index 485e58d4..593fe981 100644 --- a/src/Repository/CarrierTaxeRepository.php +++ b/src/Repository/CarrierTaxeRepository.php @@ -64,7 +64,7 @@ public function generateFullQuery($langIso, $withSelecParameters) ->select('ca.id_reference') ->select('co.id_zone') ->select(' - CASE + CASE WHEN d.id_range_weight IS NOT NULL AND d.id_range_weight != 0 THEN d.id_range_weight WHEN d.id_range_price IS NOT NULL AND d.id_range_price != 0 THEN d.id_range_price END AS id_range @@ -73,7 +73,7 @@ public function generateFullQuery($langIso, $withSelecParameters) ->select('co.iso_code as country_id') ->select(' GROUP_CONCAT( - DISTINCT + DISTINCT s.iso_code ORDER BY s.iso_code ASC SEPARATOR \',\' diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index 3dd81e73..29a9d628 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -49,7 +49,9 @@ public function generateFullQuery($langIso, $withSelecParameters) // WTF IS THAT ? if (!parent::getContext()->employee instanceof \Employee) { - if (($employees = \Employee::getEmployees()) !== false) { + $employees = \Employee::getEmployees(); + + if ($employees) { parent::getContext()->employee = new \Employee($employees[0]['id_employee']); } } diff --git a/src/Service/ApiAuthorizationService.php b/src/Service/ApiAuthorizationService.php index 923975a6..ff1e7ac8 100644 --- a/src/Service/ApiAuthorizationService.php +++ b/src/Service/ApiAuthorizationService.php @@ -102,6 +102,8 @@ public function authorize($jobId, $isHealthCheck) case $exception instanceof FirebaseException: $this->errorHandler->handle($exception); break; + default: + break; } return false; diff --git a/src/Service/ApiShopContentService.php b/src/Service/ApiShopContentService.php index f4041e83..a1a1a28f 100644 --- a/src/Service/ApiShopContentService.php +++ b/src/Service/ApiShopContentService.php @@ -27,14 +27,11 @@ namespace PrestaShop\Module\PsEventbus\Service; use PrestaShop\Module\PsEventbus\Config\Config; -use PrestaShop\Module\PsEventbus\Exception\EnvVarException; -use PrestaShop\Module\PsEventbus\Exception\FirebaseException; use PrestaShop\Module\PsEventbus\Exception\QueryParamsException; use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler; use PrestaShop\Module\PsEventbus\Repository\IncrementalSyncRepository; use PrestaShop\Module\PsEventbus\Repository\SyncRepository; use PrestaShop\Module\PsEventbus\Service\ShopContent\LanguagesService; -use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; if (!defined('_PS_VERSION_')) { exit; @@ -170,14 +167,6 @@ public function handleDataSync($shopContent, $jobId, $langIso, $limit, $fullSync $response ) ); - } catch (\PrestaShopDatabaseException $exception) { - $this->errorHandler->handle($exception); - } catch (EnvVarException $exception) { - $this->errorHandler->handle($exception); - } catch (FirebaseException $exception) { - $this->errorHandler->handle($exception); - } catch (ServiceNotFoundException $exception) { - $this->errorHandler->handle($exception); } catch (\Exception $exception) { $this->errorHandler->handle($exception); } diff --git a/src/Service/CommonService.php b/src/Service/CommonService.php index a838e452..9c83df03 100644 --- a/src/Service/CommonService.php +++ b/src/Service/CommonService.php @@ -60,8 +60,6 @@ public static function exitWithResponse($response) */ public static function exitWithExceptionMessage(\Exception $exception) { - $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); - switch ($exception) { case $exception instanceof \PrestaShopDatabaseException: $code = Config::DATABASE_QUERY_ERROR_CODE; diff --git a/src/Service/PresenterService.php b/src/Service/PresenterService.php index 7907fc68..832d8c51 100644 --- a/src/Service/PresenterService.php +++ b/src/Service/PresenterService.php @@ -93,7 +93,7 @@ public function expose(\ModuleCore $module, $requiredConsents = [], $optionalCon */ private function convertObjectToArray($object) { - if ($object == false) { + if (!$object) { return []; } $array = []; diff --git a/src/Service/PsAccountsAdapterService.php b/src/Service/PsAccountsAdapterService.php index bad8891e..d877993d 100644 --- a/src/Service/PsAccountsAdapterService.php +++ b/src/Service/PsAccountsAdapterService.php @@ -59,7 +59,7 @@ public function __construct(ModuleHelper $moduleHelper) */ public function getModule() { - if ($this->moduleHelper->isInstalledAndActive('ps_accounts') == false) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { return false; } @@ -75,7 +75,7 @@ public function getModule() */ public function getService() { - if ($this->moduleHelper->isInstalledAndActive('ps_accounts') == false) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { return false; } @@ -91,7 +91,7 @@ public function getService() */ public function getPresenter() { - if ($this->moduleHelper->isInstalledAndActive('ps_accounts') == false) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { return false; } @@ -107,7 +107,7 @@ public function getPresenter() */ public function getShopUuid() { - if ($this->moduleHelper->isInstalledAndActive('ps_accounts') == false) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { return ''; } @@ -123,7 +123,7 @@ public function getShopUuid() */ public function getOrRefreshToken() { - if ($this->moduleHelper->isInstalledAndActive('ps_accounts') == false) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { return ''; } diff --git a/src/Service/ShopContent/EmployeesService.php b/src/Service/ShopContent/EmployeesService.php index b3e879c2..1ccf7b3e 100644 --- a/src/Service/ShopContent/EmployeesService.php +++ b/src/Service/ShopContent/EmployeesService.php @@ -136,7 +136,6 @@ private function castEmployees(&$currencies) $employee['has_enabled_gravatar'] = (bool) $employee['has_enabled_gravatar']; } - // FIXME: use a random salt generated during module install $employee['email_hash'] = hash('sha256', $employee['email'] . 'dUj4GMBD6689pL9pyr'); unset($employee['email']); } diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index 45443d25..4963371b 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -205,14 +205,6 @@ private function castCustomPrices(&$customPrices) * @param bool $usetax * @param bool $usereduc * @param \Context|null $context - * @param int $decimals - * @param null $divisor - * @param bool $onlyReduc - * @param null $idCustomer - * @param null $idCart - * @param null $idAddress - * @param null $specificPriceOutput - * @param bool $useGroupReduction * * @return float|int|void * @@ -224,15 +216,7 @@ private function getPriceStatic( $specificPriceId, $usetax = true, $usereduc = true, - $context = null, - $decimals = 6, - $divisor = null, - $onlyReduc = false, - $idCustomer = null, - $idCart = null, - $idAddress = null, - &$specificPriceOutput = null, - $useGroupReduction = true + $context = null ) { if (!$context) { /** @var \Context $context */ @@ -253,6 +237,8 @@ private function getPriceStatic( $idCurrency = \Validate::isLoadedObject($currency) ? (int) $currency->id : (int) \Configuration::get('PS_CURRENCY_DEFAULT'); $currentCart = $context->cart; + $idAddress = null; + if ($currentCart != null && \Validate::isLoadedObject($currentCart)) { $idAddress = $currentCart->{\Configuration::get('PS_TAX_ADDRESS_TYPE')}; } @@ -268,7 +254,7 @@ private function getPriceStatic( } if ( - $usetax != false + $usetax && !empty($address->vat_number) && $address->id_country != \Configuration::get('VATNUMBER_COUNTRY') && \Configuration::get('VATNUMBER_MANAGEMENT') @@ -293,11 +279,11 @@ private function getPriceStatic( $idCurrency, $idGroup, $usetax, - $decimals, - $onlyReduc, + 6, + false, $usereduc, $specificPriceOutput, - $useGroupReduction + true ); } @@ -419,17 +405,14 @@ private function priceCalculation( if (is_array($result) && (!$specificPrice || !$specificPrice['id_product_attribute'] || $specificPrice['price'] < 0)) { $attributePrice = \Tools::convertPrice($result['attribute_price'] !== null ? (float) $result['attribute_price'] : 0, $idCurrency); // If you want the default combination, please use NULL value instead - if ($idProductAttribute !== false) { + if ($idProductAttribute) { $price += $attributePrice; } } - if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.0.0', '>=')) { - // Customization price - if ((int) $idCustomization) { - /* @phpstan-ignore-next-line */ - $price += \Tools::convertPrice(\Customization::getCustomizationPrice($idCustomization), $idCurrency); - } + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '1.7.0.0', '>=') && (int) $idCustomization) { + /* @phpstan-ignore-next-line */ + $price += \Tools::convertPrice(\Customization::getCustomizationPrice($idCustomization), $idCurrency); } // Tax @@ -504,7 +487,7 @@ private function priceCalculation( // Group reduction if ($useGroupReduction) { $reductionFromCategory = \GroupReduction::getValueForProduct($idProduct, $idGroup); - if ($reductionFromCategory !== false) { + if ($reductionFromCategory) { $groupReduction = $price * (float) $reductionFromCategory; } else { // apply group reduction if there is no group reduction for this category $groupReduction = (($reduc = \Group::getReductionByIdGroup($idGroup)) != 0) ? ($price * $reduc / 100) : 0; diff --git a/src/Service/ShopContent/StocksService.php b/src/Service/ShopContent/StocksService.php index 8bc83eae..12d20f2e 100644 --- a/src/Service/ShopContent/StocksService.php +++ b/src/Service/ShopContent/StocksService.php @@ -58,7 +58,7 @@ public function getContentsForFull($offset, $limit, $langIso) return []; } - $this->castStocks($result, $langIso); + $this->castStocks($result); return array_map(function ($item) { return [ @@ -82,7 +82,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon $result = $this->stockRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); if (!empty($result)) { - $this->castStocks($result, $langIso); + $this->castStocks($result); } return parent::formatIncrementalSyncResponse(Config::COLLECTION_STOCKS, $result, $deletedContents); @@ -102,11 +102,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $stocks - * @param string $langIso * * @return void */ - private function castStocks(&$stocks, $langIso) + private function castStocks(&$stocks) { foreach ($stocks as &$stock) { $stock['id_stock_available'] = (int) $stock['id_stock_available']; diff --git a/src/Service/ShopContent/WishlistsService.php b/src/Service/ShopContent/WishlistsService.php index 671bf1d8..2b559698 100644 --- a/src/Service/ShopContent/WishlistsService.php +++ b/src/Service/ShopContent/WishlistsService.php @@ -58,7 +58,7 @@ public function getContentsForFull($offset, $limit, $langIso) return []; } - $this->castWishlists($result, $langIso); + $this->castWishlists($result); return array_map(function ($item) { return [ @@ -82,7 +82,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon $result = $this->wishlistRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso); if (!empty($result)) { - $this->castWishlists($result, $langIso); + $this->castWishlists($result); } return parent::formatIncrementalSyncResponse(Config::COLLECTION_WISHLISTS, $result, $deletedContents); @@ -102,11 +102,10 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) /** * @param array $wishlists - * @param string $langIso * * @return void */ - private function castWishlists(&$wishlists, $langIso) + private function castWishlists(&$wishlists) { foreach ($wishlists as &$wishlist) { $wishlist['id_wishlist'] = (int) $wishlist['id_wishlist']; diff --git a/src/Service/SynchronizationService.php b/src/Service/SynchronizationService.php index 5a275ba9..f238a72d 100644 --- a/src/Service/SynchronizationService.php +++ b/src/Service/SynchronizationService.php @@ -346,7 +346,7 @@ public function insertContentIntoIncremental($contentTypesWithIds, $actionType, } } - if (empty($contentToInsert) == false) { + if (!empty($contentToInsert)) { $this->incrementalSyncRepository->insertIncrementalObject($contentToInsert); } } diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 1a06b9da..ed246a71 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -143,7 +143,7 @@ public function getHooks() public function hookActionObjectImageDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Image $image */ $image = $parameters['object']; @@ -168,7 +168,7 @@ public function hookActionObjectImageDeleteAfter($parameters) public function hookActionObjectImageAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Image $image */ $image = $parameters['object']; @@ -193,7 +193,7 @@ public function hookActionObjectImageAddAfter($parameters) public function hookActionObjectImageUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Image $image */ $image = $parameters['object']; @@ -218,7 +218,7 @@ public function hookActionObjectImageUpdateAfter($parameters) public function hookActionObjectLanguageDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Language $language */ $language = $parameters['object']; @@ -243,7 +243,7 @@ public function hookActionObjectLanguageDeleteAfter($parameters) public function hookActionObjectLanguageAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Language $language */ $language = $parameters['object']; @@ -268,7 +268,7 @@ public function hookActionObjectLanguageAddAfter($parameters) public function hookActionObjectLanguageUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Language $language */ $language = $parameters['object']; @@ -293,7 +293,7 @@ public function hookActionObjectLanguageUpdateAfter($parameters) public function hookActionObjectManufacturerDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; @@ -318,7 +318,7 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) public function hookActionObjectManufacturerAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; @@ -343,7 +343,7 @@ public function hookActionObjectManufacturerAddAfter($parameters) public function hookActionObjectManufacturerUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Manufacturer $manufacturer */ $manufacturer = $parameters['object']; @@ -368,7 +368,7 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) public function hookActionObjectSupplierDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Supplier $supplier */ $supplier = $parameters['object']; @@ -393,7 +393,7 @@ public function hookActionObjectSupplierDeleteAfter($parameters) public function hookActionObjectSupplierAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Supplier $supplier */ $supplier = $parameters['object']; @@ -418,7 +418,7 @@ public function hookActionObjectSupplierAddAfter($parameters) public function hookActionObjectSupplierUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Supplier $supplier */ $supplier = $parameters['object']; @@ -443,7 +443,7 @@ public function hookActionObjectSupplierUpdateAfter($parameters) public function hookActionObjectProductDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Product $product */ $product = $parameters['object']; @@ -475,7 +475,7 @@ public function hookActionObjectProductAddAfter($parameters) } /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var CustomProductCarrierRepository $customProductCarrierRepository */ $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository'); @@ -523,7 +523,7 @@ public function hookActionObjectProductUpdateAfter($parameters) } /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var CustomProductCarrierRepository $customProductCarrierRepository */ $customProductCarrierRepository = $this->getService('PrestaShop\Module\PsEventbus\Repository\CustomProductCarrierRepository'); @@ -564,7 +564,7 @@ public function hookActionObjectProductUpdateAfter($parameters) public function hookActionObjectWishlistDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $wishlist = $parameters['object']; @@ -588,7 +588,7 @@ public function hookActionObjectWishlistDeleteAfter($parameters) public function hookActionObjectWishlistAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $wishlist = $parameters['object']; @@ -612,7 +612,7 @@ public function hookActionObjectWishlistAddAfter($parameters) public function hookActionObjectWishlistUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $wishlist = $parameters['object']; @@ -636,7 +636,7 @@ public function hookActionObjectWishlistUpdateAfter($parameters) public function hookActionObjectStockAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Stock $stock */ $stock = $parameters['object']; @@ -661,7 +661,7 @@ public function hookActionObjectStockAddAfter($parameters) public function hookActionObjectStockUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Stock $stock */ $stock = $parameters['object']; @@ -686,7 +686,7 @@ public function hookActionObjectStockUpdateAfter($parameters) public function hookActionObjectStoreDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Store $store */ $store = $parameters['object']; @@ -711,7 +711,7 @@ public function hookActionObjectStoreDeleteAfter($parameters) public function hookActionObjectStoreAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Store $store */ $store = $parameters['object']; @@ -736,7 +736,7 @@ public function hookActionObjectStoreAddAfter($parameters) public function hookActionObjectStoreUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Store $store */ $store = $parameters['object']; @@ -761,7 +761,7 @@ public function hookActionObjectStoreUpdateAfter($parameters) public function hookActionObjectCombinationDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Combination $combination */ $combination = $parameters['object']; @@ -786,7 +786,7 @@ public function hookActionObjectCombinationDeleteAfter($parameters) public function hookActionObjectCategoryAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Category $category * */ $category = $parameters['object']; @@ -811,7 +811,7 @@ public function hookActionObjectCategoryAddAfter($parameters) public function hookActionObjectCategoryUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Category $category * */ $category = $parameters['object']; @@ -836,7 +836,7 @@ public function hookActionObjectCategoryUpdateAfter($parameters) public function hookActionObjectCategoryDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Category $category * */ $category = $parameters['object']; @@ -861,7 +861,7 @@ public function hookActionObjectCategoryDeleteAfter($parameters) public function hookActionObjectCustomerAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Customer $customer * */ $customer = $parameters['object']; @@ -886,7 +886,7 @@ public function hookActionObjectCustomerAddAfter($parameters) public function hookActionObjectCustomerUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Customer $customer * */ $customer = $parameters['object']; @@ -911,7 +911,7 @@ public function hookActionObjectCustomerUpdateAfter($parameters) public function hookActionObjectCustomerDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Customer $customer * */ $customer = $parameters['object']; @@ -936,7 +936,7 @@ public function hookActionObjectCustomerDeleteAfter($parameters) public function hookActionObjectCurrencyAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Currency $currency * */ $currency = $parameters['object']; @@ -961,7 +961,7 @@ public function hookActionObjectCurrencyAddAfter($parameters) public function hookActionObjectCurrencyUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Currency $currency * */ $currency = $parameters['object']; @@ -986,7 +986,7 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) public function hookActionObjectCurrencyDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Currency $currency * */ $currency = $parameters['object']; @@ -1011,7 +1011,7 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) public function hookActionObjectCartAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $cart = $parameters['object']; @@ -1035,7 +1035,7 @@ public function hookActionObjectCartAddAfter($parameters) public function hookActionObjectCartUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $cart = $parameters['object']; @@ -1059,7 +1059,7 @@ public function hookActionObjectCartUpdateAfter($parameters) public function hookActionObjectCartRuleAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $cartRule = $parameters['object']; @@ -1083,7 +1083,7 @@ public function hookActionObjectCartRuleAddAfter($parameters) public function hookActionObjectCartRuleDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $cartRule = $parameters['object']; @@ -1107,7 +1107,7 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) public function hookActionObjectCartRuleUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $cartRule = $parameters['object']; @@ -1131,7 +1131,7 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) public function hookActionObjectOrderAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $order = $parameters['object']; @@ -1155,7 +1155,7 @@ public function hookActionObjectOrderAddAfter($parameters) public function hookActionObjectOrderUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $order = $parameters['object']; @@ -1179,7 +1179,7 @@ public function hookActionObjectOrderUpdateAfter($parameters) public function hookActionObjectCarrierAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Carrier $carrier */ $carrier = $parameters['object']; @@ -1216,7 +1216,7 @@ public function hookActionObjectCarrierAddAfter($parameters) public function hookActionObjectCarrierUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Carrier $carrier */ $carrier = $parameters['object']; @@ -1253,7 +1253,7 @@ public function hookActionObjectCarrierUpdateAfter($parameters) public function hookActionObjectCarrierDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \Carrier $carrier */ $carrier = $parameters['object']; @@ -1287,7 +1287,7 @@ public function hookActionObjectCarrierDeleteAfter($parameters) public function hookActionObjectCountryAddAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1304,7 +1304,7 @@ public function hookActionObjectCountryAddAfter() public function hookActionObjectCountryUpdateAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1321,7 +1321,7 @@ public function hookActionObjectCountryUpdateAfter() public function hookActionObjectCountryDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1338,7 +1338,7 @@ public function hookActionObjectCountryDeleteAfter() public function hookActionObjectStateAddAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1355,7 +1355,7 @@ public function hookActionObjectStateAddAfter() public function hookActionObjectStateUpdateAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1372,7 +1372,7 @@ public function hookActionObjectStateUpdateAfter() public function hookActionObjectStateDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1389,7 +1389,7 @@ public function hookActionObjectStateDeleteAfter() public function hookActionObjectZoneAddAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1406,7 +1406,7 @@ public function hookActionObjectZoneAddAfter() public function hookActionObjectZoneUpdateAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1423,7 +1423,7 @@ public function hookActionObjectZoneUpdateAfter() public function hookActionObjectZoneDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1440,7 +1440,7 @@ public function hookActionObjectZoneDeleteAfter() public function hookActionObjectTaxAddAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1457,7 +1457,7 @@ public function hookActionObjectTaxAddAfter() public function hookActionObjectTaxUpdateAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1474,7 +1474,7 @@ public function hookActionObjectTaxUpdateAfter() public function hookActionObjectTaxDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1491,7 +1491,7 @@ public function hookActionObjectTaxDeleteAfter() public function hookActionObjectTaxRulesGroupAddAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1508,7 +1508,7 @@ public function hookActionObjectTaxRulesGroupAddAfter() public function hookActionObjectTaxRulesGroupUpdateAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1525,7 +1525,7 @@ public function hookActionObjectTaxRulesGroupUpdateAfter() public function hookActionObjectTaxRulesGroupDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1542,7 +1542,7 @@ public function hookActionObjectTaxRulesGroupDeleteAfter() public function hookActionShippingPreferencesPageSave() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], @@ -1559,7 +1559,7 @@ public function hookActionShippingPreferencesPageSave() public function hookActionObjectEmployeeAddAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], @@ -1576,7 +1576,7 @@ public function hookActionObjectEmployeeAddAfter() public function hookActionObjectEmployeeDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_DELETE, @@ -1592,7 +1592,7 @@ public function hookActionObjectEmployeeDeleteAfter() public function hookActionObjectEmployeeUpdateAfter() { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], @@ -1619,7 +1619,7 @@ public function hookActionObjectEmployeeUpdateAfter() public function hookActionDispatcherBefore($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); try { /* @@ -1657,22 +1657,20 @@ public function hookActionDispatcherBefore($parameters) public function hookActionObjectSpecificPriceAddAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof \SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); - $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], - Config::INCREMENTAL_TYPE_UPSERT, - date(DATE_ATOM), - $this->shopId, - false - ); - } + if ($specificPrice instanceof \SpecificPrice && isset($specificPrice->id)) { + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], + Config::INCREMENTAL_TYPE_UPSERT, + date(DATE_ATOM), + $this->shopId, + false + ); } } @@ -1684,22 +1682,20 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) public function hookActionObjectSpecificPriceUpdateAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof \SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); - $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], - Config::INCREMENTAL_TYPE_UPSERT, - date(DATE_ATOM), - $this->shopId, - false - ); - } + if ($specificPrice instanceof \SpecificPrice && isset($specificPrice->id)) { + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], + Config::INCREMENTAL_TYPE_UPSERT, + date(DATE_ATOM), + $this->shopId, + false + ); } } @@ -1711,22 +1707,20 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) public function hookActionObjectSpecificPriceDeleteAfter($parameters) { /** @var SynchronizationService $synchronizationService * */ - $synchronizationService = $this->getService('PrestaShop\Module\PsEventbus\Service\SynchronizationService'); + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof \SpecificPrice) { - if (isset($specificPrice->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'delete'); - $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], - Config::INCREMENTAL_TYPE_DELETE, - date(DATE_ATOM), - $this->shopId, - false - ); - } + if ($specificPrice instanceof \SpecificPrice && isset($specificPrice->id)) { + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'delete'); + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], + Config::INCREMENTAL_TYPE_DELETE, + date(DATE_ATOM), + $this->shopId, + false + ); } } } diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index 63d45366..08c83fbf 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -76,8 +76,8 @@ function upgrade_module_4_0_0() } } - $updateIncrementalTable .= ' - ON DUPLICATE KEY UPDATE + $updateIncrementalTable .= ' + ON DUPLICATE KEY UPDATE type = VALUES(type), id_object = VALUES(id_object), id_shop = VALUES(id_shop), @@ -94,7 +94,6 @@ function upgrade_module_4_0_0() // Drop eventbus_deleted_objects table $dropDeletedTable = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'eventbus_deleted_objects`'; - $dropDeletedTableResult = (bool) $db->query($dropDeletedTable); - return $dropDeletedTableResult; + return (bool) $db->query($dropDeletedTable); } From 69b17b8081e1f06f9c8579e38900147e770434a9 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 20 Nov 2024 10:31:32 +0100 Subject: [PATCH 147/162] fix: unused var --- src/Repository/AbstractRepository.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index f55ab60d..ad95ec90 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -135,8 +135,6 @@ protected function checkIfTableExist($tableName) */ protected function runQuery($disableCurrentExplain = null) { - $result = []; - $explainSql = false; if (defined('PS_EVENTBUS_EXPLAIN_SQL_ENABLED')) { From bb941a01dba7d2769ba9a582e26bf11a90521da4 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 20 Nov 2024 10:42:54 +0100 Subject: [PATCH 148/162] fix: php-stan --- src/Service/ShopContent/SpecificPricesService.php | 8 +++----- src/Traits/UseHooks.php | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Service/ShopContent/SpecificPricesService.php b/src/Service/ShopContent/SpecificPricesService.php index 4963371b..eb080900 100644 --- a/src/Service/ShopContent/SpecificPricesService.php +++ b/src/Service/ShopContent/SpecificPricesService.php @@ -301,7 +301,7 @@ private function getPriceStatic( * @param int $decimals * @param bool $onlyReduc * @param bool $useReduc - * @param null $specificPrice + * @param array $specificPrice * @param bool $useGroupReduction * @param int $idCustomization * @@ -348,7 +348,7 @@ private function priceCalculation( } } - if ($idShop !== null && $context->shop->id != (int) $idShop) { + if ($idShop && $context->shop->id != (int) $idShop) { $context->shop = new \Shop((int) $idShop); } @@ -356,8 +356,6 @@ private function priceCalculation( $idProductAttribute = \Product::getDefaultAttribute($idProduct); } - // reference parameter is filled before any returns - /** @var array $specificPrice */ $specificPrice = $this->getSpecificPrice($specificPriceId); // fetch price & attribute price @@ -365,7 +363,7 @@ private function priceCalculation( if (!isset($pricesLevel2[$cacheId2])) { $result = $this->productRepository->getProductPriceAndDeclinations($idProduct); - if (is_array($result) && count($result)) { + if ($result) { foreach ($result as $row) { $array_tmp = [ 'price' => $row['price'], diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index ed246a71..1a3af64d 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -1659,7 +1659,6 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); - /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; if ($specificPrice instanceof \SpecificPrice && isset($specificPrice->id)) { @@ -1687,7 +1686,7 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof \SpecificPrice && isset($specificPrice->id)) { + if ($specificPrice->id) { $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], @@ -1712,7 +1711,7 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) /** @var \SpecificPrice $specificPrice */ $specificPrice = $parameters['object']; - if ($specificPrice instanceof \SpecificPrice && isset($specificPrice->id)) { + if ($specificPrice->id) { $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'delete'); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], From 07ffa00ed11fd9bcbd28b6487fa636ea5da89042 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 20 Nov 2024 12:45:47 +0100 Subject: [PATCH 149/162] fix: fixture 1.6 --- e2e/src/fixtures/1.6/carriers.json | 16 +- e2e/src/fixtures/1.6/orders.json | 170 +++++++++++++++++--- src/Repository/CarrierRepository.php | 22 ++- src/Service/ShopContent/CarriersService.php | 2 +- 4 files changed, 174 insertions(+), 36 deletions(-) diff --git a/e2e/src/fixtures/1.6/carriers.json b/e2e/src/fixtures/1.6/carriers.json index 25fa1229..95f27c3c 100644 --- a/e2e/src/fixtures/1.6/carriers.json +++ b/e2e/src/fixtures/1.6/carriers.json @@ -6,13 +6,9 @@ "id_carrier": "1", "id_reference": "1", "name": "0", - "carrier_taxes_rates_group_id": "1", "url": "", "active": true, "deleted": false, - "shipping_handling": 0, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": true, @@ -25,6 +21,10 @@ "max_weight": 0, "grade": 0, "delay": "Pick up in-store", + "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } @@ -36,13 +36,9 @@ "id_carrier": "2", "id_reference": "2", "name": "My carrier", - "carrier_taxes_rates_group_id": "1", "url": "", "active": true, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, @@ -55,6 +51,10 @@ "max_weight": 0, "grade": 0, "delay": "Delivery next day!", + "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } diff --git a/e2e/src/fixtures/1.6/orders.json b/e2e/src/fixtures/1.6/orders.json index 346878e8..68d19afb 100644 --- a/e2e/src/fixtures/1.6/orders.json +++ b/e2e/src/fixtures/1.6/orders.json @@ -11,22 +11,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 55, "total_paid_tax_incl": 55, - "new_customer": true, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "cheque", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 2, - "created_at": "2024-07-16T15:33:56+0200", - "updated_at": "2024-07-16T15:33:56+0200", + "created_at": "2024-08-22T12:24:54+0200", + "updated_at": "2024-08-22T12:24:54+0200", "id_carrier": 2, "payment_name": "cheque", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Canceled", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 53, + "total_products_wt": 53, + "total_shipping_tax_incl": 2, + "total_shipping_tax_excl": 2, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": true, "total_paid_tax": 0, "delivery_country_code": "US", "invoice_country_code": "US" @@ -44,22 +68,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 75.9, "total_paid_tax_incl": 75.9, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "cheque", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 2, - "created_at": "2024-07-16T15:33:56+0200", - "updated_at": "2024-07-16T15:33:56+0200", + "created_at": "2024-08-22T12:24:54+0200", + "updated_at": "2024-08-22T12:24:54+0200", "id_carrier": 2, "payment_name": "cheque", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Awaiting check payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 73, + "total_products_wt": 73, + "total_shipping_tax_incl": 2, + "total_shipping_tax_excl": 2, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 0, "delivery_country_code": "US", "invoice_country_code": "US" @@ -77,22 +125,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 76.01, "total_paid_tax_incl": 76.01, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "cheque", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 2, - "created_at": "2024-07-16T15:33:56+0200", - "updated_at": "2024-07-16T15:33:56+0200", + "created_at": "2024-08-22T12:24:54+0200", + "updated_at": "2024-08-22T12:24:54+0200", "id_carrier": 2, "payment_name": "cheque", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Payment error", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 74, + "total_products_wt": 74, + "total_shipping_tax_incl": 2, + "total_shipping_tax_excl": 2, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 0, "delivery_country_code": "US", "invoice_country_code": "US" @@ -110,22 +182,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 89.89, "total_paid_tax_incl": 89.89, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "cheque", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 2, - "created_at": "2024-07-16T15:33:56+0200", - "updated_at": "2024-07-16T15:33:56+0200", + "created_at": "2024-08-22T12:24:54+0200", + "updated_at": "2024-08-22T12:24:54+0200", "id_carrier": 2, "payment_name": "cheque", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Awaiting check payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 87, + "total_products_wt": 87, + "total_shipping_tax_incl": 2, + "total_shipping_tax_excl": 2, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 0, "delivery_country_code": "US", "invoice_country_code": "US" @@ -143,22 +239,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 71.51, "total_paid_tax_incl": 71.51, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "bankwire", "payment_mode": "Bank wire", "total_paid_real": "0.000000", "shipping_cost": 2, - "created_at": "2024-07-16T15:33:56+0200", - "updated_at": "2024-07-16T15:33:56+0200", + "created_at": "2024-08-22T12:24:54+0200", + "updated_at": "2024-08-22T12:24:54+0200", "id_carrier": 2, "payment_name": "bankwire", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Awaiting bank wire payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 69, + "total_products_wt": 69, + "total_shipping_tax_incl": 2, + "total_shipping_tax_excl": 2, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 0, "delivery_country_code": "US", "invoice_country_code": "US" diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php index 3e970229..6fd6213e 100644 --- a/src/Repository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -59,8 +59,26 @@ public function generateFullQuery($langIso, $withSelecParameters) ; if ($withSelecParameters) { - $this->query->select('c.*') - ->select('cl.delay AS delay'); + $this->query + ->select('c.id_carrier') + ->select('c.id_reference') + ->select('c.name') + ->select('c.url') + ->select('c.active') + ->select('c.deleted') + ->select('c.range_behavior AS disable_carrier_when_out_of_range') + ->select('c.is_module') + ->select('c.is_free') + ->select('c.shipping_external') + ->select('c.need_range') + ->select('c.external_module_name') + ->select('c.max_width') + ->select('c.max_height') + ->select('c.max_depth') + ->select('c.max_weight') + ->select('c.grade') + ->select('cl.delay AS delay') + ; } } diff --git a/src/Service/ShopContent/CarriersService.php b/src/Service/ShopContent/CarriersService.php index f59b7065..701a4d2b 100644 --- a/src/Service/ShopContent/CarriersService.php +++ b/src/Service/ShopContent/CarriersService.php @@ -163,7 +163,7 @@ private function castCarriers(&$carriers) $carrier['shipping_handling'] = (float) $shippingHandling; $carrier['free_shipping_starts_at_price'] = (float) $freeShippingStartsAtPrice; $carrier['free_shipping_starts_at_weight'] = (float) $freeShippingStartsAtWeight; - $carrier['disable_carrier_when_out_of_range'] = (bool) $carrier['range_behavior']; + $carrier['disable_carrier_when_out_of_range'] = (bool) $carrier['disable_carrier_when_out_of_range']; $carrier['is_module'] = (bool) $carrier['is_module']; $carrier['is_free'] = (bool) $carrier['is_free']; $carrier['shipping_external'] = (bool) $carrier['shipping_external']; From bc8be576412301730fff344c04943e89e098d219 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 20 Nov 2024 15:11:08 +0100 Subject: [PATCH 150/162] fix: fixture of another tests --- e2e/src/fixtures/1.7/carrier_details.json | 138 ++-------------- e2e/src/fixtures/1.7/carriers.json | 76 ++++----- e2e/src/fixtures/1.7/orders.json | 170 +++++++++++++++++--- e2e/src/fixtures/8/carriers.json | 40 ++--- src/Service/ShopContent/BundlesService.php | 5 +- src/Service/ShopContent/OrdersService.php | 4 + src/Service/ShopContent/ProductsService.php | 1 + 7 files changed, 217 insertions(+), 217 deletions(-) diff --git a/e2e/src/fixtures/1.7/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json index 309a9a16..5197325e 100644 --- a/e2e/src/fixtures/1.7/carrier_details.json +++ b/e2e/src/fixtures/1.7/carrier_details.json @@ -1,20 +1,4 @@ [ - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5, - "id_carrier_detail": "1" - } - }, { "action": "upsert", "collection": "carrier_details", @@ -25,60 +9,12 @@ "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "country_ids": "", + "state_ids": "", "price": 5, "id_carrier_detail": "1" } }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "FR", - "state_ids": "", - "price": 3, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "FR", - "state_ids": "", - "price": 1, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "4" - } - }, { "action": "upsert", "collection": "carrier_details", @@ -89,8 +25,8 @@ "shipping_method": "range_price", "delimiter1": 0, "delimiter2": 50, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "country_ids": "", + "state_ids": "", "price": 4, "id_carrier_detail": "2" } @@ -105,8 +41,8 @@ "shipping_method": "range_price", "delimiter1": 50, "delimiter2": 100, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "country_ids": "", + "state_ids": "", "price": 2, "id_carrier_detail": "3" } @@ -121,57 +57,9 @@ "shipping_method": "range_price", "delimiter1": 100, "delimiter2": 200, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "FR", + "country_ids": "", "state_ids": "", "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "FR", - "state_ids": "", - "price": 2, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5, "id_carrier_detail": "4" } }, @@ -185,8 +73,8 @@ "shipping_method": "range_weight", "delimiter1": 0, "delimiter2": 1, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "country_ids": "", + "state_ids": "", "price": 0, "id_carrier_detail": "2" } @@ -201,8 +89,8 @@ "shipping_method": "range_weight", "delimiter1": 1, "delimiter2": 3, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "country_ids": "", + "state_ids": "", "price": 3, "id_carrier_detail": "3" } @@ -217,8 +105,8 @@ "shipping_method": "range_weight", "delimiter1": 3, "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "country_ids": "", + "state_ids": "", "price": 6, "id_carrier_detail": "4" } diff --git a/e2e/src/fixtures/1.7/carriers.json b/e2e/src/fixtures/1.7/carriers.json index edb2df8d..749c3334 100644 --- a/e2e/src/fixtures/1.7/carriers.json +++ b/e2e/src/fixtures/1.7/carriers.json @@ -3,19 +3,15 @@ "action": "upsert", "collection": "carriers", "properties": { - "id_carrier": "3", - "id_reference": "3", - "name": "My cheap carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "1", + "id_reference": "1", + "name": "0", "url": "", - "active": false, + "active": true, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, - "is_free": false, + "is_free": true, "shipping_external": false, "need_range": false, "external_module_name": "", @@ -24,7 +20,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Buy more to pay less!", + "delay": "Pick up in-store", + "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } @@ -33,16 +33,12 @@ "action": "upsert", "collection": "carriers", "properties": { - "id_carrier": "4", - "id_reference": "4", - "name": "My light carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "2", + "id_reference": "2", + "name": "My carrier", "url": "", - "active": false, + "active": true, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, @@ -54,7 +50,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "The lighter the cheaper!", + "delay": "Delivery next day!", + "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } @@ -63,19 +63,15 @@ "action": "upsert", "collection": "carriers", "properties": { - "id_carrier": "1", - "id_reference": "1", - "name": "0", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "3", + "id_reference": "3", + "name": "My cheap carrier", "url": "", - "active": true, + "active": false, "deleted": false, - "shipping_handling": 0, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, - "is_free": true, + "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", @@ -84,7 +80,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Pick up in-store", + "delay": "Buy more to pay less!", + "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } @@ -93,16 +93,12 @@ "action": "upsert", "collection": "carriers", "properties": { - "id_carrier": "2", - "id_reference": "2", - "name": "My carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "4", + "id_reference": "4", + "name": "My light carrier", "url": "", - "active": true, + "active": false, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, @@ -114,7 +110,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Delivery next day!", + "delay": "The lighter the cheaper!", + "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } diff --git a/e2e/src/fixtures/1.7/orders.json b/e2e/src/fixtures/1.7/orders.json index e1cf8c9a..dfcba136 100644 --- a/e2e/src/fixtures/1.7/orders.json +++ b/e2e/src/fixtures/1.7/orders.json @@ -11,22 +11,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 66.8, "total_paid_tax_incl": 68.2, - "new_customer": true, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100", + "created_at": "2024-10-26T00:32:43+0200", + "updated_at": "2024-10-26T00:32:43+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Canceled", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 59, + "total_products_wt": 59, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": true, "total_paid_tax": 1.4000000000000057, "delivery_country_code": "US", "invoice_country_code": "US" @@ -44,22 +68,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 169.9, "total_paid_tax_incl": 169.9, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 0, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100", + "created_at": "2024-10-26T00:32:43+0200", + "updated_at": "2024-10-26T00:32:43+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Awaiting check payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 169, + "total_products_wt": 169, + "total_shipping_tax_incl": 0, + "total_shipping_tax_excl": 0, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 0, "delivery_country_code": "US", "invoice_country_code": "US" @@ -77,22 +125,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 19.9, "total_paid_tax_incl": 21.3, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100", + "created_at": "2024-10-26T00:32:43+0200", + "updated_at": "2024-10-26T00:32:43+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Payment error", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 12, + "total_products_wt": 12, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 1.4000000000000021, "delivery_country_code": "US", "invoice_country_code": "US" @@ -110,22 +182,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 19.9, "total_paid_tax_incl": 21.3, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_checkpayment", "payment_mode": "Payment by check", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100", + "created_at": "2024-10-26T00:32:43+0200", + "updated_at": "2024-10-26T00:32:43+0200", "id_carrier": 2, "payment_name": "ps_checkpayment", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Awaiting check payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 12, + "total_products_wt": 12, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 1.4000000000000021, "delivery_country_code": "US", "invoice_country_code": "US" @@ -143,22 +239,46 @@ "conversion_rate": 1, "total_paid_tax_excl": 25.9, "total_paid_tax_incl": 27.3, - "new_customer": false, "currency": "EUR", - "refund": 0, - "refund_tax_excl": 0, "payment_module": "ps_wirepayment", "payment_mode": "Bank wire", "total_paid_real": "0.000000", "shipping_cost": 7, - "created_at": "2023-12-20T22:56:49+0100", - "updated_at": "2023-12-20T22:56:49+0100", + "created_at": "2024-10-26T00:32:43+0200", + "updated_at": "2024-10-26T00:32:43+0200", "id_carrier": 2, "payment_name": "ps_wirepayment", "is_validated": "0", "is_paid": false, "is_shipped": "0", "status_label": "Awaiting bank wire payment", + "id_shop_group": 1, + "id_shop": 1, + "id_lang": 1, + "id_currency": 1, + "recyclable": false, + "gift": false, + "total_discounts": 0, + "total_discounts_tax_incl": 0, + "total_discounts_tax_excl": 0, + "total_products": 18, + "total_products_wt": 18, + "total_shipping_tax_incl": 8, + "total_shipping_tax_excl": 7, + "carrier_tax_rate": 0, + "total_wrapping": 0, + "total_wrapping_tax_incl": 0, + "total_wrapping_tax_excl": 0, + "round_mode": 0, + "round_type": 0, + "invoice_number": 0, + "delivery_number": 0, + "invoice_date": "0000-00-00 00:00:00", + "delivery_date": "0000-00-00 00:00:00", + "valid": false, + "refund": 0, + "refund_tax_excl": 0, + "new_customer": false, "total_paid_tax": 1.4000000000000021, "delivery_country_code": "US", "invoice_country_code": "US" diff --git a/e2e/src/fixtures/8/carriers.json b/e2e/src/fixtures/8/carriers.json index 2315ed6b..7e6f3f13 100644 --- a/e2e/src/fixtures/8/carriers.json +++ b/e2e/src/fixtures/8/carriers.json @@ -9,15 +9,12 @@ "url": "", "active": true, "deleted": false, - "shipping_handling": 0, - "range_behavior": "0", + "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": true, "shipping_external": false, "need_range": false, "external_module_name": "", - "shipping_method": "0", - "position": "0", "max_width": 0, "max_height": 0, "max_depth": 0, @@ -25,13 +22,12 @@ "grade": 0, "delay": "Pick up in-store", "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - }, - "action": "upsert" + } }, { "action": "upsert", @@ -43,15 +39,12 @@ "url": "", "active": true, "deleted": false, - "shipping_handling": 2, - "range_behavior": "0", + "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", - "shipping_method": "0", - "position": "1", "max_width": 0, "max_height": 0, "max_depth": 0, @@ -59,13 +52,12 @@ "grade": 0, "delay": "Delivery next day!", "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - }, - "action": "upsert" + } }, { "action": "upsert", @@ -77,15 +69,12 @@ "url": "", "active": false, "deleted": false, - "shipping_handling": 2, - "range_behavior": "0", + "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", - "shipping_method": "2", - "position": "2", "max_width": 0, "max_height": 0, "max_depth": 0, @@ -93,13 +82,12 @@ "grade": 0, "delay": "Buy more to pay less!", "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - }, - "action": "upsert" + } }, { "action": "upsert", @@ -111,15 +99,12 @@ "url": "", "active": false, "deleted": false, - "shipping_handling": 2, - "range_behavior": "0", + "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", - "shipping_method": "1", - "position": "3", "max_width": 0, "max_height": 0, "max_depth": 0, @@ -127,12 +112,11 @@ "grade": 0, "delay": "The lighter the cheaper!", "carrier_taxes_rates_group_id": "1", + "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, - "disable_carrier_when_out_of_range": false, "currency": "EUR", "weight_unit": "kg" - }, - "action": "upsert" + } } ] diff --git a/src/Service/ShopContent/BundlesService.php b/src/Service/ShopContent/BundlesService.php index 512c86e7..7645e524 100644 --- a/src/Service/ShopContent/BundlesService.php +++ b/src/Service/ShopContent/BundlesService.php @@ -109,8 +109,11 @@ public function getFullSyncContentLeft($offset, $limit, $langIso) private function castBundles(&$bundles, $langIso) { foreach ($bundles as &$bundle) { - $bundle['id_product'] = $bundle['id_product_item']; + $bundle['id_product'] = (string) $bundle['id_product_item']; $bundle['unique_product_id'] = "{$bundle['id_bundle']}-{$bundle['product_id_attribute']}-{$langIso}"; + $bundle['id_bundle'] = (string) $bundle['id_bundle']; + $bundle['id_product_attribute'] = (string) $bundle['id_product_attribute']; + $bundle['quantity'] = (string) $bundle['quantity']; unset($bundle['product_id_attribute']); unset($bundle['id_product_item']); diff --git a/src/Service/ShopContent/OrdersService.php b/src/Service/ShopContent/OrdersService.php index a6f70f39..d4594e92 100644 --- a/src/Service/ShopContent/OrdersService.php +++ b/src/Service/ShopContent/OrdersService.php @@ -123,6 +123,7 @@ private function castOrders(&$orders, $langIso) { foreach ($orders as &$order) { $order['id_order'] = (int) $order['id_order']; + $order['id_cart'] = (string) $order['id_cart']; $order['id_customer'] = (int) $order['id_customer']; $order['current_state'] = (int) $order['current_state']; $order['conversion_rate'] = (float) $order['conversion_rate']; @@ -161,6 +162,9 @@ private function castOrders(&$orders, $langIso) $order['delivery_number'] = (int) $order['delivery_number']; $order['valid'] = (bool) $order['valid']; + $order['is_shipped'] = (string) $order['is_shipped']; + $order['is_validated'] = (string) $order['is_validated']; + $this->castAddressIsoCodes($order); // remove extra properties diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index f082f179..010e19b4 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -178,6 +178,7 @@ private function castProducts(&$products) $product['id_attribute'] = (int) $product['id_attribute']; $product['id_category_default'] = (int) $product['id_category_default']; $product['quantity'] = (int) $product['quantity']; + $product['additional_delivery_times'] = (string) $product['additional_delivery_times']; $product['weight'] = (float) $product['weight']; $product['active'] = $product['active'] == '1'; $product['manufacturer'] = (string) $product['manufacturer']; From db549563fd101b817322ae508dbd91cc084cf5b3 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 20 Nov 2024 17:45:13 +0100 Subject: [PATCH 151/162] fix: carrier details fixtures --- e2e/src/fixtures/1.7/carrier_details.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e/src/fixtures/1.7/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json index 5197325e..d94b4acb 100644 --- a/e2e/src/fixtures/1.7/carrier_details.json +++ b/e2e/src/fixtures/1.7/carrier_details.json @@ -27,7 +27,7 @@ "delimiter2": 50, "country_ids": "", "state_ids": "", - "price": 4, + "price": 0, "id_carrier_detail": "2" } }, @@ -43,7 +43,7 @@ "delimiter2": 100, "country_ids": "", "state_ids": "", - "price": 2, + "price": 0, "id_carrier_detail": "3" } }, @@ -75,7 +75,7 @@ "delimiter2": 1, "country_ids": "", "state_ids": "", - "price": 0, + "price": 6, "id_carrier_detail": "2" } }, @@ -84,14 +84,14 @@ "collection": "carrier_details", "properties": { "id_reference": "4", - "id_zone": "2", + "id_zone": "1", "id_range": "3", "shipping_method": "range_weight", "delimiter1": 1, "delimiter2": 3, "country_ids": "", "state_ids": "", - "price": 3, + "price": 6, "id_carrier_detail": "3" } }, From 42cc6f3421bc126c40e6b3350d3b2ac06d7be86a Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 20 Nov 2024 17:45:20 +0100 Subject: [PATCH 152/162] fix: carrier details fixtures --- src/Repository/CarrierDetailRepository.php | 10 +++++++- upgrade/Upgrade-3.2.1.php | 27 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Repository/CarrierDetailRepository.php b/src/Repository/CarrierDetailRepository.php index 5a33b8ac..04aee10a 100644 --- a/src/Repository/CarrierDetailRepository.php +++ b/src/Repository/CarrierDetailRepository.php @@ -101,7 +101,15 @@ public function generateFullQuery($langIso, $withSelecParameters) SEPARATOR \',\' ) AS state_ids ') - ->select('d.price') + ->select(' + ( + SELECT d2.price + FROM ps_delivery d2 + WHERE d2.id_carrier = d.id_carrier + ORDER BY d2.id_delivery DESC + LIMIT 1 + ) AS price + ') ; $this->query->groupBy('ca.id_reference, co.id_zone, id_range'); diff --git a/upgrade/Upgrade-3.2.1.php b/upgrade/Upgrade-3.2.1.php index aa0e23b3..d41f0e60 100644 --- a/upgrade/Upgrade-3.2.1.php +++ b/upgrade/Upgrade-3.2.1.php @@ -1,4 +1,31 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ +if (!defined('_PS_VERSION_')) { + exit; +} /** * @return bool From 2a962184838915b44a0faf3cdf0a91946145dfa6 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 21 Nov 2024 11:13:10 +0100 Subject: [PATCH 153/162] fix: carrier details fixtures --- e2e/src/fixtures/1.6/carrier_details.json | 35 +--- e2e/src/fixtures/1.7/carrier_details.json | 115 +---------- e2e/src/fixtures/8/carrier_details.json | 227 +-------------------- e2e/src/fixtures/9/carrier_details.json | 227 +-------------------- src/Repository/CarrierDetailRepository.php | 2 +- 5 files changed, 5 insertions(+), 601 deletions(-) diff --git a/e2e/src/fixtures/1.6/carrier_details.json b/e2e/src/fixtures/1.6/carrier_details.json index b18a4766..fe51488c 100644 --- a/e2e/src/fixtures/1.6/carrier_details.json +++ b/e2e/src/fixtures/1.6/carrier_details.json @@ -1,34 +1 @@ -[ - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "id_carrier_detail": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "GB", - "state_ids": "", - "price": 5 - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "2", - "id_range": "1", - "id_carrier_detail": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "", - "state_ids": "", - "price": 5 - } - } -] +[] diff --git a/e2e/src/fixtures/1.7/carrier_details.json b/e2e/src/fixtures/1.7/carrier_details.json index d94b4acb..fe51488c 100644 --- a/e2e/src/fixtures/1.7/carrier_details.json +++ b/e2e/src/fixtures/1.7/carrier_details.json @@ -1,114 +1 @@ -[ - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "2", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "", - "state_ids": "", - "price": 5, - "id_carrier_detail": "1" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "", - "state_ids": "", - "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "", - "state_ids": "", - "price": 0, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "", - "state_ids": "", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "", - "state_ids": "", - "price": 6, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "", - "state_ids": "", - "price": 6, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "", - "state_ids": "", - "price": 6, - "id_carrier_detail": "4" - } - } -] +[] diff --git a/e2e/src/fixtures/8/carrier_details.json b/e2e/src/fixtures/8/carrier_details.json index 309a9a16..fe51488c 100644 --- a/e2e/src/fixtures/8/carrier_details.json +++ b/e2e/src/fixtures/8/carrier_details.json @@ -1,226 +1 @@ -[ - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5, - "id_carrier_detail": "1" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "2", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 5, - "id_carrier_detail": "1" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "FR", - "state_ids": "", - "price": 3, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "FR", - "state_ids": "", - "price": 1, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 4, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 2, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "FR", - "state_ids": "", - "price": 2, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 3, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 6, - "id_carrier_detail": "4" - } - } -] +[] diff --git a/e2e/src/fixtures/9/carrier_details.json b/e2e/src/fixtures/9/carrier_details.json index 309a9a16..fe51488c 100644 --- a/e2e/src/fixtures/9/carrier_details.json +++ b/e2e/src/fixtures/9/carrier_details.json @@ -1,226 +1 @@ -[ - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5, - "id_carrier_detail": "1" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "2", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 5, - "id_carrier_detail": "1" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "FR", - "state_ids": "", - "price": 3, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "FR", - "state_ids": "", - "price": 1, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 4, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 2, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "FR", - "state_ids": "", - "price": 2, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 3, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 6, - "id_carrier_detail": "4" - } - } -] +[] diff --git a/src/Repository/CarrierDetailRepository.php b/src/Repository/CarrierDetailRepository.php index 04aee10a..ce51b3bf 100644 --- a/src/Repository/CarrierDetailRepository.php +++ b/src/Repository/CarrierDetailRepository.php @@ -48,9 +48,9 @@ public function generateFullQuery($langIso, $withSelecParameters) $this->query ->innerJoin('delivery', 'd', 'ca.id_carrier = d.id_carrier AND d.id_zone IS NOT NULL') + ->innerJoin('country', 'co', 'd.id_zone = co.id_zone AND co.iso_code IS NOT NULL AND co.active = 1') ->leftJoin('range_weight', 'rw', 'ca.id_carrier = rw.id_carrier AND d.id_range_weight = rw.id_range_weight') ->leftJoin('range_price', 'rp', 'ca.id_carrier = rp.id_carrier AND d.id_range_price = rp.id_range_price') - ->leftJoin('country', 'co', 'd.id_zone = co.id_zone AND co.iso_code IS NOT NULL AND co.active = 1') ->leftJoin('state', 's', 'co.id_zone = s.id_zone AND co.id_country = s.id_country AND s.active = 1') ->leftJoin('configuration', 'conf', 'conf.name = "PS_SHIPPING_METHOD"') ; From 0edc15972ef950f18064dc55f4027e46373549bf Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 21 Nov 2024 15:32:43 +0100 Subject: [PATCH 154/162] fix: 1.6 fixtures --- e2e/src/fixtures/1.6/carrier_details.json | 20 ++++++++- e2e/src/fixtures/1.6/products.json | 45 +++++++++++++++++++++ src/Config/Config.php | 22 +++------- src/Service/ShopContent/ProductsService.php | 4 +- 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/e2e/src/fixtures/1.6/carrier_details.json b/e2e/src/fixtures/1.6/carrier_details.json index fe51488c..32492964 100644 --- a/e2e/src/fixtures/1.6/carrier_details.json +++ b/e2e/src/fixtures/1.6/carrier_details.json @@ -1 +1,19 @@ -[] +[ + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "1", + "id_range": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "GB", + "state_ids": "", + "price": 5, + "id_carrier_detail": "1" + } + } + ] + \ No newline at end of file diff --git a/e2e/src/fixtures/1.6/products.json b/e2e/src/fixtures/1.6/products.json index 6f2c6a5a..1107067e 100644 --- a/e2e/src/fixtures/1.6/products.json +++ b/e2e/src/fixtures/1.6/products.json @@ -56,6 +56,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > T-shirts", "category_id_path": "1 > 2 > 3 > 4 > 5", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -117,6 +118,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > T-shirts", "category_id_path": "1 > 2 > 3 > 4 > 5", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -178,6 +180,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > T-shirts", "category_id_path": "1 > 2 > 3 > 4 > 5", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -239,6 +242,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > T-shirts", "category_id_path": "1 > 2 > 3 > 4 > 5", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -300,6 +304,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > T-shirts", "category_id_path": "1 > 2 > 3 > 4 > 5", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -361,6 +366,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > T-shirts", "category_id_path": "1 > 2 > 3 > 4 > 5", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -422,6 +428,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > Blouses", "category_id_path": "1 > 2 > 3 > 4 > 7", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -483,6 +490,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > Blouses", "category_id_path": "1 > 2 > 3 > 4 > 7", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -544,6 +552,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > Blouses", "category_id_path": "1 > 2 > 3 > 4 > 7", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -605,6 +614,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > Blouses", "category_id_path": "1 > 2 > 3 > 4 > 7", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -666,6 +676,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > Blouses", "category_id_path": "1 > 2 > 3 > 4 > 7", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -727,6 +738,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Tops > Blouses", "category_id_path": "1 > 2 > 3 > 4 > 7", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -788,6 +800,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Casual Dresses", "category_id_path": "1 > 2 > 3 > 8 > 9", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -849,6 +862,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Casual Dresses", "category_id_path": "1 > 2 > 3 > 8 > 9", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -910,6 +924,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Casual Dresses", "category_id_path": "1 > 2 > 3 > 8 > 9", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -971,6 +986,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Evening Dresses", "category_id_path": "1 > 2 > 3 > 8 > 10", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1032,6 +1048,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Evening Dresses", "category_id_path": "1 > 2 > 3 > 8 > 10", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1093,6 +1110,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Evening Dresses", "category_id_path": "1 > 2 > 3 > 8 > 10", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1154,6 +1172,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Evening Dresses", "category_id_path": "1 > 2 > 3 > 8 > 10", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1215,6 +1234,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Evening Dresses", "category_id_path": "1 > 2 > 3 > 8 > 10", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1276,6 +1296,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Evening Dresses", "category_id_path": "1 > 2 > 3 > 8 > 10", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1337,6 +1358,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1398,6 +1420,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1459,6 +1482,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1520,6 +1544,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1581,6 +1606,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1642,6 +1668,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1703,6 +1730,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1764,6 +1792,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1825,6 +1854,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1886,6 +1916,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -1947,6 +1978,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2008,6 +2040,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2069,6 +2102,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2130,6 +2164,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2191,6 +2226,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2252,6 +2288,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2313,6 +2350,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2374,6 +2412,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2435,6 +2474,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2496,6 +2536,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2557,6 +2598,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2618,6 +2660,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2679,6 +2722,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } @@ -2740,6 +2784,7 @@ "sale_tax": 0, "category_path": "Root > Home > Women > Dresses > Summer Dresses", "category_id_path": "1 > 2 > 3 > 8 > 11", + "additional_delivery_times": "", "isbn": "", "mpn": "" } diff --git a/src/Config/Config.php b/src/Config/Config.php index 66a82087..e263df59 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -34,13 +34,16 @@ class Config { const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s'; - const INCREMENTAL_SYNC_TABLE_NAME = 'eventbus_incremental_sync'; const INCREMENTAL_SYNC_TABLE_SIZE_CHECK_MOD = 20; const INCREMENTAL_SYNC_MAX_TABLE_SIZE = 100000; + const INCREMENTAL_TYPE_UPSERT = 'upsert'; + const INCREMENTAL_TYPE_DELETE = 'delete'; const SYNC_API_MAX_TIMEOUT = 5; - const COLLECTOR_MAX_TIMEOUT = 30; + const SYNC_SERVICE_NAME = 'PrestaShop\Module\PsEventbus\Service\SynchronizationService'; + const COLLECTOR_MULTIPART_BOUNDARY = 'ps_eventbus_boundary'; + const REFRESH_TOKEN_ERROR_CODE = 452; const ENV_MISCONFIGURED_ERROR_CODE = 453; const DATABASE_QUERY_ERROR_CODE = 454; @@ -134,19 +137,4 @@ class Config self::COLLECTION_WISHLISTS, self::COLLECTION_WISHLIST_PRODUCTS, ]; - - const INCREMENTAL_TYPE_UPSERT = 'upsert'; - const INCREMENTAL_TYPE_DELETE = 'delete'; - - const SYNC_SERVICE_NAME = 'PrestaShop\Module\PsEventbus\Service\SynchronizationService'; - - /** - * @param mixed $message - * - * @return void - */ - public static function dev_log($message) - { - file_put_contents('/var/www/html/php.log', $message . PHP_EOL, FILE_APPEND); - } } diff --git a/src/Service/ShopContent/ProductsService.php b/src/Service/ShopContent/ProductsService.php index 010e19b4..1314fd70 100644 --- a/src/Service/ShopContent/ProductsService.php +++ b/src/Service/ShopContent/ProductsService.php @@ -183,8 +183,8 @@ private function castProducts(&$products) $product['active'] = $product['active'] == '1'; $product['manufacturer'] = (string) $product['manufacturer']; $product['default_category'] = (string) $product['default_category']; - $product['isbn'] = isset($product['isbn']) ? (string) $product['isbn'] : ''; - $product['mpn'] = isset($product['mpn']) ? (string) $product['mpn'] : ''; + $product['isbn'] = (string) $product['isbn']; + $product['mpn'] = (string) $product['mpn']; $product['ean'] = (string) $product['ean']; $product['upc'] = (string) $product['upc']; $product['is_default_attribute'] = $product['id_attribute'] === 0 ? true : $product['is_default_attribute'] == 1; From ca51eee81c8141e99f171ce8ad4b467536d3e8ff Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 21 Nov 2024 15:35:09 +0100 Subject: [PATCH 155/162] fix: php-cs-fixer --- src/Config/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index e263df59..99f6e6cf 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -41,7 +41,7 @@ class Config const SYNC_API_MAX_TIMEOUT = 5; const SYNC_SERVICE_NAME = 'PrestaShop\Module\PsEventbus\Service\SynchronizationService'; - + const COLLECTOR_MULTIPART_BOUNDARY = 'ps_eventbus_boundary'; const REFRESH_TOKEN_ERROR_CODE = 452; From 8997124dafcb186273c2bb13e4d32f55dc1858d7 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 21 Nov 2024 17:42:38 +0100 Subject: [PATCH 156/162] fix: test for 9.0 --- e2e/src/fixtures/8/carrier_details.json | 228 +++++++++++++++++++++- e2e/src/fixtures/9/categories.json | 9 - e2e/src/fixtures/9/manufacturers.json | 2 - e2e/src/fixtures/9/suppliers.json | 2 - src/Repository/CategoryRepository.php | 6 +- src/Repository/ManufacturerRepository.php | 6 +- src/Repository/SupplierRepository.php | 6 +- 7 files changed, 242 insertions(+), 17 deletions(-) diff --git a/e2e/src/fixtures/8/carrier_details.json b/e2e/src/fixtures/8/carrier_details.json index fe51488c..29bcbd62 100644 --- a/e2e/src/fixtures/8/carrier_details.json +++ b/e2e/src/fixtures/8/carrier_details.json @@ -1 +1,227 @@ -[] +[ + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "1", + "id_range": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "FR", + "state_ids": "", + "price": 5, + "id_carrier_detail": "1" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "2", + "id_range": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 5, + "id_carrier_detail": "1" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "2", + "shipping_method": "range_price", + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "FR", + "state_ids": "", + "price": 0, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "3", + "shipping_method": "range_price", + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "FR", + "state_ids": "", + "price": 0, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "4", + "shipping_method": "range_price", + "delimiter1": 100, + "delimiter2": 200, + "country_ids": "FR", + "state_ids": "", + "price": 0, + "id_carrier_detail": "4" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "2", + "shipping_method": "range_price", + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "3", + "shipping_method": "range_price", + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "4", + "shipping_method": "range_price", + "delimiter1": 100, + "delimiter2": 200, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "4" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "2", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 1, + "country_ids": "FR", + "state_ids": "", + "price": 6, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "3", + "shipping_method": "range_weight", + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "FR", + "state_ids": "", + "price": 6, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "4", + "shipping_method": "range_weight", + "delimiter1": 3, + "delimiter2": 10000, + "country_ids": "FR", + "state_ids": "", + "price": 6, + "id_carrier_detail": "4" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "2", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 1, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "3", + "shipping_method": "range_weight", + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "4", + "shipping_method": "range_weight", + "delimiter1": 3, + "delimiter2": 10000, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "4" + } + } + ] + \ No newline at end of file diff --git a/e2e/src/fixtures/9/categories.json b/e2e/src/fixtures/9/categories.json index 80f587d5..91c81ce5 100644 --- a/e2e/src/fixtures/9/categories.json +++ b/e2e/src/fixtures/9/categories.json @@ -10,7 +10,6 @@ "description": "", "link_rewrite": "root", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:21+0200", @@ -28,7 +27,6 @@ "description": "", "link_rewrite": "home", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:21+0200", @@ -46,7 +44,6 @@ "description": "PHA+RGlzY292ZXIgb3VyIGZhdm9yaXRlcyBmYXNoaW9uYWJsZSBkaXNjb3ZlcmllcywgYSBzZWxlY3Rpb24gb2YgY29vbCBpdGVtcyB0byBpbnRlZ3JhdGUgaW4geW91ciB3YXJkcm9iZS4gQ29tcG9zZSBhIHVuaXF1ZSBzdHlsZSB3aXRoIHBlcnNvbmFsaXR5IHdoaWNoIG1hdGNoZXMgeW91ciBvd24uPC9wPg==", "link_rewrite": "clothes", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:30+0200", @@ -64,7 +61,6 @@ "description": "PHA+VC1zaGlydHMsIHN3ZWF0ZXJzLCBob29kaWVzIGFuZCBtZW4ncyBhY2Nlc3Nvcmllcy4gRnJvbSBiYXNpY3MgdG8gb3JpZ2luYWwgY3JlYXRpb25zLCBmb3IgZXZlcnkgc3R5bGUuIDwvcD4=", "link_rewrite": "men", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:30+0200", @@ -82,7 +78,6 @@ "description": "PHA+VC1zaGlydHMsIHN3ZWF0ZXJzLCBob29kaWVzIGFuZCB3b21lbidzIGFjY2Vzc29yaWVzLiBGcm9tIGJhc2ljcyB0byBvcmlnaW5hbCBjcmVhdGlvbnMsIGZvciBldmVyeSBzdHlsZS4gPC9wPg==", "link_rewrite": "women", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:30+0200", @@ -100,7 +95,6 @@ "description": "PHA+SXRlbXMgYW5kIGFjY2Vzc29yaWVzIGZvciB5b3VyIGRlc2ssIGtpdGNoZW4gb3IgbGl2aW5nIHJvb20uIE1ha2UgeW91ciBob3VzZSBhIGhvbWUgd2l0aCBvdXIgZXllLWNhdGNoaW5nIGRlc2lnbnMuIDwvcD4=", "link_rewrite": "accessories", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:30+0200", @@ -118,7 +112,6 @@ "description": "PHA+Tm90ZWJvb2tzLCBhZ2VuZGFzLCBvZmZpY2UgYWNjZXNzb3JpZXMgYW5kIG1vcmUuIEV2ZXJ5dGhpbmcgeW91IG5lZWQgdG8gY29tYmluZSB0aGUgcGxlYXNhbnQgYW5kIHRoZSB1c2VmdWwsIGVpdGhlciBhdCB3b3JrIG9yIGF0IGhvbWUuIDwvcD4=", "link_rewrite": "stationery", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:30+0200", @@ -136,7 +129,6 @@ "description": "PHA+RGV0YWlscyBtYXR0ZXIhIExpdmVuIHVwIHlvdXIgaW50ZXJpb3Igd2l0aCBvdXIgc2VsZWN0aW9uIG9mIGhvbWUgYWNjZXNzb3JpZXMuIDwvcD4=", "link_rewrite": "home-accessories", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:30+0200", @@ -154,7 +146,6 @@ "description": "PHA+RnJhbWVkIHBvc3RlciBhbmQgdmVjdG9yIGltYWdlcywgYWxsIHlvdSBuZWVkIHRvIGdpdmUgcGVyc29uYWxpdHkgdG8geW91ciB3YWxscyBvciBicmluZyB5b3VyIGNyZWF0aXZlIHByb2plY3RzIHRvIGxpZmUuPC9wPg==", "link_rewrite": "art", "meta_title": "", - "meta_keywords": "", "meta_description": "", "iso_code": "en", "created_at": "2024-06-10T02:27:30+0200", diff --git a/e2e/src/fixtures/9/manufacturers.json b/e2e/src/fixtures/9/manufacturers.json index b1cffbfd..53f052c3 100644 --- a/e2e/src/fixtures/9/manufacturers.json +++ b/e2e/src/fixtures/9/manufacturers.json @@ -12,7 +12,6 @@ "description": "

Studio Design offers a range of items from ready-to-wear collections to contemporary objects. The brand has been presenting new ideas and trends since its creation in 2012.

", "short_description": "", "meta_title": "", - "meta_keywords": "", "meta_description": "", "id_shop": 1 } @@ -30,7 +29,6 @@ "description": "

Since 2010, Graphic Corner offers a large choice of quality posters, available on paper and many other formats.

", "short_description": "", "meta_title": "", - "meta_keywords": "", "meta_description": "", "id_shop": 1 } diff --git a/e2e/src/fixtures/9/suppliers.json b/e2e/src/fixtures/9/suppliers.json index b0060748..af6ce5b7 100644 --- a/e2e/src/fixtures/9/suppliers.json +++ b/e2e/src/fixtures/9/suppliers.json @@ -11,7 +11,6 @@ "id_lang": 1, "description": "", "meta_title": "", - "meta_keywords": "", "meta_description": "", "id_shop": 1 } @@ -28,7 +27,6 @@ "id_lang": 1, "description": "", "meta_title": "", - "meta_keywords": "", "meta_description": "", "id_shop": 1 } diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php index 083ff4e2..d2b2c2a0 100644 --- a/src/Repository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -64,12 +64,16 @@ public function generateFullQuery($langIso, $withSelecParameters) ->select('cl.description') ->select('cl.link_rewrite') ->select('cl.meta_title') - ->select('cl.meta_keywords') ->select('cl.meta_description') ->select('l.iso_code') ->select('c.date_add as created_at') ->select('c.date_upd as updated_at') ; + + // REMOVED HERE: https://github.com/PrestaShop/PrestaShop/commit/f37a8f61017654bae160b528a1a2eaf49edbdac0 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '9.0', '<')) { + $this->query->select('cl.meta_keywords'); + } } } diff --git a/src/Repository/ManufacturerRepository.php b/src/Repository/ManufacturerRepository.php index 599a44c8..b2bbc81a 100644 --- a/src/Repository/ManufacturerRepository.php +++ b/src/Repository/ManufacturerRepository.php @@ -61,10 +61,14 @@ public function generateFullQuery($langIso, $withSelecParameters) ->select('mal.description') ->select('mal.short_description') ->select('mal.meta_title') - ->select('mal.meta_keywords') ->select('mal.meta_description') ->select('mas.id_shop') ; + + // REMOVED HERE: https://github.com/PrestaShop/PrestaShop/commit/f37a8f61017654bae160b528a1a2eaf49edbdac0 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '9.0', '<')) { + $this->query->select('mal.meta_keywords'); + } } } diff --git a/src/Repository/SupplierRepository.php b/src/Repository/SupplierRepository.php index 38a6b6ca..9a2a81c4 100644 --- a/src/Repository/SupplierRepository.php +++ b/src/Repository/SupplierRepository.php @@ -63,10 +63,14 @@ public function generateFullQuery($langIso, $withSelecParameters) ->select('sul.id_lang') ->select('sul.description') ->select('sul.meta_title') - ->select('sul.meta_keywords') ->select('sul.meta_description') ->select('sus.id_shop') ; + + // REMOVED HERE: https://github.com/PrestaShop/PrestaShop/commit/f37a8f61017654bae160b528a1a2eaf49edbdac0 + if (defined('_PS_VERSION_') && version_compare(_PS_VERSION_, '9.0', '<')) { + $this->query->select('sul.meta_keywords'); + } } } From 92ef45fc3007df5562f9d463a5428ba7f4289fe4 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:38:23 +0100 Subject: [PATCH 157/162] fix: add product attribute shop content (#396) --- config/front/services.yml | 4 + e2e/src/fixtures/1.6/attributes.json | 1 + e2e/src/fixtures/1.6/carrier_details.json | 33 +- e2e/src/fixtures/1.7/attributes.json | 1 + e2e/src/fixtures/8/attributes.json | 1 + e2e/src/fixtures/8/carrier_details.json | 449 +++++++++--------- e2e/src/fixtures/9/attributes.json | 1 + e2e/src/helpers/shop-contents.ts | 1 + src/Config/Config.php | 2 + src/Service/ShopContent/AttributesService.php | 75 +++ src/Traits/UseHooks.php | 4 +- 11 files changed, 328 insertions(+), 244 deletions(-) create mode 100644 e2e/src/fixtures/1.6/attributes.json create mode 100644 e2e/src/fixtures/1.7/attributes.json create mode 100644 e2e/src/fixtures/8/attributes.json create mode 100644 e2e/src/fixtures/9/attributes.json create mode 100644 src/Service/ShopContent/AttributesService.php diff --git a/config/front/services.yml b/config/front/services.yml index 4efb7643..15959e8e 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -54,6 +54,10 @@ services: ############################################################################################################ ###################################### SHOP CONTENT SERVICES ############################################### ############################################################################################################ + PrestaShop\Module\PsEventbus\Service\ShopContent\AttributesService: + class: PrestaShop\Module\PsEventbus\Service\ShopContent\AttributesService + public: true + PrestaShop\Module\PsEventbus\Service\ShopContent\BundlesService: class: PrestaShop\Module\PsEventbus\Service\ShopContent\BundlesService public: true diff --git a/e2e/src/fixtures/1.6/attributes.json b/e2e/src/fixtures/1.6/attributes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.6/attributes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/1.6/carrier_details.json b/e2e/src/fixtures/1.6/carrier_details.json index 32492964..e0ec1665 100644 --- a/e2e/src/fixtures/1.6/carrier_details.json +++ b/e2e/src/fixtures/1.6/carrier_details.json @@ -1,19 +1,18 @@ [ - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "GB", - "state_ids": "", - "price": 5, - "id_carrier_detail": "1" - } + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "1", + "id_range": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "GB", + "state_ids": "", + "price": 5, + "id_carrier_detail": "1" } - ] - \ No newline at end of file + } +] diff --git a/e2e/src/fixtures/1.7/attributes.json b/e2e/src/fixtures/1.7/attributes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/1.7/attributes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/attributes.json b/e2e/src/fixtures/8/attributes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/8/attributes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/fixtures/8/carrier_details.json b/e2e/src/fixtures/8/carrier_details.json index 29bcbd62..89f4a992 100644 --- a/e2e/src/fixtures/8/carrier_details.json +++ b/e2e/src/fixtures/8/carrier_details.json @@ -1,227 +1,226 @@ [ - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "1", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 5, - "id_carrier_detail": "1" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "2", - "id_zone": "2", - "id_range": "1", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 5, - "id_carrier_detail": "1" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "FR", - "state_ids": "", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_price", - "delimiter1": 0, - "delimiter2": 50, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "3", - "shipping_method": "range_price", - "delimiter1": 50, - "delimiter2": 100, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "3", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_price", - "delimiter1": 100, - "delimiter2": 200, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 0, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "FR", - "state_ids": "", - "price": 6, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "FR", - "state_ids": "", - "price": 6, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "1", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "FR", - "state_ids": "", - "price": 6, - "id_carrier_detail": "4" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "2", - "shipping_method": "range_weight", - "delimiter1": 0, - "delimiter2": 1, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 6, - "id_carrier_detail": "2" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "3", - "shipping_method": "range_weight", - "delimiter1": 1, - "delimiter2": 3, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 6, - "id_carrier_detail": "3" - } - }, - { - "action": "upsert", - "collection": "carrier_details", - "properties": { - "id_reference": "4", - "id_zone": "2", - "id_range": "4", - "shipping_method": "range_weight", - "delimiter1": 3, - "delimiter2": 10000, - "country_ids": "US", - "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", - "price": 6, - "id_carrier_detail": "4" - } + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "1", + "id_range": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "FR", + "state_ids": "", + "price": 5, + "id_carrier_detail": "1" } - ] - \ No newline at end of file + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "2", + "id_zone": "2", + "id_range": "1", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 10000, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 5, + "id_carrier_detail": "1" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "2", + "shipping_method": "range_price", + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "FR", + "state_ids": "", + "price": 0, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "3", + "shipping_method": "range_price", + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "FR", + "state_ids": "", + "price": 0, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "1", + "id_range": "4", + "shipping_method": "range_price", + "delimiter1": 100, + "delimiter2": 200, + "country_ids": "FR", + "state_ids": "", + "price": 0, + "id_carrier_detail": "4" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "2", + "shipping_method": "range_price", + "delimiter1": 0, + "delimiter2": 50, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "3", + "shipping_method": "range_price", + "delimiter1": 50, + "delimiter2": 100, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "3", + "id_zone": "2", + "id_range": "4", + "shipping_method": "range_price", + "delimiter1": 100, + "delimiter2": 200, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 0, + "id_carrier_detail": "4" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "2", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 1, + "country_ids": "FR", + "state_ids": "", + "price": 6, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "3", + "shipping_method": "range_weight", + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "FR", + "state_ids": "", + "price": 6, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "1", + "id_range": "4", + "shipping_method": "range_weight", + "delimiter1": 3, + "delimiter2": 10000, + "country_ids": "FR", + "state_ids": "", + "price": 6, + "id_carrier_detail": "4" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "2", + "shipping_method": "range_weight", + "delimiter1": 0, + "delimiter2": 1, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "2" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "3", + "shipping_method": "range_weight", + "delimiter1": 1, + "delimiter2": 3, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "3" + } + }, + { + "action": "upsert", + "collection": "carrier_details", + "properties": { + "id_reference": "4", + "id_zone": "2", + "id_range": "4", + "shipping_method": "range_weight", + "delimiter1": 3, + "delimiter2": 10000, + "country_ids": "US", + "state_ids": "AA,AE,AK,AL,AP,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY", + "price": 6, + "id_carrier_detail": "4" + } + } +] diff --git a/e2e/src/fixtures/9/attributes.json b/e2e/src/fixtures/9/attributes.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/src/fixtures/9/attributes.json @@ -0,0 +1 @@ +[] diff --git a/e2e/src/helpers/shop-contents.ts b/e2e/src/helpers/shop-contents.ts index a654217c..ed67ac07 100644 --- a/e2e/src/helpers/shop-contents.ts +++ b/e2e/src/helpers/shop-contents.ts @@ -1,6 +1,7 @@ import R from "ramda"; export const shopContentMapping = { + attributes: "attributes", bundles: "bundles", carriers: "carriers", carrier_details: "carrier-details", diff --git a/src/Config/Config.php b/src/Config/Config.php index 99f6e6cf..916f46d9 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -64,6 +64,7 @@ class Config self::PS_ACCOUNTS_NOT_INSTALLED => 'PsAccounts not installed', ]; + const COLLECTION_ATTRIBUTES = 'attributes'; const COLLECTION_BUNDLES = 'bundles'; const COLLECTION_CARRIERS = 'carriers'; const COLLECTION_CARRIER_DETAILS = 'carrier_details'; @@ -101,6 +102,7 @@ class Config const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; const SHOP_CONTENTS = [ + self::COLLECTION_ATTRIBUTES, self::COLLECTION_BUNDLES, self::COLLECTION_CARRIERS, self::COLLECTION_CARRIER_DETAILS, diff --git a/src/Service/ShopContent/AttributesService.php b/src/Service/ShopContent/AttributesService.php new file mode 100644 index 00000000..9055003c --- /dev/null +++ b/src/Service/ShopContent/AttributesService.php @@ -0,0 +1,75 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\Module\PsEventbus\Service\ShopContent; + +use PrestaShop\Module\PsEventbus\Config\Config; + +if (!defined('_PS_VERSION_')) { + exit; +} + +// The service exists solely because it is necessary to notify CloudSync about the deleted content, +// and there is nothing specific to synchronize in full sync, or that has been upserted. +class AttributesService extends ShopContentAbstractService implements ShopContentServiceInterface +{ + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return array + */ + public function getContentsForFull($offset, $limit, $langIso) + { + return []; + } + + /** + * @param int $limit + * @param array $upsertedContents + * @param array $deletedContents + * @param string $langIso + * + * @return array + */ + public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso) + { + return parent::formatIncrementalSyncResponse(Config::COLLECTION_BUNDLES, [], $deletedContents); + } + + /** + * @param int $offset + * @param int $limit + * @param string $langIso + * + * @return int + */ + public function getFullSyncContentLeft($offset, $limit, $langIso) + { + return 0; + } +} diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 1a3af64d..1b03feb3 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -767,9 +767,9 @@ public function hookActionObjectCombinationDeleteAfter($parameters) $combination = $parameters['object']; if (isset($combination->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_ATTRIBUTES, 'delete'); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS => $combination->id], + [Config::COLLECTION_ATTRIBUTES => $combination->id], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId, From e1b624ec8e80a0f848b8117521ea880f54306350 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 26 Nov 2024 14:48:47 +0100 Subject: [PATCH 158/162] fix: carriers --- src/Repository/CarrierRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Repository/CarrierRepository.php b/src/Repository/CarrierRepository.php index 6fd6213e..b6c5b3e4 100644 --- a/src/Repository/CarrierRepository.php +++ b/src/Repository/CarrierRepository.php @@ -78,6 +78,7 @@ public function generateFullQuery($langIso, $withSelecParameters) ->select('c.max_weight') ->select('c.grade') ->select('cl.delay AS delay') + ->select('c.shipping_handling') ; } } From 9594985369f3d96d89ba2c6efe99f0fcd2be6113 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 26 Nov 2024 15:01:57 +0100 Subject: [PATCH 159/162] fix: carriers fixtures --- e2e/src/fixtures/8/carriers.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/src/fixtures/8/carriers.json b/e2e/src/fixtures/8/carriers.json index 7e6f3f13..5205b166 100644 --- a/e2e/src/fixtures/8/carriers.json +++ b/e2e/src/fixtures/8/carriers.json @@ -21,8 +21,8 @@ "max_weight": 0, "grade": 0, "delay": "Pick up in-store", - "carrier_taxes_rates_group_id": "1", "shipping_handling": 0, + "carrier_taxes_rates_group_id": "1", "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", @@ -51,8 +51,8 @@ "max_weight": 0, "grade": 0, "delay": "Delivery next day!", + "shipping_handling": 2, "carrier_taxes_rates_group_id": "1", - "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", @@ -81,8 +81,8 @@ "max_weight": 0, "grade": 0, "delay": "Buy more to pay less!", + "shipping_handling": 2, "carrier_taxes_rates_group_id": "1", - "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", @@ -111,8 +111,8 @@ "max_weight": 0, "grade": 0, "delay": "The lighter the cheaper!", + "shipping_handling": 2, "carrier_taxes_rates_group_id": "1", - "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", From 5dd6b6242b9fc0ecad9e4ec80e9cf5195ff449b8 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 26 Nov 2024 15:12:19 +0100 Subject: [PATCH 160/162] =?UTF-8?q?fix:=20carriers=20fixtures=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e/src/fixtures/1.6/carriers.json | 4 +- e2e/src/fixtures/1.7/carriers.json | 8 +-- e2e/src/fixtures/9/carriers.json | 80 ++++++++++++++---------------- 3 files changed, 44 insertions(+), 48 deletions(-) diff --git a/e2e/src/fixtures/1.6/carriers.json b/e2e/src/fixtures/1.6/carriers.json index 95f27c3c..588ab5e5 100644 --- a/e2e/src/fixtures/1.6/carriers.json +++ b/e2e/src/fixtures/1.6/carriers.json @@ -21,8 +21,8 @@ "max_weight": 0, "grade": 0, "delay": "Pick up in-store", - "carrier_taxes_rates_group_id": "1", "shipping_handling": 0, + "carrier_taxes_rates_group_id": "1", "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", @@ -51,8 +51,8 @@ "max_weight": 0, "grade": 0, "delay": "Delivery next day!", + "shipping_handling": 2, "carrier_taxes_rates_group_id": "1", - "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", diff --git a/e2e/src/fixtures/1.7/carriers.json b/e2e/src/fixtures/1.7/carriers.json index 749c3334..283bf500 100644 --- a/e2e/src/fixtures/1.7/carriers.json +++ b/e2e/src/fixtures/1.7/carriers.json @@ -21,8 +21,8 @@ "max_weight": 0, "grade": 0, "delay": "Pick up in-store", - "carrier_taxes_rates_group_id": "1", "shipping_handling": 0, + "carrier_taxes_rates_group_id": "1", "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", @@ -51,8 +51,8 @@ "max_weight": 0, "grade": 0, "delay": "Delivery next day!", + "shipping_handling": 2, "carrier_taxes_rates_group_id": "1", - "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", @@ -81,8 +81,8 @@ "max_weight": 0, "grade": 0, "delay": "Buy more to pay less!", + "shipping_handling": 2, "carrier_taxes_rates_group_id": "1", - "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", @@ -111,8 +111,8 @@ "max_weight": 0, "grade": 0, "delay": "The lighter the cheaper!", + "shipping_handling": 2, "carrier_taxes_rates_group_id": "1", - "shipping_handling": 0, "free_shipping_starts_at_price": 0, "free_shipping_starts_at_weight": 0, "currency": "EUR", diff --git a/e2e/src/fixtures/9/carriers.json b/e2e/src/fixtures/9/carriers.json index 4332f5aa..5205b166 100644 --- a/e2e/src/fixtures/9/carriers.json +++ b/e2e/src/fixtures/9/carriers.json @@ -2,21 +2,16 @@ { "action": "upsert", "collection": "carriers", - "properties": { - "id_carrier": "3", - "id_reference": "3", - "name": "My cheap carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "1", + "id_reference": "1", + "name": "Click and collect", "url": "", - "active": false, + "active": true, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, - "is_free": false, + "is_free": true, "shipping_external": false, "need_range": false, "external_module_name": "", @@ -25,7 +20,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Buy more to pay less!", + "delay": "Pick up in-store", + "shipping_handling": 0, + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } @@ -33,18 +32,13 @@ { "action": "upsert", "collection": "carriers", - "properties": { - "id_carrier": "4", - "id_reference": "4", - "name": "My light carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "2", + "id_reference": "2", + "name": "My carrier", "url": "", - "active": false, + "active": true, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, @@ -56,7 +50,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "The lighter the cheaper!", + "delay": "Delivery next day!", + "shipping_handling": 2, + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } @@ -64,21 +62,16 @@ { "action": "upsert", "collection": "carriers", - "properties": { - "id_carrier": "1", - "id_reference": "1", - "name": "Click and collect", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "3", + "id_reference": "3", + "name": "My cheap carrier", "url": "", - "active": true, + "active": false, "deleted": false, - "shipping_handling": 0, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, - "is_free": true, + "is_free": false, "shipping_external": false, "need_range": false, "external_module_name": "", @@ -87,7 +80,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Pick up in-store", + "delay": "Buy more to pay less!", + "shipping_handling": 2, + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } @@ -95,18 +92,13 @@ { "action": "upsert", "collection": "carriers", - "properties": { - "id_carrier": "2", - "id_reference": "2", - "name": "My carrier", - "carrier_taxes_rates_group_id": "1", + "id_carrier": "4", + "id_reference": "4", + "name": "My light carrier", "url": "", - "active": true, + "active": false, "deleted": false, - "shipping_handling": 2, - "free_shipping_starts_at_price": 0, - "free_shipping_starts_at_weight": 0, "disable_carrier_when_out_of_range": false, "is_module": false, "is_free": false, @@ -118,7 +110,11 @@ "max_depth": 0, "max_weight": 0, "grade": 0, - "delay": "Delivery next day!", + "delay": "The lighter the cheaper!", + "shipping_handling": 2, + "carrier_taxes_rates_group_id": "1", + "free_shipping_starts_at_price": 0, + "free_shipping_starts_at_weight": 0, "currency": "EUR", "weight_unit": "kg" } From aa4d64eefaf0801c44eacddfc5248e3fa2b7ac41 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 27 Nov 2024 11:05:31 +0100 Subject: [PATCH 161/162] fix: missing hooks incremental --- src/Config/Config.php | 2 - src/Repository/BundleRepository.php | 2 +- src/Repository/OrderCartRuleRepository.php | 2 +- src/Repository/OrderDetailRepository.php | 2 +- .../OrderStatusHistoryRepository.php | 2 +- src/Repository/ProductSupplierRepository.php | 2 +- src/Repository/StockMovementRepository.php | 2 +- src/Traits/UseHooks.php | 167 ++++++++++++------ 8 files changed, 117 insertions(+), 64 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 916f46d9..ae865a4c 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -76,7 +76,6 @@ class Config const COLLECTION_CURRENCIES = 'currencies'; const COLLECTION_CUSTOMERS = 'customers'; const COLLECTION_CUSTOM_PRODUCT_CARRIERS = 'custom_product_carriers'; - const COLLECTION_DELETED = 'deleted'; const COLLECTION_EMPLOYEES = 'employees'; const COLLECTION_IMAGES = 'images'; const COLLECTION_IMAGE_TYPES = 'image_types'; @@ -113,7 +112,6 @@ class Config self::COLLECTION_CATEGORIES, self::COLLECTION_CURRENCIES, self::COLLECTION_CUSTOMERS, - self::COLLECTION_DELETED, self::COLLECTION_EMPLOYEES, self::COLLECTION_IMAGES, self::COLLECTION_IMAGE_TYPES, diff --git a/src/Repository/BundleRepository.php b/src/Repository/BundleRepository.php index f8b60968..d7c804ad 100644 --- a/src/Repository/BundleRepository.php +++ b/src/Repository/BundleRepository.php @@ -105,7 +105,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) $this->generateFullQuery($langIso, true); $this->query - ->where('pac.id_bundle IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('pac.id_product IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/OrderCartRuleRepository.php b/src/Repository/OrderCartRuleRepository.php index 07b4ad89..c855e9bc 100644 --- a/src/Repository/OrderCartRuleRepository.php +++ b/src/Repository/OrderCartRuleRepository.php @@ -101,7 +101,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) $this->generateFullQuery($langIso, true); $this->query - ->where('ocr.id_order_cart_rule IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('ocr.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit); return $this->runQuery(); diff --git a/src/Repository/OrderDetailRepository.php b/src/Repository/OrderDetailRepository.php index ee952c21..447897eb 100644 --- a/src/Repository/OrderDetailRepository.php +++ b/src/Repository/OrderDetailRepository.php @@ -124,7 +124,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) $this->generateFullQuery($langIso, true); $this->query - ->where('od.id_order_detail IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('od.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/OrderStatusHistoryRepository.php b/src/Repository/OrderStatusHistoryRepository.php index 51ffcf49..5ad0e6b3 100644 --- a/src/Repository/OrderStatusHistoryRepository.php +++ b/src/Repository/OrderStatusHistoryRepository.php @@ -108,7 +108,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) $this->generateFullQuery($langIso, true); $this->query - ->where('oh.id_order_state IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('oh.id_order IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/ProductSupplierRepository.php b/src/Repository/ProductSupplierRepository.php index 98e65f3c..683d67d3 100644 --- a/src/Repository/ProductSupplierRepository.php +++ b/src/Repository/ProductSupplierRepository.php @@ -97,7 +97,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) $this->generateFullQuery($langIso, true); $this->query - ->where('ps.id_product_supplier IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('ps.id_product IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Repository/StockMovementRepository.php b/src/Repository/StockMovementRepository.php index e7fb3ff4..f897a2ab 100644 --- a/src/Repository/StockMovementRepository.php +++ b/src/Repository/StockMovementRepository.php @@ -112,7 +112,7 @@ public function retrieveContentsForIncremental($limit, $contentIds, $langIso) $this->generateFullQuery($langIso, true); $this->query - ->where('sm.id_stock_mvt IN(' . implode(',', array_map('intval', $contentIds)) . ')') + ->where('sm.id_stock IN(' . implode(',', array_map('intval', $contentIds)) . ')') ->limit($limit) ; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 1b03feb3..3185eca6 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -149,10 +149,11 @@ public function hookActionObjectImageDeleteAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES,Config::INCREMENTAL_TYPE_DELETE); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS => $image->id_product], - Config::INCREMENTAL_TYPE_DELETE, + [Config::COLLECTION_IMAGES => $image->id_image], + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, true @@ -174,9 +175,10 @@ public function hookActionObjectImageAddAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES,Config::INCREMENTAL_TYPE_UPSERT); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS => $image->id_product], + [Config::COLLECTION_IMAGES => $image->id_image], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, @@ -199,9 +201,10 @@ public function hookActionObjectImageUpdateAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES, Config::INCREMENTAL_TYPE_UPSERT); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS => $image->id_product], + [Config::COLLECTION_IMAGES => $image->id_image], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, @@ -224,7 +227,7 @@ public function hookActionObjectLanguageDeleteAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_DELETE, @@ -249,7 +252,7 @@ public function hookActionObjectLanguageAddAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -274,7 +277,7 @@ public function hookActionObjectLanguageUpdateAfter($parameters) $language = $parameters['object']; if ($language->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_LANGUAGES => $language->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -299,7 +302,7 @@ public function hookActionObjectManufacturerDeleteAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_DELETE, @@ -324,7 +327,7 @@ public function hookActionObjectManufacturerAddAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -349,7 +352,7 @@ public function hookActionObjectManufacturerUpdateAfter($parameters) $manufacturer = $parameters['object']; if (isset($manufacturer->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_MANUFACTURERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_MANUFACTURERS => $manufacturer->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -374,7 +377,7 @@ public function hookActionObjectSupplierDeleteAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_DELETE, @@ -399,7 +402,7 @@ public function hookActionObjectSupplierAddAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -424,7 +427,7 @@ public function hookActionObjectSupplierUpdateAfter($parameters) $supplier = $parameters['object']; if (isset($supplier->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SUPPLIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SUPPLIERS => $supplier->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -449,9 +452,20 @@ public function hookActionObjectProductDeleteAfter($parameters) $product = $parameters['object']; if (isset($product->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_PRODUCTS, 'delete'); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_PRODUCTS, + Config::COLLECTION_BUNDLES, + Config::COLLECTION_PRODUCT_SUPPLIERS + ], + Config::INCREMENTAL_TYPE_DELETE + ); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_PRODUCTS => $product->id], + [ + Config::COLLECTION_PRODUCTS => $product->id, + Config::COLLECTION_BUNDLES => $product->id, + Config::COLLECTION_PRODUCT_SUPPLIERS => $product->id + ], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId, @@ -489,17 +503,23 @@ public function hookActionObjectProductAddAfter($parameters) $synchronizationService->sendLiveSync( [ Config::COLLECTION_PRODUCTS, + Config::COLLECTION_BUNDLES, + Config::COLLECTION_PRODUCT_SUPPLIERS, Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, Config::COLLECTION_STOCKS, + CONFIG::COLLECTION_STOCK_MOVEMENTS ], - 'upsert' + Config::INCREMENTAL_TYPE_UPSERT ); $synchronizationService->insertContentIntoIncremental( [ Config::COLLECTION_PRODUCTS => $product->id, + Config::COLLECTION_BUNDLES => $product->id, + Config::COLLECTION_PRODUCT_SUPPLIERS => $product->id, Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $customProductCarrierIds, Config::COLLECTION_STOCKS => $stockId, + CONFIG::COLLECTION_STOCK_MOVEMENTS => $stockId ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), @@ -539,8 +559,9 @@ public function hookActionObjectProductUpdateAfter($parameters) Config::COLLECTION_PRODUCTS, Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, Config::COLLECTION_STOCKS, + CONFIG::COLLECTION_STOCK_MOVEMENTS ], - 'upsert' + Config::INCREMENTAL_TYPE_UPSERT ); $synchronizationService->insertContentIntoIncremental( @@ -548,6 +569,7 @@ public function hookActionObjectProductUpdateAfter($parameters) Config::COLLECTION_PRODUCTS => $product->id, Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS => $customProductCarrierIds, Config::COLLECTION_STOCKS => $stockId, + CONFIG::COLLECTION_STOCK_MOVEMENTS => $stockId ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), @@ -569,7 +591,7 @@ public function hookActionObjectWishlistDeleteAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_DELETE, @@ -593,7 +615,7 @@ public function hookActionObjectWishlistAddAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -617,7 +639,7 @@ public function hookActionObjectWishlistUpdateAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_WISHLISTS => $wishlist->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -642,7 +664,7 @@ public function hookActionObjectStockAddAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -667,7 +689,7 @@ public function hookActionObjectStockUpdateAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STOCKS => $stock->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -692,7 +714,7 @@ public function hookActionObjectStoreDeleteAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_DELETE, @@ -717,7 +739,7 @@ public function hookActionObjectStoreAddAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -742,7 +764,7 @@ public function hookActionObjectStoreUpdateAfter($parameters) $store = $parameters['object']; if ($store->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_STORES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_STORES => $store->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -767,7 +789,7 @@ public function hookActionObjectCombinationDeleteAfter($parameters) $combination = $parameters['object']; if (isset($combination->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_ATTRIBUTES, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_ATTRIBUTES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ATTRIBUTES => $combination->id], Config::INCREMENTAL_TYPE_DELETE, @@ -792,7 +814,7 @@ public function hookActionObjectCategoryAddAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -817,7 +839,7 @@ public function hookActionObjectCategoryUpdateAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -842,7 +864,7 @@ public function hookActionObjectCategoryDeleteAfter($parameters) $category = $parameters['object']; if (isset($category->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CATEGORIES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CATEGORIES => $category->id], Config::INCREMENTAL_TYPE_DELETE, @@ -867,7 +889,7 @@ public function hookActionObjectCustomerAddAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -892,7 +914,7 @@ public function hookActionObjectCustomerUpdateAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -917,7 +939,7 @@ public function hookActionObjectCustomerDeleteAfter($parameters) $customer = $parameters['object']; if ($customer->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CUSTOMERS => $customer->id], Config::INCREMENTAL_TYPE_DELETE, @@ -942,7 +964,7 @@ public function hookActionObjectCurrencyAddAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -967,7 +989,7 @@ public function hookActionObjectCurrencyUpdateAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -992,7 +1014,7 @@ public function hookActionObjectCurrencyDeleteAfter($parameters) $currency = $parameters['object']; if (isset($currency->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CURRENCIES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CURRENCIES => $currency->id], Config::INCREMENTAL_TYPE_DELETE, @@ -1016,13 +1038,23 @@ public function hookActionObjectCartAddAfter($parameters) $cart = $parameters['object']; if (isset($cart->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CARTS, 'upsert'); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_CARTS, + Config::COLLECTION_CART_PRODUCTS + ], + Config::INCREMENTAL_TYPE_UPSERT + ); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CARTS => $cart->id], + [ + Config::COLLECTION_CARTS => $cart->id, + Config::COLLECTION_CART_PRODUCTS => $cart->id + ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, - false + true ); } } @@ -1040,13 +1072,23 @@ public function hookActionObjectCartUpdateAfter($parameters) $cart = $parameters['object']; if (isset($cart->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CARTS, 'upsert'); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_CARTS, + Config::COLLECTION_CART_PRODUCTS + ], + Config::INCREMENTAL_TYPE_UPSERT + ); + $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_CARTS => $cart->id], + [ + Config::COLLECTION_CARTS => $cart->id, + Config::COLLECTION_CART_PRODUCTS => $cart->id + ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, - false + true ); } } @@ -1064,7 +1106,7 @@ public function hookActionObjectCartRuleAddAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -1088,7 +1130,7 @@ public function hookActionObjectCartRuleDeleteAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_DELETE, @@ -1112,7 +1154,7 @@ public function hookActionObjectCartRuleUpdateAfter($parameters) $cartRule = $parameters['object']; if (isset($cartRule->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_CART_RULES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CART_RULES => $cartRule->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -1136,7 +1178,7 @@ public function hookActionObjectOrderAddAfter($parameters) $order = $parameters['object']; if (isset($order->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_ORDERS, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_ORDERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_ORDERS => $order->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -1160,9 +1202,22 @@ public function hookActionObjectOrderUpdateAfter($parameters) $order = $parameters['object']; if (isset($order->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_ORDERS, 'upsert'); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_ORDERS, + Config::COLLECTION_ORDER_CART_RULES, + Config::COLLECTION_ORDER_DETAILS, + Config::COLLECTION_ORDER_STATUS_HISTORY, + ], + Config::INCREMENTAL_TYPE_UPSERT + ); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_ORDERS => $order->id], + [ + Config::COLLECTION_ORDERS => $order->id, + Config::COLLECTION_ORDER_CART_RULES => $order->id, + Config::COLLECTION_ORDER_DETAILS => $order->id, + Config::COLLECTION_ORDER_STATUS_HISTORY => $order->id, + ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, @@ -1191,7 +1246,7 @@ public function hookActionObjectCarrierAddAfter($parameters) Config::COLLECTION_CARRIER_DETAILS => $carrier->id, Config::COLLECTION_CARRIER_TAXES => $carrier->id, ], - 'upsert' + Config::INCREMENTAL_TYPE_UPSERT ); $synchronizationService->insertContentIntoIncremental( @@ -1228,7 +1283,7 @@ public function hookActionObjectCarrierUpdateAfter($parameters) Config::COLLECTION_CARRIER_DETAILS, Config::COLLECTION_CARRIER_TAXES, ], - 'upsert' + Config::INCREMENTAL_TYPE_UPSERT ); $synchronizationService->insertContentIntoIncremental( @@ -1264,7 +1319,7 @@ public function hookActionObjectCarrierDeleteAfter($parameters) Config::COLLECTION_CARRIER_DETAILS, Config::COLLECTION_CARRIER_TAXES, ], - 'delete' + Config::INCREMENTAL_TYPE_DELETE ); $synchronizationService->insertContentIntoIncremental( @@ -1662,7 +1717,7 @@ public function hookActionObjectSpecificPriceAddAfter($parameters) $specificPrice = $parameters['object']; if ($specificPrice instanceof \SpecificPrice && isset($specificPrice->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -1687,7 +1742,7 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters) $specificPrice = $parameters['object']; if ($specificPrice->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'upsert'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_UPSERT, @@ -1712,7 +1767,7 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters) $specificPrice = $parameters['object']; if ($specificPrice->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, 'delete'); + $synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id], Config::INCREMENTAL_TYPE_DELETE, From 907c9804b45fc5fbc0c5da10d321a083c0759831 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 28 Nov 2024 11:17:53 +0100 Subject: [PATCH 162/162] fix: some hooks --- src/Config/Config.php | 10 +-- src/Traits/UseHooks.php | 181 +++++++++++++++++++++++++++++++++++----- 2 files changed, 167 insertions(+), 24 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index ae865a4c..3fc7593d 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -78,24 +78,24 @@ class Config const COLLECTION_CUSTOM_PRODUCT_CARRIERS = 'custom_product_carriers'; const COLLECTION_EMPLOYEES = 'employees'; const COLLECTION_IMAGES = 'images'; - const COLLECTION_IMAGE_TYPES = 'image_types'; + const COLLECTION_IMAGE_TYPES = 'image_types'; // NO INCREMENTAL const COLLECTION_LANGUAGES = 'languages'; const COLLECTION_MANUFACTURERS = 'manufacturers'; - const COLLECTION_MODULES = 'modules'; + const COLLECTION_MODULES = 'modules'; // NO INCREMENTAL const COLLECTION_ORDERS = 'orders'; const COLLECTION_ORDER_CART_RULES = 'order_cart_rules'; const COLLECTION_ORDER_DETAILS = 'order_details'; const COLLECTION_ORDER_STATUS_HISTORY = 'order_status_history'; const COLLECTION_PRODUCTS = 'products'; const COLLECTION_PRODUCT_SUPPLIERS = 'product_suppliers'; - const COLLECTION_SHOPS = 'shops'; + const COLLECTION_SHOPS = 'shops'; // NO INCREMENTAL const COLLECTION_SPECIFIC_PRICES = 'specific_prices'; const COLLECTION_STOCKS = 'stocks'; const COLLECTION_STOCK_MOVEMENTS = 'stock_movements'; const COLLECTION_STORES = 'stores'; const COLLECTION_SUPPLIERS = 'suppliers'; - const COLLECTION_TAXONOMIES = 'taxonomies'; - const COLLECTION_THEMES = 'themes'; + const COLLECTION_TAXONOMIES = 'taxonomies'; // NO INCREMENTAL + const COLLECTION_THEMES = 'themes'; // NO INCREMENTAL const COLLECTION_TRANSLATIONS = 'translations'; const COLLECTION_WISHLISTS = 'wishlists'; const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products'; diff --git a/src/Traits/UseHooks.php b/src/Traits/UseHooks.php index 3185eca6..7cedca00 100644 --- a/src/Traits/UseHooks.php +++ b/src/Traits/UseHooks.php @@ -149,7 +149,7 @@ public function hookActionObjectImageDeleteAfter($parameters) $image = $parameters['object']; if ($image->id_product) { - $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES,Config::INCREMENTAL_TYPE_DELETE); + $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_IMAGES => $image->id_image], @@ -213,6 +213,84 @@ public function hookActionObjectImageUpdateAfter($parameters) } } + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectImageTypeDeleteAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + + /** @var \ImageType $imageType */ + $imageType = $parameters['object']; + + if ($imageType->id) { + $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGE_TYPES, Config::INCREMENTAL_TYPE_DELETE); + + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_IMAGE_TYPES => $imageType->id], + Config::INCREMENTAL_TYPE_DELETE, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectImageTypeAddAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + + /** @var \ImageType $imageType */ + $imageType = $parameters['object']; + + if ($imageType->id) { + $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGE_TYPES, Config::INCREMENTAL_TYPE_DELETE); + + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_IMAGE_TYPES => $imageType->id], + Config::INCREMENTAL_TYPE_DELETE, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + + /** + * @param array $parameters + * + * @return void + */ + public function hookActionObjectImageTypeUpdateAfter($parameters) + { + /** @var SynchronizationService $synchronizationService * */ + $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + + /** @var \ImageType $imageType */ + $imageType = $parameters['object']; + + if ($imageType->id) { + $synchronizationService->sendLiveSync(Config::COLLECTION_IMAGE_TYPES, Config::INCREMENTAL_TYPE_DELETE); + + $synchronizationService->insertContentIntoIncremental( + [Config::COLLECTION_IMAGE_TYPES => $imageType->id], + Config::INCREMENTAL_TYPE_DELETE, + date(DATE_ATOM), + $this->shopId, + true + ); + } + } + /** * @param array $parameters * @@ -591,9 +669,18 @@ public function hookActionObjectWishlistDeleteAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, Config::INCREMENTAL_TYPE_DELETE); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_WISHLISTS, + Config::COLLECTION_WISHLIST_PRODUCTS + ], + Config::INCREMENTAL_TYPE_DELETE + ); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_WISHLISTS => $wishlist->id], + [ + Config::COLLECTION_WISHLISTS => $wishlist->id, + Config::COLLECTION_WISHLIST_PRODUCTS => $wishlist->id + ], Config::INCREMENTAL_TYPE_DELETE, date(DATE_ATOM), $this->shopId, @@ -615,9 +702,18 @@ public function hookActionObjectWishlistAddAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, Config::INCREMENTAL_TYPE_UPSERT); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_WISHLISTS, + Config::COLLECTION_WISHLIST_PRODUCTS + ], + Config::INCREMENTAL_TYPE_UPSERT + ); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_WISHLISTS => $wishlist->id], + [ + Config::COLLECTION_WISHLISTS => $wishlist->id, + Config::COLLECTION_WISHLIST_PRODUCTS => $wishlist->id + ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, @@ -639,9 +735,18 @@ public function hookActionObjectWishlistUpdateAfter($parameters) $wishlist = $parameters['object']; if ($wishlist->id) { - $synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, Config::INCREMENTAL_TYPE_UPSERT); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_WISHLISTS, + Config::COLLECTION_WISHLIST_PRODUCTS + ], + Config::INCREMENTAL_TYPE_UPSERT + ); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_WISHLISTS => $wishlist->id], + [ + Config::COLLECTION_WISHLISTS => $wishlist->id, + Config::COLLECTION_WISHLIST_PRODUCTS => $wishlist->id + ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, @@ -664,9 +769,18 @@ public function hookActionObjectStockAddAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, Config::INCREMENTAL_TYPE_UPSERT); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_STOCKS, + Config::COLLECTION_STOCK_MOVEMENTS + ], + Config::INCREMENTAL_TYPE_UPSERT + ); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_STOCKS => $stock->id], + [ + Config::COLLECTION_STOCKS => $stock->id, + Config::COLLECTION_STOCK_MOVEMENTS => $stock->id + ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, @@ -689,9 +803,18 @@ public function hookActionObjectStockUpdateAfter($parameters) $stock = $parameters['object']; if (isset($stock->id)) { - $synchronizationService->sendLiveSync(Config::COLLECTION_STOCKS, Config::INCREMENTAL_TYPE_UPSERT); + $synchronizationService->sendLiveSync( + [ + Config::COLLECTION_STOCKS, + Config::COLLECTION_STOCK_MOVEMENTS + ], + Config::INCREMENTAL_TYPE_UPSERT + ); $synchronizationService->insertContentIntoIncremental( - [Config::COLLECTION_STOCKS => $stock->id], + [ + Config::COLLECTION_STOCKS => $stock->id, + Config::COLLECTION_STOCK_MOVEMENTS => $stock->id + ], Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, @@ -1319,7 +1442,7 @@ public function hookActionObjectCarrierDeleteAfter($parameters) Config::COLLECTION_CARRIER_DETAILS, Config::COLLECTION_CARRIER_TAXES, ], - Config::INCREMENTAL_TYPE_DELETE + Config::INCREMENTAL_TYPE_UPSERT ); $synchronizationService->insertContentIntoIncremental( @@ -1328,7 +1451,7 @@ public function hookActionObjectCarrierDeleteAfter($parameters) Config::COLLECTION_CARRIER_DETAILS => $carrier->id, Config::COLLECTION_CARRIER_TAXES => $carrier->id, ], - Config::INCREMENTAL_TYPE_DELETE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1344,6 +1467,7 @@ public function hookActionObjectCountryAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1361,6 +1485,7 @@ public function hookActionObjectCountryUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1378,9 +1503,10 @@ public function hookActionObjectCountryDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_DELETE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1395,6 +1521,7 @@ public function hookActionObjectStateAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1412,6 +1539,7 @@ public function hookActionObjectStateUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1429,9 +1557,10 @@ public function hookActionObjectStateDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_DELETE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1446,6 +1575,7 @@ public function hookActionObjectZoneAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1463,6 +1593,7 @@ public function hookActionObjectZoneUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1480,9 +1611,10 @@ public function hookActionObjectZoneDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_DELETE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1497,6 +1629,7 @@ public function hookActionObjectTaxAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1514,6 +1647,7 @@ public function hookActionObjectTaxUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1531,9 +1665,10 @@ public function hookActionObjectTaxDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_DELETE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1548,6 +1683,7 @@ public function hookActionObjectTaxRulesGroupAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1565,6 +1701,7 @@ public function hookActionObjectTaxRulesGroupUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1582,9 +1719,10 @@ public function hookActionObjectTaxRulesGroupDeleteAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_DELETE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1599,9 +1737,10 @@ public function hookActionShippingPreferencesPageSave() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_CARRIERS, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_CARRIERS => 0], - Config::INCREMENTAL_TYPE_DELETE, + Config::INCREMENTAL_TYPE_UPSERT, date(DATE_ATOM), $this->shopId, false @@ -1616,6 +1755,7 @@ public function hookActionObjectEmployeeAddAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_UPSERT, @@ -1632,6 +1772,8 @@ public function hookActionObjectEmployeeDeleteAfter() { /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + + $synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_DELETE); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_DELETE, @@ -1649,6 +1791,7 @@ public function hookActionObjectEmployeeUpdateAfter() /** @var SynchronizationService $synchronizationService * */ $synchronizationService = $this->getService(Config::SYNC_SERVICE_NAME); + $synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_UPSERT); $synchronizationService->insertContentIntoIncremental( [Config::COLLECTION_EMPLOYEES => 0], Config::INCREMENTAL_TYPE_UPSERT,