Skip to content

How to override vendormagentoframeworkViewPageConfigRenderer.php in Module

Thanks in advance 🙂

I can confirm the module is working correctly.
I have tried adding the following to the di.xml file in my module:

<preference for="MagentoFrameworkViewPageConfigRenderer" type="VendorModuleFrameworkViewPageConfigRenderer" />

And the following to my Renderer.php file in appcodeVendorModuleFrameworkViewPageConfig:

<?php

namespace VendorModuleFrameworkViewPageConfig;

use MagentoFrameworkViewPageConfigRenderer as MagentoRenderer;

class Renderer extends MagentoRenderer
{

  /**
   * Render head content
   *
   * @return string
   */
  public function renderHeadContent()
  {
    $result = '';
    return $result;
  }
}

Without any effect and no entries in any log to debug.

I can make these changes directly here:

vendormagentoframeworkViewPageConfigRenderer.php

or here

libinternalMagentoFrameworkViewPageConfigRenderer.php

and the changes are then visible, but for obvious reasons would like to stay away from the core and restrict my changes to modules.

I would like to start with overriding public function renderHeadContent, but ultimately, I would like to modify protected function addDefaultAttributes. Any advice or assistance would be appreciated, thanks!

Tried: Magento 2: Overriding a protected function that implements another interface

Also tried: How to override /vendor/magento/framework/Logger/Handler/system.php

Also tried: Override framework file vendor/magento/framework/View/Element/Html/Link/Current.php