Browse Source

[Boutique] Favoris : correctif ajout favoris si utilisateur non connecté

feature/souke
Guillaume Bourgeois 10 months ago
parent
commit
0646880b9d
1 changed files with 20 additions and 16 deletions
  1. +20
    -16
      producer/controllers/SiteController.php

+ 20
- 16
producer/controllers/SiteController.php View File

@@ -215,23 +215,27 @@ class SiteController extends ProducerBaseController
public function actionBookmarks(string $action)
{
$producer = $this->getProducerCurrent();
$userProducer = $this->getUserProducerModule()
->createUserProducerIfNotExist(GlobalParam::getCurrentUser(), $producer);

if ($action == 'add') {
$userProducer->bookmark = 1;
$this->setFlash(
'success',
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être ajouté à vos favoris.'
);
} else {
$userProducer->bookmark = 0;
$this->setFlash(
'success',
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être supprimé de vos favoris.'
);

$userCurrent = $this->getUserCurrent();
if($userCurrent) {
$userProducer = $this->getUserProducerModule()
->createUserProducerIfNotExist($userCurrent, $producer);

if ($action == 'add') {
$userProducer->bookmark = 1;
$this->setFlash(
'success',
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être ajouté à vos favoris.'
);
} else {
$userProducer->bookmark = 0;
$this->setFlash(
'success',
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être supprimé de vos favoris.'
);
}
$userProducer->save();
}
$userProducer->save();

return $this->redirect(['site/index']);
}

Loading…
Cancel
Save