opencartopencart-3opencart-module

Plugin makes options dropdown not working in opencart product


I have a problem with Option tab on Add/Edit product. The problem is that when I installed the extension Autocomplete No More and when I choose Option it throws this error

Fatal error: Uncaught Error: Call to a member function getOptionData() on null in /../ocartdata/storage/modification/admin/controller/catalog/option.php:437

in option.php line 437 is

$option_data = $this->model_extension_catalog_autocomplete_no_more->getOptionData($this->request->post['option_id']);

And full function is this one

public function getOptionData() {
    
    if (isset($this->request->post['option_id'])) {

        $this->load->language('catalog/option');            
        $this->load->model('catalog/autocomplete_no_more');         
        $this->load->model('tool/image');
        
        $option_data = $this->model_extension_catalog_autocomplete_no_more->getOptionData($this->request->post['option_id']);
                        
        $this->response->setOutput(json_encode($option_data));
    }
}

Is anyone has an idea why this throws null?


Solution

  • Issue:

    You are trying to call a method of an Object

    $this->model_extension_catalog_autocomplete_no_more
    

    with the extension in the object name.

    but then you are loading the model without the extension in the path:

    $this->load->model('catalog/autocomplete_no_more')
    

    So obviously the Error signals that you have not yet defined this object

    Call to a member function getOptionData() on null

    Solution:

    Fix it by adding extension to the path:

    $this->load->model('extension/catalog/autocomplete_no_more')
    

    or remove if from the object name:

    $this->model_catalog_autocomplete_no_more