rotatingProductRepository = $this->loadService(RotatingProductRepository::class); } public function instanciateRotating(Producer $producer): Rotating { $rotating = new Rotating(); $rotating->setProducer($producer); $rotating->setStatus(StatusInterface::STATUS_ONLINE); return $rotating; } public function initSelectedProductsIds(Rotating $rotating): void { $selectedProductsIdsArray = []; $rotatingProductsArray = $this->rotatingProductRepository->findRotatingProductsByRotating($rotating); foreach($rotatingProductsArray as $rotatingProduct) { $selectedProductsIdsArray[] = $rotatingProduct->getProduct()->id; } $rotating->setSelectedProductsIds($selectedProductsIdsArray); } }