/** * Get matching products to validate product * * @param GroupInterface $variantGroup the variant group * @param ProductInterface $entity the product * @param array $criteria query criterias * * @return ProductInterface[] */ protected function getMatchingProductsForProduct(GroupInterface $variantGroup, ProductInterface $entity, array $criteria = []) { if (!$variantGroup->getId()) { return []; } $matchingProducts = $this->repository->findProductIdsForVariantGroup($variantGroup, $criteria); $matchingProducts = array_filter($matchingProducts, function ($product) use($entity) { return $product['id'] !== $entity->getId(); }); return $matchingProducts; }