Commit df2bd6ad authored by tchauviere's avatar tchauviere

[*] BO : PrestaShop RSS analytics update

parent b9437bf7
......@@ -353,12 +353,40 @@ class AdminDashboardControllerCore extends AdminController
foreach ($rss->channel->item as $item)
{
if ($articles_limit > 0 && Validate::isCleanHtml((string)$item->title) && Validate::isCleanHtml((string)$item->description))
{
if (in_array($this->context->mode, array(Context::MODE_HOST, Context::MODE_HOST_CONTRIB)))
$utm_content = 'cloud';
else
$utm_content = 'download';
$shop_default_country_id = (int)Configuration::get('PS_COUNTRY_DEFAULT');
$shop_default_iso_country = (string)Tools::strtoupper(Country::getIsoById($shop_default_country_id));
$analytics_params = array('utm_source' => 'back-office',
'utm_medium' => 'rss',
'utm_campaign' => 'back-office-'.$shop_default_iso_country,
'utm_content' => $utm_content
);
$url_query = parse_url($item->link, PHP_URL_QUERY);
parse_str($url_query, $link_query_params);
if ($link_query_params)
{
$full_url_params = array_merge($link_query_params, $analytics_params);
$base_url = explode('?', (string)$item->link);
$base_url = (string)$base_url[0];
$article_link = $base_url.'?'.http_build_query($full_url_params);
}
else
$article_link = (string)$item->link.'?'.http_build_query($analytics_params);
$return['rss'][] = array(
'date' => Tools::displayDate(date('Y-m-d', strtotime((string)$item->pubDate))),
'title' => (string)Tools::htmlentitiesUTF8($item->title),
'short_desc' => Tools::truncateString(strip_tags((string)$item->description), 150),
'link' => (string)$item->link,
'link' => (string)$article_link,
);
}
else
break;
$articles_limit --;
......
......@@ -197,7 +197,7 @@ function getBlogRss() {
success : function(jsonData) {
if (typeof jsonData !== 'undefined' && jsonData !== null && !jsonData.has_errors) {
for (var article in jsonData.rss) {
var article_html = '<article><h4><a href="'+jsonData.rss[article].link+'" class="_blank">'+jsonData.rss[article].title+'</a></h4><span class="dash-news-date text-muted">'+jsonData.rss[article].date+'</span><p>'+jsonData.rss[article].short_desc+' <a href="'+jsonData.rss[article].link+'">'+read_more+'</a><p></article><hr/>';
var article_html = '<article><h4><a href="'+jsonData.rss[article].link+'" target="_blank" class="_blank">'+jsonData.rss[article].title+'</a></h4><span class="dash-news-date text-muted">'+jsonData.rss[article].date+'</span><p>'+jsonData.rss[article].short_desc+' <a href="'+jsonData.rss[article].link+'">'+read_more+'</a><p></article><hr/>';
$('.dash_news .dash_news_content').append(article_html);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment