Coroico / AdvSearch

Dynamic content search add-on for MODx Revolution that supports results highlighting, faceted search and search in custom packages
21 stars 14 forks source link

joined fields are not getting parsed when using queryHook #85

Open travisbotello opened 8 years ago

travisbotello commented 8 years ago

I am using the following queryHook to get custom search results:

$main = array(
    'package' => 'modx',
    'packagePath' => '{core_path}model/',
    'class' => 'modResource',                         
    'fields' => 'pagetitle',                        
    'withFields' => 'pagetitle',                    
    'sortby' => 'scProductMeta.price DESC',
    'tablePrefix' => 'hsx_'
);

$joined = array(
    array(
        'package' => 'simplecartresource',        
        'packagePath' => '{core_path}components/simplecart/model/', 
        'class' => 'scProductMeta',
        'withFields' => 'price,image',
        'fields' => 'price,image',
        'joinCriteria' => 'modResource.id = scProductMeta.resource',
        'tablePrefix' => 'hsx_'
    )
);

$andConditions = array(
    'modResource.class_key:=' => 'scProductResource'
);

// set the query hook declaration
$qhDeclaration = array(
    'qhVersion' => '1.3',       // version of queryHook - to manage futures changes
    'main' => $main,
    'joined' => $joined,
    'andConditions' => $andConditions
); 
$hook->setQueryHook($qhDeclaration);

return true;

Debugging information show that it is returning the correct search results with the joined fields scProductMeta_image and scProductMeta_price. However in my resultsTpl the placeholders are empty:

[[+advsearch.scProductMeta_image]] - [[+advsearch.scProductMeta_price]]

Investigating further where the fields are dropped, the debugging information shows

advsearchresults.class.php : 556: [AdvSearch] Config parameters after checking in class AdvSearchResults: Array (
...
[fields] => pagetitle,
[withFields] => pagetitle
...
)

Any ideas, why the joined fields are getting dropped although the query returns the correct results?

MODx 2.5.0