Bläddra i källkod

Correctifs

packProduct
Guillaume 3 år sedan
förälder
incheckning
4cab890b0e
5 ändrade filer med 74 tillägg och 26 borttagningar
  1. +15
    -15
      Controller/Merchant/FavoriteMerchantController.php
  2. +15
    -0
      Definition/Field/Product/ProductCategoryFieldDefinition.php
  3. +7
    -1
      Model/Section/SectionModel.php
  4. +15
    -10
      Repository/Product/ProductFamilyRepositoryQuery.php
  5. +22
    -0
      Solver/Product/ProductFamilySolver.php

+ 15
- 15
Controller/Merchant/FavoriteMerchantController.php Visa fil

@@ -18,29 +18,29 @@ class FavoriteMerchantController extends AbstractController
*/
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);
$entityManager->update($user);
$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);
}
}
}

+ 15
- 0
Definition/Field/Product/ProductCategoryFieldDefinition.php Visa fil

@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\ImageManagerField;
use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Translation\TranslatorAdmin;

@@ -52,6 +53,19 @@ class ProductCategoryFieldDefinition extends AbstractFieldDefinition
];
}

public function configurePanelMain(): array
{
return [
'section',
'parent',
'title',
'description',
'image',
'saleStatus',
'isEligibleTicketRestaurant',
];
}

public function configureFields(): array
{
$productCategoryArray = $this->productCategoryStore
@@ -63,6 +77,7 @@ class ProductCategoryFieldDefinition extends AbstractFieldDefinition
'position' => NumberField::new('position')->setSortable(true),
'parent' => AssociationField::new('parent')
->setFormTypeOption('choices', $productCategoryArray),
'image' => ImageManagerField::new('image'),
'description' => CKEditorField::new('description'),
'saleStatus' => ToggleField::new('saleStatus')->setSortable(true),
'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),

+ 7
- 1
Model/Section/SectionModel.php Visa fil

@@ -5,11 +5,11 @@ namespace Lc\CaracoleBundle\Model\Section;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface;
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
@@ -24,6 +24,12 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant
{
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\JoinColumn(nullable=false)

+ 15
- 10
Repository/Product/ProductFamilyRepositoryQuery.php Visa fil

@@ -2,9 +2,12 @@

namespace Lc\CaracoleBundle\Repository\Product;

use Doctrine\ORM\Query\Expr;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
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\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
@@ -93,24 +96,24 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
public function filterLikeBehaviorStockCycle(string $behaviorStockCycle): self
{
return $this
->andWhere('.behaviorStockCycle LIKE :behaviorStockCycle')
->setParameter('behaviorStockCycle', $behaviorStockCycle);
->andWhere('.behaviorStockCycle LIKE :behaviorStockCycle')
->setParameter('behaviorStockCycle', $behaviorStockCycle);
}

public function filterByProductCategory(ProductCategoryInterface $category): self
{
$this->joinProductCategories();
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();
return $this
->andWhere(':categoryArray MEMBER OF .productCategories')
->setParameter('categoryArray', $categoryArray);
->andWhere(':categoryArray MEMBER OF .productCategories')
->setParameter('categoryArray', $categoryArray);
}


@@ -121,18 +124,20 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
}

return $this->andWhere(':now <= .propertyNoveltyExpirationDate')
->setParameter('now', $dateTime);
->setParameter('now', $dateTime);
}

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()
{
return $this->andWhere(':now <= .propertyNoveltyExpirationDate')
->setParameter('now', new \DateTime());
->setParameter('now', new \DateTime());
}

public function filterByTerms($terms): self

+ 22
- 0
Solver/Product/ProductFamilySolver.php Visa fil

@@ -377,6 +377,28 @@ class ProductFamilySolver
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)
{
return $this->getQualityLabelByArray($productFamily, ProductFamilyModel::$organicLabels);

Laddar…
Avbryt
Spara