From 199cddba21ee5430bd1461ca5fa38da816e0e39f Mon Sep 17 00:00:00 2001 From: 4Giedrius <4giedrius@gmail.com> Date: Thu, 29 Jan 2015 13:08:57 +0200 Subject: [PATCH] If there is promo with same code created already, do not let create new one --- src/bb-modules/Product/Service.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bb-modules/Product/Service.php b/src/bb-modules/Product/Service.php index d93b8baca..61ea9e3ca 100644 --- a/src/bb-modules/Product/Service.php +++ b/src/bb-modules/Product/Service.php @@ -567,6 +567,10 @@ class Service implements InjectionAwareInterface public function createPromo($code, $type, $value, $products = array(), $periods = array(), $clientGroups = array(), $data) { + if ($this->di['db']->findOne('Promo', 'code = :code', array(':code' => $code))){ + throw new \Box_Exception('This promo code already exists.'); + } + $systemService = $this->di['mod_service']('system'); $systemService->checkLimits('Model_Promo', 2);