0

I have created new module for adding custom attribute for category section in admin area of Magento 2. After that when I tried to run the setup:upgrade command it gives us the following errors on fallback.php

Invalid argument supplied for foreach() in /vendor/magento/module-store/Model/Config/Processor/Fallback.php on line 125

Also I have checked the app/etc/env.php file it looks like working but I don't understand how can we resolve this issue. So please suggest and help that will be great for me.

  • Can you please add code which creates category attribute? – Abhishek Panchal Oct 26 '17 at 13:30
  • Yes. I have added the below code for creating the custom attribute in setup/installdata.php – user3611432 Oct 26 '17 at 13:35
  • $categorySetup->addAttribute( 'catalog_category', 'additional_image', [ 'type' => 'varchar', 'label' => 'Additional Image', 'input' => 'image', 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image', 'required' => false, 'sort_order' => 100, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Content', ] ); – user3611432 Oct 26 '17 at 13:36
0

Try Below code:

<?php
namespace Namespace\Module\Setup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Catalog\Setup\CategorySetupFactory;
class InstallData
    implements InstallDataInterface
{
    /**
     * Category setup factory
     *
     * @var CategorySetupFactory
     */
    private $categorySetupFactory;
    /**
     * Init
     *
     * @param CategorySetupFactory $categorySetupFactory
     */
    public function __construct(
        CategorySetupFactory $categorySetupFactory
    ) {
        $this->categorySetupFactory = $categorySetupFactory;
    }
    /**
     * {@inheritdoc}
     */
    public function install(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $setup->startSetup();
        /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
        $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
        $categorySetup->addAttribute(
            'catalog_category',
            'additional_image',
            [
                'type' => 'varchar',
                'label' => 'Additional Image',
                'input' => 'image',
                'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image',
                'required' => false,
                'sort_order' => 100,
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'group' => 'General Information',
            ]
        );
        $setup->endSetup();
    }
}
  • I have already used same code which you have provided here in installdata.php but still gives same errors on fallback.php line no 125 – user3611432 Oct 26 '17 at 14:14
  • I don't understand how this was happening with my end. – user3611432 Oct 26 '17 at 14:15

Your Answer

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

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