@@ -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'); | |||
} | |||
} |
@@ -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'; | |||
} | |||
} | |||
} |
@@ -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'); |
@@ -21,7 +21,7 @@ class UserMerchantEmailFilter extends AssociationFilter | |||
array( | |||
'required' => false, | |||
'attr' => array( | |||
'class' => ' input-sm', | |||
'class' => ' input-sm autocomplete-disabled', | |||
'form' => 'filters-form', | |||
), | |||
) |
@@ -21,7 +21,7 @@ class UserMerchantFirstnameFilter extends AssociationFilter | |||
array( | |||
'required' => false, | |||
'attr' => array( | |||
'class' => ' input-sm', | |||
'class' => ' input-sm autocomplete-disabled', | |||
'form' => 'filters-form', | |||
), | |||
) |
@@ -24,7 +24,7 @@ class UserMerchantLastnameFilter | |||
array( | |||
'required' => false, | |||
'attr' => array( | |||
'class' => ' input-sm', | |||
'class' => ' input-sm autocomplete-disabled', | |||
'form' => 'filters-form', | |||
), | |||
) |
@@ -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; |
@@ -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 |
@@ -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(); | |||
} | |||
} |
@@ -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'); | |||
} | |||
} |
@@ -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; |
@@ -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, |
@@ -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); | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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) { |