Skip to content

loadAllAttributes fails for EAV entities #5339

@maderlock

Description

@maderlock

Preconditions

Magento 2.1.0

Steps to reproduce

  1. Install Magento 2.1.0
  2. Create a new EAV entity type 'my_eav_attr' with static and non-static attributes
  3. During run-time, create an instance of a collection that extends Magento\Eav\Model\Entity\Collection\AbstractCollection
  4. Call addAttributeToSelect('*') on collection

Expected result

  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions