1

So I've set up a new product in my Magento storefront. All works fine, however when I try to upload an image to the product I'm getting this error:

Could not read config file

I've checked the folder where the image would be uploaded to and it is actually there so it's been uploaded, but can't actually save the image.

I've tried to debug it and it seems the problem is in the FileResolver.php file in this method:

public function get($filename, $scope)
    {
        switch ($scope) {
            case 'global':
                $iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
                $themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
                if ($themeConfigFile
                    && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
                ) {
                    $iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] =
                        $this->rootDirectory->readFile(
                            $this->rootDirectory->getRelativePath(
                                $themeConfigFile
                            )
                        );
                } else {
                    $designPath = $this->resolver->resolve(
                        RulePool::TYPE_FILE,
                        'etc/view.xml',
                        $this->area,
                        $this->currentTheme
                    );
                    if (file_exists($designPath)) {
                        try {
                            $designDom = new \DOMDocument;
                            $designDom->load($designPath);
                            $iterator[$designPath] = $designDom->saveXML();
                        } catch (\Exception $e) {
                            throw new \Magento\Framework\Exception\LocalizedException(
                                new \Magento\Framework\Phrase('Could not read config file')
                            );
                        }
                    }
                }
                break;
            default:
                $iterator = $this->iteratorFactory->create([]);
                break;
        }
        return $iterator;
    }
4
  • it is occurs in Magento 1 or Magento 2 Commented Jun 27, 2017 at 17:27
  • @RamaChandran Magento 2
    – user52738
    Commented Jun 27, 2017 at 17:29
  • I think some of your xml files don't have read permissions. You can add before the throw statement this echo $e->getMessage();exit; to see on the screen what's the exact error. Commented Jun 27, 2017 at 17:36
  • What is the error through after display $e->getMessage();exit; please let me know Commented Jun 27, 2017 at 17:53

1 Answer 1

0

I think some of your xml files don't have read permissions. You can add before the throw statement this echo $e->getMessage();exit; and what the is on the screen what is the error through.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.