I use in my decision the answer that was in this question Magento 2 Custom Collection

Everything works fine, but how to filter data when they are searched?

My code

$collection = $this->_postFactory->create()->getCollection();

    $collection2 = $this->_purchaseListCollection;

    foreach ($collection->getData() as $key => $data) {
        $data['model_number'] = 'tested'.$key;
            new \Magento\Framework\DataObject($data)


    return parent::_prepareCollection();

Code create table

            'header'            => __('Model number'),
            'index'             => 'model_number',
            'sortable'          => true,
            'type'              => 'text',
            'escape'            => true,
            'header_css_class'  => 'col-value',
            'column_css_class'  => 'col-value',

My code on model/resourceModel collection

namespace Magento\PurchaseWizard\Model\ResourceModel\PurchaseList;

use Magento\Framework\Data\Collection as DataCollection;
class EmptyCollection extends DataCollection


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.