Skip to content

Commit

Permalink
Merge branch '2.8.x' into 1419-fix-error-in-optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
androshchuk authored Jun 21, 2019
2 parents 5a6bb66 + e82e5fa commit 311ce3e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ define([
*/
addItemId: function (item) {
item.id = _.uniqueId(this.index + "_option_");
item.displayProductCount = this.displayProductCount && (item.count >= 1)
item.displayProductCount = this.displayProductCount && (item.count >= 1);

return item;
},
});
Expand Down
46 changes: 45 additions & 1 deletion src/module-elasticsuite-tracker/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,29 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
*/
private $sessionManager;

/**
* @var \Magento\Framework\Stdlib\CookieManagerInterface
*/
private $cookieManager;

/**
* PHP Constructor
*
* @param \Magento\Framework\App\Helper\Context $context The current context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager The Store Manager
* @param \Magento\Framework\Session\SessionManagerInterface $sessionManager Session Manager
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager Cookie manager
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Session\SessionManagerInterface $sessionManager
\Magento\Framework\Session\SessionManagerInterface $sessionManager,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
) {
$this->urlBuilder = $context->getUrlBuilder();
$this->storeManager = $storeManager;
$this->sessionManager = $sessionManager;
$this->cookieManager = $cookieManager;
parent::__construct($context);
}

Expand Down Expand Up @@ -168,4 +176,40 @@ public function getRetentionDelay()
{
return (int) $this->scopeConfig->getValue(self::CONFIG_RETENTION_DELAY_XPATH);
}

/**
* Return the current tracker visitor id
*
* @return null|string
*/
public function getCurrentVisitorId()
{
$visitorId = null;

$cookieConfig = $this->getCookieConfig();
if (array_key_exists('visitor_cookie_name', $cookieConfig)) {
$visitorCookieName = $cookieConfig['visitor_cookie_name'];
$visitorId = $this->cookieManager->getCookie($visitorCookieName);
}

return $visitorId;
}

/**
* Return the current tracker session id
*
* @return null|string
*/
public function getCurrentSessionId()
{
$visitorId = null;

$cookieConfig = $this->getCookieConfig();
if (array_key_exists('visit_cookie_name', $cookieConfig)) {
$sessionCookieName = $cookieConfig['visit_cookie_name'];
$visitorId = $this->cookieManager->getCookie($sessionCookieName);
}

return $visitorId;
}
}

0 comments on commit 311ce3e

Please sign in to comment.