2

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!

asked Dec 27, 2017 at 6:33

1 Answer 1

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]);
 } */
answered Dec 27, 2017 at 6:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.