angelvilaplana / module-visual-search-hyva
Hyvä Themes compatibility for the Magento 2 visual search module: search the catalog with a photo.
Package info
github.com/angelvilaplana/magento2-visual-search-hyva
Language:HTML
Type:magento2-module
pkg:composer/angelvilaplana/module-visual-search-hyva
Requires
- php: ~8.2.0||~8.3.0||~8.4.0||~8.5.0
- angelvilaplana/module-visual-search: ^1.2
- hyva-themes/magento2-compat-module-fallback: ^1.1
- hyva-themes/magento2-theme-module: ^1.3.14
- magento/framework: ^103.0.7
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Hyvä Themes compatibility for Visual Search for Magento 2: shoppers search your catalog with a photo, from a camera button inside the Hyvä search field.
- The camera opens on phones and the file picker on desktop, where an image can also be dragged onto the search field.
- Results are shown on the Hyvä search result page, with the shopper photo, layered navigation, sorting and pagination.
- Built the Hyvä way: Alpine.js components, Tailwind CSS and no RequireJS or jQuery. Works with the default and the CSP Hyvä themes.
- Only the frontend is replaced. Search, indexing, security and configuration are provided by the Visual Search module, so Luma and Hyvä store views behave the same.
| Mobile | Results |
|---|---|
![]() |
![]() |
Requirements
| Component | Version |
|---|---|
Visual Search for Magento 2 (angelvilaplana/module-visual-search) |
1.2 or later, installed and configured |
Hyvä Theme (hyva-themes/magento2-theme-module) |
1.3.14 or later |
| PHP | 8.2 – 8.5 |
Tested with Magento 2.4.9, PHP 8.5 and Hyvä Theme 1.5.5, with the default theme and with the CSP theme in strict mode (no unsafe-inline or unsafe-eval scripts).
Installation
composer require angelvilaplana/module-visual-search-hyva bin/magento module:enable AngelVilaplana_VisualSearchHyva bin/magento setup:upgrade bin/magento hyva:config:generate
Then rebuild the CSS of your Hyvä theme so it includes the module's Tailwind classes:
cd app/design/frontend/<Vendor>/<theme>/web/tailwind npm run build
In production mode, also run bin/magento setup:di:compile and bin/magento setup:static-content:deploy.
There is nothing to configure in this module: enable visual search in Stores > Configuration > Catalog > Visual Search as described in the Visual Search README.
How it works
The module is registered as a Hyvä compatibility module for AngelVilaplana_VisualSearch, so it only changes store views that use a Hyvä theme:
- Search field: a block in the
hyva_defaultlayout renders an Alpine.js component that is moved into the search field (#search_mini_form .input-group) withx-teleport. The Hyvä search form template is not replaced, so theme customizations of it are kept. - Result page: the Visual Search photo template (
AngelVilaplana_VisualSearch::photo.phtml) is replaced by an Alpine.js version through the Hyvä compatibility module fallback. - Scripts: inline scripts are registered with
HyvaCsp, and the Alpine.js components only use property and method names, as required by the Hyvä CSP theme. - Styles:
view/frontend/tailwind/module.cssadds the module templates to the Tailwind sources of the theme.
The photo is resized and converted to JPEG in the browser before upload, and the thumbnail shown on the result page stays in the browser session storage, exactly as in Luma.
Customization
Override the templates in your theme, as with any Hyvä module:
| Template | Theme path |
|---|---|
| Camera button | app/design/frontend/<Vendor>/<theme>/AngelVilaplana_VisualSearchHyva/templates/form.phtml |
| Shopper photo on the result page | app/design/frontend/<Vendor>/<theme>/AngelVilaplana_VisualSearchHyva/templates/photo.phtml |
If your theme replaces the search form with one that has no #search_mini_form .input-group element, override form.phtml and change the x-teleport target.
Running the tests
The integration tests render the pages with the Hyvä and the Luma themes. Run them from the Magento integration test folder:
cd dev/tests/integration
../../../vendor/bin/phpunit -c phpunit.xml.dist ../../../vendor/angelvilaplana/module-visual-search-hyva/Test/Integration


