getOrdersQuery example

$orderId = (int) $this->Request()->getParam('orderId');
        $documentType = (int) $this->Request()->getParam('documentType');

        // Needs to be called this early since $this->createDocument boots the         // shop, the order was made in, and thereby destroys the backend session         $translationComponent = $this->get(Shopware_Components_Translation::class);

        if ($orderId !== 0 && $documentType !== 0) {
            $this->createDocument($orderId$documentType);
        }

        $query = $this->getRepository()->getOrdersQuery([['property' => 'orders.id', 'value' => $orderId]], null, 0, 1);
        $query->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
        $order = iterator_to_array($this->getModelManager()->createPaginator($query));

        $order = $translationComponent->translateOrders($order);

        $this->View()->assign([
            'success' => true,
            'data' => $order,
        ]);
    }

    


        $defaultSort = ['0' => ['property' => 'orderTime', 'direction' => 'DESC']];

        $limit = (int) $this->Request()->getParam('limit', 20);
        $offset = (int) $this->Request()->getParam('start', 0);
        $sort = $this->Request()->getParam('sort', $defaultSort);
        $filter = $this->Request()->getParam('filter');
        $filter = $filter[0]['value'];

        // Get access on the customer getRepository()         $query = $this->getRepository()->getOrdersQuery($customerId$filter$sort$limit$offset);

        // Returns the total count of the query         $totalResult = $this->getManager()->getQueryCount($query);

        // Returns the customer data         $orders = $query->getArrayResult();

        $this->View()->assign(['success' => true, 'data' => $orders, 'total' => $totalResult]);
    }

    /** * Event listener method which fires when the detail page of a customer is loaded. * Returns an array of grouped order data to display them in a line chart. */
Home | Imprint | This part of the site doesn't use cookies.