rotatingProductRepository = $this->loadService(RotatingProductRepository::class); } public function instanciateRotatingProduct(Rotating $rotating): RotatingProduct { $rotatingProduct = new RotatingProduct(); $rotatingProduct ->setRotating($rotating) ->setStatus(StatusInterface::STATUS_ONLINE); return $rotatingProduct; } public function initRotatingProductPosition(RotatingProduct $rotatingProduct): RotatingProduct { $lastRotatingProduct = $this->rotatingProductRepository->findOneLastRotatingProduct($rotatingProduct->getRotating()); if($lastRotatingProduct) { $rotatingProduct->setPosition($lastRotatingProduct->getPosition() + 1); } else { $rotatingProduct->setPosition(1); } return $rotatingProduct; } }