Skip to content

Quick Search

Module: Magenx_QuickSearchGraphQl · replaces Magenx_PopularSearchGraphQl

Fills the header search dropdown before and around the results:

  • Top searches: your store’s most searched phrases, shown when the box opens.
  • Promotions: products, categories, brands or links you choose. General promotions show when the box is empty. Promotions with keywords show below the results when the search matches.
Header search dropdown with top searches and promoted items
The search dropdown with top searches and promotions.

Top searches come from Magento’s own search term log. A term shows when it is active, returns results, and has Display in Suggested Terms on (Marketing > SEO & Search > Search Terms).

A new store shows no top searches until shoppers have searched or you add terms.

  1. Go to Marketing > SEO & Search > Quick Search Promotions and add a promotion.
  2. Choose the Type and its target:
    • Product: a SKU.
    • Category: picked from the category tree.
    • Brand: picked from the manufacturer options.
    • Link: a storefront path such as /deals, or a full http(s) URL. Needs a title and an image.
  3. Optional: override the Title and Image. The image must be a JPG, PNG, GIF, WebP or AVIF file in the media folder, up to 5 MB.
  4. Enter Keywords, comma-separated, or leave them empty for a general promotion.
  5. Set the store view, dates and sort order.
Quick Search Promotions grid in the admin with category, product and brand promotions and their type, target, store view, dates and sort order
Marketing > SEO & Search > Quick Search Promotions.
  • A keyword matches when the search contains it, or it starts with the search: “sams” already matches “samsung”.
  • A promotion whose target is gone is skipped: a disabled, hidden or out-of-stock product, an inactive category, a deleted brand.
  • Links to executables and installers are refused. SVG images are refused.
  • Saving a promotion updates the dropdown immediately. Start and end dates need no cache flush.

Shopper opens the search box

  1. The storefront sends one request for the store view.
  2. It receives up to N popular phrases (most popular first) and the promotion pool.
  3. It shows top searches and general promotions.

Shopper types

  1. The storefront filters the pool locally by keyword match.
  2. Matching and general promotions appear under the product results; no new request.

Merchandiser adds a promotion

  1. They choose a type and target (SKU text; category and brand from lists; link address), optional title and image, keywords, store view, dates and order.
  2. Saving checks the target, link and image and refreshes the store's promotion cache.
  3. The promotion shows from its start date to its end date (inclusive), with no further action.

Moderator curates

  1. On the search phrase list they approve or remove phrases for top searches.
  2. Changes show at once.

First install

  1. Phrases each store view showed at that moment are approved automatically, so the storefront does not change.

These always hold:

  • With approval on, no unapproved phrase is shown.
  • No promotion with a missing or unsafe target is shown.
  • A promotion never shows outside its store view or dates.
  • One part failing or switched off never breaks the other.
  • Keyword match = typed text contains the keyword, or the keyword starts with the typed text, ignoring case.
  • Dates: start ≤ today ≤ end in the store's time zone; open ends allowed.
  • Pool ≤ maximum; phrases ≤ count.
  • Start and end dates take effect without clearing any cache.
  • A saved or deleted promotion shows on the next request.
SituationWhat happens
Someone searches an abusive phrase 10,000 times.Not shown while unapproved.
Promoted product goes out of stock.Promotion dropped.
Link javascript:… or //other-host.Refused on save and dropped on read.
Link to an installer file.Refused.
Vector image renamed as a bitmap.Refused.
End date today.Shown today.
Store view deleted.Its promotions deleted.
50 phrases asked, count 8.8 phrases.
New store without searches.Empty phrases, no error.
  • Every shopper; content per store view; prices for the request's customer group.
  • Search results, product-name autocomplete or ranking.
  • Personalised suggestions.
  • Click or impression tracking.
  • Server-side keyword matching per keystroke.
  • Images hosted outside the store's media.
Terminal window
composer require magenxcommerce/module-quick-search-graph-ql
bin/magento module:enable Magenx_QuickSearchGraphQl
bin/magento setup:upgrade
bin/magento setup:di:compile # production mode only
bin/magento cache:flush
  • PHP ~8.4.0||~8.5.0, Magento 2.4.8.

Settings carry over from Magenx_PopularSearchGraphQl. Both modules can run side by side. Remove the old one only after the storefront release that uses this module is live: an older storefront still asks for the old module’s fields, and Magento would reject its store config query.

Terminal window
bin/magento module:disable Magenx_PopularSearchGraphQl
composer remove magenxcommerce/module-popular-search-graph-ql
bin/magento setup:upgrade

Stores > Configuration > Magenx > Quick Search

Popular Search Terms

