Просмотр исходного кода

[Global] Ouverture limité à certain produit

feature/module_traiteur_v1
Fab 3 лет назад
Родитель
Сommit
2b873bba36
7 измененных файлов: 55 добавлений и 4 удалений
  1. +5
    -0
      ShopBundle/EventSubscriber/ListEventSubscriber.php
  2. +17
    -0
      ShopBundle/Model/ProductCategory.php
  3. +17
    -0
      ShopBundle/Model/ProductFamily.php
  4. +4
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +2
    -2
      ShopBundle/Resources/views/backend/default/list.html.twig
  6. +3
    -0
      ShopBundle/Resources/views/backend/productfamily/panel_general.html.twig
  7. +7
    -1
      ShopBundle/Services/Order/OrderUtilsStockTrait.php

+ 5
- 0
ShopBundle/EventSubscriber/ListEventSubscriber.php Просмотреть файл

@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\EventSubscriber;

use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -49,6 +50,10 @@ class ListEventSubscriber implements EventSubscriberInterface

}else {*/

if ($entityObject instanceof ProductFamilyInterface) {
$paginator->nbResultsOnSale = $entityRepo->count(array('saleStatus' =>1, 'status'=> 1, 'merchant'=> $criteria['merchant']));
}

if ($entityObject instanceof StatusInterface) {

for ($status = -1; $status <= 1; $status++) {

+ 17
- 0
ShopBundle/Model/ProductCategory.php Просмотреть файл

@@ -38,6 +38,11 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt
*/
protected $productFamilies;

/**
* @ORM\Column(type="boolean")
*/
protected $saleStatus;

public function __construct()
{
$this->childrens = new ArrayCollection();
@@ -154,4 +159,16 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt

return $this;
}

public function getSaleStatus(): ?bool
{
return $this->saleStatus;
}

public function setSaleStatus(bool $saleStatus): self
{
$this->saleStatus = $saleStatus;

return $this;
}
}

+ 17
- 0
ShopBundle/Model/ProductFamily.php Просмотреть файл

@@ -223,6 +223,11 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
protected $behaviorPrice;


/**
* @ORM\Column(type="boolean")
*/
protected $saleStatus;

public function __construct()
{
$this->productCategories = new ArrayCollection();
@@ -840,4 +845,16 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

return false ;
}

public function getSaleStatus(): ?bool
{
return $this->saleStatus;
}

public function setSaleStatus(bool $saleStatus): self
{
$this->saleStatus = $saleStatus;

return $this;
}
}

+ 4
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml Просмотреть файл

@@ -6,7 +6,9 @@ list:
nbResultsFiltered: Total d'élements filtrés
nbResultsOnline: Total d'élements en ligne
nbResultsOffline: Total d'élements hors ligne
nbResultsDeleted: Total d'élements supprimé
nbResultsDeleted: Total d'élements supprimés
nbResultsOnSale: Total de produits en vente
nbProductFamilyOnline: Total de produits visibles
listChildren: Afficher les enfants
edit: Éditer
delete: Supprimer
@@ -163,6 +165,7 @@ field:
deliveryAvailabilty: Créneau de livraison
id: Id
status: Statut
saleStatus: En vente sur le site
statusOptions:
offline: <span class="badge badge-danger">Hors ligne</span>
online: <span class="badge badge-success">En ligne</span>

+ 2
- 2
ShopBundle/Resources/views/backend/default/list.html.twig Просмотреть файл

@@ -110,11 +110,11 @@
<i class="fa fa-check"></i> </span>{% endif %}
{% if paginator.nbResultsOffline is defined %}<span data-toggle="tooltip"
title="{{ "list.nbResultsOffline"|trans }}"
class="badge badge-warning">{{ paginator.nbResultsOffline }}
class="badge badge-danger">{{ paginator.nbResultsOffline }}
<i class="fa fa-pen"></i></span>{% endif %}
{% if is_granted('ROLE_SUPER_ADMIN') and paginator.nbResultsDeleted is defined %}<span
data-toggle="tooltip" title="{{ "list.nbResultsDeleted"|trans }}"
class="badge badge-danger">{{ paginator.nbResultsDeleted }} <i
class="badge badge-secondary">{{ paginator.nbResultsDeleted }} <i
class="fa fa-trash"></i>
</span>{% endif %}
{% endblock %}

+ 3
- 0
ShopBundle/Resources/views/backend/productfamily/panel_general.html.twig Просмотреть файл

@@ -7,6 +7,9 @@
<div class="col-12">
{{ form_row(form.status) }}
</div>
<div class="col-12">
{{ form_row(form.saleStatus) }}
</div>
<div class="col-12">
{{ form_row(form.supplier) }}
</div>

+ 7
- 1
ShopBundle/Services/Order/OrderUtilsStockTrait.php Просмотреть файл

@@ -61,10 +61,16 @@ trait OrderUtilsStockTrait

public function isProductAvailable(Product $product, $quantityOrder = 0, $checkCart = false, $orderShop = null)
{
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus() != 1) {
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus() != 1 || $product->getProductFamily()->getSaleStatus()!=1) {
return false;
}

$allCategoriesSalesOff = true;
foreach ($product->getProductFamily()->getProductCategories() as $category){
if($category->getSaleStatus())$allCategoriesSalesOff = false;
}
if($allCategoriesSalesOff)return false;

if (!$orderShop) {
$orderShop = $this->getCartCurrent();
}

Загрузка…
Отмена
Сохранить