Expand my Community achievements bar.

Cannot save product attributes for Visual & Text swatch

Avatar

Level 1

I faced the below message once try to save or create product attributes for Visual & Text swatch type. Any suggestion, please advise.

 

My Magento version is 2.4.5 p2.

 

TypeError: Illegal offset type in /home/..../public_html/vendor/magento/module-swatches/Model/Plugin/EavAttribute.php:239


Stack trace:

#0 /home/..../public_html/vendor/magento/module-swatches/Model/Plugin/EavAttribute.php(239): array_column()
#1 /home/..../public_html/vendor/magento/module-swatches/Model/Plugin/EavAttribute.php(202): Magento\Swatches\Model\Plugin\EavAttribute->prepareOptionLinks()
#2 /home/..../public_html/vendor/magento/module-swatches/Model/Plugin/EavAttribute.php(122): Magento\Swatches\Model\Plugin\EavAttribute->processSwatchOptions()
#3 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Swatches\Model\Plugin\EavAttribute->afterAfterSave()
#4 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->Magento\Framework\Interception\{closure}()
#5 /home/..../public_html/generated/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute/Interceptor.php(32): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->___callPlugins()
#6 /home/..../public_html/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(842): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->afterSave()
#7 /home/..../public_html/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(402): Magento\Framework\Model\ResourceModel\Db\AbstractDb->processAfterSaves()
#8 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save()
#9 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Model\ResourceModel\Attribute\Interceptor->___callParent()
#10 /home/..../public_html/vendor/magento/module-catalog-search/Model/Attribute/SearchWeight.php(62): Magento\Catalog\Model\ResourceModel\Attribute\Interceptor->Magento\Framework\Interception\{closure}()
#11 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\CatalogSearch\Model\Attribute\SearchWeight->aroundSave()
#12 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\ResourceModel\Attribute\Interceptor->Magento\Framework\Interception\{closure}()
#13 /home/..../public_html/generated/code/Magento/Catalog/Model/ResourceModel/Attribute/Interceptor.php(32): Magento\Catalog\Model\ResourceModel\Attribute\Interceptor->___callPlugins()
#14 /home/..../public_html/vendor/magento/framework/Model/AbstractModel.php(658): Magento\Catalog\Model\ResourceModel\Attribute\Interceptor->save()
#15 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\Model\AbstractModel->save()
#16 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->___callParent()
#17 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->Magento\Framework\Interception\{closure}()
#18 /home/..../public_html/generated/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute/Interceptor.php(50): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->___callPlugins()
#19 /home/..../public_html/vendor/magento/module-catalog/Controller/Adminhtml/Product/Attribute/Save.php(304): Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor->save()
#20 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save->execute()
#21 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->___callParent()
#22 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->Magento\Framework\Interception\{closure}()
#23 /home/..../public_html/generated/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save/Interceptor.php(23): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->___callPlugins()
#24 /home/..../public_html/vendor/magento/framework/App/Action/Action.php(111): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->execute()
#25 /home/..../public_html/vendor/magento/module-backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch()
#26 /home/..../public_html/vendor/magento/module-catalog/Controller/Adminhtml/Product/Attribute.php(79): Magento\Backend\App\AbstractAction->dispatch()
#27 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Catalog\Controller\Adminhtml\Product\Attribute->dispatch()
#28 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->___callParent()
#29 /home/..../public_html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(145): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->Magento\Framework\Interception\{closure}()
#30 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch()
#31 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->Magento\Framework\Interception\{closure}()
#32 /home/..../public_html/generated/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save/Interceptor.php(32): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->___callPlugins()
#33 /home/..../public_html/vendor/magento/framework/App/FrontController.php(245): Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\Interceptor->dispatch()
#34 /home/..../public_html/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#35 /home/..../public_html/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
#36 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#37 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#38 /home/..../public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#39 /home/..../public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#40 /home/..../public_html/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#41 /home/..../public_html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#42 /home/..../public_html/pub/index.php(48): Magento\Framework\App\Bootstrap->run()
#43 {main}<br />
<font size='1'><table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught Exception: User Error: Some transactions have not been committed or rolled back in /home/..../public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 4067 in /home/..../public_html/vendor/magento/framework/App/ErrorHandler.php on line <i>62</i></th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Exception: User Error: Some transactions have not been committed or rolled back in /home/..../public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 4067 in /home/..../public_html/vendor/magento/framework/App/ErrorHandler.php on line <i>62</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.3503</td><td bgcolor='#eeeeec' align='right'>25642104</td><td bgcolor='#eeeeec'>Magento\Framework\DB\Adapter\Pdo\Mysql->__destruct(  )</td><td title='/home/..../public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php' bgcolor='#eeeeec'>.../Mysql.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.3503</td><td bgcolor='#eeeeec' align='right'>25642104</td><td bgcolor='#eeeeec'><a href='http://www.php.net/function.trigger-error' target='_new'>trigger_error</a>( <span>$message = </span><span>&#39;Some transactions have not been committed or rolled back&#39;</span>, <span>$error_level = </span><span>256</span> )</td><td title='/home/..../public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php' bgcolor='#eeeeec'>.../Mysql.php<b>:</b>4067</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>3</td><td bgcolor='#eeeeec' align='center'>0.3504</td><td bgcolor='#eeeeec' align='right'>25642432</td><td bgcolor='#eeeeec'>Magento\Framework\App\ErrorHandler->handler( <span>$errorNo = </span><span>256</span>, <span>$errorStr = </span><span>&#39;Some transactions have not been committed or rolled back&#39;</span>, <span>$errorFile = </span><span>&#39;/home/..../public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php&#39;</span>, <span>$errorLine = </span><span>4067</span> )</td><td title='/home/..../public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php' bgcolor='#eeeeec'>.../Mysql.php<b>:</b>4067</td></tr>
</table></font>
 
Regards,
1 Reply

Avatar

Level 2

Hey! 

 

I recommend logging the problem area to identify which attribute and product is causing the error.

 

The TypeError: Illegal offset type error in the EavAttribute.php file within your Magento 2.4.5-p2 installation, particularly concerning the swatches module, indicates an issue with the data types used as array keys in PHP. This error often occurs when a key of an array is of a non-string and non-integer type (like an array or an object).

Steps to Resolve the Issue:

  1. Code Inspection:

    • Open the file /home/..../public_html/vendor/magento/module-swatches/Model/Plugin/EavAttribute.php and navigate to line 239.
    • Examine the operations occurring at this line and the data types used as array keys.
  2. Debugging:

    • Consider adding temporary logging or debugging code at this point to observe the data being passed and causing the error.
  3. Module Compatibility Check:

    • Ensure that all installed modules and custom extensions are compatible with Magento version 2.4.5-p2.
  4. Updates/Patches:

    • Check for available updates or patches for Magento or the product swatches module that might resolve this issue.
  5. Seeking Help:

    • If you're not confident in debugging or resolving the issue, consider seeking assistance from Magento professionals or the community.
  6. Backup:

    • Ensure you have a current backup of your site before making any changes to the code.
  7. System Logs Check:

    • Review Magento system logs for additional information that might help identify the cause of the error.

Possible Causes of the Error:

  • Incorrect Data Types: Using unsupported data types as array keys.
  • Module Conflicts: Potential conflicts between installed modules or extensions.
  • Core Magento Issues: In rare cases, the error might be due to a bug in Magento itself.

Be cautious when editing code and always make backups before making changes.

 

Regards,

Eugene