how to use "&&" and "||" together in a search condition?
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
how to use "&&" and "||" together in a search condition?
i want to use "&&" and "||" together in a search condition to get orders, for example:
in this example i want to get orders those mtime is lower than a timeLimit "&&" with orders those payment status is PAY_PENDING "or" payment status is PAY_CANCELLED.
how can i do this with a just once search items?
Code: Select all
$first_expr = array(
$search->compare('<', 'order.mtime', $limit),
$search->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING),
);
$second_expr = array(
$search->compare('<', 'order.mtime', $limit),
$search->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_CANCELLED),
);
how can i do this with a just once search items?
Re: how to use "&&" and "||" together in a search condition?
The easiest way is using a list of values if they are of the same type:
If you have OR conditions of different types:
Code: Select all
$status = [\Aimeos\MShop\Order\Item\Base::PAY_PENDING, \Aimeos\MShop\Order\Item\Base::PAY_CANCELLED];
$search = $manager->filter();
$search->add( $filter->and( [
$search->compare('<', 'order.mtime', $limit),
$search->compare('==', 'order.statuspayment', $status),
] );
Code: Select all
$search->add( $filter->and( [
$search->compare('<', 'order.mtime', $limit),
$search->or( [
$search->compare('==', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING),
$search->compare('==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_PENDING),
] )
] );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star