Skip to main content
1 of 2
Pankaj Bhope
  • 1.5k
  • 13
  • 26

Ok, So referencing to Attachment.php (modified a little, so copy this)

<?php
namespace Vendor\Module\Controller\Adminhtml;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
use Vendor\Module\Model\AttachmentFactory;

abstract class Attachment extends Action
{

    protected $_attachmentFactory;           
    protected $_coreRegistry;

    public function __construct(
        Context $context            
        AttachmentFactory $attachmentFactory,
        Registry $coreRegistry,

    ) {
        $this->_attachmentFactory     = $attachmentFactory;
        $this->_coreRegistry          = $coreRegistry;
        parent::__construct($context);
    }


    protected function _initAttachment()
    {
        $attachmentId  = (int)$this->getRequest()->getParam('attachment_id');

        $attachment    = $this->_attachmentFactory->create();
        if ($attachmentId) {
            $attachment->load($attachmentId);
        }
        $this->_coreRegistry->register('solwin_productattachment_attachment', $attachment);
        return $attachment;
    }
}

Modify your Edit.php like this:

_resultPageFactory = $resultPageFactory; $this->_resultJsonFactory = $resultJsonFactory; parent::__construct($context, attachmentFactory, $coreRegistry); }
Pankaj Bhope
  • 1.5k
  • 13
  • 26