executeS($sql); foreach ($productos as $producto) { $word = pSQL($producto['ean13']); foreach ($languages as $lang) { foreach ($shops as $shopId) { // Insertar o actualizar la palabra en search_word $sqlInsertWord = " INSERT IGNORE INTO " . _DB_PREFIX_ . "search_word (id_word, id_lang, id_shop, word) VALUES (NULL, '" . (int)$lang['id_lang'] . "', '" . (int)$shopId . "', '$word') "; Db::getInstance()->execute($sqlInsertWord); $id_word = Db::getInstance()->Insert_ID(); // Si la palabra fue insertada con éxito, proceder con la inserción o actualización en search_index if ($id_word) { $weight = Configuration::get('PS_SEARCH_WEIGHT_REF'); $idProduct = (int)$producto['id_product']; $sqlInsertIndex = " INSERT INTO " . _DB_PREFIX_ . "search_index (id_product, id_word, weight) VALUES ('$idProduct', '$id_word', '$weight') ON DUPLICATE KEY UPDATE weight = '$weight' "; Db::getInstance()->execute($sqlInsertIndex); } } } } } return $result; } }