<block class="Vendor\Demo\Block\Menu" name="navpro.topnav" template="Vendor_Demo::menu.phtml" ttl="3600" before="-" ifconfig="Demo/top/identifier" />

AS you can see ttl="3600" given in the above block, now I want to set its value to zero from module or theme is it possible? if yes how?


1 Answer 1


You can add plugin to override getCacheLifetime() method in path app\code\VendorName\ModuleName\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">
    <type name="Vendor\Demo\Block\Menu">
        <plugin name="override_cachelifetime" type="VendorName\ModuleName\Plugin\Block\MenuPlugin" />

namespace VendoreName\ModuleName\Plugin;

class MenuPlugin
    public function afterGetCacheLifetime(\Vendor\Demo\Block\Menu $subject, $oldLifetime)
        return null; // return the new value here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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