Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Hexmage opened this issue Jun 2, 2022 · 21 comments

Comments

@Hexmage
Copy link

Hexmage commented Jun 2, 2022

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 Hexmage added the feature label Jun 2, 2022
@Hexmage
Copy link
Author

Hexmage commented Jun 2, 2022

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

@vahonc
Copy link
Collaborator

vahonc commented Jun 2, 2022

Hello @Hexmage,

Which version of Magento you are using?

BR,
Vadym

@Hexmage
Copy link
Author

Hexmage commented Jun 2, 2022

@vahonc
Tested it on 2.4.2

@romainruaud
Copy link
Collaborator

Hi @Hexmage

Apart from Vadym's questions, this issue looks like this one : #809

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

Regards

@Hexmage
Copy link
Author

Hexmage commented Jun 2, 2022

@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
Copy link
Author

Hexmage commented Jun 2, 2022

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

@romainruaud
Copy link
Collaborator

Did it help you solving your issue @Hexmage ?

Regards

@Hexmage
Copy link
Author

Hexmage commented Jun 9, 2022

@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.

@romainruaud
Copy link
Collaborator

Ok @Hexmage

do you mind if I close ?

Regards

@Hexmage
Copy link
Author

Hexmage commented Jun 9, 2022

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

@romainruaud
Copy link
Collaborator

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

@joachimVT
Copy link

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

Thanks!

@Hexmage
Copy link
Author

Hexmage commented Aug 12, 2022

@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;
    }
}

@onepack
Copy link

onepack commented Dec 8, 2023

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

@vahonc
Copy link
Collaborator

vahonc commented Dec 11, 2023

@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

@onepack
Copy link

onepack commented Dec 13, 2023

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.

@ioweb-gr
Copy link

ioweb-gr commented Jan 12, 2024

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.

@romainruaud
Copy link
Collaborator

Hi @ioweb-gr

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

Regards

@ioweb-gr
Copy link

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

@rikwillems
Copy link

I did some research into this as I'm running into the issue as well. It turns out the stock qty is not indexed per simple. The relationship with the simples is stored, among with its attributes. The plugin filters out the out of stock simples from that relation, so prevents them from being indexed.
Now, I'm not sure whether the relationship with out of stock simples has a use case for being in the index. Maybe we could have Elasticsuite look at the Magento core setting to display out of stock products or not.

The provided plugin works for non-MSI, but the MSI implementation is the same. That runs through the non-deprecated class. If we come to a solution of how it should work based on requirements and Elasticsuite internal workings I will work out a PR for this.

@vahonc
Copy link
Collaborator

vahonc commented Dec 9, 2024

@rikwillems,

Thank you for sharing your observations and research on this issue.

Indeed the proposed workaround here works for non-MSI setups but relies on a deprecated class, making it less future-proof.
As we know, Adobe has decided to replace MSI as the standard inventory management system for Magento. Unfortunately, Adobe has not provided a timeline for this transition, leaving many projects in a state of uncertainty. Therefore, the legacy Inventory module is still available, but it is expected to be deprecated entirely in the future.

I'm not sure if the MSI implementation is the same as for non-MSI. Because MSI uses a different inventory model that doesn't fully rely on the legacy inventory module. So, I believe this plugin won't be effective for stores that use MSI. Of course I could be wrong.

At this point we still don't have a clear vision of the solution, it would be OK for us if this were implemented as a configurable option. You can suggest a PR based on your research and we will see if it suits us.

BR,
Vadym

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants