Preoc Product Manager integrates Google Gemini (viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sergio-salcedo-dev/excel-product-manager/llms.txt
Use this file to discover all available pages before exploring further.
@google/genai) to provide two AI-powered search modes that surface real construction product data and let you import it into your catalog with one click. Both modes use the gemini-3-flash-preview model with Google Search grounding to retrieve up-to-date, real-world pricing — CYPE Precios for technically coded Spanish construction products, and Mercado AI for broader market research.
How It Works
The AI search workflow follows a straightforward four-step flow:- Type a search term into the toolbar search bar (e.g., “hormigón HA-25”, “cable eléctrico 2.5mm”).
- Click either CYPE Precios or Mercado AI to start a search.
- Gemini returns a JSON array of matching products, which appears in a results modal with checkboxes.
- Select the products you want and click Añadir N productos seleccionados to bulk-import them into your catalog.
Both AI search modes require a valid Gemini API key. Configure it by setting
NEXT_PUBLIC_GEMINI_API_KEY in your .env.local file before starting the
application. See Environment Variables for setup
instructions.CYPE Precios Search
The CYPE Precios button (primary color, left of the search bar) searches Spain’s CYPE Generador de Precios — the standard cost-estimation database used across the Spanish construction industry. The request is made bysearchInCype, which instantiates new GoogleGenAI({ apiKey: process.env.NEXT_PUBLIC_GEMINI_API_KEY }) on the client side and calls ai.models.generateContent with the gemini-3-flash-preview model. The googleSearch grounding tool is enabled via config.tools: [{ googleSearch: {} }] and the response is requested as responseMimeType: "application/json", so results are anchored to live web data rather than model training weights. Gemini is prompted to act as an expert in CYPE Generador de Precios (obra nueva) and return products with technically precise descriptions and CYPE-style article codes (e.g., MTB010, HAC010).
Best for: Looking up products that need to match standard Spanish construction specifications, budgets prepared with CYPE, or technical project documentation that references official CYPE codes.
Expected JSON Schema
Gemini is instructed to return only a JSON array matching this shape:[] and an info alert is displayed — see Error Handling below.
Mercado AI Search
The Mercado AI button (amber/accent color, rightmost in the search bar) performs a broader market search viasearchInAI, returning 3–5 real construction products available on the general market for the search term.
Like CYPE Precios, it uses gemini-3-flash-preview with googleSearch grounding (config.tools: [{ googleSearch: {} }]) and responseMimeType: "application/json". It returns the same JSON schema: description, code, unit, price, and category for each result. Product codes are realistic but not strictly CYPE-formatted.
Best for: General market pricing research, comparing prices across product types, or importing products when strict CYPE coding is not required.
Selecting and Importing Results
When either search returns results, a modal overlay appears with the full list of matched products. The modal header indicates the source (“CYPE Precios Sync” or “Mercado AI Sync”) and the number of results found. Each result card displays:- Code — the product reference code in monospace uppercase
- Description — the full technical description
- Price — unit price formatted as
{price} € / {unit} - Checkbox — to include or exclude the item from the import batch
- Deselect individual items by clicking anywhere on a result card or its checkbox.
- Toggle all at once using the Seleccionar todo master checkbox at the top of the list. The counter next to it shows the current selection as
{selected} / {total}. - Import the selection by clicking the Añadir productos seleccionados button at the top of the list. The button only appears when at least one result is selected.
addAllPreocProducts, all selected products are prepended to the catalog (they appear at position 1 on page 1) with IDs in the format preoc-{timestamp}-{index}. The results modal closes automatically and the catalog resets to page 1. The search bar text is not cleared by the bulk import — if you want an unfiltered view of the newly added products, click the X button in the search bar or use Limpiar Filtros.
Error Handling
The following error conditions are handled and surfaced as alert banners at the top of the screen: Missing API key — IfNEXT_PUBLIC_GEMINI_API_KEY is not configured or is invalid, the AI request fails and an error alert is shown asking the user to check the Gemini API key configuration.
No results found — If Gemini returns an empty array for a CYPE Precios search, an info alert appears:
“No se encontraron resultados específicos en el Generador de Precios para esta búsqueda.”For Mercado AI, the info alert reads:
“El Mercado AI no encontró productos específicos para esta búsqueda.”Network or API error (CYPE) — If the CYPE search request throws an exception, an error alert is displayed:
“Hubo un problema al conectar con el Generador de Precios (CYPE). Asegúrate de que la API Key de Gemini esté configurada correctamente.”Network or API error (Mercado AI) — If the Mercado AI search request throws an exception, a shorter error alert is shown:
“No se pudo realizar la búsqueda en el Mercado AI en este momento.”In all error cases, the loading spinner on the triggering button is dismissed and the catalog state remains unchanged.