In larvel I'm using corcel and with the help of this comment I'm trying to retrieve only simple products and variations of variable products.
$type = array('product_variation','product');
$status = 'publish';
$posts =
\Corcel\Model\Post::
type($type)->
whereHas('taxonomies', function($q) {
$q->where('taxonomy', 'product_type')
->whereHas('term', function($q) {
$q->where('slug', 'simple');
})
// since variations have no product_type taxonomy, then
->orwhere('taxonomy','<>', 'product_type');
})->
status($status)->
latest()->
limit(500)->
get();
return $posts;
but it only returns product_variation(s), and no simple product. can some one please explain my wrong doing?
i had the same problem, i realized that i can use
doesntHave