<!-- <moduleDir>/etc/<area>/di.xml -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- ... -->
<preference
for="Vendor\Namespace\Model\Example"
type="Vendor\Namespace\Model\AnotherExample" />
<!-- ... -->
</config>
Above Example is a syntax of override core model.
Here is a list of points which will describe you how to make it possible
moduleDir - Extension directory Like app/code/custom/extension
here extension
is your directory in which all the necessary folders of extension will be placed.
area - area will be frontend
or adminhtml
frontend - if extension will use functionality of frontend than di.xml
will goes to in this folder
adminhtml - if extension will use functionality of adminpanel than di.xml
will goes to in this folder
so it will be app/code/custom/extension/etc/frontend/di.xml
or app/code/custom/extension/etc/adminhtml/di.xml
If wants to use both the functionality than di.xml
file will goes direct in etc
folder no need to put in frontend
or adminhtml
folder. Like - app/code/custom/extension/etc/di.xml
for="Vendor\Namespace\Model\Example" at here, the path of the file which will override functionality of the desired function.
type="Vendor\Namespace\Model\AnotherExample" at here, the path of the file which will provides functions which will override by step - 3