/** * @param ProductInterface $product * @param AssociationTypeInterface $type * * @return array */ protected function getAssociatedProductIds(ProductInterface $product, AssociationTypeInterface $type) { $productIds = []; $association = $product->getAssociationForType($type); if ($association) { foreach ($association->getProducts() as $product) { $productIds[] = $product->getId(); } } return $productIds ?: [0]; }
/** * Test if a product has grouped products * @param ProductInterface $product * @param string $pimGrouped * * @return boolean */ protected function hasGroupedProduct(ProductInterface $product, $pimGrouped) { if ($associationType = $this->associationTypeManager->getAssociationTypeByCode($pimGrouped)) { $association = $product->getAssociationForType($associationType); return null != $association && null != $association->getProducts() && null != $association->getGroups(); } else { return false; } }