0

I have just updated from 2.1.7 to 2.1.8 but when I run:

php bin/magento setup:di:compile

I get an erroe which is:

    [Exception]
  Warning: Declaration of Plazathemes\Override\Controller\Adminhtml\Category\Save::imagePreprocessing($data) should be compatible with Magento\Catalog\Controller\Adminhtml\Category\Save::imagePreprocessing(array $data) in /home/rbadmin/public_html/app/code/Plazathemes/Override/Controller/Adminhtml/Category/Save.php on line 82

The contents of Save.php are below

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Plazathemes\Override\Controller\Adminhtml\Category;

class Save extends \Magento\Catalog\Controller\Adminhtml\Category\Save
{
    private $storeManager;

    /**
     * Filter category data
     *
     * @param array $rawData
     * @return array
     */
    protected function _filterCategoryPostData(array $rawData)
    {
        $data = $rawData;
        // @todo It is a workaround to prevent saving this data in category model and it has to be refactored in future
        if (isset($data['image']) && is_array($data['image'])) {
            if (!empty($data['image']['delete'])) {
                $data['image'] = null;
            } else {
                if (isset($data['image'][0]['name']) && isset($data['image'][0]['tmp_name'])) {
                    $data['image'] = $data['image'][0]['name'];
                } else {
                    unset($data['image']);
                }
            }
        }

        if (isset($data['thumb_nail']) && is_array($data['thumb_nail'])) {
            if (!empty($data['thumb_nail']['delete'])) {
                $data['thumb_nail'] = null;
            } else {
                if (isset($data['thumb_nail'][0]['name']) && isset($data['thumb_nail'][0]['tmp_name'])) {
                    $data['thumb_nail'] = $data['thumb_nail'][0]['name'];
                } else {
                    unset($data['thumb_nail']);
                }
            }
        }

        if (isset($data['thumb_popular']) && is_array($data['thumb_popular'])) {
            if (!empty($data['thumb_popular']['delete'])) {
                $data['thumb_popular'] = null;
            } else {
                if (isset($data['thumb_popular'][0]['name']) && isset($data['thumb_popular'][0]['tmp_name'])) {
                    $data['thumb_popular'] = $data['thumb_popular'][0]['name'];
                } else {
                    unset($data['thumb_popular']);
                }
            }
        }

        return $data;
    }

    /**
     * Image data preprocessing
     *
     * @param array $data
     *
     * @return array
     */
    public function imagePreprocessing($data)
    {
        if (empty($data['image'])) {
            unset($data['image']);
            $data['image']['delete'] = true;
        }

        if (empty($data['thumb_nail'])) {
            unset($data['thumb_nail']);
            $data['thumb_nail']['delete'] = true;
        }

        return $data;
    }
}
3

I think if you change public function imagePreprocessing($data) to public function imagePreprocessing(array $data) it won't give you the error. There could be more wrong with the theme though.

| improve this answer | |
  • That fixed it and now compiled without errors, thank you :) – HadlowJ Aug 31 '17 at 20:07
0

Please change public function imagePreprocessing($data) to public function imagePreprocessing(array $data). it solved my error, I hope your also.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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