Diese Magento 2 Extension zeigt bei konfigurierbaren Produkten (z. B. Größen- oder Farb-Swatches) direkt an, ob die jeweilige Variante auf Lager ist, basierend auf einem konfigurierbaren Schwellenwert.
Conlabz_StockIndicator erweitert die JSON-Konfiguration des Configurable-Product-Blocks (Magento\ConfigurableProduct\Block\Product\View\Type\Configurable) über ein Plugin um Lagerbestandsinformationen:
- Für jede erlaubte Produktvariante wird die aktuelle Lagermenge (
StockStateInterface::getStockQty) ermittelt. - Ein JavaScript-Mixin für den Swatch-Renderer (
view/frontend/web/js/swatch-renderer-mixin.js) nutzt diese Daten, um Varianten unterhalb des Schwellenwerts entsprechend zu markieren. - Die Texte "In stock" / "Out of stock" sowie der Schwellenwert werden über ein ViewModel (
StockInfo) bereitgestellt.
Im Magento Backend unter Stores > Configuration > Catalog > Inventory > Stock Indicator:
- Out of stock threshold (
cataloginventory/stock_indicator/out_of_stock_threshold) – Schwellenwert, ab dem eine Variante als "Out of stock" markiert wird. Standardwert:0.
Modulreihenfolge (etc/module.xml): Magento_ConfigurableProduct, Magento_CatalogInventory.
composer require conlabz/magento2-module-stock-indicator
bin/magento module:enable Conlabz_StockIndicator
bin/magento setup:upgradeBei Fragen zu dieser Extension: conlabz.de
Conlabz_StockIndicator extends the JSON configuration of the configurable product block (Magento\ConfigurableProduct\Block\Product\View\Type\Configurable) via a plugin with stock information:
- For every allowed product variant, the current stock quantity is determined (
StockStateInterface::getStockQty). - A JavaScript mixin for the swatch renderer (
view/frontend/web/js/swatch-renderer-mixin.js) uses this data to mark variants below the threshold accordingly. - The "In stock" / "Out of stock" texts and the threshold are provided via a view model (
StockInfo).
In the Magento admin under Stores > Configuration > Catalog > Inventory > Stock Indicator:
- Out of stock threshold (
cataloginventory/stock_indicator/out_of_stock_threshold) – quantity threshold below which a variant is marked as "Out of stock". Default value:0.
Module sequence (etc/module.xml): Magento_ConfigurableProduct, Magento_CatalogInventory.
composer require conlabz/magento2-module-stock-indicator
bin/magento module:enable Conlabz_StockIndicator
bin/magento setup:upgradeFor questions about this extension: conlabz.de
This extension is licensed under the MIT License. See LICENSE for details.