Closed kinhcan closed 3 years ago
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.
still a problem in CE 2.2.4
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;
}
}
@kinhcan this is dublicate to -> https://github.com/magento/magento2/issues/10454
@sduif i've follow your instruction, but it doesn't work on magento 2.2.5
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.
@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.
The bug is still present, with a configurable and only one attribute, please reopen the issue.
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.
@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.
@magento give me 2.4-develop instance
Hi @ihor-sviziev. Thank you for your request. I'm working on Magento 2.4-develop instance for you
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.
Re-opening because of https://github.com/magento/magento2/issues/27368. Looks like this issue was closed not correctly and have to be re-checked
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:
On product page:
But when I enabled one single product - it started to show "in stock" and it started showing drop-down with attribute selection:
As for me it works as expected. Do you agree?
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: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If 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
branchDetails
- 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.
Hi @kinhcan, I'm closing this issue as we weren't able to reproduce the issue and didn't get any answer https://github.com/magento/magento2/issues/15047#issuecomment-602444182 or additional info during long period of time.
@ihor-sviziev OP was referring to swatches so I don't think your replication was too relevant I'm afraid. OP didn't make that entirely clear as it's not in the title or the description, however their reference to a red strike ("should display with class disabled (red strike through) for out of stock") tells us this is the case.
Your reproduction seems to only check relating to the configurable dropdown and beyond that, only that the dropdown appears when there is at least one configuration available. Not sure if only one option appears in the dropdown in your reproduction when there is only one attribute configured by - if only one colour appears in the dropdown, it is partially relevant. If both appear with one marked out of stock, then it is entirely irrelevant.
The following is definitely happening in in 2.2/2.3/2.4 with swatches:
Thx for the additional info. I reopened this issue
Having just now reproduced this in a 2.4-develop instance over in #30046 I am also going to put this reproduction proof here too, as there seems to be many fronts to this and right now it's not clear which one is best served as the authoritative issue. Hopefully its useful for whoever looks at this issue:
Hi @engcom-Delta. 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: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If 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
branchDetails
- 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.
@magento give me 2.4-develop instance
Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Delta, here is your Magento Instance: https://1a7cac06c8fc2990b65c8f45d77618c2-2-4-develop.instances.magento-community.engineering Admin access: https://1a7cac06c8fc2990b65c8f45d77618c2-2-4-develop.instances.magento-community.engineering/admin_fb45 Login: 8f59f9cb Password: 36ca722a5014
@magento give me 2.4-develop instance
Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Delta, here is your Magento Instance: https://1a7cac06c8fc2990b65c8f45d77618c2-2-4-develop.instances.magento-community.engineering Admin access: https://1a7cac06c8fc2990b65c8f45d77618c2-2-4-develop.instances.magento-community.engineering/admin_fbf2 Login: 5a9d6237 Password: 3779025339e6
@ihor-sviziev @joshdavenport I'm not able to reproduce issue by steps on clean 2.4-develop Result: :heavy_check_mark: The red swatch (out of stock) is crossed out.
And according comment we have same result on 2.4-develop as on the latest image: if configurable product has 1 attribute(swatch) and one of the variations is out of stock, then it rendered on frontend as cross out swatch
Could we closed this issue or there are additional steps that were missed?
Well, this looks positive. I was definitely seeing this issue in mid/late November in the instance made here but in this instance you made today it does look to be working as intended. I'm guessing a change has been made in 2.4-develop in the last few weeks that has addressed this issue. If this is for real, very excited for this as it's been an ongoing saga in a current build.
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:
Would be very interested to learn what commit(s) addressed this.
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.
🤯 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:
https://github.com/magento/magento2/blob/bf4cdad2b1d0436be831c1f5c89c1adc77bfd1fc/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php#L1291-L1300
Where the false
in 1294 line stands for excluding out-of-stock products.
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.
Hi @lbajsarowicz. Thank you for your request. I'm working on Magento instance for you.
Hi @lbajsarowicz, here is your Magento Instance: https://1a7cac06c8fc2990b65c8f45d77618c2-2-4-develop.instances.magento-community.engineering Admin access: https://1a7cac06c8fc2990b65c8f45d77618c2-2-4-develop.instances.magento-community.engineering/admin_eab9 Login: 2c60abb8 Password: 8149b2d95688
Also (!) When you create completely new product:
Comments?
Reopened since we have a report that issue still reproducing on the 2.4-develop branch
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
Showed out-stock
Correct me if i'm wrong! Very appreciate it
@mrtuvn I used the test instance that Magento built.
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: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If 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
branchDetails
- 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.
@mrtuvn you have to test with a product with only 1 configurable attribute.
here is for configurable with 1 attribute swatch (no selected)
Selected option
Thanks @mrtuvn for check it out, I think te issue can finally been closed now 🎉
@lbajsarowicz, could you provide more info on how you reproduced it? Thank you!
Ignore it. We fixed that locally on the project. You can close it now.
Thanks for your update @mrtuvn. Closing the ticket as the issue is resolved.
Preconditions
Steps to reproduce
Expected result
Actual result