Skip to content

Commit 3c03249

Browse files
authored
fix: webservice products (#430)
1 parent dc98b1a commit 3c03249

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Traits/Hooks/UseProductHooks.php

Lines changed: 8 additions & 1 deletion
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
@@ -140,8 +141,14 @@ private function sendUpsertProduct($parameters)
140141
*
141142
* For the Legacy page, we don't have this problem, because the hook is called only once. But we need to handle it differently.
142143
* In the legacy page, we have the selected carriers only, but we don't have the list of carrier was unselected before.
144+
*
145+
* We have condition for webservice because the webservice is not front office call, and controller doesn't exist.
146+
* We need to handle it differently, with the presence of the webservice container.
143147
*/
144-
if (\Context::getContext()->controller instanceof \AdminProductsController) {
148+
if (
149+
\Context::getContext()->controller instanceof \AdminProductsController
150+
|| (isset(\Context::getContext()->container) && \Context::getContext()->container != null && get_class(\Context::getContext()->container) == 'WebserviceContainer') // <== Trick for webservice only
151+
) {
145152
// We are on legacy product page
146153
$incrementalSyncItems[Config::COLLECTION_CUSTOM_PRODUCT_CARRIERS] = $customProductCarrierIds;
147154

0 commit comments

Comments
 (0)