Browse Source

Frontend : page produit

reduction
Guillaume 4 years ago
parent
commit
d163d9ebb2
5 changed files with 62 additions and 6 deletions
  1. +3
    -3
      ShopBundle/Model/PriceTrait.php
  2. +52
    -0
      ShopBundle/Model/ProductFamily.php
  3. +5
    -0
      ShopBundle/Model/ProductPropertyTrait.php
  4. +1
    -1
      ShopBundle/Resources/views/backend/productfamily/form.html.twig
  5. +1
    -2
      ShopBundle/Twig/FrontendTwigExtension.php

+ 3
- 3
ShopBundle/Model/PriceTrait.php View File

@@ -50,7 +50,7 @@ trait PriceTrait

public function getPriceByUnitRef()
{
return $this->getPriceInherited() * $this->getUnitInherited()->getCoefficient() ;
return ($this->getPriceInherited() * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited() ;
}

public function getPriceByUnitRefWithTax()
@@ -91,8 +91,8 @@ trait PriceTrait

private function calculatePriceWithTax($priceWithoutTax, $taxRateValue)
{
$price = floatval($priceWithoutTax) * ($taxRateValue + 1) ;
$price = number_format(( ($price * 100)) / 100, 2) ;
$price = floatval($priceWithoutTax) * ($taxRateValue/100 + 1) ;
$price = round(( ($price * 100)) / 100, 2) ;
return $price ;
}
}

+ 52
- 0
ShopBundle/Model/ProductFamily.php View File

@@ -118,6 +118,10 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
*/
protected $typeExpirationDate;

/**
* @ORM\Column(type="string", length=32, nullable=true)
*/
protected $behaviorAddToCart;

public function __construct()
{
@@ -233,6 +237,30 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this;
}

public function getProductCategoryParent()
{
$productCategories = $this->getProductCategories() ;

if(count($productCategories) > 0) {
return $productCategories[0]->getParent() ;
}

return false ;
}

public function getProductCategoryChild()
{
$productCategories = $this->getProductCategories() ;
foreach($productCategories as $productCategory) {
if($productCategory->getParent()) {
return $productCategory ;
}
}

return false ;
}

public function getSupplierTaxRate(): ?TaxRate
{
return $this->supplierTaxRate;
@@ -430,6 +458,18 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this;
}

public function countProperties(): bool
{
$count = 0 ;

$count += (int) strlen($this->getPropertyAllergens()) > 0 ;
$count += (int) strlen($this->getPropertyComposition()) > 0 ;
$count += (int) strlen($this->getPropertyFragrances()) > 0 ;
$count += (int) strlen($this->getPropertyOrganicLabel()) > 0 ;
$count += (int) ($this->getPropertyExpirationDate() != null) ;

return $count ;
}

public function getBehaviorExpirationDate(): ?string
{
@@ -455,4 +495,16 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this;
}

public function getBehaviorAddToCart(): ?string
{
return $this->behaviorAddToCart;
}

public function setBehaviorAddToCart(?string $behaviorAddToCart): self
{
$this->behaviorAddToCart = $behaviorAddToCart;

return $this;
}

}

+ 5
- 0
ShopBundle/Model/ProductPropertyTrait.php View File

@@ -60,6 +60,11 @@ trait ProductPropertyTrait
return $this;
}

public function getQuantityInherited(): ?float
{
return $this->getQuantity() ;
}

public function getAvailableQuantity(): ?float
{
return $this->availableQuantity;

+ 1
- 1
ShopBundle/Resources/views/backend/productfamily/form.html.twig View File

@@ -42,7 +42,7 @@
{% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %}
{% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %}
{% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %}
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate }}",{% endif %}
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate|date('d/m/Y') }}",{% endif %}
};
window.productUnitPriceValues = {
{% if formValues.unit %}unit: parseInt({{ formValues.unit.id }}),{% endif %}

+ 1
- 2
ShopBundle/Twig/FrontendTwigExtension.php View File

@@ -66,8 +66,7 @@ class FrontendTwigExtension extends AbstractExtension

public function formatPrice($price)
{
$price = number_format($price, 2) ;
$price = str_replace('.',',',$price) ;
$price = number_format($price, 2, ',', ' ') ;
$price = $price .' €' ;
return $price ;
}

Loading…
Cancel
Save