Skip to content

Commit

Permalink
update recommendation content file path constant name and fixed key n…
Browse files Browse the repository at this point in the history
…ot exist issue
  • Loading branch information
shreesh-webkul committed Mar 21, 2024
1 parent e6964d7 commit 7431fe5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions classes/controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class AdminControllerCore extends Controller
const LEVEL_VIEW = 1;

/** @var string path for recomendation content */
const RECOMMENDATION_CONTENT = '';
const RECOMMENDATION_CONTENT_FILE_PATH = '';

public function __construct()
{
Expand Down Expand Up @@ -3967,9 +3967,9 @@ public function getRecommendationContent()
if ($recommendationContent = $this->updateRecommendationContent()) {
$content['cache'] = false;
}
if (!isset($this->context->cookie->{$this->controller_name.'_closed'}) || !$this->context->cookie->{$this->controller_name.'_closed'}) {
if (file_exists(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath())) {
$content['success'] = true;
if (file_exists(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath())) {
$content['success'] = true;
if (!isset($this->context->cookie->{$this->controller_name.'_closed'}) || !$this->context->cookie->{$this->controller_name.'_closed'}) {
$content['html'] = file_get_contents(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath());
}
}
Expand All @@ -3985,10 +3985,11 @@ public function updateRecommendationContent()
array('controller' => $this->context->controller->controller_name)
)) {
$recommendationContent = json_decode($recommendationContent, true);
if (isset($this->context->cookie->{$this->context->controller->controller_name.'_key'})) {
if ($this->context->cookie->{$this->context->controller->controller_name.'_key'} != $recommendationContent['key']) {
unset($this->context->cookie->{$this->context->controller->controller_name.'_closed'});
}
if (!isset($this->context->cookie->{$this->context->controller->controller_name.'_key'})) {
$this->context->cookie->{$this->context->controller->controller_name.'_key'} = '';
}
if ($this->context->cookie->{$this->context->controller->controller_name.'_key'} != $recommendationContent['key']) {
unset($this->context->cookie->{$this->context->controller->controller_name.'_closed'});
}
$this->context->cookie->{$this->context->controller->controller_name.'_key'} = $recommendationContent['key'];
if (isset($recommendationContent['success']) && $recommendationContent['success']) {
Expand Down Expand Up @@ -4018,7 +4019,7 @@ public function ajaxProcessRecommendationClosed()

public function getRecommendationFilePath()
{
return static::RECOMMENDATION_CONTENT;
return static::RECOMMENDATION_CONTENT_FILE_PATH;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class AdminDashboardControllerCore extends AdminController
{

const RECOMMENDATION_CONTENT = '/cache/dashboard_recommendation.html';
const RECOMMENDATION_CONTENT_FILE_PATH = '/cache/dashboard_recommendation.html';

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminModulesCatalogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AdminModulesCatalogControllerCore extends AdminController

public $modules;

const RECOMMENDATION_CONTENT = '/cache/catalog_recommendation.html';
const RECOMMENDATION_CONTENT_FILE_PATH = '/cache/catalog_recommendation.html';

const ELEMENT_TYPE_MODULE = 1;
const ELEMENT_TYPE_THEME = 2;
Expand Down

0 comments on commit 7431fe5

Please sign in to comment.