I want to override the "Select.php" file at: /vendor/magento/module-catalog/Block/Product/View/Options/Type/ but I'm not sure where to put the modified "Select.php" file. The only thing I changed was commenting out the "--Please Select--" line 47.

Where do I put the modified "Select.php" file?

I am using stock Magento theme.

Thank you.

1 Answer 1


You need to write a small module to override this file.

  1. Create a module under


  2. Create module.xml under app/code/<vendor_name>/Catalog/etc:

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
        <module name="<vendor_name>_Catalog" setup_version="1.0.0"/>
  3. Create registraion.php on module root folder, that is app/code/<vendor_name>/Catalog/:

  4. Create di.xml under app/code/<vendor_name>/Catalog/etc:

    <?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\Block\Product\View\Options\Type\Select" type="<vendor_name>\Catalog\Block\Product\View\Options\Type\Select" />
  5. Finally, create Select.php under app/code/<vendor_name>/Catalog/Block/Product/View/Options/Type. The file should be look like this:

    namespace <vendor_name>\Catalog\Block\Product\View\Options\Type;
    class Select extends \Magento\Catalog\Block\Product\View\Options\Type\Select
        public function getValuesHtml()
            //do your stuff

You should able to override the getValuesHtml functions on template file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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