I want to add product grid (assign product) in my custom module using UI Component.

I follow this ANSWER:

Magento 2 : How to add a product grid in custom module using ui component?

and I get the error like:

Fatal error: Call to undefined method Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::getProductsReadonly() in /home/public_html/magento2110/app/code/[Namespace]/[Module]/Block/Adminhtml/Products/Edit/Tab/Product.php on line 133

If you already fixed above error so please help me to solve it or If you have another way to fix it so please let me know.

Thanks in Advance!

1 Answer 1


Issue is you are calling a wrong method with product object in

Step3: Create Product.php in Namespace\Module\Block\Adminhtml\Products\Edit\Tab\

Just comment following code block in above example,

/*if ($this->getItem()->getProductsReadonly()) {
            $productIds = $this->_getSelectedProducts();
            if (empty($productIds)) {
                $productIds = 0;
            $this->getCollection()->addFieldToFilter('entity_id', ['in' => $productIds]);
        } */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.