/** * @param ProductInterface $product */ public function ensureAllAssociationTypes(ProductInterface $product) { $missingAssocTypes = $this->assocTypeRepository->findMissingAssociationTypes($product); if (!empty($missingAssocTypes)) { foreach ($missingAssocTypes as $associationType) { $association = new Association(); $association->setAssociationType($associationType); $product->addAssociation($association); } } }