0

I would like to add the sku to the pdp page right above "Color". I have narrowed down my html template search to the file vendor/magento/module-catalog/view/frontend/templates/product/view/options/wrapper.phtml

<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
$required = '';
if ($block->hasRequiredOptions()) {
    $required = ' data-hasrequired="' . __('* Required Fields') . '"';
}
?>
<div class="product-options-wrapper" id="product-options-wrapper"<?php /* @escapeNotVerified */ echo $required; ?>>
    <div class="fieldset" tabindex="0">
        <?php echo $block->getChildHtml('', true);?>
    </div>
</div>

I can not figure out though where $block-getChildHtml('', true); is grabbing the html from for me to edit that page?

UPDATE

The layout that this template is using is at magento/module-catalog/view/frontend/layout/catalog_product_view.xml. If I remove all of the child blocks (options.phtml, text.phtml, file.phtml etc.), nothing changes. However if I remove the parent block (product.info.options.wrapper) the content does go away. So it seems the content is coming from the parent and not the children somehow.

<block class="Magento\Catalog\Block\Product\View" name="product.info.options.wrapper" as="product_options_wrapper" template="product/view/options/wrapper.phtml">
    <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>
    <block class="Magento\Framework\View\Element\Html\Calendar" name="html_calendar" as="html_calendar" template="Magento_Theme::js/calendar.phtml"/>
</block>

enter image description here

1

Depending on the option type, it uses one of the phtml files under

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

or

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

and to get the product sku just call

$block->getProduct()->getSku();
  • Hmmm I tried editing all of those files under type and they dont seem to have an effect on the pdp page there. – Metropolis Aug 3 '17 at 19:31
  • if the pdp is a configurable product then also try vendor/magento/module-configurable-product/view/frontend/templates/product/view/type/options/configurable.phtml. Answer updated. – Nikolas Aug 3 '17 at 20:18
  • Thanks for your help Niko. I tried checking that template as well and that template does not seem to be associated with this area. I updated my question to try and better illustrate whats happening. It looks like the getChildHtml is getting html from wrapper.phtml somehow, but the child blocks in there are not the ones populating it. – Metropolis Aug 3 '17 at 20:32
  • Seems like maybe I need to edit the file at module-catalog/view/frontend/templates/product/view/form.phtml, though this seems like a parent template that should not be altered. – Metropolis Aug 3 '17 at 20:40
  • Or maybe this is authored? – Metropolis Aug 3 '17 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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