A
A
andrew_goldsmith2016-08-18 13:20:05
PHP
andrew_goldsmith, 2016-08-18 13:20:05

Running the plugin on schedule (1 time per day)?

Good day to all.
Essence of the question: Opencart, SeoGen plugin. It looks like this - inputs, checkboxes, textarea + generate button.

eAORjXKcjwO82o.png

It is necessary to generate this whole thing in the background once a day, at a certain time, the generate button (highlighted in red) calls the function with the argument + collects data from the fields.

Button code:

<a onclick="generate('products');" class="button">Генерировать</a>


Further, everything is already happening in mvc
Function from the controller:
public function generate() {
    if($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['name']) && $this->validate()) {
      $time_start = microtime(true);
      $base_memory_usage = memory_get_usage();

      $this->load->language('module/seogen');
      $this->load->model('module/seogen');
      $name = $this->request->post['name'];
        if($name == 'categories') {
        $this->model_module_seogen->generateCategories($this->request->post['seogen']);
      } elseif($name == 'products') {
        $this->model_module_seogen->generateProducts($this->request->post['seogen']);
      } elseif($name == 'manufacturers') {
        $this->model_module_seogen->generateManufacturers($this->request->post['seogen']);
      } elseif($name == 'informations') {
        $this->model_module_seogen->generateInformations($this->request->post['seogen']);
      }

      $this->response->setOutput($this->language->get('text_success_generation') . "</br><b>Total Execution Time:</b> ".(microtime(true) - $time_start).
      "<br/>" . "<b>Memory usage:</b> ". number_format((memory_get_usage() - $base_memory_usage) /1024/1024, 2, '.', '') . "Mb");
      $this->saveSettings($this->request->post['seogen']);
      $this->cache->delete("seo_pro");
    }
  }

Can you please tell me the best way to do this?
After all, it's not enough to simply execute the function with the "products" argument, you also need data from the fields.
There are many different ideas, one of the last ones is super crutch and not fully understood, but the essence is this: when you enter the page, at the top there is a button "Stop auto-generation + timer-report 30 seconds and it starts to decrease", if the person does not click on the h. 30 seconds, then through js auto-pressing the "generate" button occurs, but if the machine starts, then 30 seconds and the generation occurs, but I have no idea how to implement this in php or through cron, give advice to the young, inexperienced, I will glad for any idea or solution, thanks !

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Muhammad, 2016-08-18
@andrew_goldsmith

cron. Help:
crontab-generator.org
www.cronmaker.com

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question