Skip to content

Conversation

@CySSoO
Copy link
Contributor

@CySSoO CySSoO commented Oct 18, 2025

Summary

  • refactor the module controller to load, save, and delete product flags through EverBlockFlagDomainService
  • add an array mapper for flag entities to keep existing Smarty templates working
  • expose cache helpers on the flag domain service and remove the legacy EverblockFlagsClass along with its references

Testing

  • not run (not available)

https://chatgpt.com/codex/tasks/task_e_68f3ad26bcc48322a0ffd5d65e826944

@CySSoO CySSoO merged commit f0f1d51 into master Oct 18, 2025
0 of 6 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

everblock/everblock.php

Lines 3715 to 3764 in 49671f5

// Traitement des flags
try {
$flagDomainService = $this->getEverBlockFlagDomainService();
} catch (\RuntimeException $exception) {
$flagDomainService = null;
PrestaShopLogger::addLog($this->name . ' | ' . $exception->getMessage());
}
$flagsNumber = (int) Configuration::get('EVERPS_FLAG_NB');
if ($flagsNumber < 1) {
$flagsNumber = 1;
Configuration::updateValue('EVERPS_FLAG_NB', 1);
}
$flagsRange = range(1, $flagsNumber);
foreach ($flagsRange as $flag) {
$translations = [];
foreach (Language::getLanguages(true) as $language) {
$flagTitle = Tools::getValue((int) $flag . '_everflag_title_' . $language['id_lang']);
if ($flagTitle && !Validate::isCleanHtml($flagTitle)) {
die(json_encode(
[
'return' => false,
'error' => $this->l('Title is not valid'),
]
));
}
$flagContent = Tools::getValue((int) $flag . '_everflag_content_' . $language['id_lang']);
if ($flagContent && !Validate::isCleanHtml($flagContent)) {
die(json_encode(
[
'return' => false,
'error' => $this->l('Content is not valid'),
]
));
}
$translations[$language['id_lang']] = [
'title' => $flagTitle,
'content' => $flagContent,
];
}
if ($flagDomainService instanceof EverBlockFlagDomainService) {
$flagEntity = new EverBlockFlag();
$flagEntity->setProductId((int) $params['object']->id);
$flagEntity->setShopId((int) $context->shop->id);
$flagEntity->setFlagId((int) $flag);
$flagDomainService->save($flagEntity, $translations);
}

P1 Badge Refresh product-flag hook when saving flags

Flag creation/update is now done directly in hookActionObjectProductUpdateAfter() through EverBlockFlagDomainService (around the loop that builds $flagEntity and calls $flagDomainService->save). However the only place where the module clears the NeedProductFlagsHook_… cache and re-registers actionProductFlagsModifier is inside hookActionObjectEverBlockFlags{Update,Delete}After(). Those hooks are emitted only when an EverblockFlagsClass ObjectModel is saved, but that class was removed in this refactor, so the hooks will never fire anymore. As a result, adding or removing flags leaves the cached $needHook value unchanged and the front-end hook may stay unregistered until the configuration page is saved or the cache is cleared manually. Consider calling $this->updateProductFlagsHook() (and dropping the cache) after saving/deleting flags via the domain service to keep the hook state in sync.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants