S
S
Sergey Nalomenko2021-03-22 20:44:00
PHP
Sergey Nalomenko, 2021-03-22 20:44:00

Creating custom models in OpenCart?

I use different opencart models in the cron script inside the admin application (such as catalog/product, catalog/category).

There was a need to create their own models for working with geodata. I create a model inside a new group (folder) ./admin/model/geo/cities.php

class ModelGeoCities extends Model {
  public function getCities() {
    return [];
  }
}


In the controller at the stage of loading a new model $this->load->model('geo/cities'); the script crashes.

I understand that the model is not visible to the system, and I'm making a mistake somewhere. I will be glad to help.

Thank you! :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zeus2021, 2021-03-24
@Zeus2021

Hello
If you created a model here /admin/model/geo/cities.php then it will work relative to /admin and will not work in the /catalog/ directory ..
Therefore, if you need it to work in /catalog, then you need to create it and here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question