Browse Source

Merge branch 'develop'

master
Fab 2 years ago
parent
commit
7def40a194
15 changed files with 80 additions and 19 deletions
  1. +8
    -7
      Controller/Merchant/SwitchMerchantController.php
  2. +7
    -2
      Controller/Order/CartController.php
  3. +5
    -2
      Controller/Product/FavoriteController.php
  4. +1
    -1
      Field/Filter/User/UserMerchantEmailFilter.php
  5. +1
    -1
      Field/Filter/User/UserMerchantFirstnameFilter.php
  6. +1
    -1
      Field/Filter/User/UserMerchantLastnameFilter.php
  7. +1
    -1
      Model/Product/ProductCategoryModel.php
  8. +11
    -0
      Repository/Order/OrderShopRepositoryQuery.php
  9. +11
    -0
      Repository/Order/OrderShopStore.php
  10. +1
    -1
      Repository/Product/ProductCategoryRepositoryQuery.php
  11. +1
    -0
      Repository/Product/ProductCategoryStore.php
  12. +0
    -3
      Repository/Product/ProductFamilyStore.php
  13. +14
    -0
      Repository/User/VisitorRepositoryQuery.php
  14. +8
    -0
      Repository/User/VisitorStore.php
  15. +10
    -0
      Solver/Product/ProductFamilySolver.php

+ 8
- 7
Controller/Merchant/SwitchMerchantController.php View File

@@ -37,19 +37,20 @@ class SwitchMerchantController extends AbstractController
if ($context == 'admin') {
$url .= 'admin';
}
}

if(!$url) {
$url = $request->headers->get('referer');
}

if($url) {
return $this->redirect($url);
}
}

if ($url) {
return $this->redirect($url);
} else {
$this->addFlashTranslator('error', ActionDefinition::SWITCH_MERCHANT, 'Merchant');
return $this->redirect($request->headers->get('referer'));
}


$this->addFlashTranslator('error', ActionDefinition::SWITCH_MERCHANT, 'Merchant');
return $this->redirectToRoute('frontend_home');
}

}

+ 7
- 2
Controller/Order/CartController.php View File

@@ -21,7 +21,6 @@ class CartController extends AbstractController
protected int $quantityOrder = 1;
protected array $orderProducts = [];

//TODO Refactorer cette méthode ligne 48 return false !!! Pas possible, de plus elle retourne un json vide ...
public function addProductFamily(Request $request): JsonResponse
{
$user = $this->getUserCurrent();
@@ -34,6 +33,10 @@ class CartController extends AbstractController
$idProductFamily = $data['order_products']['id_product_family'];
$this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);

if(!$this->productFamily) {
$return['return'] = 'error';
}

// alerte si cookies non acceptés
if (!$user && !$visitor) {
$this->addFlash(
@@ -45,7 +48,7 @@ class CartController extends AbstractController
'fos_user_security_login'
) . '">connecter</a> pour ajouter un produit.'
);
return false;
$return['return'] = 'error';
}

if ($this->productFamily) {
@@ -69,6 +72,8 @@ class CartController extends AbstractController
$this->addOrderProduct($orderShop, $orderProduct);
}
}

$return['return'] = 'success';
}
}
}

+ 5
- 2
Controller/Product/FavoriteController.php View File

@@ -90,9 +90,12 @@ class FavoriteController extends AbstractController
private function _getProductFamily($request)
{
$idProductFamily = $request->request->get('idProductFamily');
$productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);

if ($productFamily) {
if($idProductFamily) {
$productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);
}

if (isset($productFamily) && $productFamily) {
return $productFamily;
} else {
throw new \ErrorException('Ce produit est introuvable');

+ 1
- 1
Field/Filter/User/UserMerchantEmailFilter.php View File

@@ -21,7 +21,7 @@ class UserMerchantEmailFilter extends AssociationFilter
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'class' => ' input-sm autocomplete-disabled',
'form' => 'filters-form',
),
)

