Magentoめも

Magento2 コアファイルの継承方法

Magento2にすでにある機能を継承して動きを変えたい場合があります。

その場合は、モジュールを作成し、etc/di.xml ファイルにpreferenceを指定すればできるようです。

Modelの継承

app/code/Yassujp/HelloWorld/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\Catalog\Model\Product" type="Yassujp\HelloWorld\Model\Product" />
</config>

参考


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS