Product "getBy" functions not working

I’ve been working on implementing the e-commerce framework. It’s been working great, but today I noticed that anytime I’m calling the DataObject\Product::getBy functions, it’s not returning anything, with the exception of getById. No error or anything, just returns blank. It works for every other data object type, except for DataObject\Product.

I also tried doing new DataObject\Product\Listing(), and adding a condition, which likewise returned nothing. Any thoughts where I would even begin to diagnose why this doesn’t work? I have verified the fieldname exists on the object (sku, in this case).



$productId = 650109;
$product = DataObject\Product::getBySku($productId, 1);

$product returns null. I’m using Elasticsearch for indexing, and the objects are variants. Would any of those things cause the problem?

OK, it appears as though it’s because they’re variants. I needed to specify:


as outlined on the Variants page:

1 Like