/** * * @param $saleCookie * @return Pap_Tracking_Cookie_Sale */ protected function getSaleCookie(Pap_Tracking_Cookie_Sale $saleCookie = null) { if ($saleCookie === null) { return null; } $this->logMessage('Sale cookie not null, affiliateid=' . $saleCookie->getAffiliateId() . ', campaignid=' . $saleCookie->getCampaignId()); if ($this->isClickDataValid($saleCookie->getAffiliateId(), $saleCookie->getCampaignId())) { $this->logMessage('Sale cookie valid, user and campaign exists.'); return $saleCookie; } $this->logMessage('Sale cookie not valid, user or campaign probably does not exists.'); return null; }
protected function setVisitorAndAccount(Pap_Tracking_ActionTracker $saleTracker, $affiliateID, $campaignID, $cookie) { if($affiliateID != '' && $campaignID != '') { try { $saleTracker->setAccountId($this->getAccountIdFromCampaign($campaignID)); } catch (Gpf_Exception $e) { throw new Gpf_Exception('Can not get accountId from campaign, error message:' . $e->getMessage()); } } else { if ($this->isOldCookies($cookie)) { $saleTracker->setCookieValue($cookie); $newVisitorId = $this->generateNewVisitorId(); try { $cookieObj = new Pap_Tracking_Cookie_Sale(); $cookieObj->decode($cookie); $this->fillAccountIdAndVisitorId($saleTracker, $this->getAccountIdFromCampaign($cookieObj->getCampaignId()), $newVisitorId); } catch (Gpf_Exception $e) { $this->debug('Can not get accountId from campaign in old cookie format, error message:' . $e->getMessage() . '. Setting default one.'); $this->fillAccountIdAndVisitorId($saleTracker, Gpf_Db_Account::DEFAULT_ACCOUNT_ID, $newVisitorId); } } else { $this->processAccountIdAndVisitorId($saleTracker, $cookie); } } $this->debug("End registering sale"); }