public function getRelatedPurchasablesFromArray(array $purchasables, $limit)
    {
        $categories = [];

        /**
         * @var PurchasableInterface $product
         */
        foreach ($purchasables as $purchasable) {
            $category = $purchasable->getPrincipalCategory();
            if (
                $category instanceof CategoryInterface &&
                !in_array($category, $categories)
            ) {
                $categories[] = $category;
            }
        }

        if (empty($categories)) {
            return [];
        }

        return $this
            ->purchasableRepository
            ->createQueryBuilder('p')
            ->where('p.principalCategory IN(:categories)')
            ->andWhere('p NOT IN(:purchasables)')
            ->andWhere('p.enabled = :enabled')
            ->setParameters([
                'categories' => $categories,
                'purchasables' => $purchasables,
                'enabled' => true,
            ])
            ->setMaxResults($limit)
            ->getQuery()
            ->getResult();
    }