Skip to content

Commit ef70929

Browse files
MC-40873: Product is shown as Out of Stock on CMS page when Category Permissions are enabled
1 parent 46486e8 commit ef70929

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function getCurrentProductData()
153153
$this->productRenderCollectorComposite
154154
->collect($product, $productRender);
155155
$data = $this->hydrator->extract($productRender);
156+
$data['is_available'] = $product->isAvailable();
156157

157158
$currentProductData = [
158159
'items' => [

app/code/Magento/Catalog/view/base/web/js/product/addtocart-button.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ define([
5555
return row['is_salable'];
5656
},
5757

58+
/**
59+
* Depends on this option, stock status text can be "In stock" or "Out Of Stock"
60+
*
61+
* @param {Object} row
62+
* @returns {Boolean}
63+
*/
64+
isAvailable: function (row) {
65+
return row['is_available'];
66+
},
67+
5868
/**
5969
* Depends on this option, "Add to cart" button can be shown or hide. Depends on backend configuration
6070
*

app/code/Magento/Catalog/view/frontend/web/template/product/addtocart-button.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
</button>
1616
</if>
1717

18-
<ifnot args="isSalable($row())">
18+
<if args="isAvailable($row()) === false">
1919
<div class="stock unavailable">
2020
<text args="$t('Availability')"/>
2121
<span translate="'Out of stock'"/>
2222
</div>
23-
</ifnot>
23+
</if>
2424
</if>

0 commit comments

Comments
 (0)