3

I was experimenting with attributes API in Magento and accidentally modified the attribute that I didn't want to modify and which seems to be important in for product form. It is links_purchased_separately.

My version of Magento is 2.3.1

Now, when I try to open any product, I get only the exception message and stack:

Exception #0 (Magento\Framework\Exception\LocalizedException): The "formElement" configuration parameter is required for the "links_purchased_separately" field.

Full stack trace:

Exception #0 (Magento\Framework\Exception\LocalizedException): The "formElement" configuration parameter is required for the "links_purchased_separately" field.
#1 Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent() called at [vendor/magento/framework/View/Layout/Generator/UiComponent.php:161]
#2 Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent() called at [vendor/magento/framework/View/Layout/Generator/UiComponent.php:161]
#3 Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent() called at [vendor/magento/framework/View/Layout/Generator/UiComponent.php:161]
#4 Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent() called at [vendor/magento/framework/View/Layout/Generator/UiComponent.php:142]
#5 Magento\Framework\View\Layout\Generator\UiComponent->generateComponent() called at [vendor/magento/framework/View/Layout/Generator/UiComponent.php:102]
#6 Magento\Framework\View\Layout\Generator\UiComponent->process() called at [vendor/magento/framework/View/Layout/GeneratorPool.php:81]
#7 Magento\Framework\View\Layout\GeneratorPool->process() called at [vendor/magento/framework/View/Layout.php:343]
#8 Magento\Framework\View\Layout->generateElements() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:89]
#9 Magento\Framework\View\Layout\Interceptor->generateElements() called at [vendor/magento/framework/View/Layout/Builder.php:129]
#10 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Page/Builder.php:55]
#11 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Layout/Builder.php:65]
#12 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Layout.php:253]
#13 Magento\Framework\View\Layout->build() called at [vendor/magento/framework/View/Layout.php:875]
#14 Magento\Framework\View\Layout->getBlock() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:414]
#15 Magento\Framework\View\Layout\Interceptor->getBlock() called at [vendor/magento/module-backend/Model/View/Result/Page.php:26]
#16 Magento\Backend\Model\View\Result\Page->setActiveMenu() called at [generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php:24]
#17 Magento\Backend\Model\View\Result\Page\Interceptor->setActiveMenu() called at [vendor/magento/module-catalog/Controller/Adminhtml/Product/Edit.php:71]
#18 Magento\Catalog\Controller\Adminhtml\Product\Edit->execute() called at [generated/code/Magento/Catalog/Controller/Adminhtml/Product/Edit/Interceptor.php:24]
#19 Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#20 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:231]
#21 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#22 Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#23 Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]
#24 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#25 Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#26 Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Controller/Adminhtml/Product/Edit/Interceptor.php:39]
#27 Magento\Catalog\Controller\Adminhtml\Product\Edit\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:159]
#28 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:99]
#29 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#30 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#31 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#32 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#33 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:136]
#34 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#35 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:258]
#36 Magento\Framework\App\Bootstrap->run() called at [index.php:39]

What can I do to fix it?

  • What change did you make there? – Ravi Soni Jun 26 '19 at 13:41
  • I overwritten this attribute with mine, so I have entirely different attribute now and I don't now how this attribute was configured before. I have the access to Magento 2.2.7 but I cannot see such attribute in there. – wmioduszewski Jun 26 '19 at 13:45
  • If you want to revert then you can check here how this attribute was created by default here: /var/www/html/magento227/vendor/magento/module-downloadable/Setup/InstallData.php – Ravi Soni Jun 26 '19 at 13:50
  • OR for same case, you can refer this solution also: https://magento.stackexchange.com/questions/204420/the-configuration-parameter-formelement-is-a-required-for-custom-attribute-pro – Ravi Soni Jun 26 '19 at 13:58
  • Thanks! Didn't know what you meant by /var/www/html/magento227/vendor/magento/module-downloadable/Setup/InstallData.php but it brought me to https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Downloadable/Setup/Patch/Data/InstallDownloadableAttributes.php#L58 where I found the defaults for this attribute and thanks to that - I resolved my problem. Thank you! :) – wmioduszewski Jun 26 '19 at 14:12
  • Should you consider providing an answer instead of comment with the summary of what we discussed here? I'd gladly mark your answer as resolution. Cheers! – wmioduszewski Jun 26 '19 at 14:13
  • I have added Answer. Please MARK AS RIGHT answer if it's help you.. :) – Ravi Soni Jun 26 '19 at 17:17

1 Answers1

0

You can find default behavior here.

\vendor\magento\module-downloadable\Setup\Patch\Data\InstallDownloadableAttributes.php

/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
/**
 * Add attributes to the eav/attribute table
 */
$eavSetup->addAttribute(
    \Magento\Catalog\Model\Product::ENTITY,
    'links_purchased_separately',
    [
        'type' => 'int',
        'backend' => '',
        'frontend' => '',
        'label' => 'Links can be purchased separately',
        'input' => '',
        'class' => '',
        'source' => '',
        'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
        'visible' => false,
        'required' => true,
        'user_defined' => false,
        'default' => '',
        'searchable' => false,
        'filterable' => false,
        'comparable' => false,
        'visible_on_front' => false,
        'unique' => false,
        'apply_to' => 'downloadable',
        'used_in_product_listing' => true
    ]
);

Might this will help to resolve your issue.

Ravi Soni
  • 1,809
  • 1
  • 16
  • 33