I am trying to compare two fields located on Variants in Commerce. One is the price field and then I also have an original price field which is a custom field. I want to compare and get all variants where the price is less than the original price.
$query = craft()->db->createCommand()
->from('commerce_variants')
->where("price < field_originalPrice")
->queryAll();
return $query;
This is what I have so far but could be way off on this since that custom field is actually on the content
table.
Any help would be awesome! Thanks!