In magento 2 how to override stock availability in product detail page in custom module

enter image description here


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="product.info.type">
        <block class="Magento\Catalog\Block\Product\View\Type\Simple" name="product.info.simple" as="product_type_data" template="Vendor_Module::product/view/type/default.phtml"/>


 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

// @codingStandardsIgnoreFile

<?php /* @var $block \Magento\Catalog\Block\Product\View\AbstractView */?>
<?php $_product = $block->getProduct() ?>

<?php if ($block->displayProductStockStatus()): ?>
    <?php if ($_product->isAvailable()): ?>
        <div class="stock available" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
            <span><?= /* @escapeNotVerified */ __('In stock with static text') ?></span>
    <?php else: ?>
        <div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
            <span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
    <?php endif; ?>
<?php endif; ?>

1 Answer 1


Your path seems wrong. You forget to add the "frontend" folder name.


Please change it and try again.

Follow this


  • I was changed the path, not yet still look like above image May 14, 2019 at 13:35
  • Please re-generate static content. php bin/magento setup:static-content:deploy May 14, 2019 at 13:38
  • After re-generate static content, still its look like that May 14, 2019 at 13:47
  • Can you please add full path of your layout and template file. May 14, 2019 at 13:48
  • can you please verify a above question May 14, 2019 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.