if ($context == 'admin') { | if ($context == 'admin') { | ||||
$url .= 'admin'; | $url .= 'admin'; | ||||
} | } | ||||
} | |||||
if(!$url) { | |||||
$url = $request->headers->get('referer'); | |||||
} | |||||
if($url) { | |||||
return $this->redirect($url); | |||||
} | } | ||||
} | |||||
if ($url) { | |||||
return $this->redirect($url); | |||||
} else { | |||||
$this->addFlashTranslator('error', ActionDefinition::SWITCH_MERCHANT, 'Merchant'); | |||||
return $this->redirect($request->headers->get('referer')); | |||||
} | } | ||||
$this->addFlashTranslator('error', ActionDefinition::SWITCH_MERCHANT, 'Merchant'); | |||||
return $this->redirectToRoute('frontend_home'); | |||||
} | } | ||||
} | } |
$idProductFamily = $data['order_products']['id_product_family']; | $idProductFamily = $data['order_products']['id_product_family']; | ||||
$this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily); | $this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily); | ||||
if(!$this->productFamily) { | |||||
$return['return'] = 'error'; | |||||
} | |||||
// alerte si cookies non acceptés | // alerte si cookies non acceptés | ||||
if (!$user && !$visitor) { | if (!$user && !$visitor) { | ||||
$this->addFlash( | $this->addFlash( | ||||
'fos_user_security_login' | 'fos_user_security_login' | ||||
) . '">connecter</a> pour ajouter un produit.' | ) . '">connecter</a> pour ajouter un produit.' | ||||
); | ); | ||||
return false; | |||||
$return['return'] = 'error'; | |||||
} | } | ||||
if ($this->productFamily) { | if ($this->productFamily) { | ||||
$this->addOrderProduct($orderShop, $orderProduct); | $this->addOrderProduct($orderShop, $orderProduct); | ||||
} | } | ||||
} | } | ||||
$return['return'] = 'success'; | |||||
} | } | ||||
} | } | ||||
} | } |
private function _getProductFamily($request) | private function _getProductFamily($request) | ||||
{ | { | ||||
$idProductFamily = $request->request->get('idProductFamily'); | $idProductFamily = $request->request->get('idProductFamily'); | ||||
$productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily); | |||||
if ($productFamily) { | |||||
if($idProductFamily) { | |||||
$productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily); | |||||
} | |||||
if (isset($productFamily) && $productFamily) { | |||||
return $productFamily; | return $productFamily; | ||||
} else { | } else { | ||||
throw new \ErrorException('Ce produit est introuvable'); | throw new \ErrorException('Ce produit est introuvable'); |
array( | array( | ||||
'required' => false, | 'required' => false, | ||||
'attr' => array( | 'attr' => array( | ||||
'class' => ' input-sm', | |||||
'class' => ' input-sm autocomplete-disabled', | |||||
'form' => 'filters-form', | 'form' => 'filters-form', | ||||
), | ), | ||||
) | ) |
array( | array( | ||||
'required' => false, | 'required' => false, | ||||
'attr' => array( | 'attr' => array( | ||||
'class' => ' input-sm', | |||||
'class' => ' input-sm autocomplete-disabled', | |||||
'form' => 'filters-form', | 'form' => 'filters-form', | ||||
), | ), | ||||
) | ) |
array( | array( | ||||
'required' => false, | 'required' => false, | ||||
'attr' => array( | 'attr' => array( | ||||
'class' => ' input-sm', | |||||
'class' => ' input-sm autocomplete-disabled', | |||||
'form' => 'filters-form', | 'form' => 'filters-form', | ||||
), | ), | ||||
) | ) |