Skip to content

Commit e6a1326

Browse files
authored
Fix: image id hook error after duplication (#444)
1 parent dafe086 commit e6a1326

File tree

9 files changed

+65
-38
lines changed

9 files changed

+65
-38
lines changed

src/Repository/ImageRepository.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA

src/Traits/Hooks/UseCustomerHooks.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -48,6 +49,7 @@ public function hookActionObjectCustomerAddAfter($parameters)
4849
/** @var \Customer $customer * */
4950
$customer = $parameters['object'];
5051

52+
// Not nullable
5153
if ($customer->id) {
5254
$synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, Config::INCREMENTAL_TYPE_UPSERT);
5355
$synchronizationService->insertContentIntoIncremental(
@@ -73,6 +75,7 @@ public function hookActionObjectCustomerUpdateAfter($parameters)
7375
/** @var \Customer $customer * */
7476
$customer = $parameters['object'];
7577

78+
// Not nullable
7679
if ($customer->id) {
7780
$synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, Config::INCREMENTAL_TYPE_UPSERT);
7881
$synchronizationService->insertContentIntoIncremental(
@@ -98,6 +101,7 @@ public function hookActionObjectCustomerDeleteAfter($parameters)
98101
/** @var \Customer $customer * */
99102
$customer = $parameters['object'];
100103

104+
// Not nullable
101105
if ($customer->id) {
102106
$synchronizationService->sendLiveSync(Config::COLLECTION_CUSTOMERS, Config::INCREMENTAL_TYPE_DELETE);
103107
$synchronizationService->insertContentIntoIncremental(

src/Traits/Hooks/UseEmployeeHooks.php

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -48,14 +49,17 @@ public function hookActionObjectEmployeeAddAfter($parameters)
4849
/** @var \Employee $employee * */
4950
$employee = $parameters['object'];
5051

51-
$synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_UPSERT);
52-
$synchronizationService->insertContentIntoIncremental(
53-
[Config::COLLECTION_EMPLOYEES => $employee->id],
54-
Config::INCREMENTAL_TYPE_UPSERT,
55-
date(DATE_ATOM),
56-
$this->shopId,
57-
false
58-
);
52+
// Not nullable
53+
if ($employee->id) {
54+
$synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_UPSERT);
55+
$synchronizationService->insertContentIntoIncremental(
56+
[Config::COLLECTION_EMPLOYEES => $employee->id],
57+
Config::INCREMENTAL_TYPE_UPSERT,
58+
date(DATE_ATOM),
59+
$this->shopId,
60+
false
61+
);
62+
}
5963
}
6064

6165
/**
@@ -71,14 +75,17 @@ public function hookActionObjectEmployeeUpdateAfter($parameters)
7175
/** @var \Employee $employee * */
7276
$employee = $parameters['object'];
7377

74-
$synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_UPSERT);
75-
$synchronizationService->insertContentIntoIncremental(
76-
[Config::COLLECTION_EMPLOYEES => $employee->id],
77-
Config::INCREMENTAL_TYPE_UPSERT,
78-
date(DATE_ATOM),
79-
$this->shopId,
80-
false
81-
);
78+
// Not nullable
79+
if ($employee->id) {
80+
$synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_UPSERT);
81+
$synchronizationService->insertContentIntoIncremental(
82+
[Config::COLLECTION_EMPLOYEES => $employee->id],
83+
Config::INCREMENTAL_TYPE_UPSERT,
84+
date(DATE_ATOM),
85+
$this->shopId,
86+
false
87+
);
88+
}
8289
}
8390

8491
/**
@@ -94,13 +101,16 @@ public function hookActionObjectEmployeeDeleteAfter($parameters)
94101
/** @var \Employee $employee * */
95102
$employee = $parameters['object'];
96103

97-
$synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_DELETE);
98-
$synchronizationService->insertContentIntoIncremental(
99-
[Config::COLLECTION_EMPLOYEES => $employee->id],
100-
Config::INCREMENTAL_TYPE_DELETE,
101-
date(DATE_ATOM),
102-
$this->shopId,
103-
false
104-
);
104+
// Not nullable
105+
if ($employee->id) {
106+
$synchronizationService->sendLiveSync(Config::COLLECTION_EMPLOYEES, Config::INCREMENTAL_TYPE_DELETE);
107+
$synchronizationService->insertContentIntoIncremental(
108+
[Config::COLLECTION_EMPLOYEES => $employee->id],
109+
Config::INCREMENTAL_TYPE_DELETE,
110+
date(DATE_ATOM),
111+
$this->shopId,
112+
false
113+
);
114+
}
105115
}
106116
}

src/Traits/Hooks/UseImageHooks.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -48,11 +49,11 @@ public function hookActionObjectImageAddAfter($parameters)
4849
/** @var \Image $image */
4950
$image = $parameters['object'];
5051

51-
if ($image->id_product) {
52+
if (isset($image->id)) {
5253
$synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES, Config::INCREMENTAL_TYPE_UPSERT);
5354

5455
$synchronizationService->insertContentIntoIncremental(
55-
[Config::COLLECTION_IMAGES => $image->id_image],
56+
[Config::COLLECTION_IMAGES => $image->id],
5657
Config::INCREMENTAL_TYPE_UPSERT,
5758
date(DATE_ATOM),
5859
$this->shopId,
@@ -74,11 +75,11 @@ public function hookActionObjectImageUpdateAfter($parameters)
7475
/** @var \Image $image */
7576
$image = $parameters['object'];
7677

77-
if ($image->id_product) {
78+
if (isset($image->id)) {
7879
$synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES, Config::INCREMENTAL_TYPE_UPSERT);
7980

8081
$synchronizationService->insertContentIntoIncremental(
81-
[Config::COLLECTION_IMAGES => $image->id_image],
82+
[Config::COLLECTION_IMAGES => $image->id],
8283
Config::INCREMENTAL_TYPE_UPSERT,
8384
date(DATE_ATOM),
8485
$this->shopId,
@@ -100,11 +101,11 @@ public function hookActionObjectImageDeleteAfter($parameters)
100101
/** @var \Image $image */
101102
$image = $parameters['object'];
102103

103-
if ($image->id_product) {
104+
if (isset($image->id)) {
104105
$synchronizationService->sendLiveSync(Config::COLLECTION_IMAGES, Config::INCREMENTAL_TYPE_UPSERT);
105106

106107
$synchronizationService->insertContentIntoIncremental(
107-
[Config::COLLECTION_IMAGES => $image->id_image],
108+
[Config::COLLECTION_IMAGES => $image->id],
108109
Config::INCREMENTAL_TYPE_UPSERT,
109110
date(DATE_ATOM),
110111
$this->shopId,

src/Traits/Hooks/UseImageTypeHooks.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -48,7 +49,7 @@ public function hookActionObjectImageTypeAddAfter($parameters)
4849
/** @var \ImageType $imageType */
4950
$imageType = $parameters['object'];
5051

51-
if ($imageType->id) {
52+
if (isset($imageType->id)) {
5253
$synchronizationService->sendLiveSync(Config::COLLECTION_IMAGE_TYPES, Config::INCREMENTAL_TYPE_UPSERT);
5354

5455
$synchronizationService->insertContentIntoIncremental(
@@ -74,7 +75,7 @@ public function hookActionObjectImageTypeUpdateAfter($parameters)
7475
/** @var \ImageType $imageType */
7576
$imageType = $parameters['object'];
7677

77-
if ($imageType->id) {
78+
if (isset($imageType->id)) {
7879
$synchronizationService->sendLiveSync(Config::COLLECTION_IMAGE_TYPES, Config::INCREMENTAL_TYPE_UPSERT);
7980

8081
$synchronizationService->insertContentIntoIncremental(
@@ -100,7 +101,7 @@ public function hookActionObjectImageTypeDeleteAfter($parameters)
100101
/** @var \ImageType $imageType */
101102
$imageType = $parameters['object'];
102103

103-
if ($imageType->id) {
104+
if (isset($imageType->id)) {
104105
$synchronizationService->sendLiveSync(Config::COLLECTION_IMAGE_TYPES, Config::INCREMENTAL_TYPE_DELETE);
105106

106107
$synchronizationService->insertContentIntoIncremental(

src/Traits/Hooks/UseLanguageHooks.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -48,6 +49,7 @@ public function hookActionObjectLanguageAddAfter($parameters)
4849
/** @var \Language $language */
4950
$language = $parameters['object'];
5051

52+
// Not nullable
5153
if ($language->id) {
5254
$synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, Config::INCREMENTAL_TYPE_UPSERT);
5355
$synchronizationService->insertContentIntoIncremental(
@@ -73,6 +75,7 @@ public function hookActionObjectLanguageUpdateAfter($parameters)
7375
/** @var \Language $language */
7476
$language = $parameters['object'];
7577

78+
// Not nullable
7679
if ($language->id) {
7780
$synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, Config::INCREMENTAL_TYPE_UPSERT);
7881
$synchronizationService->insertContentIntoIncremental(
@@ -98,6 +101,7 @@ public function hookActionObjectLanguageDeleteAfter($parameters)
98101
/** @var \Language $language */
99102
$language = $parameters['object'];
100103

104+
// Not nullable
101105
if ($language->id) {
102106
$synchronizationService->sendLiveSync(Config::COLLECTION_LANGUAGES, Config::INCREMENTAL_TYPE_DELETE);
103107
$synchronizationService->insertContentIntoIncremental(

src/Traits/Hooks/UseSpecificPriceHooks.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -72,7 +73,7 @@ public function hookActionObjectSpecificPriceUpdateAfter($parameters)
7273
/** @var \SpecificPrice $specificPrice */
7374
$specificPrice = $parameters['object'];
7475

75-
if ($specificPrice->id) {
76+
if (isset($specificPrice->id)) {
7677
$synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, Config::INCREMENTAL_TYPE_UPSERT);
7778
$synchronizationService->insertContentIntoIncremental(
7879
[Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id],
@@ -97,7 +98,7 @@ public function hookActionObjectSpecificPriceDeleteAfter($parameters)
9798
/** @var \SpecificPrice $specificPrice */
9899
$specificPrice = $parameters['object'];
99100

100-
if ($specificPrice->id) {
101+
if (isset($specificPrice->id)) {
101102
$synchronizationService->sendLiveSync(Config::COLLECTION_SPECIFIC_PRICES, Config::INCREMENTAL_TYPE_DELETE);
102103
$synchronizationService->insertContentIntoIncremental(
103104
[Config::COLLECTION_SPECIFIC_PRICES => $specificPrice->id],

src/Traits/Hooks/UseStoreHooks.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -48,6 +49,7 @@ public function hookActionObjectStoreAddAfter($parameters)
4849
/** @var \Store $store */
4950
$store = $parameters['object'];
5051

52+
// Not nullable
5153
if ($store->id) {
5254
$synchronizationService->sendLiveSync(Config::COLLECTION_STORES, Config::INCREMENTAL_TYPE_UPSERT);
5355
$synchronizationService->insertContentIntoIncremental(
@@ -73,6 +75,7 @@ public function hookActionObjectStoreUpdateAfter($parameters)
7375
/** @var \Store $store */
7476
$store = $parameters['object'];
7577

78+
// Not nullable
7679
if ($store->id) {
7780
$synchronizationService->sendLiveSync(Config::COLLECTION_STORES, Config::INCREMENTAL_TYPE_UPSERT);
7881
$synchronizationService->insertContentIntoIncremental(
@@ -98,6 +101,7 @@ public function hookActionObjectStoreDeleteAfter($parameters)
98101
/** @var \Store $store */
99102
$store = $parameters['object'];
100103

104+
// Not nullable
101105
if ($store->id) {
102106
$synchronizationService->sendLiveSync(Config::COLLECTION_STORES, Config::INCREMENTAL_TYPE_DELETE);
103107
$synchronizationService->insertContentIntoIncremental(

src/Traits/Hooks/UseWishlistHooks.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright since 2007 PrestaShop SA and Contributors
45
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -47,7 +48,7 @@ public function hookActionObjectWishlistAddAfter($parameters)
4748

4849
$wishlist = $parameters['object'];
4950

50-
if ($wishlist->id) {
51+
if (isset($wishlist->id)) {
5152
$synchronizationService->sendLiveSync(
5253
[
5354
Config::COLLECTION_WISHLISTS,
@@ -80,7 +81,7 @@ public function hookActionObjectWishlistUpdateAfter($parameters)
8081

8182
$wishlist = $parameters['object'];
8283

83-
if ($wishlist->id) {
84+
if (isset($wishlist->id)) {
8485
$synchronizationService->sendLiveSync(
8586
[
8687
Config::COLLECTION_WISHLISTS,
@@ -113,7 +114,7 @@ public function hookActionObjectWishlistDeleteAfter($parameters)
113114

114115
$wishlist = $parameters['object'];
115116

116-
if ($wishlist->id) {
117+
if (isset($wishlist->id)) {
117118
$synchronizationService->sendLiveSync(Config::COLLECTION_WISHLISTS, Config::INCREMENTAL_TYPE_DELETE);
118119
$synchronizationService->insertContentIntoIncremental(
119120
[Config::COLLECTION_WISHLISTS => $wishlist->id],

0 commit comments

Comments
 (0)