承接 amadeco/module-elasticsuite-stock 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amadeco/module-elasticsuite-stock

Composer 安装命令:

composer require amadeco/module-elasticsuite-stock

包简介

Enhance your Magento 2 store with an advanced stock filter in ElasticSuite's layered navigation. This module provides customers with the ability to easily filter products by stock availability, improving the shopping experience and helping them find in-stock items faster.

README 文档

README

Latest Stable Version Magento 2 PHP License

SPONSOR: Amadeco

This module by Amadeco extends Smile ElasticSuite (https://github.com/Smile-SA/elasticsuite) to add an advanced stock filter in the layered navigation.

PR to reimplement "quantity_and_stock_status" product attribute (currently open) : magento/magento2#40425 (comment)

Features

Capture d'écran 2025-04-13 à 21 23 40
  • Adds a dedicated stock filter in the layered navigation
  • Intelligent handling of stock status based on Magento's backorders configuration
  • Improves user experience by showing accurate product availability
  • Provides clear "In Stock" and "Out of Stock" filter options
  • Fully compatible with Magento's MSI (Multi-Source Inventory)

Installation

composer require amadeco/module-elasticsuite-stock
bin/magento module:enable Amadeco_ElasticsuiteStock
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:clean
bin/magento indexer:reindex catalogsearch_fulltext

Requirements

  • PHP 8.3+
  • Magento 2.4.x
  • Smile ElasticSuite 2.12.0 or higher (introduces the layered-navigation filter TypeProviderInterface)

Configuration

Go to Stores > Configuration > ElasticSuite > Stock Filter

Configure the following options:

  • Display Out Of Stock Filter: When enabled, shows the "Out of Stock" option in the layered navigation. When disabled, only the "In Stock" option is shown.

Usage

After installation and configuration, the stock filter will automatically appear in the layered navigation on category pages and search results pages (remember to reindex after installation).

How It Works

Smart Stock Status Determination

This module creates an indexed attribute stock_status that handles stock differently based on your Magento configuration:

When Backorders are Disabled

  • Uses Magento's native stock status logic
  • Products are either in stock or out of stock, as determined by Magento's inventory system

When Backorders are Enabled

  • Enhanced behavior: Determines availability based on actual quantity
  • Products with quantity > 0 are marked as "In Stock"
  • Products with quantity ≤ 0 are marked as "Out of Stock" (even if Magento would allow them to be ordered)
  • This gives customers a clearer view of which products have physical inventory

Filter Options in Layered Navigation

The filter provides these options:

  1. In Stock:

    • Shows products with positive inventory when backorders are enabled
    • Follows standard Magento stock status rules when backorders are disabled
  2. Out of Stock (can be hidden via configuration):

    • Shows products with zero or negative inventory when backorders are enabled
    • Shows products marked as out of stock when backorders are disabled

This approach helps customers find products based on actual availability while respecting your inventory settings.

Technical Details

Stock Data Implementation

This module leverages the existing stock.is_in_stock and stock.qty fields from quantity_and_stock_status attribute and creates a derived stock_status field that combines this information intelligently.

Instead of relying on Magento's quantity_and_stock_status attribute (which has limitations for filtering ; see reported issue: magento/magento2#33453), our module:

  • Creates a dedicated filterable attribute for stock status
  • Applies specific logic when backorders are enabled to show actual inventory status
  • Integrates seamlessly with ElasticSuite's facet filtering system

Compatibility with Other ElasticSuite Modules

Filter registration: TypeProvider pattern (no FilterList override)

This module has no dependency on Smile_ElasticsuiteRating and does not override Smile\ElasticsuiteCatalog\Model\Layer\FilterList.

The stock renderer is registered through the core ElasticSuite filterTypeProviders pool. Smile\ElasticsuiteCatalog\Model\Layer\FilterList::getAttributeFilterClass() iterates every injected Smile\ElasticsuiteCatalog\Api\Layer\Filter\TypeProviderInterface and lets it swap the filter class for its attribute. We provide one for stock_status:

<type name="Smile\ElasticsuiteCatalog\Model\Layer\FilterList">
    <arguments>
        <argument name="filterTypeProviders" xsi:type="array">
            <item name="stock" xsi:type="object">Amadeco\ElasticsuiteStock\Model\Layer\Filter\TypeProvider\Stock</item>
        </argument>
    </arguments>
</type>

Because the core categoryFilterList and searchFilterList virtual types extend that base type, they inherit the provider automatically — no preference, no virtual-type override, and no module load-order constraint against other filter modules.

Earlier versions extended FilterList and added a second preference over Smile\ElasticsuiteRating\Model\Layer\FilterList to resolve a preference conflict. Both the rating module (PR #19) and this module have since migrated to the TypeProvider pattern, so the conflict — and the dependency — no longer exist. Multiple filter modules now coexist cleanly because each only appends its own provider to the shared pool.

License

This module is licensed under the Open Software License ("OSL") v3.0. See the LICENSE.txt file for details.

amadeco/module-elasticsuite-stock 适用场景与选型建议

amadeco/module-elasticsuite-stock 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.15k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「search」 「inventory」 「elasticsearch」 「stock」 「magento」 「merchandising」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 amadeco/module-elasticsuite-stock 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 amadeco/module-elasticsuite-stock 我们能提供哪些服务?
定制开发 / 二次开发

基于 amadeco/module-elasticsuite-stock 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2025-04-11