getOrdersQueryBuilder example

/** * Returns a list of orders for the passed customer id and filtered by the filter parameter. * * @param int $customerId * @param int|null $limit * @param int|null $offset * * @return Query<Order> */
    public function getOrdersQuery($customerId$filter = null, $orderBy = null, $limit = null, $offset = null)
    {
        $builder = $this->getOrdersQueryBuilder($customerId$filter$orderBy);
        if ($limit !== null) {
            $builder->setFirstResult($offset)
                    ->setMaxResults($limit);
        }

        return $builder->getQuery();
    }

    /** * Helper function to create the query builder for the "getOrdersQuery" function. * This function can be hooked to modify the query builder of the query object. * * @param int $customerId * @param string|null $filter * @param array|null $orderBy * * @return QueryBuilder */

    public function getOrdersQuery($filters = null, $orderBy = null, $offset = null, $limit = null)
    {
        $builder = $this->getOrdersQueryBuilder($filters$orderBy);
        if ($limit !== null) {
            $builder->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        return $builder->getQuery();
    }

    /** * Helper function to create the query builder for the "getOrdersQuery" function. * This function can be hooked to modify the query builder of the query object. * * @param array<array{property: string, value: mixed, expression?: string}>|null $filters * @param string|array<array{property: string, direction: string}>|null $orderBy * * @return QueryBuilder */

    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $filters = [['property' => 'orders.id', 'expression' => '=', 'value' => $id]];
        $order = $this->getRepository()->getOrdersQueryBuilder($filters)->getQuery()
            ->getOneOrNullResult($this->getResultMode());

        if ($order === null) {
            throw new NotFoundException(sprintf('Order by id %d not found', $id));
        }

        if (\is_array($order)) {
            $order['paymentStatusId'] = $order['cleared'];
            $order['orderStatusId'] = $order['status'];
            unset($order['cleared']$order['status']);
        }

        
Home | Imprint | This part of the site doesn't use cookies.