PluginProbe
AliNext – WooCommerce Dropshipping Plugin for AliExpress / trunk
AliNext – WooCommerce Dropshipping Plugin for AliExpress vtrunk
ali2woo-lite / includes / classes / hook / product / AfterProductImportHook.php

AfterProductImportHook.php in AliNext – WooCommerce Dropshipping Plugin for AliExpress trunk, at includes/classes/hook/product/AfterProductImportHook.php

58 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Description of ProductImportHook
4 *
5 * @author Ali2Woo Team
6 *
7 * @hook: a2wl_after_product_import
8 * @ajax: true
9 *
10 */
11
12 namespace AliNext_Lite;;
13
14 use Exception;
15
16 class AfterProductImportHook
17 {
18
19 public function __construct(
20 protected BackgroundProcessFactory $BackgroundProcessFactory,
21
22 ) {}
23
24 public function __invoke(array $product): void
25 {
26
27 $this->detectAffiliate($product);
28 }
29
30
31
32 /**
33 * todo: this feature is not available temporarily
34 * @param array $Product
35 * @return void
36 */
37 private function detectAffiliate(array $Product): void
38 {
39 if (!isset($Product['is_affiliate'])) {
40 try {
41 /**
42 * @var AffiliateCheckProcess $AffiliateCheckProcess
43 */
44 $AffiliateCheckProcess = $this->BackgroundProcessFactory->createProcessByCode(
45 AffiliateCheckProcess::ACTION_CODE
46 );
47
48 $productId = $Product[ImportedProductService::FIELD_EXTERNAL_PRODUCT_ID] ?? null;
49 if ($productId) {
50 $AffiliateCheckProcess->pushToQueue([$productId])->dispatch();
51 }
52 } catch (Exception $Exception) {
53 a2wl_info_log("[ProductImportHook] Dispatch failed: " . $Exception->getMessage());
54 }
55 }
56 }
57 }
58