4

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:

enter image description here

Still unable to fix can someone write the soltion to fix this.

4
  • Are you sure all composer packages are installed? If something is corrupt in your composer and you do composer install/update it won't fix it. You have to force reinstall that package. Try cleaning the vendor folder and run composer install or composer update Commented Dec 29, 2016 at 0:41
  • Can you please provide the steps to follow to do this. Commented Dec 29, 2016 at 7:58
  • Did you remove var/di, var/generation and try run di compile again? Commented Dec 29, 2016 at 14:44
  • Clear cache and generated files and again recompile. Hope this will help you Commented Sep 25, 2017 at 16:28

3 Answers 3

0

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 {
   ......
}
0

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

1
  • 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 helps Commented Mar 29, 2018 at 2:49
0

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---
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.