3

How can i override this path: vendor/magento/framework/View/Element/Html/Select.php

with my custom module file?

4
  • Can you please look at the question clearly. @Prince Patel Commented Sep 1, 2017 at 12:33
  • Check this answer: magento.stackexchange.com/a/154517/35758 Commented Sep 1, 2017 at 12:36
  • It is not block file override @Prince Patel it is vendor/magento/framework/View/Element/Html/Select.php to override in my custom module Commented Sep 1, 2017 at 12:43
  • 1
    Select.php extends \Magento\Framework\View\Element\AbstractBlock itself is a block. Have you tried my answer? Commented Sep 1, 2017 at 13:22

2 Answers 2

5

Your_VendorName\Your_ModuleName\etc\di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
     <preference for="Magento\Framework\View\Element\Html\Select" type="Your_VendorName\Your_ModuleName\Model\Framework\View\Element\Html\Select" />
</config>
3

Try overriding the class using a preference in your di.xml file like

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Framework\View\Element\Html\Select" type="Your_Vendor\Your_Module\Your_Class_Type\Your_Class" />
</config>
3
  • can you just brief these terms Your_Class_Type\Your_Class i cannot get you @Nikolas Commented Sep 1, 2017 at 12:29
  • Please Can you reply soon @Nikloas Commented Sep 1, 2017 at 12:42
  • Is the path to your class that will override the one you requested. Your_class_type can be the Model folder for example and the Your_Class the class name.
    – Nikolas
    Commented Sep 1, 2017 at 13:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.