hostcms писал(а):
вы свой код не показали, который у вас неправильно считает.
<?php
$Shop_Controller_Show = new Shop_Controller_Extend(
Core_Entity::factory('Shop', 3)
);
Core_Entity::factory('Shop')->getTableColumns();
$Shop_Controller_Show->shopItems()
->queryBuilder()
->sqlCalcFoundRows()
// Модификации и остатки на складах модификаций
->leftJoin(array('shop_items', 'modifications'), 'modifications.modification_id', '=', 'shop_items.id')
->leftJoin(array('shop_warehouse_items', 'modifications_shop_warehouse_items'), 'modifications_shop_warehouse_items.shop_item_id', '=', 'modifications.id')
// Остатки на складах основного отвара
->leftJoin('shop_warehouse_items', 'shop_warehouse_items.shop_item_id', '=', 'shop_items.id')
// Есть остатки на основном складе
->having('SUM(shop_warehouse_items.count)', '>', 0)
// Или
->setOr()
// Есть остатки на складах у модификаций
->having('SUM(modifications_shop_warehouse_items.count)', '>', 0)
->groupBy('shop_items.id')
->setAnd()
->where('shop_items.modification_id', '=', 0)
->where('shop_items.shortcut_id', '=', 0)
->where('shop_items.deleted', '=', 0)
->where('shop_items.active', '=', 1)
->limit(2000)
;
$row = Core_QueryBuilder::select(array('FOUND_ROWS()', 'count'))->execute()->asAssoc()->current();
//echo "<p>Всего найдено: " . $row['count'];
?>