Site icon Qaisar Satti's Blogs

MassAction is Custom Module: Type Error occurred when creating object

I Have a MaaDelete Action in my Admin UI_Component GRID,  everything is working fine but when i select a record and delete a record it giving me error: Type Error occurred when creating object

  Here my massaction code from ui_component [cc lang="php" tab_size="2" lines="40"] apriljune_testimonial_testimonial_listing.apriljune_testimonial_testimonial_listing.spinner_columns.ids entity_id delete Delete Delete items Are you sure you wan’t to delete selected items? [/cc] And here is the Controller:

[cc lang="php" tab_size="2" lines="40"]testimonial = $testimonial; $this->messageManager = $context->getMessageManager(); $this->resultFactory = $context->getResultFactory(); } /** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $selectedIds = $this->getRequest()->getParams()[‘selected’]; if (!is_array($selectedIds)) { $this->messageManager->addErrorMessage(__(‘Please select one or more testimonial.’)); } else { try { $collectionSize = count($selectedIds); foreach ($selectedIds as $_id) { $testimonial = $this->testimonial->getItems()[$_id]; $testimonial->delete(); } $this->messageManager->addSuccessMessage(__(‘A total of %1 record(s) have been deleted.’, $collectionSize)); } catch (Exception $e) { $this->messageManager->addErrorMessage($e->getMessage()); } } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath(‘*/*/’); } /** * @return bool */ protected function _isAllowed() { return $this->_authorization->isAllowed(‘Apriljune_Testimonial::Testimonial’); } } [/cc]
Exit mobile version