hryvinskyi / magento2-catalog-sorting-no-image
Catalog sorting rule: products with a listing image before products without one in category listings and, optionally, search results.
Package info
github.com/hryvinskyi/magento2-catalog-sorting-no-image
Type:magento2-module
pkg:composer/hryvinskyi/magento2-catalog-sorting-no-image
Requires
- php: ~8.1.0||~8.2.0||~8.3.0||~8.4.0||~8.5.0
- hryvinskyi/magento2-catalog-sorting: ^1.0
- magento/framework: *
- magento/module-backend: *
- magento/module-catalog: *
- magento/module-config: *
- magento/module-eav: *
- magento/module-store: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Lists products with a listing image before products without one, on category pages or on category and search pages, whatever sort the shopper chose. A leading sort rule of hryvinskyi/magento2-catalog-sorting.
What it does for a store
- Products without images go last. Products whose listing image (
small_image) is not set go after the others; the shopper's sort orders each group. No value, an empty value andno_selectionall count as no image; a store-view value wins over the default one. - Category pages, or search too. Per store view: off, on category pages, or on category and search pages.
- Missing data never buries a product. A product without the field in its search document counts as having an image.
- Written at index time, nothing per request. Whether a product has an image is written into its search document as the numeric field
sort_has_image, with one query per batch of products. The engine sorts on it; there is no join and no computation per query. - Switching the setting needs no reindex. The field is written in every store whatever the store's setting.
Requirements
- PHP 8.1 to 8.5.
hryvinskyi/magento2-catalog-sorting^1.0.- The platform's Catalog, Eav, Store, Config and Backend modules (what
composer.jsonandetc/module.xmldeclare).
Installation
composer require hryvinskyi/magento2-catalog-sorting-no-image bin/magento setup:upgrade bin/magento setup:di:compile bin/magento cache:flush bin/magento indexer:reindex catalogsearch_fulltext
The module adds the field sort_has_image to the product search documents. One full catalogsearch_fulltext reindex puts it into the index mapping and writes the values; listings keep working before it, and every product counts as having an image until then.
Configuration
Stores › Configuration › Catalog › Catalog Sorting › Products without Images
| Path | Label | Default | Scope |
|---|---|---|---|
catalog_sorting/no_image/mode |
Show Products without Images Last: No (0), On Category Pages (1), On Category and Search Pages (2) |
No | default, website, store view |
Registrations
| Pool | Item |
|---|---|
rules of Hryvinskyi\CatalogSorting\Model\Search\LeadingSorts |
no_image, sortOrder 200: after the out-of-stock rule (100) when both are installed |
providers of Hryvinskyi\CatalogSorting\Model\Index\DocumentFields |
has_image, field sort_has_image (integer) |
A product's image state in the index changes when its search document is rebuilt.