-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions
Magento 2.1.0
Steps to reproduce
- Install Magento 2.1.0
- Create a new EAV entity type 'my_eav_attr' with static and non-static attributes
- During run-time, create an instance of a collection that extends Magento\Eav\Model\Entity\Collection\AbstractCollection
- Call addAttributeToSelect('*') on collection
Expected result
- A valid collection (as worked in 2.0.7)
Actual result
main.CRITICAL: Exception: Serialization of 'Magento\Framework\View\Layout\Element' is not allowed in .../vendor/magento/module-eav/Model/Entity/AttributeCache.php:116
Stack trace:
#0 .../vendor/magento/module-eav/Model/Entity/AttributeCache.php(116): serialize(Array)
#1 .../vendor/magento/module-eav/Model/Entity/AttributeLoader.php(98): Magento\Eav\Model\Entity\AttributeCache->saveAttributes('my_eav_attr', Array)
#2 .../vendor/magento/module-eav/Model/Entity/AbstractEntity.php(510): Magento\Eav\Model\Entity\AttributeLoader->loadAllAttributes(Object(MyModule\MyEAVType\Model\ResourceModel\Tile\Interceptor), NULL)
#3 .../var/generation/MyModule/MyEAVType/Model/ResourceModel/Tile/Interceptor.php(193): Magento\Eav\Model\Entity\AbstractEntity->loadAllAttributes(NULL)
#4 .../vendor/magento/module-eav/Model/Entity/Collection/AbstractCollection.php(484): MyModule\MyEAVType\Model\ResourceModel\MyEAVType\Interceptor->loadAllAttributes()
#5 .../app/code/MyModule/MyEAVType/view/frontend/templates/myblock.phtml(6): Magento\Eav\Model\Entity\Collection\AbstractCollection->addAttributeToSelect('*')
Debugging in the attribute cache, it appears that serialisation of the static attributes is failing, although it's fine for the non-static attributes.
I've seen a suggestion that this is not an issue if I specify exactly which attributes I want, which is true, but the point of using EAV is that at compile time I will not always know the complete set of attributes I need.