Bladeren bron

Import des données prestashop

feature/export_comptable
Fab 4 jaren geleden
bovenliggende
commit
f9f028f8a5
14 gewijzigde bestanden met toevoegingen van 244 en 143 verwijderingen
  1. +10
    -0
      ShopBundle/Context/SeoInterface.php
  2. +48
    -25
      ShopBundle/Controller/Backend/AdminController.php
  3. +6
    -1
      ShopBundle/Form/Backend/Common/AddressType.php
  4. +4
    -47
      ShopBundle/Model/AbstractDocumentEntity.php
  5. +3
    -3
      ShopBundle/Model/Address.php
  6. +1
    -1
      ShopBundle/Model/OrderShop.php
  7. +1
    -1
      ShopBundle/Model/ProductCategory.php
  8. +78
    -7
      ShopBundle/Model/ProductFamily.php
  9. +63
    -0
      ShopBundle/Model/SeoTrait.php
  10. +1
    -0
      ShopBundle/Repository/OrderShopRepository.php
  11. +11
    -0
      ShopBundle/Resources/views/backend/default/block/macros.html.twig
  12. +10
    -51
      ShopBundle/Resources/views/backend/productfamily/panel_property.html.twig
  13. +1
    -0
      ShopBundle/Services/OrderUtils.php
  14. +7
    -7
      ShopBundle/Services/ProductFamilyUtils.php

+ 10
- 0
ShopBundle/Context/SeoInterface.php Bestand weergeven

@@ -0,0 +1,10 @@
<?php

namespace Lc\ShopBundle\Context;

interface SeoInterface
{



}

+ 48
- 25
ShopBundle/Controller/Backend/AdminController.php Bestand weergeven

@@ -11,14 +11,17 @@ use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\SeoInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Form\AbstractEditPositionType;
use Lc\ShopBundle\Form\Backend\Common\AbstractEditPositionType;
use Lc\ShopBundle\Services\Utils;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Security\Core\Security;
@@ -30,9 +33,9 @@ class AdminController extends EasyAdminController
protected $userManager;
protected $em;
protected $utils;
protected $merchantUtils ;
protected $mailjetTransport ;
protected $orderUtils ;
protected $merchantUtils;
protected $mailjetTransport;
protected $orderUtils;
protected $translator;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils,
@@ -42,9 +45,9 @@ class AdminController extends EasyAdminController
$this->userManager = $userManager;
$this->em = $em;
$this->utils = $utils;
$this->merchantUtils = $merchantUtils ;
$this->mailjetTransport = $mailjetTransport ;
$this->orderUtils = $orderUtils ;
$this->merchantUtils = $merchantUtils;
$this->mailjetTransport = $mailjetTransport;
$this->orderUtils = $orderUtils;
$this->translator = $translator;
}

@@ -144,7 +147,6 @@ class AdminController extends EasyAdminController
}



public function listChildrenAction()
{
$this->dispatch(EasyAdminEvents::PRE_LIST);
@@ -251,23 +253,43 @@ class AdminController extends EasyAdminController

$formBuilder = parent::createEntityFormBuilder($entity, $view);

if($override)$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view);
if ($override) $formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view);

return $formBuilder;
}

public function overrideFormBuilder($formBuilder, $entity, $view){
public function overrideFormBuilder($formBuilder, $entity, $view)
{
$id = (null !== $entity->getId()) ? $entity->getId() : 0;

if ($entity instanceof SeoInterface) {
$formBuilder->add('metaTitle', TextType::class, array(
'required' => false,
'translation_domain' => 'lcshop'
)
);
$formBuilder->add('metaDescription', TextareaType::class, array(
'required' => false,
'translation_domain' => 'lcshop'
)
);
/*$formBuilder->add('oldUrls', TextareaType::class, array(
'required' => false,
'translation_domain' => 'lcshop'
)
);*/
}


if ($entity instanceof StatusInterface) {
$formBuilder->add('status', ChoiceType::class, array(
'choices' =>array(
'choices' => array(
'field.default.statusOptions.offline' => '0',
'field.default.statusOptions.online' => '1'
),
'expanded' => true,
'required' => true,
'translation_domain'=> 'lcshop'
'translation_domain' => 'lcshop'
)
);
}
@@ -295,7 +317,8 @@ class AdminController extends EasyAdminController
return $formBuilder;
}

private function loopFormField($form, $childrens){
private function loopFormField($form, $childrens)
{
foreach ($childrens as $child) {
$statusInterface = false;
$treeInterface = false;
@@ -304,8 +327,8 @@ class AdminController extends EasyAdminController
$passedOptions = $child->getConfig()->getOptions();
$classImplements = class_implements($passedOptions['class']);

$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements) ;
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements) ;
$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements);
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements);

if ($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) {

@@ -317,15 +340,15 @@ class AdminController extends EasyAdminController
$treeInterface = true;
}
$propertyMerchant = 'merchant';
if($isFilterMultipleMerchantsInterface) {
$propertyMerchant .= 's' ;
if ($isFilterMultipleMerchantsInterface) {
$propertyMerchant .= 's';
}
$form->add($child->getName(), EntityType::class, array(
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(),
'label' => $passedOptions['label'],
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false,
'placeholder' => '--',
'translation_domain'=> 'lcshop',
'translation_domain' => 'lcshop',
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface, $treeInterface, $child) {
$queryBuilder = $repo->createQueryBuilder('e');
$propertyMerchant = 'e.' . $propertyMerchant;
@@ -336,19 +359,19 @@ class AdminController extends EasyAdminController
$queryBuilder->where($propertyMerchant . ' = :currentMerchant');
}

if($statusInterface){
if ($statusInterface) {
$queryBuilder->andWhere('e.status >= 0');
}
if($treeInterface && $child->getName() =='parent'){
if ($treeInterface && $child->getName() == 'parent') {
$queryBuilder->andWhere('e.parent is null');
}
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId());

return $queryBuilder;
},
'choice_label' => function($choice) {
if($choice instanceof StatusInterface && $choice->getStatus() == 0){
return $choice.' [hors ligne]';
'choice_label' => function ($choice) {
if ($choice instanceof StatusInterface && $choice->getStatus() == 0) {
return $choice . ' [hors ligne]';
}
return $choice;

@@ -358,9 +381,9 @@ class AdminController extends EasyAdminController
)
);
}
}else{
} else {
$subChildrens = $child->all();
if(count($subChildrens)){
if (count($subChildrens)) {
$this->loopFormField($child, $subChildrens);
}
}

+ 6
- 1
ShopBundle/Form/Backend/Common/AddressType.php Bestand weergeven

@@ -3,6 +3,7 @@
namespace Lc\ShopBundle\Form\Backend\Common;

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Doctrine\ORM\EntityManagerInterface;
@@ -49,7 +50,11 @@ class AddressType extends AbstractType
->add('zip', TextType::class, ['label' => 'Code postale'])
->add('city', TextType::class, ['label' => 'Ville'])
->add('country', TextType::class, ['label' => 'Pays'])
->add('phone', TextType::class, ['label' => 'Téléphone', 'required' => false])
->add('phone', CollectionType::class, [
'entry_type'=>TextType::class,
'label' => 'Téléphone',
'required' => false
])
->add('company', TextType::class, ['label' => 'Entreprise', 'required' => false])
->add('siret', TextType::class, ['label' => 'SIRET', 'required' => false])
->add('tva', TextType::class, ['label' => 'Numéro TVA', 'required' => false]);

+ 4
- 47
ShopBundle/Model/AbstractDocumentEntity.php Bestand weergeven

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

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Context\SeoInterface;
use Lc\ShopBundle\Context\SluggableInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface;
@@ -14,7 +15,7 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich;
* @ORM\MappedSuperclass
* @Vich\Uploadable
*/
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface, SeoInterface
{
use SortableTrait;

@@ -22,6 +23,8 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn

use SluggableTrait;

use SeoTrait;

/**
* @ORM\Column(type="string", length=255)
*/
@@ -48,16 +51,7 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
*/
protected $devAlias;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $metaDescription;

/**
* @var array
* @ORM\Column(name="old_url", type="array", nullable=true)
*/
private $oldUrl;


public function setImageFile(File $image = null)
@@ -104,43 +98,6 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
}


/**
* Set oldUrl
*
* @param array $oldUrl
*
* @return AbstractEntity
*/
public function setOldUrl($oldUrl)
{
$this->oldUrl = $oldUrl;

return $this;
}

/**
* Get oldUrl
*
* @return array
*/
public function getOldUrl()
{
return $this->oldUrl;
}


public function getMetaDescription(): ?string
{
return $this->metaDescription;
}

public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;

return $this;
}

public function getImage(): ?string
{
return $this->image;

+ 3
- 3
ShopBundle/Model/Address.php Bestand weergeven

@@ -76,7 +76,7 @@ abstract class Address extends AbstractEntity
protected $tva;

/**
* @ORM\Column(type="string", length=127, nullable=true)
* @ORM\Column(type="array", nullable=true)
*/
protected $phone;

@@ -293,12 +293,12 @@ abstract class Address extends AbstractEntity
return $this;
}

public function getPhone(): ?string
public function getPhone(): ?array
{
return $this->phone;
}

public function setPhone(?string $phone): self
public function setPhone(?array $phone): self
{
$this->phone = $phone;


+ 1
- 1
ShopBundle/Model/OrderShop.php Bestand weergeven

@@ -31,7 +31,7 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
protected $visitor;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="order")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
*/
protected $invoiceAddress;


+ 1
- 1
ShopBundle/Model/ProductCategory.php Bestand weergeven

@@ -28,7 +28,7 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt
protected $parent;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="parent")
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="parent" , fetch="EAGER"))
*/
protected $childrens;


+ 78
- 7
ShopBundle/Model/ProductFamily.php Bestand weergeven

@@ -112,17 +112,38 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $propertyWeightQuantity;
protected $propertyPackaging;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $propertyPackaging;
protected $propertyCharacteristics;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $propertyCharacteristics;
protected $propertyWeight;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $propertyQuantity;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $propertyFeature;


/**
* @ORM\Column(type="text", nullable=true)
*/
protected $propertyVariety;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $propertyAlcoholLevel;

/**
* @ORM\Column(type="string", length=255, nullable=true)
@@ -499,18 +520,68 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
}


public function getPropertyWeightQuantity(): ?string
public function getPropertyWeight(): ?string
{
return $this->propertyWeightQuantity;
return $this->propertyWeight;
}

public function setPropertyWeightQuantity(?string $propertyWeightQuantity): self
public function setPropertyWeight(?string $propertyWeight): self
{
$this->propertyWeightQuantity = $propertyWeightQuantity;
$this->propertyWeight = $propertyWeight;

return $this;
}


public function getPropertyQuantity(): ?string
{
return $this->propertyQuantity;
}

public function setPropertyQuantity(?string $propertyQuantity): self
{
$this->propertyQuantity = $propertyQuantity;

return $this;
}

public function getPropertyVariety(): ?string
{
return $this->propertyVariety;
}

public function setPropertyVariety(?string $propertyVariety): self
{
$this->propertyQuantity = $propertyVariety;

return $this;
}

public function getPropertyFeature(): ?string
{
return $this->propertyFeature;
}

public function setPropertyFeature(?string $propertyFeature): self
{
$this->propertyFeature = $propertyFeature;

return $this;
}

public function getPropertyAlcoholLevel(): ?string
{
return $this->propertyAlcoholLevel;
}

public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel): self
{
$this->propertyAlcoholLevel = $propertyAlcoholLevel;

return $this;
}


public function getPropertyPackaging(): ?string
{
return $this->propertyPackaging;

+ 63
- 0
ShopBundle/Model/SeoTrait.php Bestand weergeven

@@ -0,0 +1,63 @@
<?php

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;

trait SeoTrait
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $metaTitle;


/**
* @ORM\Column(type="text", nullable=true)
*/
protected $metaDescription;


/**
* @var array
* @ORM\Column(type="array", nullable=true)
*/
protected $oldUrls;


public function getMetaTitle(): ?string
{
return $this->metaTitle;
}

public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;

return $this;
}

public function getMetaDescription(): ?string
{
return $this->metaDescription;
}

public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;

return $this;
}

public function setOldUrls($oldUrls): self
{
$this->oldUrls = $oldUrls;

return $this;
}

public function getOldUrls(): ?array
{
return $this->oldUrls;
}
}

+ 1
- 0
ShopBundle/Repository/OrderShopRepository.php Bestand weergeven

@@ -20,6 +20,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
}


//TODO : AJOUTER un champ valid ds orderSTATUS
protected $statusAliasAsValid = array('paid-online', 'paid-by-credit', 'waiting-delivery', 'waiting-delivery-with-payment', 'delivered-without-payment', 'done');



+ 11
- 0
ShopBundle/Resources/views/backend/default/block/macros.html.twig Bestand weergeven

@@ -80,6 +80,17 @@

{% endmacro %}

{% macro autoresizeField(field) %}
<tr>
<td>{{ form_label(field) }}</td>
<td>
<div class="autoresize">
{{ form_widget(field, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
{% endmacro autoresizeField %}

{% macro fieldReductionList(form, field, filterOn = false, filterType='string') %}
<div class="col-12">
<div class="form-group">

+ 10
- 51
ShopBundle/Resources/views/backend/productfamily/panel_property.html.twig Bestand weergeven

@@ -53,59 +53,18 @@
<td>{{ form_widget(form.propertyExpirationDate, {'attr' : {'v-model' : 'propertyExpirationDate'}}) }}</td>
</tr>

<tr>
{#<td>
{{ form_widget(form.propertyAllergensActive, {"label" : false , "attr" : {'v-model' : 'propertyAllergensActive'}}) }}
</td>#}
<td>{{ form_label(form.propertyAllergens) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyAllergens, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>

<tr>
<td>{{ form_label(form.propertyComposition) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyComposition, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
{{ macros.autoresizeField(form.propertyAllergens) }}
{{ macros.autoresizeField(form.propertyComposition) }}
{{ macros.autoresizeField(form.propertyFragrances) }}
{{ macros.autoresizeField(form.propertyQuantity) }}
{{ macros.autoresizeField(form.propertyWeight) }}
{{ macros.autoresizeField(form.propertyCharacteristics) }}
{{ macros.autoresizeField(form.propertyPackaging) }}
{{ macros.autoresizeField(form.propertyAlcoholLevel) }}
{{ macros.autoresizeField(form.propertyVariety) }}
{{ macros.autoresizeField(form.propertyFeature) }}

<tr>
<td>{{ form_label(form.propertyFragrances) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyFragrances, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyWeightQuantity) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyWeightQuantity, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyCharacteristics) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyCharacteristics, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyPackaging) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyPackaging, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>

</tbody>
</table>

+ 1
- 0
ShopBundle/Services/OrderUtils.php Bestand weergeven

@@ -342,6 +342,7 @@ class OrderUtils
}

public function isReductionCreditAllowToBeAddToOrder($orderShop, $reductionCredit){

if($this->orderShopRepo->getValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser())>0){
return false;
}else{

+ 7
- 7
ShopBundle/Services/ProductFamilyUtils.php Bestand weergeven

@@ -14,15 +14,14 @@ class ProductFamilyUtils
public function getCheapestProduct($productFamily)
{
$priceUtils = $this->priceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily->getProducts()->getValues(), function ($a, $b) use ($priceUtils) {
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceWithTaxAndReduction($a) > $priceUtils->getPriceWithTaxAndReduction($b) ;
}, true);
}

public function getCheapestProductByRefUnit($productFamily)
{
$priceUtils = $this->priceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily->getProducts()->getValues(), function ($a, $b) use ($priceUtils) {
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) > $priceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
}, false);
}
@@ -30,20 +29,21 @@ class ProductFamilyUtils
public function getMostExpensiveProductByRefUnit($productFamily)
{
$priceUtils = $this->priceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily->getProducts()->getValues(), function ($a, $b) use ($priceUtils) {
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) < $priceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
}, false);
}

private function getCheapestOrMostExpensiveProduct($products, $comparisonFunction, $returnSelfIfNotActiveProducts)
private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts)
{
$products = $productFamily->getProducts()->getValues() ;
if (count($products) > 0) {
usort($products, $comparisonFunction);
return $products[0];
}
if ($returnSelfIfNotActiveProducts) {
return $this;
}
return $productFamily;
}
else {
return false;
}

Laden…
Annuleren
Opslaan