2016-08-02 173 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; 
?> 

這將顯示在頁面比較色塊。