1

I am trying to change de default product stock availability text to my own by using a custom phtml file. I want to overwrite "module-catalog/view/frontend/templates/product/view/type/default.phtml" therefore I created a custom module with catalog_product_view.xml with the following contents:

<?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">
<body>  
    <referenceContainer name="product.info.type">
        <block class="Magento\Catalog\Block\Product\View\Type\Simple" name="product.info.description" as="product_type_data" template="Sixways_Estdelivery::displayStockStatus.phtml">
        <argument name="cacheable" xsi:type="boolean">false</argument>
        </block>
    </referenceContainer>       
</body>

This works great but the exception.log file is filling up with this error:

main.CRITICAL: Magento\Framework\Exception\LocalizedException: The element 'product.info.type' already has a child with alias 'product_type_data' in /staging/vendor/magento/framework/Data/Structure.php:611

I tried leaving product_type_data away but that makes the original and the custom phtml appear instead of only the custom one.

What is the correct way of overwriting name="product.info.simple" as="product_type_data" in referenceContainer name="product.info.type"?

1 Answer 1

1

try with

<?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">
<body>  
    <referenceBlock name="product.info.description">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Sixways_Estdelivery::displayStockStatus.phtml</argument>
        </action>
    </referenceBlock>       
</body>
3

Your Answer

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

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