magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.52k stars 9.31k forks source link

Magento 2 configurable product selection stock issue #5948

Closed dapdx closed 7 years ago

dapdx commented 8 years ago

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.

veloraven commented 8 years ago

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

dapdx commented 8 years ago

Magento 2.1 PHP 7

Steps to Reproduce

  1. Create configurable product (in this case example t-shirt)
  2. Create linked simple prodcuts (sizes S, Med, Large, XL)
  3. Set Size attribute to Text Swatch
  4. Set Medium size to out of stock, others are in-stock

Expected Result

  1. When Medium size is out of stock, on the front end it should have a class assigned to it so you can style it with CSS to make it not available for purchase or signify that it is out of stock.

Actual Result

  1. On front end all (S, M, L, XL) text swatches appear, none have a strike through, or greyed out or missing. There is no "out of stock" class applied to the swatch so you can style it with CSS.
JohnWean commented 8 years ago

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.

andidhouse commented 8 years ago

I can confirm this on a fresh 2.1 system.

Really bad bug as we have lots of sizes :-/

duhon commented 8 years ago

@dapdx Thanks for reporting this issue. We've created internal ticket MAGETWO-56480 to fix it.

otg-chris commented 8 years ago

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);
}
epadmin commented 8 years ago

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

mjankiewicz commented 8 years ago

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

zrzut ekranu 2016-08-28 16 36 56

Maybe it will be useful for someone :)

MorganGonzales commented 8 years ago

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!

mjankiewicz commented 8 years ago

Hi @MhorGonzales,

1) the module is enabled ? php bin/magento module:status 2) do you see some error messages on the frontend or backend ?

mjankiewicz commented 8 years ago

@MhorGonzales

I've checked again my module on fresh Magento 2 (sample data) and everything works fine. Detail view without module:

zrzut ekranu 2016-08-31 10 02 36

And with module:

zrzut ekranu 2016-08-31 10 01 20
epadmin commented 8 years ago

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 notifications@github.com Date: Wed, August 31, 2016 3:07 am To: magento/magento2 magento2@noreply.github.com Cc: epadmin admin@elemeno-pee.com, Comment comment@noreply.github.com

@MhorGonzales I've checked again my module on fresh Magento 2 (sample data) and everything works fine. Detail view without module: And with module: —You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.

mjankiewicz commented 8 years ago

Yes. I use Magento ver. 2.1.1 (installed by composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2demo)

MorganGonzales commented 8 years ago

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.

MorganGonzales commented 8 years ago

@mjankiewicz Does it mean, this issue is still not yet resolved in 2.1.1???

mjankiewicz commented 8 years ago

Yes. The issue isn't resolved in 2.1.1. (tested on fresh installation Magento 2.1.1 with sample data)

RishabhRkRai commented 8 years ago

Hi, I also have this problem and i'm using 2.1.1

andidhouse commented 8 years ago

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

cuiyang000 commented 8 years ago

Can confirm the problem with 2.1.1

And @mjankiewicz 's module worked great! Thanks a lot, really saved my hair :)

staffrob commented 8 years ago

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

immist commented 8 years ago

+1 @staffrob & @andidhouse

@magento-admin @magento-team : MAGETWO-56480 (this issue) and MAGETWO-58922 (#6799/#5762) are breaking absolutely mission critical features for any ecommerce site.

How are we supposed to recommend Magento to customers, with such mission critical bugs not being fixed?

Ctucker9233 commented 8 years ago

@mjankiewicz Looks like a cool module. But I can't use composer. Do you have a .zip version?

mjankiewicz commented 8 years ago

thx.

1) https://github.com/mjankiewicz/MagentoConfigurableProduct 2) magento

epadmin commented 8 years ago

thanks for your help guys. At this point we are scrapping our attempts for an M2 site and starting over with an M1 site.

jakobfdev commented 7 years ago

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.

LucScu commented 7 years ago

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.

LucScu commented 7 years ago

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)

LucScu commented 7 years ago

Related question: is normal that if i flagged USE PRODUCT FLAT TABLE, magento continue to use and search in catalog_product_index_eav?

itaymesh commented 7 years ago

@duhon, what's the status of this bug? We can't publish our website without a proper solution. Thanks

itaymesh commented 7 years ago

Any news?

LucScu commented 7 years ago

EHILA???!?!?! no one magento contributor here? It is very incredible how magento release these bug, they deserve a nobel.

yumicom commented 7 years ago

I also have this problem in v. 2.1.2

sennin32 commented 7 years ago

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

audexpro commented 7 years ago

A very, very big and frustrating problem :(

jmtakahashi commented 7 years ago

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!

mjankiewicz commented 7 years ago

@jmtakahashi yes. it works with 2.1.2

jmtakahashi commented 7 years ago

@mjankiewicz thanks! will test installation now.

qbo-tech commented 7 years ago

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.

staffrob commented 7 years ago

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’s 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?

chrisclarkegolf commented 7 years ago

Any updates on this issue, very frustrating that this simple feature does not work. Thanks

DavidMartinKonstructive commented 7 years ago

Magento 2.1.3 solved this issue for us.

cwabbott22 commented 7 years ago

Did Magento 2.1.3 solve this for anyone else?

giacmir commented 7 years ago

2.1.3 solved for me too.

alrayn commented 7 years ago

am using 2.1.5 but these problem stile there !

I must to change status manually vi MySQL

v0gler commented 7 years ago

What variable do you change in MySQL?

alrayn commented 7 years ago

stock_status to 1 on cataloginventory_stock_status table

but now I change PHP version to 5.6 and it's work fine

pushonscott commented 7 years ago

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?

LupoiuAlin15 commented 7 years ago

For magento 2.1.6 to work i was needed to create another custom module. See the answer

https://magento.stackexchange.com/questions/191431/out-of-stock-products-from-configurable-not-appears-in-swatches-on-magento-2/191435#191435

magento-engcom-team commented 7 years ago

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

waqarriaz commented 7 years ago

its only work on swatches icons not on dropdown