}
} else {
    if ($only_service_stocks == 1 || $only_common == 1) {
        $stock = new CProductStockService();
        $ljoin = array('product' => 'product.product_id = product_stock_service.product_id');
        $where['product_stock_service.object_id'] = "= '{$service_id}'";
        $where['product_stock_service.object_class'] = "= 'CService'";
        // XXX
        if ($only_common) {
            $where['product_stock_service.common'] = "= '1'";
        }
        if ($keywords) {
            $where['product.name'] = $stock->_spec->ds->prepareLike("%{$keywords}%");
        }
        /** @var CProductStockService[] $stocks_service */
        $stocks_service = $stock->seek($keywords, $where, $limit, true, $ljoin, 'product.name');
        $count_stocks = $stock->_totalSeek;
        $stocks = array();
        if ($stocks_service) {
            foreach ($stocks_service as $_id => $stock_service) {
                if ($stock_service->_ref_product->cancelled) {
                    continue;
                }
                //if (count($stocks) == 20) continue;
                $stock = new CProductStockGroup();
                $stock->product_id = $stock_service->_ref_product->_id;
                $stock->group_id = $group_id;
                if ($stock->loadMatchingObject()) {
                    $stock->updateFormFields();
                    $stock->_ref_stock_service = $stock_service;
                    $stock->quantity = max(0, $stock_service->getOptimumQuantity() - $stock_service->quantity);