$c = $modx->newQuery('Products');
$c->where(array('product_groups.category_id' => $categoryId));
$c->andCondition(array('product_groups.product_group_id' => $productGroupId));
$c->sortby('product_groups.product_group_id','ASC');
$products = $modx->getCollection('Products',$c);
foreach($products as $product) {
$output = 'Image: ' . $product->get('group_image');
}
echo $output;Right—xPDO uses the class names and aliases (for relationships) that you define in your schema. So in this case it should be something like this (assuming product_groups is the table name of the Products class):
product_groups is the name of the database table, I’m guessing that’s incorrect, I’m still thinking in sql mode.
<?php
$output = array();
$c = $modx->newQuery('Products');
$c->where(array(
'category_id' => $categoryId,
'product_group_id' => $productGroupId
));
$c->sortby('product_group_id','ASC');
$products = $modx->getCollection('Products', $c);
foreach($products as $product) {
$output[] = 'Image: ' . $product->get('group_image');
}
return implode("\n", $output);
Using the table_prefix is not recommended unless you have a good reason to specifically set the table prefix.