Magento – Warning: call_user_func_array() expects parameter 1 to be a valid callback Magento 2.3

catalogsearchelasticsearchmagento2.3.0

I have installed Smile_Elasticsearch extension.It is working fine with the default mode but when I enabled developer mode it is showing an error.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in
app/code/Smile/ElasticsuiteVirtualCategory/Model/Layer/Filter/Category.php
on line 150

Please see attached screenshot.

enter image description here

Technology Detail's:

  • Magento version: 2.3
  • Smile Elasticsearch version: 2.7.0 (which is compatible with Magento 2.3)
  • Installed Elasticsearch version: 5.6.15 (which is compatible with magento 2.3)
  • PHP version: 7.1

So, Please let me know how can I fix this error?
Your help would be appreciated.
Thanks in advance.!!!

Best Answer

Here parameter 1 [$virtualRule, $callback] must be an array to callback these function.
Here is solution.
Goto line around 151 to 156 /module-elasticsuite-virtual-category/Model/Layer/Filter/Category.php

if ($data === false) {
$virtualRule = $category->getVirtualRule();
$data = call_user_func_array([$virtualRule, $callback], [$category]);
$cacheData = serialize($data);
$this->cache->save($cacheData, $cacheKey, [\Magento\Catalog\Model\Category::CACHE_TAG]);
}

Change to this

if ($data === false) {
$virtualRule = $category->getVirtualRule();
$data = call_user_func_array(array[$virtualRule, $callback], [$category]);
$cacheData = serialize($data);
$this->cache->save($cacheData, $cacheKey, [\Magento\Catalog\Model\Category::CACHE_TAG]);
}

Reference: https://www.php.net/manual/en/function.call-user-func.php

Related Topic