+ 1
- 1
Field/Filter/User/UserMerchantFirstnameFilter.php View File

@@ -21,7 +21,7 @@ class UserMerchantFirstnameFilter extends AssociationFilter
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'class' => ' input-sm autocomplete-disabled',
'form' => 'filters-form',
),
)

+ 1
- 1
Field/Filter/User/UserMerchantLastnameFilter.php View File

@@ -24,7 +24,7 @@ class UserMerchantLastnameFilter
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'class' => ' input-sm autocomplete-disabled',
'form' => 'filters-form',
),
)

+ 1
- 1
Model/Product/ProductCategoryModel.php View File

@@ -29,7 +29,7 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn
protected $parent;

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="parent" , fetch="EAGER"))
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="parent", fetch="EAGER")
* @ORM\OrderBy({"position" = "ASC"})
*/
protected $childrens;

+ 11
- 0
Repository/Order/OrderShopRepositoryQuery.php View File

@@ -107,6 +107,12 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->setParameter('user', $user);
}

public function filterByUserIsNull(): self
{
return $this
->andWhere('.user IS NULL');
}

public function filterByUserEmail(string $email): self
{
$this->joinUser();
@@ -205,6 +211,11 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
return $this->andWhereEqual('visitor', $visitor);
}

public function filterByVisitorIsNull(): self
{
return $this->andWhere('.visitor IS NULL');
}

public function filterByAddress(AddressInterface $address): self
{
return $this

+ 11
- 0
Repository/Order/OrderShopStore.php View File

@@ -662,4 +662,15 @@ class OrderShopStore extends AbstractStore

return true;
}

public function getCartAlone($query = null){

$query = $this->createQuery($query);

$query->filterByAlias(OrderStatusModel::$statusAliasAsCart);
$query->filterByUserIsNull();
$query->filterByVisitorIsNull();

return $query->limit(50000)->find();
}
}

+ 1
- 1
Repository/Product/ProductCategoryRepositoryQuery.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Product;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
@@ -36,5 +37,4 @@ class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery

return $this->andWhere('productFamilies.status = 1');
}

}

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

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Repository\AbstractStore;

+ 0
- 3
Repository/Product/ProductFamilyStore.php View File

@@ -120,11 +120,9 @@ class ProductFamilyStore extends AbstractStore
public function getOrganic($user = null, $organizeByParentCategory = true, $query = null)
{
$query = $this->createDefaultQuery($query);

$query
->filterIsOrganicLabel()
->filterIsOnline();

$results = $query->find();

return $this->getWithReductions($results, $user, false, $organizeByParentCategory);
@@ -151,7 +149,6 @@ class ProductFamilyStore extends AbstractStore
return [];
}


// findByTerms
public function getByTerms(
$terms,

+ 14
- 0
Repository/User/VisitorRepositoryQuery.php View File

@@ -18,4 +18,18 @@ class VisitorRepositoryQuery extends AbstractRepositoryQuery
->andWhere('.cookie LIKE :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);
}
}

+ 8
- 0
Repository/User/VisitorStore.php View File

@@ -36,4 +36,12 @@ class VisitorStore extends AbstractStore
$query->filterByCookie($cookie);
return $query->findOne();
}

public function getOldVisitors(\DateTime $lastAccess, $query = null){

$query = $this->createDefaultQuery($query);
$query->filterByLastAccess($lastAccess);
$query->filterByTotalVisit(1);
return $query->limit(50000)->find();
}
}

+ 10
- 0
Solver/Product/ProductFamilySolver.php View File

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Solver\Product;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
@@ -467,6 +468,15 @@ class ProductFamilySolver
return null;
}

public function getMerchant(ProductFamilyInterface $productFamily): ?MerchantInterface
{
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {
return $productFamilySectionProperty->getSection()->getMerchant();
}

return null;
}

public function isInSection(ProductFamilyInterface $productFamily, SectionInterface $section): bool
{
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {

Loading…
Cancel
Save