0

I'm trying to change product options templates :

<block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" template="product/view/options.phtml">
 <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" as="default" template="product/view/options/type/default.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\Text" as="text" template="product/view/options/type/text.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\File" as="file" template="product/view/options/type/file.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\Select" as="select" template="product/view/options/type/select.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\Date" as="date" template="product/view/options/type/date.phtml"/>
</block>

In my module, I try several methods:

<referenceBlock name="text" template="Vendor_Module::path/to/newfile.phtml" />

--

<referenceBlock name="text">
 <action method="setTemplate">
 <argument name="template" xsi:type="string">Vendor_Module::path/to/newfile.phtml</argument>
 </action>
</referenceBlock>

--

<referenceBlock name="text">
 <arguments>
 <argument name="template" xsi:type="string">Vendor_Module::path/to/newfile.phtml</argument>
 </arguments>
</referenceBlock>

This one is really weird

To check, i try with name = "copyright", and it works...

How can I do it with product options templates ?

Note : The changes that will be made in the templates are not for appearance.

Excuse my english

Ahmad
6181 gold badge6 silver badges16 bronze badges
asked Dec 12, 2016 at 13:17

1 Answer 1

0

Try this.

In your extension your_extension/view/frontend/layout/catalog_product_view.xml

<page layout="1column" 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.options" remove="true" />
 <referenceBlock name="product.info.options.wrapper">
 <block class="Magento\Catalog\Block\Product\View\Options" name="yourcustomname.product.info.options" as="yourcustomname.packaging_product_options" template="product/view/options.phtml">
 <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" as="default" template="product/view/options/type/default.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\Text" as="text" template="Your_Extension::product/view/options/type/text.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\File" as="file" template="product/view/options/type/file.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\Select" as="select" template="product/view/options/type/select.phtml"/>
 <block class="Magento\Catalog\Block\Product\View\Options\Type\Date" as="date" template="product/view/options/type/date.phtml"/>
 </block>
 </referenceBlock>
</body>

And copy

vendor/magento/module-catalog/view/frontend/templates/product/view/options/type/text.phtml

to

your_extension/view/frontend/templates/product/view/options/type/text.phtml

You make the modifications in the text.phtml of your extension.

This solution could cause problems if there is another extension that modifies the block product.info.options

7ochem
7,61516 gold badges54 silver badges82 bronze badges
answered Jan 17, 2017 at 10:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.