elasticsuite
elasticsuite copied to clipboard
The ability to exclude out of stock simple product options from filters for configurable product.
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
The default Magento implementation is to not index the attribute options of simples that are out of stock.
Hello @Hexmage,
Which version of Magento you are using?
BR, Vadym
@vahonc Tested it on 2.4.2
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 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.
@romainruaud On second look I need to modified the workaround slightly because one of the classes got moved and deprecated.
Did it help you solving your issue @Hexmage ?
Regards
@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.
Ok @Hexmage
do you mind if I close ?
Regards
@romainruaud I'd still like it to become a default feature in Elasticsuite though.
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
@Hexmage could you show how you were able to fix this issue ? I'm also looking for a solution for this problem.
Thanks!
@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;
}
}
My customer just notified me of the same issue. Is there a permanent fix for this or a fix in sight?
@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
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.
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.
Hi @ioweb-gr
Feel free to use the workaround given above by @Hexmage until we implement this as a configurable option.
Regards
@romainruaud I used the workaround as well it seems to mitigate the issue