Преглед изворни кода

[Backoffice] Moulinette slug

feature/export_comptable
Fab пре 4 година
родитељ
комит
54f9145017
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;
}



}

Loading…
Откажи
Сачувај