Popular topics

Technology News Gaming Business & Finance Sports Artificial Intelligence
Programming

Magento 2 Avoid Cache Issue from core_config_value

Magento 2 Avoid Cache Issue from core_config_value
Magento2

This article was published on September 10, 2021. Some details may be out of date.

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 🙂

Written by

GyaanHub