[[Magentoめも]]

*Magento2 コアファイルの継承方法 [#f9d8948c]

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

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

*Modelの継承 [#v7d9c4ad]

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>

参考
-http://magento.stackexchange.com/questions/86497/how-to-override-core-block-model-and-controller-in-magento2
-http://magento.stackexchange.com/questions/113511/how-to-override-magento-checkout-customerdata-cart-php

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