1

I want to update the class Select and its getValuesHTML() method which is saved here: module-catalog/Block/Product/View/Options/Type/Select.php

I have made a copy of this file and placed it in my theme here: VENDOR/THEME/Magento_Catalog/Block/Product/View/Options/Type/Select.php

I've done the following, but my changes still aren't taking effect:

php bin/magento setup:static-content:deploy

php bin/magento indexer:reindex

php bin/magento cache:clean

Have I placed the file in the wrong folder location?

1

You can't overwrite .php files using theme, you have to create new module in app/code/Vendor/Module, and create an etc/di.xml file inside this module.

This should be inside di.xml file:

<?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\Module\Block\Product\View\Options\Type\Select" />
</config>

Vendor\Module\Block\Product\View\Options\Type\Select should extend Magento\Catalog\Block\Product\View\Options\Type\Select

or using plugin http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html

| improve this answer | |
  • Thank you for your reply. I don't seem to have a folder named code in my app folder, just design and etc? – MikeMason Apr 23 '16 at 14:16
  • Then you need to create it :) – Bartłomiej Szubert Apr 23 '16 at 14:22
  • Hi, I've tried to update the class as per your instructions but have come up against some issues. Would you mind having a look here: magento.stackexchange.com/questions/112542/… – MikeMason Apr 25 '16 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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