0

I just want to override vendor/magento/module-catalog/view/base/templates/product/composite/fieldset/options/view/checkable.php in my custom module but I can't

I can't find any solution to this

already tried using template hierarchy but not working

2 Answers 2

1

In your custom module etc/di.xml

<?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\Checkable" type="VendorName\ModuleName\Rewrite\Checkable"/>
</config>

In VendorName/ModuleName/Rewrite/Checkable.php

<?php
/**
 * Copyright ©  All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace VendorName\ModuleName\Rewrite;

class Checkable extends \Magento\Catalog\Block\Product\View\Options\Type\Select\Checkable
{
    protected $_template = 'VendorName_ModuleName::product/composite/fieldset/options/view/checkable.phtml';
}
2
  • tried the same way but getting this error : Uncaught Error: Class 'Vendor\Module\Block\Product\View\Options\Type\Select\Magento\Product\Block\Product\View\Options\Type\Select' not found in /var/www/html/app/code/Vendor/Module/Block/Product/View/Options/Type/Select/Checkable.php:15
    – Cv Gandhi
    Commented Oct 27, 2021 at 9:13
  • Please check the paths and make sure the paths are correct. I find issue is with the paths. Commented Oct 27, 2021 at 9:14
0

The above file is set from this block file.

Magento\Catalog\Block\Product\View\Options\Type\Select\Checkable.php

So you need to overide this file into custom module and then need to set the template file instade of orignal one.

2
  • i tried but got this error after compile: Uncaught Error: Class 'Vendor\Module\Block\Product\View\Options\Type\Select\Magento\Product\Block\Product\View\Options\Type\Select' not found in /var/www/html/app/code/Vendor/Module/Block/Product/View/Options/Type/Select/Checkable.php:15
    – Cv Gandhi
    Commented Oct 27, 2021 at 9:01
  • please ask the seprate question for this one with the code, sop you will get the answer of that one like how to overide the block. Commented Oct 27, 2021 at 9:03

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.