tzyganu / Magento2SampleModule

This is where I would put a Magento 2.0 Sample CRUD module if I had one.
MIT License
158 stars 65 forks source link

Modifier load redundant data #21

Open yaroslav-zenin opened 7 years ago

yaroslav-zenin commented 7 years ago

I just found that Sample\News\Ui\DataProvider\Author\Form\Modifier\AuthorData modifier load all data but should only one with specific author.

    public function modifyData(array $data)
    {
        $items = $this->collection->getItems();
        // here $items will contain all items present in DB, but should 
        // only filtered with specific author

        /** @var $author \Sample\News\Model\Author */
        foreach ($items as $author) {

Any ideas how to fix it?

BTW thanks for the nice sample module. It has started from 2015. Is it still actual with latest magento release?

tzyganu commented 7 years ago

@yaroslav-zenin That code looked strange to me too but I picked it up from the core. It's in the CMS module I just adapted it a bit If it's worth something, the collection always returns one single item everytime (or at least it did for me). I guess there are some magic filters applied somewhere based on the request params. So it is not actually loading the full collection.