Browse Source

Merge branch 'develop'

master
Fab 4 years ago
parent
commit
909ca381de
2 changed files with 13 additions and 40 deletions
  1. +13
    -0
      ShopBundle/Repository/BaseRepository.php
  2. +0
    -40
      ShopBundle/Services/Utils.php

+ 13
- 0
ShopBundle/Repository/BaseRepository.php View File

@@ -99,4 +99,17 @@ class BaseRepository extends EntityRepository implements ServiceEntityRepository
return parent::findOneBy($criteria, $orderBy);
}

public function findSimilarSlug($merchant){
$qb = $this->createQueryBuilder('entity')
->select('entity.id, COUNT(entity.slug) as niche')
->andWhere('entity.status>=0')
->andWhere('entity.merchant= :merchant')
->setParameter('merchant', $merchant)

->groupBy('entity.slug')
->having('COUNT(entity.slug) >1');

return $qb->getQuery()->getResult();
}

}

+ 0
- 40
ShopBundle/Services/Utils.php View File

@@ -506,46 +506,6 @@ class Utils
}


public function duplicateEntity($entity){
$newEntity = clone $entity ;

if($newEntity instanceof ImageInterface){
$this->duplicateImage($entity);
$newEntity->setImage(null);
}

if($newEntity instanceof ProductFamilyInterface){
$this->productFamilyUtils->processBeforePersistProductFamily($newEntity);
}

$this->em->persist($newEntity) ;
$this->em->flush();

return $newEntity;
}

public function duplicateImage($entity, $folder = false){
$basePath = $this->parameterBag->get('kernel.project_dir').'/public/uploads/images/' ;


if($entity->getImage() && file_exists($basePath.$entity->getImage())) {
dump(pathinfo($basePath.$entity->getImage()));
}
die();


$newImage = md5(uniqid()).'.jpg';
if($folder) $newImage = $folder.'/'.$newImage;

if($entity->getImage() && file_exists($basePath.$entity->getImage())) {
copy($basePath.$entity->getImage(), $basePath . $newImage);
$entity->setImage($newImage);
}else{
$entity->setImage(null);
}
return $entity;
}



}

Loading…
Cancel
Save