magento2: [EE 2.1.0] - Edit Product doesn't work after upgrade from 2.0.7 to 2.1.0

Steps to reproduce

  1. Upgrade Magento EE from 2.0.7 to 2.1.0
  2. Log in to backend and browse to products -> catalog
  3. Click on any product to edit

Expected result

  1. Product can be edited

Actual result

  1. HTTP ERROR 500

error log: PHP message: PHP Fatal error: Uncaught TypeError: Argument 3 passed to Magento\Framework\View\Element\UiComponentFactory::mergeMetadataElement() must be of the type array, null given, called in /var/www/html/vendor/magento/framework/View/Element/UiComponentFactory.php on line 335 and defined in /var/www/html/vendor/magento/framework/View/Element/UiComponentFactory.php:287 Stack trace: #0 /var/www/html/vendor/magento/framework/View/Element/UiComponentFactory.php(335): Magento\Framework\View\Element\UiComponentFactory->mergeMetadataElement(Array, 'schedule-design...', NULL, false) #1 /var/www/html/vendor/magento/framework/View/Element/UiComponentFactory.php(363): Magento\Framework\View\Element\UiComponentFactory->mergeMetadataItem(Array, Array, false) #2 /var/www/html/vendor/magento/framework/View/Element/UiComponentFactory.php(363): Magento\Framework\View\Element\UiComponentFactory->mergeMetadataItem(Array, Array, false)

magento_debug

Workaround: If you disable following modules it will work properly: Magento_BundleStaging Magento_ConfigurableProductStaging Magento_CatalogImportExportStaging Magento_CatalogStaging Magento_DownloadableStaging Magento_ProductVideoStaging

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 14
  • Comments: 30 (5 by maintainers)

Most upvoted comments

Firstly, the issue should happen for the products using custom attribute sets. You just need to go to the database to fix the schedule design update attribute group in the custom attribute sets and then you should be able to access the product edit page. After that, you may be not able to save because of another issue - “Update with id “0” does not exist.”. For this following issue, you can solve it by update the value of the column “created_in” in the table “catalog_product_entity” from 0 to 1.

I spent whole day to solve it.

I scripted @jasonyip2014’s answer to:

<?php

namespace Example\Module\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

/**
 * Class UpgradeData
 * @package Example\Module\Setup
 */
class UpgradeData implements UpgradeDataInterface
{
    /**
     * @var \Magento\Eav\Setup\EavSetupFactory
     */
    protected $eavSetupFactory;

    /**
     * UpgradeData constructor.
     * @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
     */
    public function __construct(
        \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
    ) {
        $this->eavSetupFactory = $eavSetupFactory;
    }

    /**
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     */
    public function upgrade(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $setup->startSetup();

        if (version_compare($context->getVersion(), '1.0.0', '<')) {
            /** @var \Magento\Eav\Setup\EavSetup $eavSetup */
            $eavSetup = $this->eavSetupFactory->create();

            $setup->getConnection()->update(
                'eav_attribute_group',
                ['tab_group_code' => 'advanced', 'sort_order' => 55],
                'attribute_group_code = "schedule-design-update"'
            );

            $setIds = $eavSetup->getAllAttributeSetIds(\Magento\Catalog\Model\Product::ENTITY);
            $groupId = 'schedule-design-update';
            foreach ($setIds as $setId) {
                foreach (['custom_design_from', 'custom_design_to', 'custom_design', 'custom_layout'] as $attribute) {
                    $eavSetup->addAttributeToSet(\Magento\Catalog\Model\Product::ENTITY, $setId, $groupId, $attribute);
                }
            }

            $setup->getConnection()->update('catalog_product_entity', ['created_in' => 1]);
        }

        $setup->endSetup();
    }
}

@jasonyip2014 This works. I did as you said: 1) UPDATE eav_attribute_group SET tab_group_code = “advanced”, sort_order = 55 WHERE attribute_group_code = “schedule-design-update”; `// This will update default attribute set too but it should have these values already.

  1. And moved in admin 3 attributes in each custom attribute set:
  • custom_design_from
  • custom_design_to
  • custom_design
  • custom_layout (already there) in group Schedule Design Update. Now I can see the product page in admin.

UPDATE catalog_product_entity SET created_in = “1”;

Just in case, flushed cache storage, cleared var/generation/* and deployed static content in pub/static (not the magento command). And reindex everything with command magento indexer:reindex

Thank you

https://jira.corp.magento.com/browse/MAGETWO-55944 ticket closed as cannot reproduce so closing

For me following point 2 in the above message by @daniel-ifrim solved the problem. All the attribute sets must have those attributes in that group, this seems related to the scheduled updates feature.

Nonetheless it is quite disappointing to see a major bug like this in EE not fixed in two months.

Yes @vkhandelwal1993 is right. I migrated the data from magento 1.9.3.7 to magento 2.2.5. When I click the add product button it showed me the same error. The way I resolved it was to go Admin->Store->Attribute Set. And edited the Default and Migration_Default Attributes Set. Initially the Migration_Default Attribute had the attribute sets but the Default was empty. I added the attributes to the Default Attribute Set and executed the reindex command sudo php bin/magento indexer:reindex

And it worked…

Hi All, Those who are facing this error should check there attributes set in admin, for me the whole attribute set was empty (default + migration_default). Assign the attributes to the set, reindex the data and check the product

Also check if the attribute set id is set for that product or not in admin ( table catalog_product_entity)

Updating the value suggested by @jasonyip2014 corrects my product editing issue as well, but I’m still trying to understand why this is necessary. The InstallData.php script for the catalog-staging module explicitly sets the created_in value of all existing products to 0. As we’ve seen this destroys the ability to update products that existed prior to the 2.1 update, but is there a reason why this value was used? What does the created_in value actually mean in this context?