diff --git a/Constants.php b/Constants.php index b35eb64..0680b69 100644 --- a/Constants.php +++ b/Constants.php @@ -28,8 +28,8 @@ class Constants public const WEBHOOK_RESOURCE_ORDERS = 'orders'; public const WEBHOOK_RESOURCE_PRODUCTS = 'products'; - - public const AFTERSHIP_TIKTOK_SHOP_VERSION = '1.0.13'; + + public const AFTERSHIP_TIKTOK_SHOP_VERSION = '1.0.14'; public const WEBHOOK_CONFIG_SCOPE_PATH = 'aftership/webhooks/webhooks'; diff --git a/Observer/SalesOrderUpdateObserver.php b/Observer/SalesOrderUpdateObserver.php index a6cc331..09da4cb 100644 --- a/Observer/SalesOrderUpdateObserver.php +++ b/Observer/SalesOrderUpdateObserver.php @@ -122,6 +122,28 @@ public function execute(Observer $observer) ->setResource(Constants::WEBHOOK_RESOURCE_ORDERS) ->setEvent($webhookEvent); $this->publisher->execute($event); + // Send product update event for each order item. + $orderItems = $order->getAllItems(); + foreach ($orderItems as $orderItem) { + try { + $productId = $orderItem->getProductId(); + if (!$productId) { + continue; + } + $event = new WebhookEvent(); + $event->setId($productId) + ->setResource(Constants::WEBHOOK_RESOURCE_PRODUCTS) + ->setEvent(Constants::WEBHOOK_EVENT_UPDATE); + $this->publisher->execute($event); + } catch (\Exception $e) { + $this->logger->error( + sprintf( + '[AfterShip TikTokShop] Failed to send order related products webhook on OrderUpdateObserver, %s', + $e->getMessage() + ) + ); + } + } } catch (\Exception $e) { $this->logger->error( sprintf( diff --git a/composer.json b/composer.json index 2a3ffc9..345d15a 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "aftership/tiktok-shop", "description": "Aftership TikTok Shop extension for Magento 2. Allows connect with TikTok Shop and more.", "type": "magento2-module", - "version": "1.0.13", + "version": "1.0.14", "minimum-stability": "stable", "license": "MIT", "keywords": ["aftership", "magento", "magento2", "magento-2", "tiktok", "shopping", "shop", "feed"], diff --git a/etc/module.xml b/etc/module.xml index 9be6185..1cddf7a 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - +