modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Configurable.php
public static function recursiveConfigurableTree(array &$tree, array $available_config, array $current_config = []) {
    $subtree = ['#available_config' => $available_config];

    foreach ($available_config as $id => $config) {
      $subtree_available_config = $available_config;
      unset($subtree_available_config[$id]);

      foreach ($config['values'] as $option) {
        $value = $option['value_id'];
        $subtree_current_config = array_merge($current_config, [$id => $value]);

        if (count($subtree_available_config) > 0) {
          $subtree["$id:$value"] = Configurable::recursiveConfigurableTree(
            $tree,
            $subtree_available_config,
            $subtree_current_config
          );
        }
        else {
          $subtree["$id:$value"] = Configurable::findProductInTreeWithConfig(
            $tree,
            $subtree_current_config
          );
        }
      }
    }

    return $subtree;
  }
public static function recursiveConfigurableTree(array &$tree, array $available_config, array $current_config = []) {
    $subtree = ['#available_config' => $available_config];

    foreach ($available_config as $id => $config) {
      $subtree_available_config = $available_config;
      unset($subtree_available_config[$id]);

      foreach ($config['values'] as $option) {
        $value = $option['value_id'];
        $subtree_current_config = array_merge($current_config, [$id => $value]);

        if (count($subtree_available_config) > 0) {
          $subtree["$id:$value"] = Configurable::recursiveConfigurableTree(
            $tree,
            $subtree_available_config,
            $subtree_current_config
          );
        }
        else {
          $subtree["$id:$value"] = Configurable::findProductInTreeWithConfig(
            $tree,
            $subtree_current_config
          );
        }
      }
    }

    return $subtree;
  }
public static function recursiveConfigurableTree ( array & $ tree , array $ available_config , array $ current_config = [ ] ) { $ subtree = [ '#available_config' => $ available_config ] ; foreach ( $ available_config as $ id => $ config ) { $ subtree_available_config = $ available_config ; unset ( $ subtree_available_config [ $ id ] ) ; foreach ( $ config [ 'values' ] as $ option ) { $ value = $ option [ 'value_id' ] ; $ subtree_current_config = array_merge ( $ current_config , [ $ id => $ value ] ) ; if ( count ( $ subtree_available_config ) > 0 ) { $ subtree [ "$id:$value" ] = Configurable :: recursiveConfigurableTree ( $ tree , $ subtree_available_config , $ subtree_current_config ) ; } else { $ subtree [ "$id:$value" ] = Configurable :: findProductInTreeWithConfig ( $ tree , $ subtree_current_config ) ; } } } return $ subtree ; }
Creates subtrees based on available config.

@param array $tree
Tree of products.
@param array $available_config
Available configs.
@param array $current_config
Config of current product.

@return array
Subtree.
Creates subtrees based on available config .