dtg25862
2017-07-20 07:36
浏览 82
已采纳

Magento 2 - 获取系统配置值时如何跳过缓存?

I'm trying to get config values using:

$this->_scopeConfig->getValue(
    $config_path,
    \Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

& it returns the cached value.
Is there any way to make it skip the cache without disabling it?
*I want the cache to be enabled but still bypass it for this value only.
**I also don't want to always clear the cache programmatically before getting it.
-- Any idea?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用以下方法获取配置值:

   $ this-> _scopeConfig-> getValue(
 $ config_path,
 \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE 
); 
   
 
 

&安培; 它返回缓存的值。
有没有办法让它跳过缓存没有禁用它?
*我希望缓存启用但仍然绕过缓存 仅限值。
**我也不想在获取之前始终以编程方式清除缓存。
--任何想法?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongsou8980 2017-07-20 14:52
    已采纳

    What you basically need is to query the database directly.

    So Inject a Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory in your class.

    Then you can query the database : $collection = $collectionFactory->create(); $collection->addScopeFilter($scope, $scopeId, $section)

    The $section is the path, $scopeId the id of the store or website depending on the scope & $scope is either "stores" or "website" or "default".

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题