elasticsuite icon indicating copy to clipboard operation
elasticsuite copied to clipboard

The ability to exclude out of stock simple product options from filters for configurable product.

Open Hexmage opened this issue 2 years ago • 19 comments

Is your feature request related to a problem? Please describe. We have a pair of shoes. Which are a configurable product. They have 3 sizes 35, 36 and 37. Size 35 is out of stock the other 2 sizes are in stock. Currently the configurable product is returned if you filter on size 35, 36 or 37. While we only want it to be returned when you filter for 36 or 37

Describe the solution you'd like The option to not return a configurable product when you filter on the simple products attribute value when that simple product is out of stock. Especially for fashion products, which very regularly don't get new stock when the original stock is gone, this option is very much a necessity to prevent disappointment for your customers

Hexmage avatar Jun 02 '22 11:06 Hexmage

The default Magento implementation is to not index the attribute options of simples that are out of stock.

Hexmage avatar Jun 02 '22 13:06 Hexmage

Hello @Hexmage,

Which version of Magento you are using?

BR, Vadym

vahonc avatar Jun 02 '22 13:06 vahonc

@vahonc Tested it on 2.4.2

Hexmage avatar Jun 02 '22 13:06 Hexmage

Hi @Hexmage

Apart from Vadym's questions, this issue looks like this one : https://github.com/Smile-SA/elasticsuite/issues/809

A workaround was given by an other user, maybe it's worth givin it a try.

Regards

romainruaud avatar Jun 02 '22 13:06 romainruaud

@romainruaud That looks like it would work.

The difference between elasticsuite and default elasticsearch, is that search doesn't index out of stock products (when configured correctly). While suite uses a filter when requesting them from the elasticsearch server and because the simple product stock data is not known by elasticsearch there is no way to filter them properly.

Hexmage avatar Jun 02 '22 13:06 Hexmage

@romainruaud On second look I need to modified the workaround slightly because one of the classes got moved and deprecated.

Hexmage avatar Jun 02 '22 13:06 Hexmage

Did it help you solving your issue @Hexmage ?

Regards

romainruaud avatar Jun 08 '22 13:06 romainruaud

@romainruaud Slightly modifying that plugin did indeed fix my problem. It does however use a now deprecated class. So it might break with a future update.

Hexmage avatar Jun 09 '22 07:06 Hexmage

Ok @Hexmage

do you mind if I close ?

Regards

romainruaud avatar Jun 09 '22 13:06 romainruaud

@romainruaud I'd still like it to become a default feature in Elasticsuite though.

Hexmage avatar Jun 09 '22 14:06 Hexmage

I agree this could be helpful, considering the number of times we've had this question asked there.

Could you work on a PR for this ?

I'd like this setting to be disabled by default (to not mess up with existing install) and being activable through configuration.

Regards

romainruaud avatar Jun 27 '22 12:06 romainruaud

@Hexmage could you show how you were able to fix this issue ? I'm also looking for a solution for this problem.

Thanks!

joachimVT avatar Jul 11 '22 14:07 joachimVT

@romainruaud @joachimVT This is what I ended up with, but this uses a deprecated class of the module so it isn't guaranteed to stay fixed.

A plugin on the Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Indexer\Fulltext\Datasource\AttributeData class

use Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Indexer\Fulltext\Datasource\AttributeData as Source;
use Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Indexer\Fulltext\Datasource\Deprecation\InventoryData;

class AttributeData
{
    private $inventoryData;

    /**
     * @param InventoryData $inventoryData
     */
    public function __construct(InventoryData $inventoryData)
    {
        $this->inventoryData = $inventoryData;
    }

    /**
     * @param AttributeData $subject
     * @param callable $proceed
     * @param $productIds
     * @param $storeId
     * @return mixed
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function aroundLoadChildrens(Source $subject, callable $proceed, $productIds, $storeId)
    {
        $children = $proceed($productIds, $storeId);

        $inventoryData = $this->inventoryData->loadInventoryData($storeId, array_keys($children));

        foreach ($inventoryData as $inventoryDataRow) {
            $productId = (int) $inventoryDataRow['product_id'];
            if (!$inventoryDataRow['stock_status']) {
                unset($children[$productId]);
            }
        }

        return $children;
    }
}

Hexmage avatar Aug 12 '22 13:08 Hexmage

My customer just notified me of the same issue. Is there a permanent fix for this or a fix in sight?

onepack avatar Dec 08 '23 14:12 onepack

@onepack,

We don't have a working solution at the moment, but you can try the workaround suggested by another user. We will try to return to this in our future releases.

BR, Vadym

vahonc avatar Dec 11 '23 15:12 vahonc

I've implemented this suggested fix with an extra module but I needed to use a deprecated class. Also I had to find out that there's a big difference between using the Inventory module set or not.

onepack avatar Dec 13 '23 20:12 onepack

Guys indeed this is a huge issue. The customer is filtering products to find his shoe in the proper size and he gets 1000 results while in actuality only 10 are available for purchase. It's hindering sales. We just got notified by our client that we need to fix this asap as the telephone calls are now insanely high due to this :( It's pushing customers to purchase by the phone instead of online. I also believe it should be marked as a bug not a feature, because by default we have the option not to show out of stock products in the catalog, so they shouldn't be included in any area like search / layered navigation etc etc.

ioweb-gr avatar Jan 12 '24 13:01 ioweb-gr

Hi @ioweb-gr

Feel free to use the workaround given above by @Hexmage until we implement this as a configurable option.

Regards

romainruaud avatar Jan 12 '24 16:01 romainruaud

@romainruaud I used the workaround as well it seems to mitigate the issue

ioweb-gr avatar Jan 14 '24 09:01 ioweb-gr