Explorar el Código

Merge branch 'develop'

master
Fabien Normand hace 3 años
padre
commit
3a05209a52
Se han modificado 2 ficheros con 32 adiciones y 17 borrados
  1. +25
    -15
      Resolver/MerchantResolver.php
  2. +7
    -2
      Solver/Product/ProductFamilySolver.php

+ 25
- 15
Resolver/MerchantResolver.php Ver fichero

@@ -61,6 +61,11 @@ class MerchantResolver
$this->settingSolver = $settingSolver;
}

public function isOutOfMerchant()
{
return !$this->getCurrentProtected();
}

public function getCurrent(): MerchantInterface
{
if (isset($this->currentMerchant) && $this->currentMerchant) {
@@ -68,6 +73,23 @@ class MerchantResolver
}

$this->currentMerchant = null;
$merchant = $this->getCurrentProtected();

if($merchant) {
$this->currentMerchant = $merchant;
}

if ($this->currentMerchant instanceof MerchantInterface) {
return $this->currentMerchant;
}
else {
throw new \ErrorException('Aucun merchant courant');
}
}

protected function getCurrentProtected(): ?MerchantInterface
{
$currentMerchant = null;
$request = $this->requestStack->getCurrentRequest();
$merchants = $this->merchantRepository->findAll();
$isCli = php_sapi_name() === 'cli';
@@ -76,7 +98,7 @@ class MerchantResolver
if ($isCli || $this->urlResolver->isServerLocalhost()) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) {
$this->currentMerchant = $merchant;
$currentMerchant = $merchant;
}
}
} // distant
@@ -84,25 +106,13 @@ class MerchantResolver
foreach ($merchants as $merchant) {
$url = $this->settingSolver->getSettingValue($merchant, MerchantSettingDefinition::SETTING_URL);
if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) {
$this->currentMerchant = $merchant;
}
}
}
} else {
/*if ($_ENV['CURRENT_MERCHANT_COMMAND']) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_COMMAND']) {
$currentMerchant = $merchant;
}
}
}*/
}
}

if ($this->currentMerchant instanceof MerchantInterface) {
return $this->currentMerchant;
} else {
throw new \ErrorException('Aucun merchant courant');
}
return $currentMerchant;
}

public function getUserMerchant(

+ 7
- 2
Solver/Product/ProductFamilySolver.php Ver fichero

@@ -177,12 +177,17 @@ class ProductFamilySolver
}


public function getProductCategoryParent(ProductFamilyInterface $productFamily)
public function getProductCategoryParent(ProductFamilyInterface $productFamily, SectionInterface $section)
{
$productCategories = $productFamily->getProductCategories();

if (count($productCategories) > 0) {
return $productCategories[0]->getParent();
foreach ($productCategories as $productCategory) {
if($productCategory->getSection() === $section && $productCategory->getParent()!==null){
return $productCategory->getParent();
}
}

}

return false;

Cargando…
Cancelar
Guardar