I need to load all configs with some filter, including values, that defined in config.xml files. Here's some code to make some clarity about what I need to do:

public function __construct(
        \Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory $scopeCollectionFactory
    ) {       
        $this->scopeCollectionFactory = $scopeCollectionFactory;        

public function loadConfigs(array $configIds = [], $fromId = 0, $limit = 1000): array
        $collection = $this->scopeCollectionFactory->create()->addFieldToFilter('config_id', ['gt' => $fromId]);
        if (!empty($configIds)) {
            $collection->addFieldToFilter('config_id', ['in' => $configIds]);
        return $collection->getItems();

It does not return items that defined in config.xml. How do I achieve that?

  • Scopeconllectionfactory will return all the data which is stored in the core_config_table. If you have created custom module config.xml file, then save the configuration from the system configuration backend once, you will get all the data. – Nits Jul 30 '20 at 13:02
  • Yeah, I already got that. But is there a way to load both aggregated data from config.xml and db? – Vadim Shmyrov Jul 31 '20 at 5:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.