SettingDefaultScopeNotes
Enable Popular Search Terms
magenx_quick_search/popular_terms/enabled
emptyStore viewYes/No. When disabled quickSearchSuggestions returns no popular terms and the storefront hides its "Top searches" section.
Number of Terms
magenx_quick_search/popular_terms/count
emptyStore viewText. Shown when Enable Popular Search Terms = Yes. How many terms are returned at most. Terms come from the search_query log (Marketing > SEO & Search > Search Terms); only active terms with results that are shown in suggestions are returned.
Show Only Approved Terms
magenx_quick_search/popular_terms/require_approval
emptyStore viewYes/No. Shown when Enable Popular Search Terms = Yes. Recommended. Shoppers add and rank search terms just by searching, so without approval anyone can push a phrase into every visitor's "Top searches" by repeating it. When on, only terms approved on Marketing > SEO & Search > Search Terms (mass action "Approve for Top Searches", column "Top Searches") are returned.

Promotions

SettingDefaultScopeNotes
Enable Quick Search Promotions
magenx_quick_search/promotions/enabled
YesStore viewYes/No. When disabled quickSearchSuggestions returns no promotions and the storefront shows no sponsored items. Items are managed under Marketing > SEO & Search > Quick Search Promotions.
Maximum Items
magenx_quick_search/promotions/max_items
10Store viewText. Shown when Enable Quick Search Promotions = Yes. How many promotions (active, in date range, in sort order) are returned at most for a store view. The storefront filters these by keyword, so this caps the whole pool, not one dropdown.
  • Magento_Backend::marketing_seo > Quick Search Promotions

Grant these under System > Permissions > User Roles > Role Resources:

ResourceUnderID
Quick Search PromotionsMarketing > Magento_Backend::marketing_seoMagenx_QuickSearchGraphQl::promotion
Quick Search SectionStores > Settings > ConfigurationMagenx_QuickSearchGraphQl::config

The storefront runs quickSearchSuggestions once, the first time the dropdown opens. Keyword matching happens in the browser, so typing costs no extra request. A disabled part returns an empty list, never an error.

Queries

quickSearchSuggestions(popularTermsCount: Int): QuickSearchSuggestions

Everything the storefront's quick-search dropdown shows before results: the store's popular search terms and its sponsored items, for the request's store view. Each part is computed only when selected, and each is empty when its feature is disabled.

ArgumentTypeDescription
popularTermsCountIntHow many popular terms to return (capped at the store's configured count). Defaults to the configured count.

Types

type QuickSearchSuggestions - Quick-search dropdown suggestions for a store view.
FieldTypeDescription
popular_terms[QuickSearchPopularTerm!]!The most searched phrases (Magento's search_query log: active, with results, flagged 'Display in Suggested Terms' and, unless the store turned approval off, approved for top searches by an admin), most popular first.
promotions[QuickSearchPromotion!]!Sponsored items: active, inside their date window, in sort order, capped at the store's configured maximum. Items without keywords are general (shown on open and under every search); items with keywords target searches that match them. Items whose target no longer resolves (deleted, disabled, out-of-stock or invisible product; inactive category; removed brand option; invalid link) are left out.
type QuickSearchPopularTerm - A popular search phrase.
FieldTypeDescription
query_textString!The search phrase as typed by shoppers.
num_resultsIntHow many products the phrase matched when last searched.
popularityIntHow many times the phrase has been searched.
enum QuickSearchPromotionType - What a quick-search promotion points at.
ValueDescription
PRODUCTA product, given by SKU. `product` is set.
CATEGORYA category. `category_url_path` is set.
BRANDA brand: an option of the manufacturer attribute. `brand_label` is set.
LINKA custom link with an admin image: a storefront path or an absolute http(s) URL. `link_url` is set.
type QuickSearchPromotion - One sponsored item in the quick-search dropdown.
FieldTypeDescription
idInt!The promotion id.
typeQuickSearchPromotionType!What the promotion points at.
titleString!Display title: the admin override, else the product name, category name or brand label. Always the admin title for links.
image_urlStringAbsolute image URL: the admin override, else the category image for categories and the manufacturer option's image swatch for brands. Null when none; for products the storefront falls back to `product.image`.
keywords[String!]!Lower-cased targeting keywords. Empty for general promotions.
productProductInterfaceThe promoted product (PRODUCT only).
category_url_pathStringThe category's URL path in the request's store view (CATEGORY only).
brand_labelStringThe brand's manufacturer option label in the request's store view (BRAND only).
link_urlStringWhere the promotion links: a storefront path starting with `/`, or an absolute http(s) URL (LINK only).
TermMeaning
Search phraseA logged search: text, result count, popularity, store view.
Popular phraseActive phrase with results, marked for suggestions, approved when approval is on.
ApprovalAdmin flag allowing a phrase into top searches.
PromotionSponsored dropdown item: type, target, optional title and image, keywords, store view, dates, order.
TargetProduct SKU, category, brand, or link address.
General promotionPromotion without keywords; shown on opening and with every search.
Keyword matchThe typed text contains a keyword, or a keyword starts with the typed text.
PoolAll live promotions for a store view, loaded once per opening.