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

if ($context == 'admin') { if ($context == 'admin') {
$url .= '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

protected int $quantityOrder = 1; protected int $quantityOrder = 1;
protected array $orderProducts = []; 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 public function addProductFamily(Request $request): JsonResponse
{ {
$user = $this->getUserCurrent(); $user = $this->getUserCurrent();
$idProductFamily = $data['order_products']['id_product_family']; $idProductFamily = $data['order_products']['id_product_family'];
$this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily); $this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);


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

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


if ($this->productFamily) { if ($this->productFamily) {
$this->addOrderProduct($orderShop, $orderProduct); $this->addOrderProduct($orderShop, $orderProduct);
} }
} }

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

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

private function _getProductFamily($request) private function _getProductFamily($request)
{ {
$idProductFamily = $request->request->get('idProductFamily'); $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; return $productFamily;
} else { } else {
throw new \ErrorException('Ce produit est introuvable'); throw new \ErrorException('Ce produit est introuvable');

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

array( array(
'required' => false, 'required' => false,
'attr' => array( 'attr' => array(
'class' => ' input-sm',
'class' => ' input-sm autocomplete-disabled',
'form' => 'filters-form', 'form' => 'filters-form',
), ),
) )

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

array( array(
'required' => false, 'required' => false,
'attr' => array( 'attr' => array(
'class' => ' input-sm',
'class' => ' input-sm autocomplete-disabled',
'form' => 'filters-form', 'form' => 'filters-form',
), ),
) )

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

array( array(
'required' => false, 'required' => false,
'attr' => array( 'attr' => array(
'class' => ' input-sm',
'class' => ' input-sm autocomplete-disabled',
'form' => 'filters-form', 'form' => 'filters-form',
), ),
) )

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

protected $parent; 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"}) * @ORM\OrderBy({"position" = "ASC"})
*/ */
protected $childrens; protected $childrens;

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

->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

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



return true; 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

namespace Lc\CaracoleBundle\Repository\Product; namespace Lc\CaracoleBundle\Repository\Product;


use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Doctrine\EntityInterface; use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery; use Lc\SovBundle\Repository\AbstractRepositoryQuery;


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

} }

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

namespace Lc\CaracoleBundle\Repository\Product; namespace Lc\CaracoleBundle\Repository\Product;


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

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

public function getOrganic($user = null, $organizeByParentCategory = true, $query = null) public function getOrganic($user = null, $organizeByParentCategory = true, $query = null)
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);

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

$results = $query->find(); $results = $query->find();


return $this->getWithReductions($results, $user, false, $organizeByParentCategory); return $this->getWithReductions($results, $user, false, $organizeByParentCategory);
return []; return [];
} }



// findByTerms // findByTerms
public function getByTerms( public function getByTerms(
$terms, $terms,

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

->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);
}
} }

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

$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->limit(50000)->find();
}
} }

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

use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface; use Lc\CaracoleBundle\Model\Product\ProductInterface;
return null; 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 public function isInSection(ProductFamilyInterface $productFamily, SectionInterface $section): bool
{ {
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) { foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {

Loading…
Cancel
Save