translatePaymentMethods example

$builder->select(['payment', 'ruleSets'])
                    ->from('Shopware\Models\Payment\Payment', 'payment');
            $builder->leftJoin('payment.ruleSets', 'ruleSets');
            $builder->orderBy('payment.active', 'desc');
            $builder->addOrderBy('payment.id');

            $result = $builder->getQuery()->getArrayResult();
            $total = $this->get('models')->getQueryCount($builder->getQuery());

            // Translate the payment methods             $translationComponent = $this->get(Shopware_Components_Translation::class);
            $result = $translationComponent->translatePaymentMethods($result);

            $this->View()->assign(['success' => true, 'data' => $result, 'total' => $total]);
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'errorMsg' => $e->getMessage()]);
        }
    }

    /** * Function to delete a single rule. * It is called, when the user clicks on the delete button of a rule. */
    
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']];
            }

            if ($translatedDispatchMethods[$order['dispatch']['id']]) {
                

        ];

        $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,
                


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

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

        // Translate payments         /** @var Shopware_Components_Translation $translationComponent */
        $translationComponent = $this->get(Shopware_Components_Translation::class);
        $data = $translationComponent->translatePaymentMethods($data);

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

    /** * Returns a list of customer groups. Supports store paging, sorting and filtering over the standard ExtJs store parameters. * Each customer group has the following fields: * <code> * [int] id * [string] key * [string] description * [int] tax * [int] taxInput * [int] mode * </code> */
$stateTranslator = $this->get('shopware.components.state_translator');
        $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,
                
Home | Imprint | This part of the site doesn't use cookies.