Setting up configurable products and using the text swatch option to select shirt sizes. The issue is the out of stock shirt text swatches are still showing up, clickable, and have no styling to show that they are out of stock. I'd like the swatch to still show up, but not be clickable and appear faded out or something so you know they are out of stock. Any help?
I'm not seeing any class for out of stock being passed through that I can style with CSS.
This worked fine in Magento 1, where on drop downs the out of stock simple products were not selectable, but in Magento 2, both on drop downs and text swatches they still show up and you can click on them, but when added to the cart you get the "product not in stock" error.
@dapdx thank you for your report.
Please provide description according to the template: with steps, actual result and expected result.
Please also provide the used version. If the problem is actual for a specific tag, please, specify it and be sure that the latest update was used.
Magento 2.1
PHP 7
Steps to Reproduce
Expected Result
Actual Result
I also have the same problems and then I have to use an extension from the third part to solve it although this issue can be overcome quite easily in Magento 1 as you have said.
I have been using this Magento 2 extension - Configurable product grid table view bought from a Magento provider to make out of stock product still visible but unavailable to choose quantity in the box . The quantity box is faded and cannot fill in.
I can confirm this on a fresh 2.1 system.
Really bad bug as we have lots of sizes :-/
@dapdx Thanks for reporting this issue.
We've created internal ticket MAGETWO-56480 to fix it.
This bug came up when I updated a site from 2.02 to 2.1. Before the out-of-stock options were not shown. A quick fix to hide them (probably won't work with multiple options)
is to modify the /vendor/magento/module-swatches/Block/Product/Renderer/Configurable.php file
change the getConfigurableOptionsIds function to this
protected function getConfigurableOptionsIds (array $attributeData) {
$ids = [];
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
foreach ($this->getAllowProducts() as $product) {
if (0 == $StockState->getStockQty($product->getId(), $product->getStore()->getWebsiteId())) continue;
/** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $attribute */
foreach ($this->helper->getAllowAttributes($this->getProduct()) as $attribute) {
$productAttribute = $attribute->getProductAttribute();
$productAttributeId = $productAttribute->getId();
if (isset($attributeData[$productAttributeId])) {
$ids[$product->getData($productAttribute->getAttributeCode())] = 1;
}
}
}
return array_keys($ids);
}
I also have this problem. Worked in 2.0 but on 2.1 it does not.
http://foxtrotboutique.com/sally-gaucho-crop-denim-by-level-99-white.html Size 24 for example is out of stock and should not let you choose it, but it lets you pick it until you try to add to cart and then gives an out of stock message
Hi, I had similar problem but the client did not want to hide products out of stock but display on gray or other a style (as unavailable).
I've prepared simple module to that: https://github.com/mjankiewicz/MagentoConfigurableProduct
Maybe it will be useful for someone :)
Hi @mjankiewicz,
Tried installing your module (followed the steps), but wasn't able to make it work (tried to install it on a fresh M2.1 environment).
Badly need a fix for this issue for our client.
Thanks!
Hi @MhorGonzales,
1) the module is enabled ? php bin/magento module:status
2) do you see some error messages on the frontend or backend ?
@MhorGonzales
I've checked again my module on fresh Magento 2 (sample data) and everything works fine.
Detail view without module:
And with module:
it seemed to work in 2.01 but on 2.1 it does not. 聽Are you using 2.1?
-------- Original Message --------
Subject: Re: [magento/magento2] Magento 2 configurable product selection
stock issue (#5948)
From: mjankiewicz [email protected]
Date: Wed, August 31, 2016 3:07 am
To: magento/magento2 [email protected]
Cc: epadmin [email protected], Comment
[email protected]
@MhorGonzales I've checked again my module on fresh Magento 2 (sample data) and everything works fine. Detail view without module: And with module: 鈥擸ou are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
Yes. I use Magento ver. 2.1.1 (installed by composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2demo
)
Hi @mjankiewicz,
Thank you for the response, after investigation, it seems that this conflicts with the extension MagicToolbox_MagicZoom.
Anyway, it is working now. However, is there a tweak where in it should show the slash/not-available, if just the status alone is "Out of Stock", regardless of the "Quantity" value? As observed, "Quantity" should be set to zero (0) for this to work.
Thank you in advance.
@mjankiewicz Does it mean, this issue is still not yet resolved in 2.1.1???
Yes. The issue isn't resolved in 2.1.1. (tested on fresh installation Magento 2.1.1 with sample data)
Hi,
I also have this problem and i'm using 2.1.1
@magento-team
This is another MUST-FIX bug - a normal logic at an commerce site! I have no idea why this worked before and is missing now. Can you pls give us a feedback when this one will work again.
I think one of the main problems with m2 at this stage is that new bugs come in with every release like waves at a beach - and only some are fixed. Very frustrating at the moment to be honest.
Can confirm the problem with 2.1.1
And @mjankiewicz 's module worked great! Thanks a lot, really saved my hair :)
Thanks @mjankiewicz, your module is working for me on 2.1.1.
BTW. Is anyone here using M2 on live site with configurable products and if so how did you resolve this issue with first associated product becoming out of stock?https://github.com/magento/magento2/issues/6799
@mjankiewicz Looks like a cool module. But I can't use composer. Do you have a .zip version?
thx.
1) https://github.com/mjankiewicz/MagentoConfigurableProduct
2)
thanks for your help guys. At this point we are scrapping our attempts for an M2 site and starting over with an M1 site.
This is really frustrating. Run into the same problem. I'm already using several 3rd party and self written modules to fix these kind of bugs. Almost three months now for such a basic functionality.
Here the query that retrieves catalog products after filter
SELECT `main_select`.`entity_id`, MAX(score) AS `relevance`
FROM (
SELECT `search_index`.`entity_id`, (((0) + (0)) * 1) AS `score`
FROM `catalogsearch_fulltext_scope2` AS `search_index`
LEFT JOIN `catalog_eav_attribute` AS `cea` ON search_index.attribute_id = cea.attribute_id
LEFT JOIN `catalog_category_product_index` AS `category_ids_index` ON search_index.entity_id = category_ids_index.product_id
LEFT JOIN `catalog_product_index_eav` AS `kam_taglia_individuale_camicia_filter` ON search_index.entity_id = kam_taglia_individuale_camicia_filter.entity_id AND kam_taglia_individuale_camicia_filter.attribute_id = 153 AND kam_taglia_individuale_camicia_filter.store_id = 2
LEFT JOIN `cataloginventory_stock_status` AS `stock_index` ON search_index.entity_id = stock_index.product_id AND stock_index.website_id = 0
WHERE (stock_index.stock_status = 1)
AND (category_ids_index.category_id = 41)
AND (kam_taglia_individuale_camicia_filter.value = '243')
) AS `main_select`
GROUP BY `entity_id` ORDER BY `relevance` DESC
LIMIT 10000
you could see the subquery
SELECT `search_index`.`entity_id`, (((0) + (0)) * 1) AS `score`
FROM `catalogsearch_fulltext_scope2` AS `search_index`
LEFT JOIN `catalog_eav_attribute` AS `cea` ON search_index.attribute_id = cea.attribute_id
LEFT JOIN `catalog_category_product_index` AS `category_ids_index` ON search_index.entity_id = category_ids_index.product_id
LEFT JOIN `catalog_product_index_eav` AS `kam_taglia_individuale_camicia_filter` ON search_index.entity_id = kam_taglia_individuale_camicia_filter.entity_id AND kam_taglia_individuale_camicia_filter.attribute_id = 153 AND kam_taglia_individuale_camicia_filter.store_id = 2
LEFT JOIN `cataloginventory_stock_status` AS `stock_index` ON search_index.entity_id = stock_index.product_id AND stock_index.website_id = 0
WHERE (stock_index.stock_status = 1)
AND (category_ids_index.category_id = 41)
AND (kam_taglia_individuale_camicia_filter.value = '243')
the issue is that the query joins between catalog_product_index_eav
'entity_id','attribute_id','store_id','value',
'2233','153','1','216',
'2233','153','1','217',
'2233','153','1','243',
'2233','153','2','216',
'2233','153','2','217',
'2233','153','2','243',
'2233','153','3','216',
'2233','153','3','217',
'2233','153','3','243',
'2233','153','4','216',
'2233','153','4','217',
'2233','153','4','243'
where table correctly has ONLY CONFIGURABLE PRODCUTS, but INCORRECTLY has attribute value of child products that are OUT OF STOCK (compared to magento1.9). I think there is an error in reindex process that not clean properly this table.
if i clean manually the table removing out of stock record, after run magento indexer:reindex catalog_product_attribute
they return! The reindex is bugged, please verify and confirm! (magento 2.1.2)
Related question:
is normal that if i flagged USE PRODUCT FLAT TABLE, magento continue to use and search in catalog_product_index_eav
?
@duhon, what's the status of this bug?
We can't publish our website without a proper solution.
Thanks
Any news?
EHILA???!?!?! no one magento contributor here?
It is very incredible how magento release these bug, they deserve a nobel.
I also have this problem in v. 2.1.2
I have the same issue in Magento 2.1.2
It won't even stop showing item with 0 quantity and buyers can still buy it.
And I chose not to show any product out of stock, but the issue still there.
Tried to install mjankiewicz's project.
But actually I have no idea how to do that.
I use it as a extension (put it under app/code/mjankiewicz/MagentoConfigurableProduct)
And put all files into it.
Than use php bin/magento setup:upgrade and php bin/magento setup:di:compile
But it ends up with errors.
Does any one can tell me how to use the project@@?
A very, very big and frustrating problem :(
Any update for this???? All sentiments about how this is a problem has already been shared, so I won't reiterate, but need a fix. @mjankiewicz will this work on Magento 2.1.2 installation? Thanks!
@jmtakahashi yes. it works with 2.1.2
@mjankiewicz thanks! will test installation now.
We totally agree with @immist
The community has found 2 major bugs on your configurable products (#6799 and #5762), 1 crashing the entire catalog, and the other one not handling configurable options stock properly. It is hard to think that we have to look for third party extension or in-house development to overcome these issues.
@magento-admin @magento-team : when can we expect for you to attend these issues ?
We thank you in advance to let us know about the status of these issues.
I have just upgraded 2.1.2 to 2.1.3:
2.1.3 release notes:
Magento now correctly displays the status of all child products of a configurable product, even disabled ones. Previously, Magento did not correctly display the status of a configurable product鈥檚 child product if the child product were disabled.
However, I am still having this issue. Has 2.1.3 resolved this for anyone? Perhaps I have missed something?
Any updates on this issue, very frustrating that this simple feature does not work. Thanks
Magento 2.1.3 solved this issue for us.
Did Magento 2.1.3 solve this for anyone else?
2.1.3 solved for me too.
am using 2.1.5 but these problem stile there !
I must to change status manually vi MySQL
What variable do you change in MySQL?
stock_status to 1 on cataloginventory_stock_status table
but now I change PHP version to 5.6 and it's work fine
Just upgraded to 2.1.7 and this is still an issue for us.
The module https://github.com/mjankiewicz/MagentoConfigurableProduct works ok for swatches, but not drop downs.
Does anyone have a fix?
For magento 2.1.6 to work i was needed to create another custom module.
See the answer
@dapdx, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
its only work on swatches icons not on dropdown
Awesome solution..Its working
So it this issue fixed properly in 2.1.9?
Meaning, swatches are still displayed, but unselectable?
Currently, my store just hides the sizes that are out of stock, and only shows sizes that are in stock. I'n assuming this is proper behavior, but is there way to show the sizes that are out if stock as well, and disable them from being selectable?
I have checked this in 2.2.0. After applying above solution, It shows sizes which are out of stock and they wont be selectable.
@diptihere which solution are you referring to? The mjankiewicz extension doesn't work "out of the box" on my 2.1.9 store.
Yes, mjankiewicz extension. It worked for me. U just have to override this getOptions method. Is there any error u r getting.
@diptihere how do I override the getOptions method? Maybe thats where the problem is.
Magento 2.2.1 - I have tried the solution from @mjankiewicz but the product pages and search return blank or broken.
Update: @mjankiewicz works when installed via composer. When I tried via zip and upload, it didn't but does when installed via composer.
Magento 2.2.2 - Still not working...
@mjankiewicz your solution is only a partial fix.
It will not work in the following situations;
If only one attribute Size as Text Swatch is available ( Size dropped )
If Color and Size are set but one Color has no Sizes available ( Color dropped )
If none of the Colors have one of the Size available ( Size dropped )
Looking at the php and javascript there does not seem to be an easy fix for every situation.
In my opinion all available Simple products should always render ( with exception of disabled Simple products )
In the case Stock alerts are enabled and backorders are turned off, out of stock Simple products should be selectable after selecting a Stock alert text + link should appear below the options.
Something like;
We are sorry this product is not available at this time, LINK NOTIFY ME when the product becomes available.
@dawhoo @Wernervanrun I think I have found the reason why this error appeared. Please, review this PR - https://github.com/magento/magento2/pull/12936
The main problem, from my point of view, was in the incorrect stock status filter appliance. It was successfully implemented previously in Magento\ConfigurableProduct\Model\Product\Type\Configurable::getSalableUsedProducts(\Magento\Catalog\Model\Product $product, $requiredAttributeIds = null)
This method called the $this->loadUsedProducts($product, $cacheKey, true);
method where 3rd param allows stock status filter in Magento\ConfigurableProduct\Model\Product\Type\Configurable::loadUsedProducts(\Magento\Catalog\Model\Product $product, $cacheKey, $salableOnly = false)
Since 100.2.0 method the getSalableUsedProducts
method was deprecated.
About suggested solution in the helper class: to be honest, it is totally not good to call the object load in the loop. This generates extra load. Much better to get needed data in one collection call to avoid performance issue.
Hi @dapdx. Thank you for your report.
The issue has been fixed in magento/magento2#12936 by @Coderimus in 2.2-develop branch
Related commit(s):
The fix will be available with the upcoming patch release.
In Magento 2.2.2
Worked out a plugin to allow for out of stock child option products of a configurable product to work in concert with the @mjankiewicz helper.
Key point was in: vendor/magento/module-configurable-product/Model/ResourceModel/Attribute/OptionSelectBuilder.php
Created a plugin to modify the select to allow for out of stock products in the configurable options:
`
namespace Watermelon\OutofStockChildProductSwatchVisible\Plugin\Magento\ConfigurableProduct\Model\ResourceModel\Attribute;
class OptionSelectBuilder
{
protected $logger;
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Psr\Log\LoggerInterface $logger)
{
$this->_scopeConfig = $scopeConfig;
$this->logger = $logger;
}
public function afterGetSelect(
\Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilder $subject,
$result
) {
$showoutofstock = $this->_scopeConfig->getValue('cataloginventory/options/show_out_of_stock', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
if ($showoutofstock == '1') {
$where = $result->getPart('where');
foreach ($where as $key => $condition)
{
//$this->logger->info("CONDITION: " . json_encode($condition));
if (strpos($condition, 'stock.stock_status = 1') !== false) {
$updatedWhere[] = 'AND (stock.stock_status IN (1,0))';
} else {
$updatedWhere[] = $condition;
}
}
$result->setPart('where', $updatedWhere);
}
return $result;
}
}`
Hope it helps someone.
Most helpful comment
Any updates on this issue, very frustrating that this simple feature does not work. Thanks