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();
    }