Skip to content

Commit b46b283

Browse files
committed
BUG#AC-2877: Product with Salable Qty of 0 shows In Stock on product page - issue fixed
1 parent 3896634 commit b46b283

File tree

2 files changed

+94
-3
lines changed

2 files changed

+94
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontSelectionOfOutOfStockChildProductsOfConfigurableProductDisabledTest">
12+
<annotations>
13+
<features value="CatalogInventory"/>
14+
<stories value="Storefront selection of out of stock child products of configurable product"/>
15+
<title value="Storefront selection of out of stock child products of configurable Product disabled"/>
16+
<description value="Storefront selection of out of stock child products of configurable are disabled on storefront when display of out of stock options are enabled"/>
17+
<severity value="MAJOR"/>
18+
<group value="catalogInventory"/>
19+
</annotations>
20+
21+
<before>
22+
<!--Set Display out of stock product-->
23+
<magentoCLI stepKey="setDisplayOutOfStockProduct" command="config:set cataloginventory/options/show_out_of_stock 1" />
24+
<!-- Create category -->
25+
<createData entity="SimpleSubCategory" stepKey="simplecategory"/>
26+
<!-- Create configurable product with two options -->
27+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct">
28+
<requiredEntity createDataKey="simplecategory"/>
29+
</createData>
30+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
31+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
32+
<requiredEntity createDataKey="createConfigProductAttribute"/>
33+
</createData>
34+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
35+
<requiredEntity createDataKey="createConfigProductAttribute"/>
36+
</createData>
37+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
38+
<requiredEntity createDataKey="createConfigProductAttribute"/>
39+
</createData>
40+
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1">
41+
<requiredEntity createDataKey="createConfigProductAttribute"/>
42+
</getData>
43+
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2">
44+
<requiredEntity createDataKey="createConfigProductAttribute"/>
45+
</getData>
46+
<!-- Create child products -->
47+
<createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1">
48+
<requiredEntity createDataKey="createConfigProductAttribute"/>
49+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
50+
</createData>
51+
<createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2">
52+
<requiredEntity createDataKey="createConfigProductAttribute"/>
53+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
54+
</createData>
55+
<createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption">
56+
<requiredEntity createDataKey="createConfigProduct"/>
57+
<requiredEntity createDataKey="createConfigProductAttribute"/>
58+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
59+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
60+
</createData>
61+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1">
62+
<requiredEntity createDataKey="createConfigProduct"/>
63+
<requiredEntity createDataKey="createConfigChildProduct1"/>
64+
</createData>
65+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2">
66+
<requiredEntity createDataKey="createConfigProduct"/>
67+
<requiredEntity createDataKey="createConfigChildProduct2"/>
68+
</createData>
69+
<magentoCron groups="index" stepKey="reindex"/>
70+
</before>
71+
72+
<after>
73+
<magentoCLI stepKey="setDisplayOutOfStockProduct" command="config:set cataloginventory/options/show_out_of_stock 0" />
74+
<deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/>
75+
<deleteData createDataKey="simplecategory" stepKey="deleteSimpleCategory"/>
76+
<deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/>
77+
<deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/>
78+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
79+
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
80+
</after>
81+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/>
82+
<amOnPage url="{{AdminProductEditPage.url($$createConfigChildProduct1.id$$)}}" stepKey="openProductEditPageToSetStatus"/>
83+
<selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="Out of Stock" stepKey="selectOutOfStockStatus"/>
84+
<actionGroup ref="AdminFormSaveAndCloseActionGroup" stepKey="saveProductWithSetOutOfStockStatus"/>
85+
<!-- Go to configurable product page -->
86+
<amOnPage url="/{{ApiConfigurableProduct.urlKey}}2.html" stepKey="goToConfigProductPage"/>
87+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
88+
<!-- Assert the out of stock child product option is disabled on storefront -->
89+
<seeElement selector="#product-options-wrapper .super-attribute-select option:disabled" stepKey="assertConfigAttributeOption1Disabled"/>
90+
</test>
91+
</tests>

app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ define([
459459
'</div>' + input +
460460
'</div>'
461461
);
462-
462+
463463
$widget.optionsMap[item.id] = {};
464464

465465
// Aggregate options array to hash (key => value)
@@ -505,13 +505,13 @@ define([
505505
let item = this;
506506

507507
if ($widget.options.jsonConfig.canDisplayShowOutOfStockStatus) {
508-
let salableProd = $widget.options.jsonConfig.salable[item.id],
508+
let salableProducts = $widget.options.jsonConfig.salable[item.id],
509509
swatchOptions = container.find('.swatch-option');
510510

511511
swatchOptions.each(function (key, value) {
512512
let optionId = $(value).data('option-id');
513513

514-
if (!salableProd.hasOwnProperty(optionId)) {
514+
if (!salableProducts.hasOwnProperty(optionId)) {
515515
$(value).attr('disabled', true).addClass('disabled');
516516
}
517517
});

0 commit comments

Comments
 (0)