I checked and unfortunately attribute parameter not filter products properly in my case. Maybe it's woocommerce related bug. I attached some codes maybe it helps you
use Codexshaper\WooCommerce\Facades\Product;
use Codexshaper\WooCommerce\Facades\Variation;
$products = Product::whereType('variable')->get();;
$variations = [];
$option = "S";
foreach ($products as $product) {
$p_variations = Variation::all($product->id);
foreach ($p_variations as $product_variation) {
$attributes = $product_variation->attributes;
foreach ($attributes as $attribute) {
if($attribute->option != $option) continue;
$variations[] = $product_variation;
}
}
}
var_dump($variations);
@invaders-xx
I checked and unfortunately attribute parameter not filter products properly in my case. Maybe it's woocommerce related bug. I attached some codes maybe it helps you
If not work inform me. Thanks