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.
Create a module under
app/code//Catalog/
Create
module.xmlunderapp/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"/> </config>Create
registraion.phpon module root folder, that isapp/code/<vendor_name>/Catalog/:<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, '<vendor_name>_Catalog', __DIR__ ); ?>Create
di.xmlunderapp/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" /> </config>Finally, create
Select.phpunderapp/code/<vendor_name>/Catalog/Block/Product/View/Options/Type. The file should be look like this:<?php 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.