public function getVariationByAttributes(array $attributes)
    {
        if (!is_array($attributes)) {
            return null;
        }

        $attrs = array_filter(array_values($attributes));
        $set = Variation::get()->filter('ProductID', $this->owner->ID);

        foreach ($attrs as $i => $valueid) {
            $alias = "A$i";
            $set = $set->innerJoin(
                'SilverShop_Variation_AttributeValues',
                "\"SilverShop_Variation\".\"ID\" = \"$alias\".\"SilverShop_VariationID\"",
                $alias
            )->where(["\"$alias\".\"SilverShop_AttributeValueID\" = ?" => $valueid]);
        }

        return $set->first();
    }
public function getVariationByAttributes(array $attributes)
    {
        if (!is_array($attributes)) {
            return null;
        }

        $attrs = array_filter(array_values($attributes));
        $set = Variation::get()->filter('ProductID', $this->owner->ID);

        foreach ($attrs as $i => $valueid) {
            $alias = "A$i";
            $set = $set->innerJoin(
                'SilverShop_Variation_AttributeValues',
                "\"SilverShop_Variation\".\"ID\" = \"$alias\".\"SilverShop_VariationID\"",
                $alias
            )->where(["\"$alias\".\"SilverShop_AttributeValueID\" = ?" => $valueid]);
        }

        return $set->first();
    }
public function getVariationByAttributes ( array $ attributes ) { if ( ! is_array ( $ attributes ) ) { return null ; } $ attrs = array_filter ( array_values ( $ attributes ) ) ; $ set = Variation :: get ( ) -> filter ( 'ProductID' , $ this -> owner -> ID ) ; foreach ( $ attrs as $ i => $ valueid ) { $ alias = "A$i" ; $ set = $ set -> innerJoin ( 'SilverShop_Variation_AttributeValues' , "\"SilverShop_Variation\".\"ID\" = \"$alias\".\"SilverShop_VariationID\"" , $ alias ) -> where ( [ "\"$alias\".\"SilverShop_AttributeValueID\" = ?" => $ valueid ] ) ; } return $ set -> first ( ) ; }
Pass an array of attribute ids to query for the appropriate variation.

@param array $attributes

@return Variation|null
Pass an array of attribute ids to query for the appropriate variation .