I need to update a template defined in a Constant at Configurable Class(Magento/Swatches/Block/Product/Renderer/Configurable.php).
I tried with a Plugin, but how the function which gets the constant is protected, I can't update the Constant correctly.
Anyone knows the correct way to update this constant or rewrite the function to change the path to my Module template.
const CONFIGURABLE_RENDERER_TEMPLATE = 'Magento_ConfigurableProduct::product/view/type/options/configurable.phtml';
protected function getRendererTemplate()
{
return $this->isProductHasSwatchAttribute ?
self::SWATCH_RENDERER_TEMPLATE :
self::CONFIGURABLE_RENDERER_TEMPLATE;
}
Best Answer
You can create before plugin on setTemplate method and overwrite template argument.
Create plugin
and declare it in DI.xml
See more details in official documentation