I want to override Magento core block how can I do that vendor\magento\module-catalog\view\frontend\templates\product\view\options\type\Select.php.

I want to remove -- before and after Please Select text as shown in the image below

enter image description here

So Far I have tried to create a Module to override the block in app/code, app/code/Abcd/Xyz but when i have enabled it it just removed the whole select box as shown in below image


3 Answers 3


you can create you own module that contains a translation file i18n/en_US.csv with this content:

"-- Please Select --","Please Select"
  • Ya, I thought that but now, I want to do something Like this insted of Please Select I want Select Size, Select Color So I have to override the view block. Aug 17, 2016 at 8:33
  • that is a totally different questions. please don't mix them.
    – Marius
    Aug 17, 2016 at 8:57
  • I followed you advice and create a new question for it magento.stackexchange.com/questions/131762/… Aug 17, 2016 at 9:44

need to override the below block


in the above file change the below line

 $select->setName('options[' . $_option->getid() . ']')->addOption('', __('-- Please Select --')); 


 $select->setName('options[' . $_option->getid() . ']')->addOption('', __('Please Select'));

for override the block refer this answer

note: I am not tested but I hope it works

  • Hi, I have done the same. I have override the Magento\Catalog\Block\Product\View\Options\Type\Select Block in my module, but doing so, Removed the select box from the view as in the above image[Refer Question] Aug 17, 2016 at 8:36
  • Do I have to override template file as well in the module vendor\magento\module-catalog\view\frontend\templates\product\view\options\type\select.phtml Aug 17, 2016 at 8:38
  • for trial just directly change the text in vendor/magento/module-catalog/Block/Product/View/Options/Type/Select.php. after that clear cache then load page. If it worked, definitely you make mistake in override. Aug 17, 2016 at 8:50

given that Marius' solution is likely the most effective one, I take the chance to offer an alternative to avoid block rewrite. It is based on the usage of a plugin.

Assuming you know how to define your own module, you can declare the plugin in the <your_module_dir>/etc/di.xml file as follows:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="Magento\Framework\View\Element\Html\Select">
        <plugin name="vendorname_view_element_html_select"
                type="VendorName\ModuleName\Plugin\View\Element\Html\SelectPlugin" />

Note: change VendorName and ModuleName according to your needs.

Then define the plugin in <your_module_dir>/Plugin/View/Element/Html/SelectPlugin.php:


namespace VendorName\ModuleName\Plugin\View\Element\Html;

class SelectPlugin
    public function beforeAddOption($subject, $value, $label) 
        if ($value == '') {
            $label = __("Whatever you want");
        return [$value, $label];

Hope it helps.

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.