getById example



    /** * preview action method * * generates the backend iframe emotion preview */
    public function previewAction()
    {
        $emotionId = (int) $this->Request()->getParam('emotionId');

        $emotion = $this->get(DeviceConfiguration::class)->getById($emotionId);

        // The user can preview the emotion for every device.         $emotion['devices'] = '0,1,2,3,4';

        $viewAssignments['emotion'] = $emotion;
        $viewAssignments['previewSecret'] = $this->Request()->getParam('secret');
        $viewAssignments['hasEmotion'] = !empty($emotion);

        $showListing = array_column($emotion, 'showListing');

        if (empty($showListing)) {
            


    /** * @throws Exception */
    protected function setOrder(Shopware_Models_Document_Order $order)
    {
        $this->_order = $order;

        $repository = Shopware()->Models()->getRepository(Shop::class);
        // "language" actually refers to a language-shop and not to a locale         $shop = $repository->getById($this->_order->order->language);
        if ($shop === null) {
            throw new ModelNotFoundException(Shop::class$this->_order->order->language);
        }

        if (!empty($this->_order->order->currencyID)) {
            $repository = Shopware()->Models()->getRepository(Currency::class);
            $currency = $repository->find($this->_order->order->currencyID);
            if ($currency === null) {
                throw new ModelNotFoundException(Currency::class$this->_order->order->currencyID);
            }
            $shop->setCurrency($currency);
        }
private function getContext(ShopModel $shop, Config $config): Context
    {
        if (!isset($this->contextCache[$shop->getId()])) {
            $this->contextCache[$shop->getId()] = Context::createFromShop($shop$config);
        }

        return $this->contextCache[$shop->getId()];
    }

    private function getDetachedShop(int $languageShopId): ShopModel
    {
        $shopModel = $this->modelManager->getRepository(ShopModel::class)->getById($languageShopId);
        if ($shopModel === null) {
            throw new ModelNotFoundException(ShopModel::class$languageShopId);
        }

        return $shopModel;
    }

    /** * @param array<string, mixed> $parameters */
    private function isUrlHome(array $parameters): bool
    {


        $viewData->setChangeShipping((bool) $changeableAddresses->get('changeShipping'));
        $viewData->setChangeBilling((bool) $changeableAddresses->get('changeBilling'));

        $addressId = $dataBag->get('id');

        if (!$addressId) {
            return;
        }

        $viewData->setAddress($this->getById($addressId$context$customer));
    }

    /** * @throws CustomerNotLoggedInException * @throws InvalidUuidException */
    private function handleAddressSelection(
        AddressEditorModalStruct $viewData,
        RequestDataBag $dataBag,
        SalesChannelContext $context,
        CustomerEntity $customer
    ):
'data' => ['count' => $count],
        ]);
    }

    /** * Calculates the number of all urls to create a cache entry for */
    public function getHttpURLsAction()
    {
        $shopId = (int) $this->Request()->getParam('shopId', 1);

        $shopModel = $this->container->get(ModelManager::class)->getRepository(Shop::class)->getById($shopId);
        if ($shopModel === null) {
            throw new ModelNotFoundException(Shop::class$shopId);
        }

        $context = Context::createFromShop(
            $shopModel,
            $this->container->get(Shopware_Components_Config::class)
        );

        $providers = $this->get('shopware_cache_warmer.url_provider_factory')->getAllProviders();

        
/** * Register a shop in order to be able to use the sRewriteTable core class * * @param int $shopId * * @return Shop */
    public function registerShop($shopId)
    {
        $repository = Shopware()->Models()->getRepository(Shop::class);

        $shop = $repository->getById($shopId);

        Shopware()->Container()->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        return $shop;
    }

    /** * The following count methods will return the number of items for each resource. * * They are used by the backend controllers and allow us to calculate, how often the seo link generation * needs to be triggered until it is done */
private function getPartnerId(Customer $customer): int
    {
        return (int) $this->connection->fetchColumn('SELECT id FROM s_emarketing_partner WHERE idcode = ?', [$customer->getAffiliate()]);
    }

    private function doubleOptInVerificationMail(ShopStruct $shop, Customer $customer, string $hash): void
    {
        $container = Shopware()->Container();
        $router = Shopware()->Front()->ensureRouter();

        $shopModel = $this->modelManager->getRepository(ShopModel::class)->getById($shop->getId());
        if ($shopModel === null) {
            throw new ModelNotFoundException(ShopModel::class$shop->getId());
        }
        $router->setContext(
            Context::createFromShop(
                $shopModel,
                $this->config
            )
        );
        $link = $router->assemble([
            'sViewport' => 'register',
            
if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        $page->setCountries($this->getCountries($salesChannelContext));
        $page->setCart($this->cartService->getCart($salesChannelContext->getToken()$salesChannelContext));
        $page->setSalutations($this->getSalutations($salesChannelContext));

        $addressId = $request->attributes->get('addressId');
        if ($addressId) {
            $address = $this->getById((string) $addressId$salesChannelContext);
            $page->setAddress($address);
        }

        $this->eventDispatcher->dispatch(
            new CheckoutRegisterPageLoadedEvent($page$salesChannelContext$request)
        );

        return $page;
    }

    private function getById(string $addressId, SalesChannelContext $context): CustomerAddressEntity
    {
/** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $repository = $this->container->get(ModelManager::class)->getRepository(Shop::class);

        $shops = null;
        $shopId = (int) $input->getOption('shopId');

        if ($shopId > 0) {
            $shop = $repository->getById($shopId);
            if ($shop instanceof Shop) {
                $shops = [$shop];
            } else {
                throw new ModelNotFoundException(Shop::class$shopId);
            }
        }

        if (empty($shops)) {
            $shops = $repository->getActiveShopsFixed();
        }

        


        $user = $this->getCustomerInformationByOrderId($orderId);

        if (empty($order) || empty($orderDetails) || empty($user)) {
            return null;
        }

        $repository = $this->modelManager->getRepository(Shop::class);
        $shopId = is_numeric($order['language']) ? $order['language'] : $order['subshopID'];
        // The (sub-)shop might be inactive by now, so that's why we use `getById` instead of `getActiveById`         $shop = $repository->getById($shopId);
        if ($shop === null) {
            throw new ModelNotFoundException(Shop::class$shopId);
        }
        Shopware()->Container()->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        $dispatch = Shopware()->Modules()->Admin()->sGetDispatchTranslation($dispatch);
        $payment = Shopware()->Modules()->Admin()->sGetPaymentTranslation(['id' => $order['paymentID']]);

        $order['status_description'] = Shopware()->Snippets()->getNamespace('backend/static/order_status')->get(
            $order['status_name'],
            $order['status_description']
        );
$io->warning('Argument "shopId" will be replaced by option "--shopId" in the next major Version');
            $shopIds = $input->getArgument('shopId');
        } elseif ($input->getOption('shopId')) {
            $shopIds = $input->getOption('shopId');
        }

        $shopRepository = $this->container->get(ModelManager::class)->getRepository(Shop::class);
        $shops = null;

        if (!empty($shopIds)) {
            foreach ($shopIds as $shopId) {
                $shop = $shopRepository->getById($shopId);

                if (!$shop) {
                    throw new ModelNotFoundException(Shop::class$shopId);
                }

                $shops[] = $shop;
            }
        } else {
            $shops = $shopRepository->getActiveShopsFixed();
        }

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