下面的代码以编程方式刷新缓存。它为我工作得很好。
案例1:外磁
use MagentoFrameworkAppBootstrap;
include('../app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
try{
$_cacheTypeList = $objectManager->create('MagentoFrameworkAppCacheTypeListInterface');
$_cacheFrontendPool = $objectManager->create('MagentoFrameworkAppCacheFrontendPool');
$types = array('config','layout','block_html','collections','reflection','db_ddl','eav','config_integration','config_integration_api','full_page','translate','config_webservice');
foreach ($types as $type) {
$_cacheTypeList->cleanType($type);
}
foreach ($_cacheFrontendPool as $cacheFrontend) {
$cacheFrontend->getBackend()->clean();
}
}catch(Exception $e){
echo $msg = 'Error : '.$e->getMessage();die();
}
案例2:在Magento
公共功能__construct(
上下文语境美元,
程序缓存框架Magento typelistinterface cachetypelist美元,
程序缓存框架Magento 前端池cachefrontendpool美元
){
家长::__construct(合语境);
美元-> _cachetypelist = $ cachetypelist;
美元-> _cachefrontendpool = $ cachefrontendpool;
}
$类型=阵列('config ','layout ','block_html ','collections ','reflection ','db_ddl ','eav ','config_integration ','config_integration_api ','full_page ','translate ','config_webservice ');
foreach($类型达型){
美元-> _cachetypelist -> cleantype(合型);
}
foreach(美元-> _cachefrontendpool达cachefrontend){
cachefrontend美元-> getbackend()