Merge branch 'ticket-12563-TrustedBadge' into develop
This commit is contained in:
commit
2567489a37
@ -15,11 +15,9 @@ class ReviewIndicatorCollector
|
||||
$returnedArray = array();
|
||||
$tsId = Configuration::get('TRUSTED_SHOP_' . strtoupper(Language::getIsoById((int)$this->id_lang)) . '_ID');
|
||||
try{
|
||||
if (FALSE === ($jsonResult = TrustedShopsCache::getReviewIndicatorCache($tsId))) {
|
||||
$jsonResult = $this->getApiResult($tsId);
|
||||
TrustedShopsCache::setReviewIndicatorCache($tsId, $jsonResult);
|
||||
}
|
||||
$jsonResult = $this->getApiResult($tsId);
|
||||
$jsonObject = json_decode($jsonResult,true);
|
||||
TrustedShopsCache::setReviewIndicatorCache($tsId, $jsonResult);
|
||||
$returnedArray['result'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['overallMark'];
|
||||
$returnedArray['count'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['activeReviewCount'];
|
||||
$returnedArray['shop_name'] = $jsonObject['response']['data']['shop']['name'];
|
||||
|
@ -153,22 +153,28 @@ class TrustedShopsBbb extends Module
|
||||
}
|
||||
public function hookFooter($params){
|
||||
global $smarty, $cookie;
|
||||
$resultArray = array();
|
||||
if (in_array(strtoupper(Language::getIsoById($cookie->id_lang)), array("FR","ES"), true)) {
|
||||
$reviewIndicatorCollector = new ReviewIndicatorCollector((int)($cookie->id_lang));
|
||||
$resultArray = $reviewIndicatorCollector->getResults();
|
||||
}
|
||||
if(count($resultArray)> 0 and (int)$resultArray['count'] > 0){
|
||||
$smarty->assign(array(
|
||||
'shopName' => $resultArray['shop_name'],
|
||||
'result' => $resultArray['result'],
|
||||
'max' => self::TS_BEST_RATING,
|
||||
'count' => $resultArray['count'],
|
||||
));
|
||||
return $this->display(__FILE__, 'views/rich_snippets.tpl');
|
||||
}else{
|
||||
return false;
|
||||
|
||||
$cache_id = (int)$cookie->id_lang.'_trustedshopsbbb';
|
||||
|
||||
if (!$this->isTemplateCached($cache_id)) {
|
||||
$resultArray = array();
|
||||
if (in_array(strtoupper(Language::getIsoById($cookie->id_lang)), array("FR","ES"), true)) {
|
||||
$reviewIndicatorCollector = new ReviewIndicatorCollector((int)($cookie->id_lang));
|
||||
$resultArray = $reviewIndicatorCollector->getResults();
|
||||
}
|
||||
if(count($resultArray)> 0 and (int)$resultArray['count'] > 0){
|
||||
$smarty->assign(array(
|
||||
'shopName' => $resultArray['shop_name'],
|
||||
'result' => $resultArray['result'],
|
||||
'max' => self::TS_BEST_RATING,
|
||||
'count' => $resultArray['count'],
|
||||
));
|
||||
return $this->display(__FILE__, 'views/rich_snippets.tpl');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $this->flushTemplateCache($cache_id);
|
||||
}
|
||||
public function hookOrderConfirmation($params)
|
||||
{
|
||||
@ -181,4 +187,24 @@ class TrustedShopsBbb extends Module
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function isTemplateCached(&$cache_id)
|
||||
{
|
||||
global $smarty;
|
||||
|
||||
Tools::enableCache();
|
||||
$smarty->cache_lifetime = 84000;
|
||||
|
||||
return $this->isCached('rich_snippets.tpl', $cache_id);
|
||||
}
|
||||
|
||||
private function flushTemplateCache($cache_id)
|
||||
{
|
||||
global $smarty;
|
||||
|
||||
$display = $this->display(__FILE__, 'views/rich_snippets.tpl', $cache_id);
|
||||
Tools::restoreCacheSettings();
|
||||
$smarty->cache_lifetime = -1;
|
||||
return $display;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user