How to override same class which exist in 2 different custom modules
Eg:
1) I have a file Result.php.
from Vendor\Module1\Block\Result
and almost same Result.php
from Vendor\Module2\Block\Result
which overrides
Magento\CatalogSearch\Block\Result
2) Do i have to give
in etc/di
of module1
<preference for="Magento\CatalogSearch\Block\Result" type="Vendor\Module1\Block\Result" />
in etc/di
of module2
<preference for="Magento\CatalogSearch\Block\Result" type="Vendor\Module2\Block\Result" />
in both the modules1 and 2's ?
3) I have (say) Index.php from controller suppose.
Do the same procedure applies in etc di for both modules?
4) Is there any better approach?