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

CE 2.2.X Configurable product with 1 Attribute - Display Out of Stock Products #15047

Closed
kinhcan opened this issue May 8, 2018 · 46 comments
Closed
Assignees
Labels
Component: Swatches Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: ready for confirmation Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@kinhcan
Copy link

kinhcan commented May 8, 2018

Preconditions

  1. Magento CE 2.2.X
  2. Apache 2.4.27
  3. PHP 7.0.22

Steps to reproduce

  1. Install Magento 2.2.X CE Sample Data
  2. Admin > Stores > Configuration > Catalog > Inventory > Stock Options > Display Out of Stock Products = Yes.
  3. CLI php bin/magento indexer:reindex
  4. Admin > Products > Catalog > Create configurable product with 1 attribute. Set either Quantity = 0 or Stock Status = Out of Stock.

Expected result

  1. Frontend product should display with all Simple products part of Configurable product and should display with class disabled (red strike through) for out of stock .

Actual result

  1. Frontend product not displayed all.
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 8, 2018
@kinhcan kinhcan changed the title CE 2.1.X Configurable product with 1 Attribute - Display Out of Stock Products CE 2.2.X Configurable product with 1 Attribute - Display Out of Stock Products May 8, 2018
@sduif
Copy link

sduif commented May 14, 2018

We have the same issue with simple products that are shown in a dropdown attribute. "Display out of stock products" = yes, but they do not appear in the dropdown on a configurable product detail page.

Even after reindexing/clearing cache.

@jeffb1a5
Copy link

still a problem in CE 2.2.4

@sduif
Copy link

sduif commented Jun 13, 2018

Edit: The following is for <= 2.2.4. This has since been changed in 2.2.5

The cause seems to be Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\InStockOptionSelectBuilder which always adds a stock status filter without regard to the "Show out of Stock Products" setting.

I personally fixed it with a custom module di.xml though I doubt that this is always the right solution since this for example doesn't check if backorders are allowed for a specific attribute . Maybe someone else has a more prominent solution?

<type name="Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface">
        <plugin name="Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder" disabled="true"/>
        <plugin name="attribute_option_select_builder_instock_fix" type="Vendor\MyModule\Plugin\Magento\ConfigurableProduct\Attribute\InStockOptionSelectBuilder" />
</type>

Vendor\MyModule\Plugin\Magento\ConfigurableProduct\Attribute\InStockOptionSelectBuilder.php

<?php

namespace Vendor\MyModule\Plugin\Magento\ConfigurableProduct\Attribute;

use Magento\CatalogInventory\Model\ResourceModel\Stock\Status;
use Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\App\Config\ScopeConfigInterface;

class InStockOptionSelectBuilder
{
    private $stockStatusResource;
    private $scopeConfig;
    
    public function __construct(
        Status $stockStatusResource,
        ScopeConfigInterface $scopeConfig
    )
    {
        $this->stockStatusResource = $stockStatusResource;
        $this->scopeConfig = $scopeConfig;
    }

    public function afterGetSelect(OptionSelectBuilderInterface $subject, Select $select)
    {
        if (!$this->scopeConfig->getValue(\Magento\CatalogInventory\Model\Configuration::XML_PATH_SHOW_OUT_OF_STOCK, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
            $select->joinInner(
                ['stock' => $this->stockStatusResource->getMainTable()],
                'stock.product_id = entity.entity_id',
                []
            )->where(
                'stock.stock_status = ?',
                \Magento\CatalogInventory\Model\Stock\Status::STATUS_IN_STOCK
            );
        }        
        
        return $select;
    }
}

@ghost
Copy link

ghost commented Jul 11, 2018

@kinhcan this is dublicate to -> #10454

@ghost ghost closed this as completed Jul 11, 2018
@ghost ghost removed their assignment Jul 11, 2018
@congson95dev
Copy link

@sduif i've follow your instruction, but it doesn't work on magento 2.2.5

@sduif
Copy link

sduif commented Jan 2, 2019

Correct, unfortunately there have been various changes in 2.2.5 that break the suggested fix. I've updated my comment to reflect this. I'm affraid I do not have an alternative fix at this time.

@congson95dev
Copy link

@sduif thanks you, i've searching for this issue all day long and find a lot of code and suggestion, but none of them work so far.

@lamasfoker
Copy link

lamasfoker commented Feb 5, 2020

The bug is still present, with a configurable and only one attribute, please reopen the issue.

@toby-pondr
Copy link

I don't believe this to be a bug. It's more just how they've decided to handle this logic.

That said, I would like an option to show sold out sizes on items with just one attribute.

@diamondavocado
Copy link

diamondavocado commented Mar 20, 2020

@kinhcan this is dublicate to -> #10454

This is not a duplicate of that issue. That issue was closed because they didn't try reproducing it correctly. They tried on a product with more than one configurable attributes. They need to try on a product with only a single configurable attribute -- as the very title of this issue says!

@magento-engcom-team or @engcom-Charlie Please re-open this issue.

@ihor-sviziev
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev. Thank you for your request. I'm working on Magento 2.4-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, here is your Magento instance.
Admin access: https://i-15047-2-4-develop.instances.magento-community.engineering/admin_4385
Login: f5a9c1e7 Password: 1902a5ba424d
Instance will be terminated in up to 3 hours.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Mar 23, 2020

Re-opening because of #27368. Looks like this issue was closed not correctly and have to be re-checked

@ihor-sviziev ihor-sviziev reopened this Mar 23, 2020
@ihor-sviziev
Copy link
Contributor

Hi @kinhcan @diamondavocado,
I just created configurable product with single attribute on test instance: https://i-15047-2-4-develop.instances.magento-community.engineering/ .

On category page configurable product is shown:
image

On product page:
image

But when I enabled one single product - it started to show "in stock" and it started showing drop-down with attribute selection:
image

As for me it works as expected. Do you agree?

@m2-assistant
Copy link

m2-assistant bot commented Mar 23, 2020

Hi @ihor-sviziev. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@ihor-sviziev
Copy link
Contributor

Hi @kinhcan,
I'm closing this issue as we weren't able to reproduce the issue and didn't get any answer #15047 (comment) or additional info during long period of time.

@joshdavenport
Copy link

Just to further corroborate this, I also followed my original steps from November in that instance and found that the swatches are indeed correctly showing now:

image

Would be very interested to learn what commit(s) addressed this.

@ihor-sviziev
Copy link
Contributor

Hi @kinhcan,
Thx for confirmation. I'm closing this issue as not relevant anymore.

Unfortunately, I don't have information on which exactly changes fixed it.

@engcom-Delta engcom-Delta removed their assignment Dec 11, 2020
@engcom-Delta engcom-Delta added the not-confirmed Use for Issue that was closed during confirmation label Dec 11, 2020
@lbajsarowicz
Copy link
Contributor

lbajsarowicz commented Jul 10, 2021

🤯 Glad the issue is sorted, but... definitely, I'd love to know which Commit fixes that or what Quality Patch offers the fix.
--- EDIT ---
The problem is still not resolved and when you try to get Out of Stock products to display, you end up with this method:

public function getUsedProducts($product, $requiredAttributeIds = null)
{
if (!$product->hasData($this->_usedProducts)) {
$collection = $this->getConfiguredUsedProductCollection($product, false, $requiredAttributeIds);
$usedProducts = array_values($collection->getItems());
$product->setData($this->_usedProducts, $usedProducts);
}
return $product->getData($this->_usedProducts);
}

Where the false in 1294 line stands for excluding out-of-stock products.

@magento-deployment-service
Copy link

Hi @lbajsarowicz. Thank you for your request. Comments like @magento give me test instance are intended for instance deployments on Pull Requests. Please use comment like: @magento give me 2.4-develop instance to request an instance on an issue.

@magento-deployment-service
Copy link

Hi @lbajsarowicz. Thank you for your request. I'm working on Magento instance for you.

@lbajsarowicz
Copy link
Contributor

lbajsarowicz commented Jul 10, 2021

  1. Settings
    image
  2. Product
    image
  3. Result
    image

Also (!) When you create completely new product:
image

Comments?

@ihor-sviziev ihor-sviziev reopened this Jul 11, 2021
@m2-community-project m2-community-project bot removed the Issue: needs update Additional information is require, waiting for response label Jul 11, 2021
@ihor-sviziev ihor-sviziev removed the not-confirmed Use for Issue that was closed during confirmation label Jul 11, 2021
@ihor-sviziev
Copy link
Contributor

Reopened since we have a report that issue still reproducing on the 2.4-develop branch

@mrtuvn
Copy link
Contributor

mrtuvn commented Jul 11, 2021

Lukas have you tested in latest code ? From my side results seem working! What do i miss something ? (2.4-develop, sampledata + inventory with config show out-stock product) Both condition i have set quantity 0 for gray variant product
No show out-stock
no-show-outstock

Showed out-stock
showed-out-stock

Correct me if i'm wrong! Very appreciate it

@lbajsarowicz
Copy link
Contributor

@mrtuvn I used the test instance that Magento built.
image

@engcom-November engcom-November self-assigned this Jul 12, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jul 12, 2021

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@lamasfoker
Copy link

@mrtuvn you have to test with a product with only 1 configurable attribute.

@mrtuvn
Copy link
Contributor

mrtuvn commented Jul 13, 2021

config-1attr
here is for configurable with 1 attribute swatch (no selected)

Selected option
config-selected

config2

@lamasfoker
Copy link

Thanks @mrtuvn for check it out, I think te issue can finally been closed now 🎉

@ihor-sviziev
Copy link
Contributor

@lbajsarowicz, could you provide more info on how you reproduced it? Thank you!

@lbajsarowicz
Copy link
Contributor

lbajsarowicz commented Jul 13, 2021

Ignore it. We fixed that locally on the project.
You can close it now.

@engcom-November
Copy link
Contributor

Thanks for your update @mrtuvn. Closing the ticket as the issue is resolved.

@ihor-sviziev ihor-sviziev added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Swatches Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: ready for confirmation Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

No branches or pull requests