Add Italian and German translations for OmniPrice module and implement cron job functionality
- Added Italian translations for the OmniPrice module, covering various settings and messages. - Implemented a new cron.php controller for handling price indexing and cleanup actions. - Created an index.php controller to redirect access attempts to the module's front controller. - Added German translations for the OmniPrice module, ensuring compliance with the Omnibus directive.
This commit is contained in:
126
modules/gm_omniprice/controllers/front/cron.php
Normal file
126
modules/gm_omniprice/controllers/front/cron.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
class Gm_OmniPriceCronModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
$this->displayTemplate();
|
||||
$token = Tools::getValue('token');
|
||||
$omni = $this->module;
|
||||
$comparedToken = $omni->getTokenForScripts();
|
||||
if ($token != $comparedToken) {
|
||||
die('invalid token');
|
||||
}
|
||||
$action = Tools::getValue('action');
|
||||
$verbose = !Tools::isSubmit('silent');
|
||||
switch ($action) {
|
||||
case 'index' :
|
||||
$start = microtime(true);
|
||||
echo 'PS '._PS_VERSION_.'<br/>';
|
||||
echo 'OmniPrice '.$omni->version.'<br/>';
|
||||
if (Tools::isSubmit('reset')) {
|
||||
$omni->resetIndex();
|
||||
echo 'RESET</br>';
|
||||
}
|
||||
$productId = null;
|
||||
if (Tools::isSubmit('pid')) {
|
||||
$productId = (int) Tools::getValue('pid');
|
||||
$omni->removeProductFromTodaysIndex($productId);
|
||||
$omni->removeProductFromTodaysHistory($productId);
|
||||
}
|
||||
$omni->savePrices(true, $productId);
|
||||
echo 'FINISH<br/>';
|
||||
if (Tools::isSubmit('debug')) {
|
||||
echo 'DEBUG:<br/>';
|
||||
$debug = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'gm_omniprice_history` WHERE `id_product` = '.$productId);
|
||||
if ($debug) {
|
||||
echo $omni->displayTable($debug, array_keys($debug[0]));
|
||||
}
|
||||
$debug = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'gm_omniprice_cache` WHERE `id_product` = '.$productId);
|
||||
if ($debug) {
|
||||
echo $omni->displayTable($debug, array_keys($debug[0]));
|
||||
}
|
||||
}
|
||||
$timeElapsedSeconds = microtime(true) - $start;
|
||||
echo round($timeElapsedSeconds, 4).' s<br/>';
|
||||
break;
|
||||
case 'cleanup' :
|
||||
$omni->cleanUp($verbose);
|
||||
echo 'FINISH<br/>';
|
||||
break;
|
||||
case 'fill' :
|
||||
$omni->fillMissingCache($verbose);
|
||||
echo 'FINISH<br/>';
|
||||
break;
|
||||
default:
|
||||
echo $omni->l('Unknown action').'<br/>';
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
protected function displayTemplate()
|
||||
{
|
||||
echo '<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
.alert {
|
||||
position: relative;
|
||||
padding: 0.75rem 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
.alert-success {
|
||||
color: #155724;
|
||||
background-color: #d4edda;
|
||||
border-color: #c3e6cb;
|
||||
}
|
||||
table {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.75rem;
|
||||
border: none!important;
|
||||
background: none;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
table td, table th {
|
||||
padding: 0.375rem 0.75rem;
|
||||
vertical-align: middle;
|
||||
border: none;
|
||||
}
|
||||
table th {
|
||||
vertical-align: middle;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
table tr:nth-of-type(odd) {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
table tr:hover {
|
||||
color: #212529;
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.alert {
|
||||
position: relative;
|
||||
padding: 0.75rem 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
.alert-success {
|
||||
color: #155724;
|
||||
background-color: #d4edda;
|
||||
border-color: #c3e6cb;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="main">';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user