magento2重写virtualType并且传参

今天遇到一个需求需要重写一个block,但是这个block是应用virtualType实现,所以需要先重写virtualType,然后却因为参数丢失而获取不到正确的结果。因此,查阅文档,需要用type标签进行传参:

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\LayeredNavigationStaging\Block\Navigation\Search" type="Silk\CatalogPopup\Block\Search" />
    <type name="Silk\CatalogPopup\Block\Search">
        <arguments>
            <argument name="filterList" xsi:type="object">searchFilterList</argument>
        </arguments>
    </type>
</config>

 

posted on 2019-05-27 17:29  一坪海岸线y  阅读(288)  评论(0编辑  收藏  举报

导航