When I compile I get this error:
PHP Fatal error: Class 'Magento\Catalog\Controller\Adminhtml\Category\Image\Upload' not found in /var/www/html/magento/app/code/Plazathemes/Override/Controller/Adminhtml/Category/Image/Upload.php on line 11
EDIT with the code:
Still unable to fix can someone write the soltion to fix this.
3 Answers 3
Seem that you're trying to override the class Magento\Catalog\Controller\Adminhtml\Category\Image\Upload. So, make sure your custom class will extend from this class.
class Upload extends \Magento\Catalog\Controller\Adminhtml\Category\Image\Upload {
......
}
Not sure why you are getting the error itself but if i may suggest just making your file like this?
namespace ....
use Magento\Backend\App\Action;
use Magento\Catalog\Model\ImageUploader;
class Upload extends Action{
/**
* Image uploader
*
* @var \Magento\Catalog\Model\ImageUploader
*/
protected $imageUploader;
/**
* Upload constructor.
*
* @param Action\Context $context
* @param \Magento\Catalog\Model\ImageUploader $imageUploader
*/
public function __construct(
Action\Context $context,
ImageUploader $imageUploader
) {
parent::__construct($context);
$this->imageUploader = $imageUploader;
}
public function execute(){
....
}
}
I also suggest you use the Magento image uploader instead of the category uploader unless that is really your intention. Like here Create beautiful image upload in configuration magento 2
-
Just a comment. Since i do not know the intend or the page where you are using this i can not provide a specific solution but i hope this helpsCompactCode– CompactCode2018年03月29日 02:49:37 +00:00Commented Mar 29, 2018 at 2:49
Try to give a alias name for the extended class - as shown below:
use Magento\Catalog\Controller\Adminhtml\Category\Image\Upload as CatalogImageUopload
class Upload extends CatalogImageUopload
{
-----write your code here---
}
Explore related questions
See similar questions with these tags.
var/di,var/generationand try run di compile again?