src/Entities/Products/UnlockableProductExtraSet.php
public static function createFromProduct(Product $product)
    {
        $linkedSets = [];
        $productOptionSets = $product->getOptionSets();

        while ($set = array_shift($productOptionSets)) {
            foreach ($set->getOptions() as $option) {
                $productOptionSets = array_merge($productOptionSets, $option->getUnlockOptionSets());
                foreach ($option->getUnlockExtraSets() as $unlockExtraSet) {
                    $linkedSets[$unlockExtraSet->getId()]['set'] = $unlockExtraSet;
                    $linkedSets[$unlockExtraSet->getId()]['options'][] = $option->getId();
                }
            }
        }

        $linkedSetInstances = [];

        foreach ($linkedSets as $linkedSet) {
            $linkedSetInstances[] = new static($linkedSet['set'], $linkedSet['options']);
        }

        return $linkedSetInstances;
    }
public static function createFromProduct(Product $product)
    {
        $linkedSets = [];
        $productOptionSets = $product->getOptionSets();

        while ($set = array_shift($productOptionSets)) {
            foreach ($set->getOptions() as $option) {
                $productOptionSets = array_merge($productOptionSets, $option->getUnlockOptionSets());
                foreach ($option->getUnlockExtraSets() as $unlockExtraSet) {
                    $linkedSets[$unlockExtraSet->getId()]['set'] = $unlockExtraSet;
                    $linkedSets[$unlockExtraSet->getId()]['options'][] = $option->getId();
                }
            }
        }

        $linkedSetInstances = [];

        foreach ($linkedSets as $linkedSet) {
            $linkedSetInstances[] = new static($linkedSet['set'], $linkedSet['options']);
        }

        return $linkedSetInstances;
    }
@param Product $product

@return array|static[]