Skip to content

Commit

Permalink
chore: remove extra id in payload send to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
fox-john committed Oct 24, 2024
1 parent 15baebd commit e194b2e
Show file tree
Hide file tree
Showing 31 changed files with 20 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ 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 extends ShopContentAbstractService implements ShopContentServiceInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +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_NAME = 'eventbus_incremental_sync';
const INCREMENTAL_SYNC_TABLE_SIZE_CHECK_MOD = 20;
const INCREMENTAL_SYNC_MAX_TABLE_SIZE = 100000;

Expand Down
1 change: 0 additions & 1 deletion src/Repository/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

namespace PrestaShop\Module\PsEventbus\Repository;

use PrestaShop\Module\PsEventbus\Config\Config;
use PrestaShop\Module\PsEventbus\Service\CommonService;

if (!defined('_PS_VERSION_')) {
Expand Down
3 changes: 1 addition & 2 deletions src/Repository/IncrementalSyncRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

namespace PrestaShop\Module\PsEventbus\Repository;

use PrestaShop\Module\PsEventbus\Config\Config;
use PrestaShop\Module\PsEventbus\Handler\ErrorHandler\ErrorHandler;

if (!defined('_PS_VERSION_')) {
Expand Down Expand Up @@ -146,7 +145,7 @@ public function getIncrementalSyncObjects($shopContent, $langIso, $limit)

$this->query->select(
'eis.type',
'eis.id_object as id',
'eis.id_object as id',
'eis.action'
);

Expand Down
2 changes: 0 additions & 2 deletions src/Repository/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

namespace PrestaShop\Module\PsEventbus\Repository;

use PrestaShop\Module\PsEventbus\Config\Config;

if (!defined('_PS_VERSION_')) {
exit;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/ShopContent/CarrierDetailsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
foreach ($result as $carrierData) {
$carrierDetails = array_merge($carrierDetails, $this->buildCarrierDetails($carrierData));
}

$this->castCarrierDetails($carrierDetails);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Service/ShopContent/CarrierTaxesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon

$this->castCarrierTaxes($carrierTaxes);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_CARRIER_TAXES, 'id_carrier', $result, $upsertedContents, $deletedContents);
}

Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/CartRulesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_cart_rule'],
'collection' => Config::COLLECTION_CART_RULES,
'properties' => $item,
];
Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/CurrenciesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_currency'],
'collection' => Config::COLLECTION_CURRENCIES,
'properties' => $item,
];
Expand Down
2 changes: 1 addition & 1 deletion src/Service/ShopContent/CustomProductCarriersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getContentsForFull($offset, $limit, $langIso)
public function getContentsForIncremental($limit, $upsertedContents, $deletedContents, $langIso)
{
$result = $this->customProductCarrierRepository->retrieveContentsForIncremental($limit, array_column($upsertedContents, 'id'), $langIso);

return parent::formatIncrementalSyncResponse(Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS, 'id_carrier_reference', $result, $upsertedContents, $deletedContents);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Service/ShopContent/EmployeesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castEmployees($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_EMPLOYEES, 'id_employee', $result, $upsertedContents, $deletedContents);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Service/ShopContent/ImageTypesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castImageTypes($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_IMAGE_TYPES, 'id_image_type', $result, $upsertedContents, $deletedContents);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/LanguagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_lang'],
'collection' => Config::COLLECTION_LANGUAGES,
'properties' => $item,
];
Expand All @@ -84,7 +83,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castLanguages($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_LANGUAGES, 'id_lang', $result, $upsertedContents, $deletedContents);
}

Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/ManufacturersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_manufacturer'],
'collection' => Config::COLLECTION_MANUFACTURERS,
'properties' => $item,
];
Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/OrderCartRulesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_order_cart_rule'],
'collection' => Config::COLLECTION_ORDER_CART_RULES,
'properties' => $item,
];
Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/OrderDetailsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_order_detail'],
'collection' => Config::COLLECTION_ORDER_DETAILS,
'properties' => $item,
];
Expand All @@ -84,7 +83,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castOrderDetails($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_ORDER_DETAILS, 'id_order_detail', $result, $upsertedContents, $deletedContents);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/OrderHistoriesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_order_history'],
'collection' => Config::COLLECTION_ORDER_HISTORIES,
'properties' => $item,
];
Expand All @@ -84,7 +83,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castOrderHistories($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_ORDER_HISTORIES, 'id_order_state', $result, $upsertedContents, $deletedContents);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/OrdersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_order'],
'collection' => Config::COLLECTION_ORDERS,
'properties' => $item,
];
Expand All @@ -97,7 +96,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castOrders($result, $langIso);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_ORDERS, 'id_order', $result, $upsertedContents, $deletedContents);
}

Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/ProductBundlesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_bundle'],
'collection' => Config::COLLECTION_PRODUCT_BUNDLES,
'properties' => $item,
];
Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/ProductSuppliersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_product_supplier'],
'collection' => Config::COLLECTION_PRODUCT_SUPPLIERS,
'properties' => $item,
];
Expand Down
5 changes: 2 additions & 3 deletions src/Service/ShopContent/ShopContentAbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ protected function formatIncrementalSyncResponse($collection, $idKeyForBinding,
$data = [];

// We need to bind the upserted data with list of upserted content from incremental table to get the action
foreach($upsertedContents as $upsertedContent) {
foreach($upsertedList as $item) {
foreach ($upsertedContents as $upsertedContent) {
foreach ($upsertedList as $item) {
if ($upsertedContent[$idKeyForBinding] == $item['id']) {
$data[] = [
'collection' => $collection,
Expand All @@ -54,7 +54,6 @@ protected function formatIncrementalSyncResponse($collection, $idKeyForBinding,
$data[] = [
'collection' => $collection,
'properties' => [
'id' => $item['id'],
],
'action' => $item['action'],
];
Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/SpecificPricesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_specific_price'],
'collection' => Config::COLLECTION_SPECIFIC_PRICES,
'properties' => $item,
];
Expand All @@ -91,7 +90,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castCustomPrices($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_SPECIFIC_PRICES, 'id_specific_price', $result, $upsertedContents, $deletedContents);
}

Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/StockMovementsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_stock_mvt'],
'collection' => Config::COLLECTION_STOCK_MOVEMENTS,
'properties' => $item,
];
Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/StocksService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_stock_available'],
'collection' => Config::COLLECTION_STOCKS,
'properties' => $item,
];
Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/StoresService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_store'],
'collection' => Config::COLLECTION_STORES,
'properties' => $item,
];
Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/SuppliersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_supplier'],
'collection' => Config::COLLECTION_SUPPLIERS,
'properties' => $item,
];
Expand All @@ -84,7 +83,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castSuppliers($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_SUPPLIERS, 'id_supplier', $result, $upsertedContents, $deletedContents);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/TaxonomiesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['taxonomy_id'],
'collection' => Config::COLLECTION_TAXONOMIES,
'properties' => $item,
];
Expand All @@ -84,7 +83,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castTaxonomies($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_TAXONOMIES, 'id_category', $result, $upsertedContents, $deletedContents);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['theme_id'],
'collection' => Config::COLLECTION_THEMES,
'properties' => $item,
];
Expand All @@ -86,7 +85,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$themes = $this->formatThemes($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_THEMES, 'theme_id', $themes, $upsertedContents, $deletedContents);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/TranslationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_lang'],
'collection' => Config::COLLECTION_TRANSLATIONS,
'properties' => $item,
];
Expand All @@ -84,7 +83,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castTranslations($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_TRANSLATIONS, 'id_translation', $result, $upsertedContents, $deletedContents);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/ShopContent/WishlistProductsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_wishlist_product'],
'collection' => Config::COLLECTION_WISHLIST_PRODUCTS,
'properties' => $item,
];
Expand All @@ -84,7 +83,7 @@ public function getContentsForIncremental($limit, $upsertedContents, $deletedCon
if (!empty($result)) {
$this->castWishlistProducts($result);
}

return parent::formatIncrementalSyncResponse(Config::COLLECTION_WISHLIST_PRODUCTS, 'id_wishlist', $result, $upsertedContents, $deletedContents);
}

Expand Down
1 change: 0 additions & 1 deletion src/Service/ShopContent/WishlistsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function getContentsForFull($offset, $limit, $langIso)

return array_map(function ($item) {
return [
'id' => $item['id_wishlist'],
'collection' => Config::COLLECTION_WISHLISTS,
'properties' => $item,
];
Expand Down

0 comments on commit e194b2e

Please sign in to comment.