I've created a custom module with an EAV model, and am now trying to render it into an admin grid. I've defined the attributes and they're being saved properly, but when I try to run `addAttributeToSelect('*')` to the model collection (`\Namespace\Module\Model\Obj\CollectionFactory`), `addAttributeToSelect` is not defined. My obj collection class extends `
\Magento\Eav\Model\Entity\Collection\AbstractCollection`
Hi @nbgrommet,
Can you share more code?
From provided information I can assume that you are calling addAttributeToSelect on CollectionFactory... Didn't you forget to create the collection ($collectionFactory->create()->addAttributeToSelect('*'))
Hi - here's the rest of the code:
namespace Vendor\Namespace\Ui\Component\Listing\DataProviders\Namespace\Obj; class Grid extends \Magento\Ui\DataProvider\AbstractDataProvider { public function __construct( $name, $primaryFieldName, $requestFieldName, \Vendor\Namespace\Model\ResourceModel\Obj\CollectionFactory $collectionFactory, array $meta = [], array $data = [] ) { parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); $this->collection = $collectionFactory->create(); $this->collection->addAttributeToSelect('*'); $this->collection->load(); } }
My collection factory extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
Thanks
`addAttributeToSelect()` only exists for EAV collections (inheriting `Magento\Eav\Model\Entity\Collection\AbstractCollection`)
For regular collections you have to use `addFieldToSelect()`