2016-08-02 118 views

回答

1

要对产品颜色swtach比较,您需要创建自定义模块页: - 创建名称为catalog_product_compare_index.xml布局文件,并添加以下代码在创建的文件中。

<?xml version="1.0"?> 
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> 
    <head> 
     <css src="Magento_Swatches::css/swatches.css"/> 
    </head> 
    <body> 
     <referenceContainer name="content"> 
      <referenceBlock name="catalog.compare.list"> 
       <action method="setTemplate"> 
        <argument name="template" xsi:type="string">W3solver_Compareswatch::product/compare/list.phtml</argument> 
       </action> 
       <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers"> 
        <block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" /> 
       </block> 
      </referenceBlock> 
     </referenceContainer> 

    </body> 
</page> 

您需要在您的被覆盖的list.phtml添加一个功能上线63

<?php 
    if($_item->getTypeId() == "configurable"): 
     echo $block->getProductDetailsHtml($_item); 
    endif; 
?> 

这将显示在页面比较色块。