浏览代码

Merge branch 'develop'

master
Fab 4 年前
父节点
当前提交
909ca381de
共有 2 个文件被更改,包括 13 次插入40 次删除
  1. +13
    -0
      ShopBundle/Repository/BaseRepository.php
  2. +0
    -40
      ShopBundle/Services/Utils.php

+ 13
- 0
ShopBundle/Repository/BaseRepository.php 查看文件

@@ -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 查看文件

@@ -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;
}



}

正在加载...
取消
保存