return $this->getUserContainer()->getFactory()->create(); | return $this->getUserContainer()->getFactory()->create(); | ||||
} | } | ||||
public function overrideEntitiesActions(?EntityCollection $entities): void | |||||
public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void | |||||
{ | { | ||||
foreach ($entities as $entity) { | foreach ($entities as $entity) { | ||||
foreach ($entity->getActions() as $action){ | foreach ($entity->getActions() as $action){ |
return $repositoryQuery; | return $repositoryQuery; | ||||
} | } | ||||
public function overrideEntitiesActions(?EntityCollection $entities): void | |||||
public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void | |||||
{ | { | ||||
$context = $this->get(AdminContextProvider::class)->getContext(); | $context = $this->get(AdminContextProvider::class)->getContext(); | ||||
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); | $adminUrlGenerator = $this->get(AdminUrlGenerator::class); |
public function processBeforePersistProductFamilySectionInterface(EntityManagerEvent $event) | public function processBeforePersistProductFamilySectionInterface(EntityManagerEvent $event) | ||||
{ | { | ||||
$productFamilySectionProperty = $event->getEntity(); | |||||
if($productFamilySectionProperty instanceof ProductFamilySectionPropertyInterface) { | |||||
$section = $productFamilySectionProperty->getSection(); | |||||
if($productFamilySectionProperty->getStatus() == 1) { | |||||
$productCategoryArray = $productFamilySectionProperty->getProductFamily()->getProductCategories(); | |||||
foreach($productCategoryArray as $productCategory) { | |||||
if($productCategory->getSection() == $section) { | |||||
// mise à jour du statut | |||||
$productCategory->setStatus(1); | |||||
$this->entityManager->update($productCategory); | |||||
// mise à jour du statut du parent | |||||
$productCategoryParent = $productCategory->getParent(); | |||||
if($productCategoryParent) { | |||||
$productCategoryParent->setStatus(1); | |||||
$this->entityManager->update($productCategoryParent); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
//TODO à supprimer déplacer dans le script d'import, à remplacer par une alerte à l'édition d'un produit | |||||
} | } | ||||
} | } |
->setParameter('year', $year); | ->setParameter('year', $year); | ||||
} | } | ||||
public function filterByDistributions(array $distributions): self | |||||
public function filterByDistributions(array $distributionArray): self | |||||
{ | { | ||||
return $this | return $this | ||||
->andWhere('.distribution IN(:distributions)') | |||||
->setParameter('distributions', $distributions); | |||||
->andWhere('.distribution IN (:distributions)') | |||||
->setParameter('distributions', $distributionArray); | |||||
} | } | ||||
public function filterByProducts(array $products): self | public function filterByProducts(array $products): self |
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->orderBy('id', 'DESC'); | |||||
//$query->orderBy('id', 'DESC'); | |||||
return $query; | return $query; | ||||
} | } | ||||
$query->filterByDistribution($params['distribution']); | $query->filterByDistribution($params['distribution']); | ||||
} | } | ||||
if (isset($params['distributions'])) { | |||||
$query->filterByDistributions($params['distributions']); | |||||
} | |||||
if (isset($params['isCart'])) { | if (isset($params['isCart'])) { | ||||
$query->filterByStatus(OrderStatusModel::$statusAliasAsCart); | $query->filterByStatus(OrderStatusModel::$statusAliasAsCart); | ||||
} | } | ||||
if (isset($params['excludeComplementaryOrderShops']) || isset($params['mergeComplementaryOrderShops'])) { | if (isset($params['excludeComplementaryOrderShops']) || isset($params['mergeComplementaryOrderShops'])) { | ||||
$query->filterIsNullMainOrderShop(); | $query->filterIsNullMainOrderShop(); | ||||
} | } | ||||
if (isset($params['joinProductFamily'])) { | if (isset($params['joinProductFamily'])) { | ||||
$query->joinProductFamily(true); | $query->joinProductFamily(true); | ||||
} | } | ||||
if (isset($params['groupBy'])) { | if (isset($params['groupBy'])) { | ||||
$query->groupBy($params['groupBy']); | $query->groupBy($params['groupBy']); | ||||
} | } | ||||
return $query; | return $query; | ||||
} | } | ||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
public function getAllByDevAlias(string $devAlias): array | |||||
public function getByDevAlias(string $devAlias): array | |||||
{ | { | ||||
$query = $this->createDefaultQuery(); | $query = $this->createDefaultQuery(); | ||||
$query->filterByDevAlias($devAlias); | $query->filterByDevAlias($devAlias); |
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterIsOnlineAndOffline(); | |||||
$this->addFilterBySectionOptionnal($query); | $this->addFilterBySectionOptionnal($query); | ||||
$this->addFilterByMerchantViaSectionOptionnal($query); | $this->addFilterByMerchantViaSectionOptionnal($query); | ||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
//TODO ajouter status en donné de contexte pour éviter ce truc | |||||
public function getByCategoryOnlineAndOffline( | |||||
ProductCategoryInterface $productCategory, | |||||
$query = null | |||||
) { | |||||
$query = $this->createDefaultQuery($query); | |||||
$query | |||||
->filterByProductCategory($productCategory); | |||||
return $query->find(); | |||||
} | |||||
// getProductFamiliesNovelties | // getProductFamiliesNovelties | ||||
public function getNovelty($user = null, $organizeByParentCategory = true, $query = null) | public function getNovelty($user = null, $organizeByParentCategory = true, $query = null) | ||||
{ | { |
public function getUrl(SectionInterface $section) | public function getUrl(SectionInterface $section) | ||||
{ | { | ||||
if ($this->urlResolver->isServerLocalhost()) { | |||||
return $this->router->generate('frontend_home', ['section' => $section->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL); | |||||
} else { | |||||
return $this->settingSolver->getSettingValue($section->getMerchant(), MerchantSettingDefinition::SETTING_URL); | |||||
$url = $this->settingSolver->getSettingValue($section->getMerchant(), MerchantSettingDefinition::SETTING_URL); | |||||
if(!$section->getIsDefault()) { | |||||
$url .= $section->getSlug(); | |||||
} | } | ||||
return$url; | |||||
} | } | ||||
public function getMerchantUser(UserInterface $user = null) | public function getMerchantUser(UserInterface $user = null) |
if($quantity) { | if($quantity) { | ||||
return ($quantityProduct / $unit->getCoefficient()) * $quantity; | return ($quantityProduct / $unit->getCoefficient()) * $quantity; | ||||
}else{ | }else{ | ||||
$quantity = 0; | |||||
return 0; | |||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
public function isDone(OrderShopInterface $orderShop): bool | |||||
{ | |||||
if ($orderShop->getOrderStatus() && $orderShop->getOrderStatus()->getAlias() == OrderStatusModel::ALIAS_DONE ) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
// getProductQuantityMaxAddCart | // getProductQuantityMaxAddCart | ||||
public function getProductQuantityMaxAddCart(OrderShopInterface $orderShop, ProductInterface $product) | public function getProductQuantityMaxAddCart(OrderShopInterface $orderShop, ProductInterface $product) | ||||
{ | { |