Skip to content

Commit 26674b1

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-40873' into 2.4-develop-pr54
2 parents bc4cc4f + 05b4665 commit 26674b1

File tree

19 files changed

+29
-18
lines changed

19 files changed

+29
-18
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/Test/Unit/Block/Ui/ProductViewCounterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ public function testGetCurrentProductDataWithNonEmptyProduct()
166166
{
167167
$productMock = $this->getMockBuilder(ProductInterface::class)
168168
->disableOriginalConstructor()
169+
->addMethods(['isAvailable'])
169170
->getMockForAbstractClass();
170171
$productRendererMock = $this->getMockBuilder(ProductRenderInterface::class)
171172
->disableOriginalConstructor()
172173
->getMockForAbstractClass();
173174
$storeMock = $this->getMockBuilder(Store::class)
174175
->disableOriginalConstructor()
175176
->getMock();
176-
177177
$this->registryMock->expects($this->once())
178178
->method('registry')
179179
->with('product')

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/templates/product/compare/list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
</button>
7979
</form>
8080
<?php else :?>
81-
<?php if ($item->getIsSalable()) :?>
81+
<?php if ($item->isAvailable()) :?>
8282
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
8383
<?php else :?>
8484
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>

app/code/Magento/Catalog/view/frontend/templates/product/list/items.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ $_item = null;
287287
</form>
288288
<?php endif; ?>
289289
<?php else:?>
290-
<?php if ($_item->getIsSalable()):?>
290+
<?php if ($_item->isAvailable()):?>
291291
<div class="stock available">
292292
<span><?= $block->escapeHtml(__('In stock')) ?></span>
293293
</div>

app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
6363
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->escapeUrl($block->getAddToCartUrl($_product)) . '"} }\'>'
6464
. '<span>' . $block->escapeHtml(__('Add to Cart')) . '</span></button>';
6565
} else {
66-
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
66+
$info['button'] = $_product->isAvailable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
6767
'<div class="stock unavailable"><span>' . $block->escapeHtml(__('Out of stock')) . '</span></div>';
6868
}
6969

app/code/Magento/Catalog/view/frontend/templates/product/widget/new/column/new_default_list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</button>
5353
<?php endif; ?>
5454
<?php else :?>
55-
<?php if ($_product->getIsSalable()) :?>
55+
<?php if ($_product->isAvailable()) :?>
5656
<div class="stock available" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
5757
<span><?= $block->escapeHtml(__('In stock')) ?></span>
5858
</div>

app/code/Magento/Catalog/view/frontend/templates/product/widget/new/content/new_grid.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
8989
</button>
9090
<?php endif; ?>
9191
<?php else :?>
92-
<?php if ($_item->getIsSalable()) :?>
92+
<?php if ($_item->isAvailable()) :?>
9393
<div class="stock available">
9494
<span><?= $block->escapeHtml(__('In stock')) ?></span>
9595
</div>

app/code/Magento/Catalog/view/frontend/templates/product/widget/new/content/new_list.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
8888
</button>
8989
<?php endif; ?>
9090
<?php else :?>
91-
<?php if ($_item->getIsSalable()) :?>
91+
<?php if ($_item->isAvailable()) :?>
9292
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
9393
<?php else :?>
9494
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>

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)