Использую следующий код.
$oShop = Core_Entity::factory( 'Shop', $id );
$oShop_Item_Discounts = $oShop->Shop_Discounts->Shop_Item_Discounts;
$oShop_Item_Discounts->queryBuilder()
->straightJoin()
->join( 'shop_items', 'shop_item_discounts.shop_item_id', '=', 'shop_items.id' )
->join( 'shop_discounts', 'shop_item_discounts.shop_discount_id', '=', 'shop_discounts.id' )
->where( 'shop_items.shop_id', '=', $oShop->id )
->where( 'shop_discounts.active', '=', 1 )
->where( 'shop_discounts.deleted', '=', 0 )
->orderBy( 'shop_discounts.end_datetime', 'DESC' );
$aShop_Item_Discounts = $oShop_Item_Discounts->findAll();
В итоге это преобразуется в такой SQL-запрос.
SELECT
*
FROM `shop_item_discounts`
INNER JOIN `shop_items` ON `shop_item_discounts`.`shop_item_id` = `shop_items`.`id`
INNER JOIN `shop_discounts` ON `shop_item_discounts`.`shop_discount_id` = `shop_discounts`.`id`
WHERE `shop_item_discounts`.`shop_discount_id` IS NULL AND `shop_items`.`shop_id` = 4 AND `shop_discounts`.`active` = 1 AND `shop_discounts`.`deleted` = 0
ORDER BY `shop_discounts`.`end_datetime` DESC
Не могу понять, откуда берется условие
WHERE `shop_item_discounts`.`shop_discount_id` IS NULL
, и как его убрать.
Подскажите, пожалуйста.