Smile-SA / magento2-module-custom-entity-product-link

31 stars 12 forks source link

Magento 2.4.6-p3 > Add product in BO exception #63

Open grthi opened 8 months ago

grthi commented 8 months ago

Hello,

With module version 1.4.2, or 1.4.3 the same, and on a Magento 2.4.3-p6

When we go in BO, on product list, and click on "add product" top right button, I have this exception occurring

`TypeError: Smile\CustomEntityProductLink\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier\EavPlugin::aroundSetupAttributeMeta(): Argument #5 ($sortOrder) must be of type int, null given, called in /var/www/html/vendor/magento/framework/Interception/Interceptor.php on line 135 and defined in /var/www/html/vendor/smile/module-custom-entity-product-link/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/EavPlugin.php:39 Stack trace:

0 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Smile\CustomEntityProductLink\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier\EavPlugin->aroundSetupAttributeMeta(Object(Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor), Object(Closure), Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), 'search-engine-o...', NULL)

1 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), 'search-engine-o...', NULL)

2 /var/www/html/generated/code/Magento/CatalogStaging/Ui/DataProvider/Catalog/Product/Form/Modifier/Eav/Interceptor.php(59): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->___callPlugins('setupAttributeM...', Array, Array)

3 /var/www/html/vendor/magento/module-catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php(398): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->setupAttributeMeta(Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), 'search-engine-o...', NULL)

4 /var/www/html/generated/code/Magento/CatalogStaging/Ui/DataProvider/Catalog/Product/Form/Modifier/Eav/Interceptor.php(50): Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav->getContainerChildren(Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), 'search-engine-o...', NULL)

5 /var/www/html/vendor/magento/module-catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php(373): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->getContainerChildren(Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), 'search-engine-o...', NULL)

6 /var/www/html/generated/code/Magento/CatalogStaging/Ui/DataProvider/Catalog/Product/Form/Modifier/Eav/Interceptor.php(41): Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav->addContainerChildren(Array, Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), 'search-engine-o...', NULL)

7 /var/www/html/vendor/amasty/module-seo-toolkit-lite/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/EavPlugin.php(86): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->addContainerChildren(Array, Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), 'search-engine-o...', NULL)

8 /var/www/html/vendor/amasty/module-seo-toolkit-lite/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/EavPlugin.php(70): Amasty\SeoToolkitLite\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier\EavPlugin->createAttributeContainer(Object(Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor), Object(Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor), 'search-engine-o...')

9 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(146): Amasty\SeoToolkitLite\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier\EavPlugin->afterModifyMeta(Object(Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor), Array, Array)

10 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->Magento\Framework\Interception{closure}(Array)

11 /var/www/html/generated/code/Magento/CatalogStaging/Ui/DataProvider/Catalog/Product/Form/Modifier/Eav/Interceptor.php(23): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->___callPlugins('modifyMeta', Array, Array)

12 /var/www/html/vendor/magento/module-catalog/Ui/DataProvider/Product/Form/ProductDataProvider.php(73): Magento\CatalogStaging\Ui\DataProvider\Catalog\Product\Form\Modifier\Eav\Interceptor->modifyMeta(Array)

13 /var/www/html/vendor/magento/framework/View/Element/UiComponentFactory.php(330): Magento\Catalog\Ui\DataProvider\Product\Form\ProductDataProvider->getMeta()

14 /var/www/html/vendor/magento/framework/View/Element/UiComponentFactory.php(231): Magento\Framework\View\Element\UiComponentFactory->mergeMetadata('product_form', Array, false)

15 /var/www/html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(137): Magento\Framework\View\Element\UiComponentFactory->create('product_form', NULL, Array)

16 /var/www/html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(103): Magento\Framework\View\Layout\Generator\UiComponent->generateComponent(Object(Magento\Framework\View\Layout\Data\Structure), 'product_form', Array, Object(Magento\Framework\View\Layout\Interceptor))

17 /var/www/html/vendor/magento/framework/View/Layout/GeneratorPool.php(93): Magento\Framework\View\Layout\Generator\UiComponent->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))

18 /var/www/html/vendor/magento/framework/View/Layout.php(365): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))

19 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(68): Magento\Framework\View\Layout->generateElements()

20 /var/www/html/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()

21 /var/www/html/vendor/magento/framework/View/Page/Builder.php(65): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()

22 /var/www/html/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()

23 /var/www/html/vendor/magento/framework/View/Layout.php(271): Magento\Framework\View\Layout\Builder->build()

24 /var/www/html/vendor/magento/framework/View/Layout.php(896): Magento\Framework\View\Layout->build()

25 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(293): Magento\Framework\View\Layout->getBlock('menu')

26 /var/www/html/vendor/magento/module-backend/Model/View/Result/Page.php(26): Magento\Framework\View\Layout\Interceptor->getBlock('menu')

27 /var/www/html/generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php(23): Magento\Backend\Model\View\Result\Page->setActiveMenu('Magento_Catalog...')

28 /var/www/html/vendor/magento/module-catalog/Controller/Adminhtml/Product/NewAction.php(89): Magento\Backend\Model\View\Result\Page\Interceptor->setActiveMenu('Magento_Catalog...')

29 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Catalog\Controller\Adminhtml\Product\NewAction->execute()

30 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->___callParent('execute', Array)

31 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->Magento\Framework\Interception{closure}()

32 /var/www/html/generated/code/Magento/Catalog/Controller/Adminhtml/Product/NewAction/Interceptor.php(23): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->___callPlugins('execute', Array, Array)

33 /var/www/html/vendor/magento/framework/App/Action/Action.php(111): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->execute()

34 /var/www/html/vendor/magento/module-backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))

35 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))

36 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->___callParent('dispatch', Array)

37 /var/www/html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(145): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

38 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

39 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

40 /var/www/html/generated/code/Magento/Catalog/Controller/Adminhtml/Product/NewAction/Interceptor.php(32): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->___callPlugins('dispatch', Array, Array)

41 /var/www/html/vendor/magento/framework/App/FrontController.php(245): Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

42 /var/www/html/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse(Object(Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor), Object(Magento\Framework\App\Request\Http))

43 /var/www/html/vendor/magento/framework/App/FrontController.php(146): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(Magento\Catalog\Controller\Adminhtml\Product\NewAction\Interceptor))

44 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))

45 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)

46 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

47 /var/www/html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)

48 /var/www/html/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

49 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()

50 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent('launch', Array)

51 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception{closure}()

52 /var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins('launch', Array, Array)

53 /var/www/html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()

54 /var/www/html/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))

55 {main}`

grthi commented 8 months ago

Here the patch I apply on module to fix the problem.

--- /dev/null
+++ ../Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/EavPlugin.php
@@ -41,7 +41,7 @@
         callable $proceed,
         ProductAttributeInterface $attribute,
         string $groupCode,
-        int $sortOrder
+        ?int $sortOrder
     ): ?array {
         $meta = $proceed($attribute, $groupCode, $sortOrder);