ProductImportModel->get_product($productId); if (!empty($Product['is_affiliate'])) { continue; } $externalId = $Product[ImportedProductService::FIELD_EXTERNAL_PRODUCT_ID] ?? null; if (!$externalId) { continue; } $this->push_to_queue([ 'externalId' => $externalId ]); } $this->save(); a2wl_info_log("AffiliateCheckJob queued for " . count($productIds) . " products."); return $this; } protected function task($item): bool { $externalId = $item['externalId'] ?? null; if (!$externalId) { a2wl_info_log("[AffiliateCheckJob] Missing externalId. Skipping."); return false; } try { $result = $this->Aliexpress->check_affiliate($externalId); $Product = $this->ProductImportModel->get_product($externalId); $Product['is_affiliate'] = $result['affiliate'] ?? false; $this->ProductImportModel->save_product($externalId, $Product); } catch (Exception $e) { a2wl_info_log("[AffiliateCheckJob] Failed for {$externalId}: " . $e->getMessage()); } return false; } }