Skip to content

Commit

Permalink
feat: improved the code + small bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmolinacano committed Sep 4, 2023
1 parent 867a73e commit aa2dcdc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions controllers/front/landing.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public function init()
Tools::redirect('index.php?controller=404');
}

foreach ($this->landing_data['blocks'] as $block) {
foreach ($this->landing_data['blocks'] as &$block) {
if ($products_result = $this->module->searchOnApi($block['query'], 1, self::RESULTS)) {
$this->products[] = $products_result['result'];
$block['products'] = $products_result['result'];
} else {
$this->products[] = [];
$block['products'] = [];
}
}
}
Expand Down Expand Up @@ -87,18 +87,16 @@ private function renderProductList()
$this->context->getTranslator()
);

$blocks_count = 0;
foreach ($this->products as $product) {
foreach ($this->landing_data['blocks'] as &$block) {
$products = [];
foreach ($product as $productDetail) {
foreach ($block['products'] as $productDetail) {
$products[] = $presenter->present(
$presentationSettings,
$assembler->assembleProduct($productDetail),
$this->context->language
);
}
$this->landing_data['blocks'][$blocks_count]['products'] = $products;
++$blocks_count;
$block['products'] = $products;
}

$this->context->smarty->assign(
Expand Down Expand Up @@ -188,7 +186,7 @@ private function getLandingData($name, $id_shop, $id_lang, $id_currency)

$this->setLandingCache($name, $hashid, base64_encode(json_encode($data)));

return $response;
return $data;
}
}

Expand Down
4 changes: 2 additions & 2 deletions doofinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class Doofinder extends Module
const DOOMANAGER_URL = 'https://admin.doofinder.com';
const GS_SHORT_DESCRIPTION = 1;
const GS_LONG_DESCRIPTION = 2;
const VERSION = '4.7.1';
const VERSION = '4.7.2';
const YES = 1;
const NO = 0;

public function __construct()
{
$this->name = 'doofinder';
$this->tab = 'search_filter';
$this->version = '4.7.1';
$this->version = '4.7.2';
$this->author = 'Doofinder (http://www.doofinder.com)';
$this->ps_versions_compliancy = ['min' => '1.5', 'max' => _PS_VERSION_];
$this->module_key = 'd1504fe6432199c7f56829be4bd16347';
Expand Down
2 changes: 1 addition & 1 deletion upgrade/upgrade-4.7.1.php → upgrade/upgrade-4.7.2.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
exit;
}

function upgrade_module_4_7_1($module)
function upgrade_module_4_7_2($module)
{
return Db::getInstance()->delete('doofinder_landing');
}

0 comments on commit aa2dcdc

Please sign in to comment.