$markImported = $pdo->prepare("\n\tUPDATE `stn_matchup_results`\n\t\tSET `import_status`='AI'\n\t\tWHERE `ID`=:id\n\t;\n"); STN::depend('ProductDataProvider'); $processedSkus = array(); try { belongsToGroup($_SESSION, 'super administrator'); $provider = getProvider('STN'); $categories = $provider->getCategories(); $unImportable = array(); $importedCount = 0; foreach ($results->fetchAll(PDO::FETCH_ASSOC) as $importable) { $sku = $importable['stn_sku_match']; if (empty($sku)) { $error[] = 'No import candidate for item number: ' . $importable['POSItemNumber'] . ' missing SKU.'; continue; } if (productExistsLocally($sku, STN::getPDO())) { $alreadyImported[] = $sku; $importCount += 1; continue; } try { $product = $provider->getProductBySTNSKU($sku); if (!empty($product)) { $product_id = importProduct($product, $provider, $categories); $changes = array('sku' => $importable['POSItemNumber'], 'quantity' => $importable['QOH']); $failed = array(); Product::update($product_id, $changes, $failed); if (!empty($failed)) { throw new Exception('Saving product data failed.'); } Product::setPrice($product_id, $importable['RegularPrice']);