Merge branch 'ticket-12563-TrustedBadge' into develop
This commit is contained in:
commit
2567489a37
@ -15,11 +15,9 @@ class ReviewIndicatorCollector
|
|||||||
$returnedArray = array();
|
$returnedArray = array();
|
||||||
$tsId = Configuration::get('TRUSTED_SHOP_' . strtoupper(Language::getIsoById((int)$this->id_lang)) . '_ID');
|
$tsId = Configuration::get('TRUSTED_SHOP_' . strtoupper(Language::getIsoById((int)$this->id_lang)) . '_ID');
|
||||||
try{
|
try{
|
||||||
if (FALSE === ($jsonResult = TrustedShopsCache::getReviewIndicatorCache($tsId))) {
|
|
||||||
$jsonResult = $this->getApiResult($tsId);
|
$jsonResult = $this->getApiResult($tsId);
|
||||||
TrustedShopsCache::setReviewIndicatorCache($tsId, $jsonResult);
|
|
||||||
}
|
|
||||||
$jsonObject = json_decode($jsonResult,true);
|
$jsonObject = json_decode($jsonResult,true);
|
||||||
|
TrustedShopsCache::setReviewIndicatorCache($tsId, $jsonResult);
|
||||||
$returnedArray['result'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['overallMark'];
|
$returnedArray['result'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['overallMark'];
|
||||||
$returnedArray['count'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['activeReviewCount'];
|
$returnedArray['count'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['activeReviewCount'];
|
||||||
$returnedArray['shop_name'] = $jsonObject['response']['data']['shop']['name'];
|
$returnedArray['shop_name'] = $jsonObject['response']['data']['shop']['name'];
|
||||||
|
@ -153,6 +153,10 @@ class TrustedShopsBbb extends Module
|
|||||||
}
|
}
|
||||||
public function hookFooter($params){
|
public function hookFooter($params){
|
||||||
global $smarty, $cookie;
|
global $smarty, $cookie;
|
||||||
|
|
||||||
|
$cache_id = (int)$cookie->id_lang.'_trustedshopsbbb';
|
||||||
|
|
||||||
|
if (!$this->isTemplateCached($cache_id)) {
|
||||||
$resultArray = array();
|
$resultArray = array();
|
||||||
if (in_array(strtoupper(Language::getIsoById($cookie->id_lang)), array("FR","ES"), true)) {
|
if (in_array(strtoupper(Language::getIsoById($cookie->id_lang)), array("FR","ES"), true)) {
|
||||||
$reviewIndicatorCollector = new ReviewIndicatorCollector((int)($cookie->id_lang));
|
$reviewIndicatorCollector = new ReviewIndicatorCollector((int)($cookie->id_lang));
|
||||||
@ -170,6 +174,8 @@ class TrustedShopsBbb extends Module
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $this->flushTemplateCache($cache_id);
|
||||||
|
}
|
||||||
public function hookOrderConfirmation($params)
|
public function hookOrderConfirmation($params)
|
||||||
{
|
{
|
||||||
global $smarty, $cookie;
|
global $smarty, $cookie;
|
||||||
@ -181,4 +187,24 @@ class TrustedShopsBbb extends Module
|
|||||||
return false;
|
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