【发布时间】:2018-09-28 06:26:31
【问题描述】:
我正在创建一个自定义模块,我想在可配置产品页面的属性上方包含一个自定义 phtml 文件...
Click here to see the requirements
请查看我创建的模块文件以及在谷歌搜索后我做了什么 -
- etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" type="Bay20\WarehouseConfigurable\Block\Rewrite\Product\View" />
</config>
- view/frontened/layout/catalog_product_view_type_configurable.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<attribute name="class" value="page-product-configurable"/>
<referenceBlock name="product.info.options.wrapper">
<block class="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" name="product.info.options.configurable" as="options_configurable" before="-" template="product/view/type/options/configurable.phtml"/>
</referenceBlock>
</body>
- view/templates/product/view/type/options/configurable.phtml
<?php
/** @var $block \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable*/
//$_product = $block->getProduct();
//$_attributes = $block->decorateArray($block->getAllowAttributes());
?>
<p>Hello there</p>
但我无法在可配置产品视图页面上获取文件,我在做什么错了,请告诉我。
谢谢
【问题讨论】: