Skip to content

joined fields are not getting parsed when using queryHook #85

@travisbotello

Description

@travisbotello

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions