1

controller

delete.php

<?php


namespace Webkul\Mpquotesystem\Controller\Adminhtml\Managequotes;

use Magento\Backend\App\Action;
use Webkul\Mpquotesystem;

class Delete extends \Magento\Backend\App\Action
{
    protected $_mpQuoteHelper;
    protected $_mpquoteMailHelper;
    protected $_collectionFactory;
        protected $_objectManager;


    /**
     * @param Action\Context            $context
     * @param Mpquotesystem\Helper\Data $mpQuoteHelper
     */

    public function __construct(
        Action\Context $context,
        Mpquotesystem\Helper\Mail $mailHelper,
         \Magento\Framework\ObjectManagerInterface $objectmanager,
        Mpquotesystem\Model\ResourceModel\Quotes\CollectionFactory $collectionFactory,

        Mpquotesystem\Helper\Data $mpQuoteHelper
    ) {
        parent::__construct($context);
        $this->_mpQuoteHelper = $mpQuoteHelper;
        $this->_mpquoteMailHelper = $mailHelper;
        $this->_objectManager = $objectmanager;

        $this->_collectionFactory = $collectionFactory;
    }
    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed(
            'Webkul_Mpquotesystem::mpquotes'
        );
    }
    /**
     * Delete action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {
        $data = $this->getRequest()->getParams();
        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();
        if ($data) {
            $model = $this->_mpQuoteHelper->getWkQuoteModel();
            $id = $this->getRequest()->getParam('entity_id');
            if ($id) {
                 $model->load($id);




            }
            try {
                $model->delete();
                $sellerlist='';


                /* send deleted quote to email to seller and buyer - icore*/

                 // $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
                $model2=$this->_objectManager->create('Webkul\Mpquotesystem\Model\SellerQuotes');
                $datacollection=$model2->getCollection();


                 $data['quote_message']="Quote has been deleted by admin";



               foreach ($datacollection as $data) {


                    $dc=$data->getData('quote_id');
                    $delp=$data->getData('seller_quote_price');

                    foreach ((array)$dc as $test)
                    {

                        if($test==$id){

                         if($delp!=0.0000){
                             $sellerlist=$data->getData('seller_id');
                        }}
                    }


                }

                 $data['quote_message']="Quote has been deleted by admin";
                if($sellerlist) {
                    $this->_mpquoteMailHelper->quoteEditedByAdminbid(
                        $id,
                        $data['quote_message'],
                        'admin'
                    );

                }

                else{
                    echo $id;
                    $this->_mpquoteMailHelper->quoteStatusMail(
                        $id,
                        $data['quote_message'],
                        'admin'
                    );


                }
               $this->messageManager->addSuccess(__('Quote is Successfully deleted'));                
               return $resultRedirect->setPath('*/*/');
            } catch (\Magento\Framework\Exception\LocalizedException $e) {
                $this->messageManager->addError(__($e->getMessage()));
            } catch (\RuntimeException $e) {
                $this->messageManager->addError(__($e->getMessage()));
            } catch (\Exception $e) {
                $this->messageManager->addException(
                    $e,
                    __('Something went wrong while Deleting the data.')
                );
            }
            $this->_getSession()->setFormData($data);
            return $resultRedirect->setPath('*/*/');
        }
       return $resultRedirect->setPath('*/*/');
    }
}

delete() is working fine but when hide Delete method the email is working

how i can fix this error in email

closed as off-topic by Amit Bera Apr 11 at 4:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Amit Bera
If this question can be reworded to fit the rules in the help center, please edit the question.