Magento 2 Avoid Cache Issue from core_config_value

Magento2

How to get core config value without getting old cache value and retrieving live value from the config table in Magento2.

protected $scopeCollectionFactory;

public function __construct(	
	...
	\Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory $scopeCollectionFactory
) {
    ...
    $this->scopeCollectionFactory = $scopeCollectionFactory;
    ...
}
$config = $this->scopeCollectionFactory->create();
$configValue = $config->addFieldToFilter('path', ['eq' => 'your/config/path'])->getFirstItem()->getValue();

For more such tutorials you can visit.

You can also visit Magento 2 Official Documentation

Liked this? Help us spread this to the world 🙂

Leave a Reply