Create your custom module and add rewrite code in your custom module, please try following way.
Create custom module Vendor/Module
/app/code/Vendor/Module
|_ composer.json
{
"name": "vendor/module-module",
"description": "",
"type": "magento2-module",
"license": "proprietary",
"authors": [
{
"name": "TestModule",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {
"Vendor\\Module\\": ""
},
"files": [
"registration.php"
]
}
}
|_registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_Module',
__DIR__
);
|_ etc/module.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0"/>
</config>
|_ etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Vendor\Module\Block\Html\Notices" type="Magento\Cookie\Block\Html\Notices" />
</config>
|_ Block/Html/Notices.php (Please add your overrited code in this file )
<?php
/**
* Frontend form key content block
*/
namespace Vendor\Module\Block\Html;
class Notices extends \Magento\Cookie\Block\Html\Notices
{
public function getPrivacyPolicyLink()
{
return $this->_urlBuilder->getUrl('privacy-policy-cookie-restriction-mode');
}
}
Please try this way and let me know if any issue.