} | } | ||||
if (!$cart) { | if (!$cart) { | ||||
dump('niche'); | |||||
$cart = $this->create($section, $user, $visitor); | $cart = $this->create($section, $user, $visitor); | ||||
} | } | ||||
// setCookieVisitor | // setCookieVisitor | ||||
public function setCookie($response, $cookie): void | public function setCookie($response, $cookie): void | ||||
{ | { | ||||
dump('NICICIIC'); | |||||
$response->headers->setCookie( | $response->headers->setCookie( | ||||
Cookie::create( | Cookie::create( | ||||
$this->parameterBag->get('app.cookie_name_visitor'), | $this->parameterBag->get('app.cookie_name_visitor'), |
->setParameter('user', $user); | ->setParameter('user', $user); | ||||
} | } | ||||
public function filterByUserIsNull(): self | |||||
{ | |||||
return $this | |||||
->andWhere('.user IS NULL'); | |||||
} | |||||
public function filterByUserEmail(string $email): self | public function filterByUserEmail(string $email): self | ||||
{ | { | ||||
$this->joinUser(); | $this->joinUser(); | ||||
return $this->andWhereEqual('visitor', $visitor); | return $this->andWhereEqual('visitor', $visitor); | ||||
} | } | ||||
public function filterByVisitorIsNull(): self | |||||
{ | |||||
return $this->andWhere('.visitor IS NULL'); | |||||
} | |||||
public function filterByAddress(AddressInterface $address): self | public function filterByAddress(AddressInterface $address): self | ||||
{ | { | ||||
return $this | return $this |
return true; | return true; | ||||
} | } | ||||
public function getCartAlone($query = null){ | |||||
$query = $this->createQuery($query); | |||||
$query->filterByAlias(OrderStatusModel::$statusAliasAsCart); | |||||
$query->filterByUserIsNull(); | |||||
$query->filterByVisitorIsNull(); | |||||
dump($query->getQueryBuilder()->getDQL()); | |||||
return $query->limit(100000)->find(); | |||||
} | |||||
} | } |
->andWhere('.cookie LIKE :cookie') | ->andWhere('.cookie LIKE :cookie') | ||||
->setParameter('cookie', $cookie); | ->setParameter('cookie', $cookie); | ||||
} | } | ||||
public function filterByLastAccess(\DateTime $lastAccess) | |||||
{ | |||||
return $this | |||||
->andWhere('.lastAccess < :lastAccess') | |||||
->setParameter('lastAccess', $lastAccess); | |||||
} | |||||
public function filterByTotalVisit(int $totalVisit) | |||||
{ | |||||
return $this | |||||
->andWhere('.totalVisit = :totalVisit') | |||||
->setParameter('totalVisit', $totalVisit); | |||||
} | |||||
} | } |
$query->filterByCookie($cookie); | $query->filterByCookie($cookie); | ||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
public function getOldVisitors(\DateTime $lastAccess, $query = null){ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->filterByLastAccess($lastAccess); | |||||
// $query->filterByTotalVisit(1); | |||||
return $query->find(); | |||||
} | |||||
} | } |