/** * @throws \Spryker\Zed\SequenceNumber\Business\Exception\InvalidSequenceNumberException * * @return int */ protected function createNumber() { try { $this->connection->beginTransaction(); $sequence = $this->getSequence(); $idCurrent = $sequence->getCurrentId() + $this->randomNumberGenerator->generate(); $sequence->setCurrentId($idCurrent); $sequence->save(); $this->connection->commit(); } catch (\Exception $e) { $this->connection->rollback(); throw new InvalidSequenceNumberException('Could not generate sequence number. Make sure your settings are complete. Error: ' . $e->getMessage()); } return $idCurrent; }
protected function tearDown() { parent::tearDown(); $this->con->exec("SET FOREIGN_KEY_CHECKS = 1;"); $this->con->rollback(); }
public static function importJsonPrice(SocolissimoDeliveryMode $deliveryMode, ConnectionInterface $con) { $areaPrices = self::getPrices($deliveryMode); $priceExist = SocolissimoPriceQuery::create()->filterByDeliveryModeId($deliveryMode->getId())->findOne(); //If at least one price exist doesn't import the xml (or it will erase the user price) if (null !== $priceExist) { return; } $con->beginTransaction(); try { foreach ($areaPrices as $areaId => $area) { foreach ($area['slices'] as $weight => $price) { $slice = (new SocolissimoPrice())->setAreaId($areaId)->setWeightMax($weight)->setPrice($price)->setDeliveryModeId($deliveryMode->getId()); $slice->save(); } $con->commit(); } } catch (PropelException $e) { $con->rollback(); throw $e; } }