modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Configurable.php
public static function findProductInTreeWithConfig(array $tree, array $config) {
    if (isset($tree['products'])) {
      $attributes = [];
      foreach ($config as $key => $value) {
        $attributes[$key] = $value;
      }

      foreach ($tree['combinations']['by_sku'] ?? [] as $sku => $sku_attributes) {
        if (count(array_intersect_assoc($sku_attributes, $attributes)) === count($sku_attributes)) {
          return $tree['products'][$sku];
        }
      }
    }

    return NULL;
  }
public static function findProductInTreeWithConfig(array $tree, array $config) {
    if (isset($tree['products'])) {
      $attributes = [];
      foreach ($config as $key => $value) {
        $attributes[$key] = $value;
      }

      foreach ($tree['combinations']['by_sku'] ?? [] as $sku => $sku_attributes) {
        if (count(array_intersect_assoc($sku_attributes, $attributes)) === count($sku_attributes)) {
          return $tree['products'][$sku];
        }
      }
    }

    return NULL;
  }
public static function findProductInTreeWithConfig ( array $ tree , array $ config ) { if ( isset ( $ tree [ 'products' ] ) ) { $ attributes = [ ] ; foreach ( $ config as $ key => $ value ) { $ attributes [ $ key ] = $ value ; } foreach ( $ tree [ 'combinations' ] [ 'by_sku' ] ?? [ ] as $ sku => $ sku_attributes ) { if ( count ( array_intersect_assoc ( $ sku_attributes , $ attributes ) ) === count ( $ sku_attributes ) ) { return $ tree [ 'products' ] [ $ sku ] ; } } } return NULL ; }
Finds product in tree base on config.

@param array $tree
The whole configurable tree.
@param array $config
Config for the product.

@return \Drupal\acm_sku\Entity\SKU
Reference to SKU in existing tree.
Finds product in tree base on config .