Browse Source

Merge branch 'develop'

master
Fabien Normand 3 years ago
parent
commit
ef7fbaec9d
3 changed files with 31 additions and 12 deletions
  1. +7
    -0
      Repository/Product/ProductRepositoryQuery.php
  2. +1
    -0
      Repository/Product/ProductStore.php
  3. +23
    -12
      Resolver/MerchantResolver.php

+ 7
- 0
Repository/Product/ProductRepositoryQuery.php View File

} }




public function filterIsNotAvailableQuantitySupplierUnlimited():self
{
$this->andWhere('productFamily.availableQuantitySupplierUnlimited != 1');
return $this;
}


public function filterAvailableQuantityNegative() :self public function filterAvailableQuantityNegative() :self
{ {



+ 1
- 0
Repository/Product/ProductStore.php View File

$query->joinProductFamily(); $query->joinProductFamily();
$query->filterIsOnline(); $query->filterIsOnline();
$query->filterAvailableQuantitySupplierNegative(); $query->filterAvailableQuantitySupplierNegative();
$query->filterIsNotAvailableQuantitySupplierUnlimited();
$query->groupBy('productFamily.id'); $query->groupBy('productFamily.id');
$productListAvailableQuantityNegative = $query->find(); $productListAvailableQuantityNegative = $query->find();



+ 23
- 12
Resolver/MerchantResolver.php View File

$user = $this->security->getUser(); $user = $this->security->getUser();
} }


$merchants = $this->merchantStore->getOnline();

if ($user) { if ($user) {
return $user->getFavoriteMerchant(); return $user->getFavoriteMerchant();
} else {
$merchantCurrentId = $this->requestStack->getCurrentRequest()->cookies->getInt(
$this->parameterBag->get('app.cookie_name_merchant_current')
);
if ($merchantCurrentId) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $merchantCurrentId) {
return $merchant;
}
}
}
else {
$merchantCurrent = $this->getMerchantUserViaCookie();
if($merchantCurrent) {
return $merchantCurrent;
} }
} }


return false; return false;
} }


public function getMerchantUserViaCookie()
{
$merchants = $this->merchantStore->getOnline();
$merchantCurrentId = $this->requestStack->getCurrentRequest()->cookies->getInt(
$this->parameterBag->get('app.cookie_name_merchant_current')
);

if ($merchantCurrentId) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $merchantCurrentId) {
return $merchant;
}
}
}

return null;
}

} }

Loading…
Cancel
Save