I've got in a custom module created on module/view/frontend/layout/default.xml with:
<block class="\Magento\Framework\View\Element\Template" template="sample:module::sampletemplate.phtml" name="sampleblock" cacheable="false" _isScopePrivate="true"/>
I think that if i put the cacheable="false" to dont let the block to be cached, but it's not working.
How could i could remove cache of this block?
Raphael at Digital Pianism
70.8k37 gold badges192 silver badges357 bronze badges
1 Answer 1
In block class set _isScopePrivate property to true on __construct() function.
So add this to your class
public function __construct(){
$this->_isScopePrivate = true;
}
answered Apr 1, 2016 at 12:31
Asish Hira
1,9911 gold badge18 silver badges39 bronze badges
-
1Check this if you want to use _isScopePrivate devdocs.magento.com/guides/v2.1/config-guide/cache/…, _isScopePrivate is obsoleteWenping Guo– Wenping Guo2017年03月15日 01:04:37 +00:00Commented Mar 15, 2017 at 1:04
-
..and that link is obsolete too.Mavis Bacon– Mavis Bacon2020年02月07日 16:03:42 +00:00Commented Feb 7, 2020 at 16:03
-
1_isScopePrivate is already obsolete as per the Magento 2 documentation devdocs.magento.com/guides/v2.4/extension-dev-guide/cache/…phagento– phagento2020年11月12日 04:20:24 +00:00Commented Nov 12, 2020 at 4:20
-
@phagento Any idea how to fix that? How can i use private content?Sunny Rahevar– Sunny Rahevar2022年10月31日 09:12:33 +00:00Commented Oct 31, 2022 at 9:12
-
@SunnyRahevar Use AJAXphagento– phagento2024年05月26日 09:15:14 +00:00Commented May 26, 2024 at 9:15
default