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'); | |||||
} | } | ||||
} | } |
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'; | |||||
} | } | ||||
} | } | ||||
} | } |
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'); |
array( | array( | ||||
'required' => false, | 'required' => false, | ||||
'attr' => array( | 'attr' => array( | ||||
'class' => ' input-sm', | |||||
'class' => ' input-sm autocomplete-disabled', | |||||
'form' => 'filters-form', | 'form' => 'filters-form', | ||||
), | ), | ||||
) | ) |
array( | array( | ||||
'required' => false, | 'required' => false, | ||||
'attr' => array( | 'attr' => array( | ||||
'class' => ' input-sm', | |||||
'class' => ' input-sm autocomplete-disabled', | |||||
'form' => 'filters-form', | 'form' => 'filters-form', | ||||
), | ), | ||||
) | ) |
array( | array( | ||||
'required' => false, | 'required' => false, | ||||
'attr' => array( | 'attr' => array( | ||||
'class' => ' input-sm', | |||||
'class' => ' input-sm autocomplete-disabled', | |||||
'form' => 'filters-form', | 'form' => 'filters-form', | ||||
), | ), | ||||
) | ) |
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; |
->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(); | |||||
return $query->limit(50000)->find(); | |||||
} | |||||
} | } |
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'); | ||||
} | } | ||||
} | } |
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; |
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, |
->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->limit(50000)->find(); | |||||
} | |||||
} | } |
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) { |