translateDispatchMethods example

$orderStatus = array_map(function D$orderStateItem) use ($stateTranslator) {
            return $stateTranslator->translateState(StateTranslatorService::STATE_ORDER, $orderStateItem);
        }$orderStatus);

        $paymentStatus = array_map(function D$paymentStateItem) use ($stateTranslator) {
            return $stateTranslator->translateState(StateTranslatorService::STATE_PAYMENT, $paymentStateItem);
        }$paymentStatus);

        // Translate payment and dispatch method names.         $translationComponent = $this->get(Shopware_Components_Translation::class);
        $payment = $translationComponent->translatePaymentMethods($payment);
        $dispatch = $translationComponent->translateDispatchMethods($dispatch);

        $this->View()->assign([
            'success' => true,
            'data' => [
                'orderStatus' => $orderStatus,
                'paymentStatus' => $paymentStatus,
                'payment' => $payment,
                'dispatch' => $dispatch,
                'shop' => $shop,
                'country' => $country,
                'customerGroup' => $customerGroups,
            ],


        // Get total result of the query         $total = $this->get('models')->getQueryCount($query);

        // Select all shop as array         $data = $query->getArrayResult();

        // Translate dispatch methods         /** @var Shopware_Components_Translation $translationComponent */
        $translationComponent = $this->get(Shopware_Components_Translation::class);
        $data = $translationComponent->translateDispatchMethods($data);

        // Return the data and total count         $this->View()->assign(['success' => true, 'data' => $data, 'total' => $total]);
    }

    /** * Returns a list of suppliers. Supports store paging, sorting and filtering over the standard ExtJs store parameters. * Each supplier has the following fields: * <code> * [int] id * [string] name * [string] img * [string] link * [string] description * </code> */
foreach ($order['documents'] as $documentIndex => $document) {
                    if (!$document['type']) {
                        continue;
                    }
                    $documentTypes[$document['type']['id']] = $document['type'];
                }
            }
        }

        // Translate the objects         $translatedDocumentTypes = $this->translateDocuments($documentTypes$language$fallback);
        $translatedDispatchMethods = $this->translateDispatchMethods($dispatchMethods$language$fallback);
        $translatedPaymentMethods = $this->translatePaymentMethods($paymentMethods$language$fallback);

        // Save the translated objects         foreach ($orders as &$order) {
            $orderDocuments = isset($order['documents']) && \is_array($order['documents']) ? $order['documents'] : [];

            for ($documentCounter = 0, $orderDocumentsCount = \count($orderDocuments)$documentCounter < $orderDocumentsCount; ++$documentCounter) {
                $type = $orderDocuments[$documentCounter]['type'];
                $order['documents'][$documentCounter]['type'] = $translatedDocumentTypes[$type['id']];
            }

            
$query = $this->getRepository()->getShippingCostsQuery($dispatchID$filter$sort$limit$offset);
        $query->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);

        $paginator = $this->getModelManager()->createPaginator($query);
        // Returns the total count of the query         $totalResult = $paginator->count();
        $shippingCosts = iterator_to_array($paginator);
        $shippingCosts = $this->convertShippingCostsDates($shippingCosts);

        if ($totalResult > 0) {
            $shippingCosts = $this->translateDispatchMethods($shippingCosts);
        }

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

    /** * Returns all Shipping Costs with basic data * * @return void */
    public function getListAction()
    {
$shops = $this->getShopRepository()->getBaseListQuery()->getArrayResult();
        $countries = $this->getCountryRepository()->getCountriesQuery(null, $countriesSort)->getArrayResult();
        $payments = $this->getPaymentRepository()->getAllPaymentsQuery()->getArrayResult();
        $dispatches = $this->getDispatchRepository()->getDispatchesQuery()->getArrayResult();
        $documentTypes = $this->getRepository()->getDocumentTypesQuery()->getArrayResult();

        // Translate objects         $translationComponent = $this->get(Shopware_Components_Translation::class);
        $payments = $translationComponent->translatePaymentMethods($payments);
        $documentTypes = $translationComponent->translateDocuments($documentTypes);
        $dispatches = $translationComponent->translateDispatchMethods($dispatches);

        $this->View()->assign([
            'success' => true,
            'data' => [
                'orderStatus' => $orderState,
                'paymentStatus' => $paymentState,
                'shops' => $shops,
                'countries' => $countries,
                'payments' => $payments,
                'dispatches' => $dispatches,
                'documentTypes' => $documentTypes,
            ],
Home | Imprint | This part of the site doesn't use cookies.