magento2: Undefined variables during product save
The issue reporting template does not provide guides for missing keys specifically. I have attempted to fit in the missing isset() checks I have noticed
Preconditions
- Magento CE 2.2.5
Steps to reproduce
- Create Configurable Product
- Before saving the parent product, make sure that at least one configuration has a SKU that is longer than allowed.
- Save and the validation will complain about the length exceeding 64 characters
- Correct the SKU and make sure the length is shorter than the limit of 64 characters
- Save the product. The error is now reproduced.
Expected result
Expected product to be created and indexed properly.
Actual result
Error 1
The Magento error report was displayed with the mention of an undefined variable product in the save.php:
{ "0":"Notice: Undefined variable: product in \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/module-catalog\/Controller\/Adminhtml\/Product\/Save.php on line 156", "1":"#0 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/module-catalog\/Controller\/Adminhtml\/Product\/Save.php(156): Magento\\Framework\\App\\ErrorHandler->handler(8, 'Undefined varia...', '\/opt\/vaimo\/depl...', 156, Array)\n#1 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/App\/Action\/Action.php(107): Magento\\Catalog\\Controller\\Adminhtml\\Product\\Save->execute()\n#2 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/module-backend\/App\/AbstractAction.php(229): Magento\\Framework\\App\\Action\\Action->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#3 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Backend\\App\\AbstractAction->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#4 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Catalog\\Controller\\Adminhtml\\Product\\Save\\Interceptor->___callParent('dispatch', Array)\n#5 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/module-backend\/App\/Action\/Plugin\/Authentication.php(143): Magento\\Catalog\\Controller\\Adminhtml\\Product\\Save\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#6 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\\Backend\\App\\Action\\Plugin\\Authentication->aroundDispatch(Object(Magento\\Catalog\\Controller\\Adminhtml\\Product\\Save\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\n#7 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Catalog\\Controller\\Adminhtml\\Product\\Save\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#8 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/generated\/code\/Magento\/Catalog\/Controller\/Adminhtml\/Product\/Save\/Interceptor.php(26): Magento\\Catalog\\Controller\\Adminhtml\\Product\\Save\\Interceptor->___callPlugins('dispatch', Array, NULL)\n#9 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/App\/FrontController.php(55): Magento\\Catalog\\Controller\\Adminhtml\\Product\\Save\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#10 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Framework\\App\\FrontController->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#11 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Framework\\App\\FrontController\\Interceptor->___callParent('dispatch', Array)\n#12 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#13 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php(26): Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins('dispatch', Array, Array)\n#14 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/App\/Http.php(135): Magento\\Framework\\App\\FrontController\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#15 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Framework\\App\\Http->launch()\n#16 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Framework\\App\\Http\\Interceptor->___callParent('launch', Array)\n#17 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Framework\\App\\Http\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n#18 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php(26): Magento\\Framework\\App\\Http\\Interceptor->___callPlugins('launch', Array, Array)\n#19 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\\Framework\\App\\Http\\Interceptor->launch()\n#20 \/MASKED_DIR/2018-08-06_12-56-07\/htdocs\/pub\/index.php(37): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#21 {main}", "url":"\/MASKED\/catalog\/product\/save\/id\/301\/type\/simple\/store\/0\/set\/14\/key\/f7cca584661b838238aa1d82c6acbfd44a4217a38fe0ec2ea7ba1ec8d529b0ef\/back\/edit", "script_name":"\/index.php" }
I looked the save.php through, and the $product variable is declared within try and thus not available in the catch.
Error 2
Happens in the getVariationMatrix() function of Configurable.php. Apparently the $item does not contain the index newProduct and throws a notice.
Notice: Undefined index: newProduct in /MASKED/2018-08-06_12-56-07/htdocs/vendor/magento/module-configurable-product/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php on line 161
As to why the products were not created, we havent exactly located the issue. We just found these small errors along the way.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 40 (18 by maintainers)
Commits related to this issue
- issue #17436 fixed — committed to mahesh-rajawat/magento2 by mahesh-rajawat 6 years ago
I Fixed in my website! Please check below process Step 1: set “const SKU_MAX_LENGTH = 255;” in the file module-catalog/Model/Product/Attribute/Backend/Sku.php Step 2: You need to change the into database as well. Go to table eav_attribute, search for sku at column attribute code then edit the resulted row.
Update the field frontend_class to null or validate-length maximum-length-255 according to your requirement. Step 3: You have to change field size at the database table.
ALTER TABLE
catalog_product_entityCHANGEskuskuVARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT ‘SKU’;@magento-engcom-team , @michaelrachlitz I could not pinpoint it exactly. My knowledge of the UI Components is not good enough and the code is poorly documented on this part which it makes tough to understand.
What I did find out was that after clicking the Save button when you have an error message visible (not necessarily the SKU of the configurable product, can also be the price of the simple product) the dataRecord in the getChildItems method of app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js is messed up. This causes a JS error (dataRecord.slice is not a function).
I could not find the relation the save button and this data record by plowing through this related code.
Hi @magento-engcom-team I have the issue with bundle options Delete
https://www.screencast.com/t/XVpEB42MGixU
Kindly guide me to fix the issue Thanks