public function setB1G1Tag() { global $smarty; $target_path = _PS_ADMIN_DIR_ . "/product-uploads/"; /* Add the original filename to our target path */ $target_path = $target_path . basename($_FILES['b1g1_tag_file']['name']); if (move_uploaded_file($_FILES['b1g1_tag_file']['tmp_name'], $target_path)) { $f = fopen($target_path, 'r'); //read header to get the search strings $line = fgetcsv($f); $lines = array(); while ($line = fgetcsv($f)) { $lines[] = $line; } $productIDs = array(); foreach ($lines as $line) { $productId = (int) $line[0]; $productObj = new Product($productId, true); $tags = $productObj->tags; if (!in_array('buy1get1', $tags[1])) { $productObj->addTag('buy1get1'); $productIDs[] = $productId; } } SolrSearch::updateProducts($productIDs); $smarty->assign('updated_b1g1_tags', count($productIDs)); } else { print_r("file could not be uploaded"); } }