*/ | */ | ||||
public function favoriteMerchant(Request $request, Security $security, EntityManagerInterface $entityManager) | public function favoriteMerchant(Request $request, Security $security, EntityManagerInterface $entityManager) | ||||
{ | { | ||||
$user = $security->getUser(); | |||||
$form = $this->createForm(SwitchMerchantFormType::class); | |||||
$form->handleRequest($request); | |||||
if ($user) { | |||||
$form = $this->createForm(SwitchMerchantFormType::class); | |||||
$form->handleRequest($request); | |||||
if ($form->isSubmitted() && $form->isValid()) { | |||||
$merchant = $form->get('merchant')->getData(); | |||||
if ($form->isSubmitted() && $form->isValid()) { | |||||
$merchant = $form->get('merchant')->getData(); | |||||
if ($merchant) { | |||||
if ($merchant) { | |||||
$user = $security->getUser(); | |||||
if($user) { | |||||
$user->setFavoriteMerchant($merchant); | $user->setFavoriteMerchant($merchant); | ||||
$entityManager->update($user); | $entityManager->update($user); | ||||
$entityManager->flush(); | $entityManager->flush(); | ||||
} | |||||
// @TODO : à fignoler, hein gamin ? | |||||
$url = $this->get(MerchantContainer::class)->getSettingSolver()->getSettingValue( | |||||
$merchant, | |||||
MerchantSettingDefinition::SETTING_URL | |||||
) . 'admin'; | |||||
// @TODO : à fignoler, hein gamin ? | |||||
$url = $this->get(MerchantContainer::class)->getSettingSolver()->getSettingValue( | |||||
$merchant, | |||||
MerchantSettingDefinition::SETTING_URL | |||||
) . 'admin'; | |||||
if ($url) { | |||||
return $this->redirect($url); | |||||
} | |||||
if ($url) { | |||||
return $this->redirect($url); | |||||
} | } | ||||
} | } | ||||
} | } |
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore; | use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore; | ||||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | use Lc\CaracoleBundle\Repository\Section\SectionStore; | ||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\ImageManagerField; | |||||
use Lc\SovBundle\Field\ToggleField; | use Lc\SovBundle\Field\ToggleField; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
]; | ]; | ||||
} | } | ||||
public function configurePanelMain(): array | |||||
{ | |||||
return [ | |||||
'section', | |||||
'parent', | |||||
'title', | |||||
'description', | |||||
'image', | |||||
'saleStatus', | |||||
'isEligibleTicketRestaurant', | |||||
]; | |||||
} | |||||
public function configureFields(): array | public function configureFields(): array | ||||
{ | { | ||||
$productCategoryArray = $this->productCategoryStore | $productCategoryArray = $this->productCategoryStore | ||||
'position' => NumberField::new('position')->setSortable(true), | 'position' => NumberField::new('position')->setSortable(true), | ||||
'parent' => AssociationField::new('parent') | 'parent' => AssociationField::new('parent') | ||||
->setFormTypeOption('choices', $productCategoryArray), | ->setFormTypeOption('choices', $productCategoryArray), | ||||
'image' => ImageManagerField::new('image'), | |||||
'description' => CKEditorField::new('description'), | 'description' => CKEditorField::new('description'), | ||||
'saleStatus' => ToggleField::new('saleStatus')->setSortable(true), | 'saleStatus' => ToggleField::new('saleStatus')->setSortable(true), | ||||
'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true), | 'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true), |
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface; | ||||
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface; | use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface; | ||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | ||||
{ | { | ||||
const DEVALIAS_COMMON = 'common'; | const DEVALIAS_COMMON = 'common'; | ||||
/** | |||||
* @ORM\Column(type="string", length=255) | |||||
* @Gedmo\Slug(fields={"title"}, unique=false) | |||||
*/ | |||||
protected $slug; | |||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections") | * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections") | ||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use Doctrine\ORM\Query\Expr; | |||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
use Lc\CaracoleBundle\Model\Product\QualityLabel; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | ||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
public function filterLikeBehaviorStockCycle(string $behaviorStockCycle): self | public function filterLikeBehaviorStockCycle(string $behaviorStockCycle): self | ||||
{ | { | ||||
return $this | return $this | ||||
->andWhere('.behaviorStockCycle LIKE :behaviorStockCycle') | |||||
->setParameter('behaviorStockCycle', $behaviorStockCycle); | |||||
->andWhere('.behaviorStockCycle LIKE :behaviorStockCycle') | |||||
->setParameter('behaviorStockCycle', $behaviorStockCycle); | |||||
} | } | ||||
public function filterByProductCategory(ProductCategoryInterface $category): self | public function filterByProductCategory(ProductCategoryInterface $category): self | ||||
{ | { | ||||
$this->joinProductCategories(); | $this->joinProductCategories(); | ||||
return $this | return $this | ||||
->andWhere(':category MEMBER OF .productCategories') | |||||
->setParameter('category', $category->getId()); | |||||
->andWhere(':category MEMBER OF .productCategories') | |||||
->setParameter('category', $category->getId()); | |||||
} | } | ||||
public function filterByProductCategoryArray(Array $categoryArray): self | |||||
public function filterByProductCategoryArray(array $categoryArray): self | |||||
{ | { | ||||
$this->joinProductCategories(); | $this->joinProductCategories(); | ||||
return $this | return $this | ||||
->andWhere(':categoryArray MEMBER OF .productCategories') | |||||
->setParameter('categoryArray', $categoryArray); | |||||
->andWhere(':categoryArray MEMBER OF .productCategories') | |||||
->setParameter('categoryArray', $categoryArray); | |||||
} | } | ||||
} | } | ||||
return $this->andWhere(':now <= .propertyNoveltyExpirationDate') | return $this->andWhere(':now <= .propertyNoveltyExpirationDate') | ||||
->setParameter('now', $dateTime); | |||||
->setParameter('now', $dateTime); | |||||
} | } | ||||
public function filterIsOrganicLabel(): self | public function filterIsOrganicLabel(): self | ||||
{ | { | ||||
return $this->andWhere('.propertyOrganicLabel IS NOT NULL'); | |||||
return $this->innerJoin('.qualityLabels', 'qualityLabel') | |||||
->andWhere('qualityLabel.devAlias IN (:organicLabels)') | |||||
->setParameter(':organicLabels', ProductFamilyModel::$organicLabels); | |||||
} | } | ||||
public function filterIsNovelty() | public function filterIsNovelty() | ||||
{ | { | ||||
return $this->andWhere(':now <= .propertyNoveltyExpirationDate') | return $this->andWhere(':now <= .propertyNoveltyExpirationDate') | ||||
->setParameter('now', new \DateTime()); | |||||
->setParameter('now', new \DateTime()); | |||||
} | } | ||||
public function filterByTerms($terms): self | public function filterByTerms($terms): self |
return $productFamily->getPrice(); | return $productFamily->getPrice(); | ||||
} | } | ||||
public function getSummaryQualityLabels(ProductFamilyInterface $productFamily): string | |||||
{ | |||||
$strLabels = ''; | |||||
$qualityLabelArray = $productFamily->getQualityLabels()->toArray(); | |||||
foreach($qualityLabelArray as $index => $qualityLabel) { | |||||
$strLabels .= $qualityLabel->getTitle(); | |||||
if ($index !== array_key_last($qualityLabelArray)) { | |||||
$strLabels .= ', '; | |||||
} | |||||
} | |||||
return $strLabels; | |||||
} | |||||
public function hasQualityLabel(ProductFamilyInterface $productFamily): bool | |||||
{ | |||||
$qualityLabels = $productFamily->getQualityLabels(); | |||||
return $qualityLabels && count($qualityLabels) > 0; | |||||
} | |||||
public function getOrganicLabel(ProductFamilyInterface $productFamily) | public function getOrganicLabel(ProductFamilyInterface $productFamily) | ||||
{ | { | ||||
return $this->getQualityLabelByArray($productFamily, ProductFamilyModel::$organicLabels); | return $this->getQualityLabelByArray($productFamily, ProductFamilyModel::$organicLabels); |