Browse Source

Pastille product

packProduct
Fabien Normand 2 years ago
parent
commit
2de3b68916
8 changed files with 60 additions and 10 deletions
  1. +15
    -0
      Builder/Product/ProductFamilySectionPropertyBuilder.php
  2. +1
    -0
      Definition/Field/Product/ProductCategoryFieldDefinition.php
  3. +0
    -7
      Resources/views/admin/product/field/product_family_section_properties.html.twig
  4. +6
    -1
      Resources/views/admin/section/macros.html.twig
  5. +14
    -0
      Solver/Product/ProductCategorySolver.php
  6. +1
    -0
      Solver/Product/ProductFamilySectionPropertySolver.php
  7. +18
    -1
      Solver/Product/ProductFamilySolver.php
  8. +5
    -1
      Twig/StoreTwigExtension.php

+ 15
- 0
Builder/Product/ProductFamilySectionPropertyBuilder.php View File

$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver; $this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
} }



public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void
{ {
$productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section); $productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section);
} }
} }



public function disable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void
{
$productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section);

if ($productFamilySectionProperty) {
$productFamilySectionProperty->setStatus(0);
$this->entityManager->update($productFamilySectionProperty);
}
if($flush) {
$this->entityManager->flush();
}
}

} }

+ 1
- 0
Definition/Field/Product/ProductCategoryFieldDefinition.php View File

'title', 'title',
'description', 'description',
'image', 'image',
'status',
'saleStatus', 'saleStatus',
'isEligibleTicketRestaurant', 'isEligibleTicketRestaurant',
]; ];

+ 0
- 7
Resources/views/admin/product/field/product_family_section_properties.html.twig View File

{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %}
{% set item = entity.instance %}
{% for section_property in item.productFamilySectionProperties %}
{{ macros_section.section_badge(section_property.section) }}
{% else %}
<span class="badge badge-secondary">Aucune</span>
{% endfor %}

+ 6
- 1
Resources/views/admin/section/macros.html.twig View File


{% macro section_badge(section) %} {% macro section_badge(section) %}
<span class="badge badge-secondary {{ section_container.solver.getHtmlClass(section) }}">{{ section.title }}</span> <span class="badge badge-secondary {{ section_container.solver.getHtmlClass(section) }}">{{ section.title }}</span>
{% endmacro %}



{% macro section_badge_light_custom(section,title, status= 1) %}
<span class="badge badge-secondary {{ status !=1 ? 'stripped'}} {{ section_container.solver.getHtmlClass(section) }}-light">{{ title }}</span>
{% endmacro %} {% endmacro %}

+ 14
- 0
Solver/Product/ProductCategorySolver.php View File



namespace Lc\CaracoleBundle\Solver\Product; namespace Lc\CaracoleBundle\Solver\Product;


use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;

class ProductCategorySolver class ProductCategorySolver
{ {


public function isOnline(ProductCategoryInterface $productCategory)
{
if ($productCategory->getParent()) {
if ($productCategory->getStatus() && $productCategory->getParent()->getStatus()) {
return true;
}
} elseif ($productCategory->getStatus()) {
return true;
}
return false;
}

} }





+ 1
- 0
Solver/Product/ProductFamilySectionPropertySolver.php View File

} }
return null; return null;
} }

} }





+ 18
- 1
Solver/Product/ProductFamilySolver.php View File

use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
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\ProductFamilySectionPropertyInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface; use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
{ {


protected ProductSolver $productSolver; protected ProductSolver $productSolver;
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
protected ProductCategorySolver $productCategorySolver;


public function __construct(ProductSolver $productSolver)
public function __construct(ProductSolver $productSolver, ProductFamilySectionPropertySolver $productFamilySectionPropertySolver, ProductCategorySolver $productCategorySolver)
{ {
$this->productSolver = $productSolver; $this->productSolver = $productSolver;
$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
$this->productCategorySolver = $productCategorySolver;
} }






return false; return false;
} }


public function isCategoriesOnlineInSection(ProductFamilyInterface $productFamily, SectionInterface $section):bool
{
$isCategoriesOnlineInSection =false;
foreach ($productFamily->getProductCategories() as $productCatgory){
if($productCatgory->getSection() === $section && $this->productCategorySolver->isOnline($productCatgory)){
$isCategoriesOnlineInSection = true;
}
}
return $isCategoriesOnlineInSection;
}
} }



+ 5
- 1
Twig/StoreTwigExtension.php View File

return $this->sectionResolver->isOutOfSection(); return $this->sectionResolver->isOutOfSection();
} }


private $sections = null;
public function getSections() public function getSections()
{ {
return $this->sectionStore
if(!$this->sections){
$this->sections = $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent()) ->setMerchant($this->merchantResolver->getCurrent())
->getOnline(); ->getOnline();
}
return $this->sections;
} }


public function getMerchants() public function getMerchants()

Loading…
Cancel
Save