I need to display Stock Quantity on grouped products.
Grouped product detail are displaying by grouped.phtml
(Core module: module-grouped-product/view/frontend/templates/product/view/type/grouped.phtml).
I have extended this module and i need to display Quantity there.
Update: This is foreach loop that display products and I need to display Stock qty in for-each loop.
I am not sure If i can display from function reference of stock.
Line 34 - 82:
<?php foreach ($_associatedProducts as $_item): ?>
<tbody>
<tr>
<td data-th="<?php echo $block->escapeHtml(__('Product Name')); ?>" class="col item">
<strong class="product-item-name"><?php echo $block->escapeHtml($_item->getName()) ?></strong>
<?php if ($block->getCanShowProductPrice($_product)): ?>
<?php if ($block->getCanShowProductPrice($_item)): ?>
<?php /* @escapeNotVerified */ echo $block->getProductPrice($_item) ?>
<?php endif; ?>
<?php endif; ?>
</td>
<?php if ($_product->isSaleable()): ?>
<td data-th="<?php echo $block->escapeHtml(__('Qty')); ?>" class="col qty">
<?php if ($_item->isSaleable()) : ?>
<div class="control qty">
<input type="number" name="super_group[<?php /* @escapeNotVerified */ echo $_item->getId() ?>]"
data-selector="super_group[<?php /* @escapeNotVerified */ echo $_item->getId() ?>]"
maxlength="12"
value="<?php /* @escapeNotVerified */ echo $_item->getQty() * 1 ?>"
title="<?php /* @escapeNotVerified */ echo __('Qty') ?>"
class="input-text qty"
data-validate="{'validate-grouped-qty':'#super-product-table'}"
data-errors-message-box="#validation-message-box"/>
</div>
<?php else: ?>
<div class="stock unavailable" title="<?php /* @escapeNotVerified */ echo __('Availability') ?>">
<span><?php /* @escapeNotVerified */ echo __('Out of stock') ?></span>
</div>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php if ($block->getCanShowProductPrice($_product)
&& $block->getCanShowProductPrice($_item)
&& trim($block->getProductPriceHtml(
$_item,
\Magento\Catalog\Pricing\Price\TierPrice::PRICE_CODE
))): ?>
<tr class="row-tier-price">
<td colspan="2">
<?php echo $block->getProductPriceHtml(
$_item,
\Magento\Catalog\Pricing\Price\TierPrice::PRICE_CODE
) ?>
</td>
</tr>
<?php endif; ?>
</tbody>
<?php endforeach; ?>