Magento2自定義xml文件

magento 2中的自定義佈局文件覆蓋系統主題佈局文件

1.創建了一個自定義模塊xml文件

app/code/Learning/RewriteSales/view/adminhtml/layout/sales_order_view.xml

系統文件位置

vendor/magento/module-sales/view/adminhtml/layout/sales_order_view.xml

2.在module.xml文件中聲明核心模塊的依賴關係

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Modulename" setup_version="1.0.0" active="true">
        <sequence>
            <module name="Magento_Sales"/>
        </sequence>
    </module>
</config>

注:你的文件裏面,你只需要保留只需要的代碼就可以在xml文件的body標籤中使用自定義佈局文件;

3.清除緩存

bin/magento cache:clean

參考地址: https://magento.stackexchange.com/questions/140626/how-can-i-override-this-vendor-layout-file-with-my-custom-layout-file-in-magento

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章