1

I want to search for Entries of the same channel/section based on their type. Let's say, we are a travel company with two types of tours: "guided group" and "private". For group tours, we want trips associated with a particular provider. For private tours, we want trips less than a certain price (this field is N/A for group journeys).

In the controller:

$criteriaFilters = [
    'section'=>'journeys',
    'relatedTo'=> [<ids of the provider>],// Should be for group only
    'price'=>'<10', // Should be for private tour only
];
$criteria = craft()->elements->getCriteria(
    ElementType::Entry,
    $criteriaFilters
);

I need to retrieve them all in an ElementCriteriaModel object, via one SQL query. I don't want to get all private and guided tours separately and then combine them because that doesn't work well with pagination.

What do you think is best to achieve this? (in PHP, not Twig)

2
  • Just to be clear, you want to be able to search where relatedTo is equal to some list of entries OR price is less than some amount and get a single result set back?
    – Brad Bell
    Jun 29 '15 at 18:19
  • yes that's correct Jun 29 '15 at 23:02
1

I don't think it's possible to do what you're trying to do in a single ElementCriteriaModel query.

These questions are basically asking the same thing and can confirm it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.