registerShop example

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']
        );
        $order['cleared_description'] = Shopware()->Snippets()->getNamespace('backend/static/payment_status')->get(
            $order['cleared_name'],
            $order['cleared_description']
        );


        $this->send($splice, \count($data));
    }

    /** * @return void */
    public function getReferrerRevenueAction()
    {
        $shop = $this->getManager()->getRepository(Shop::class)->getActiveDefault();
        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        $result = $this->getRepository()->getReferrerRevenue(
            $shop,
            $this->getFromDate(),
            $this->getToDate()
        );

        $referrer = [];
        foreach ($result->getData() as $row) {
            $host = parse_url($row['referrer'], PHP_URL_HOST);
            if (!\is_string($host)) {
                
return;
        }

        if (!$this->Request()->getParam('value')) {
            $this->View()->assign(['success' => false, 'message' => 'Value not found']);
        }

        $recipient = Shopware()->Config()->get('mail');

        $shop = $this->get('models')->getRepository(Shop::class)->getActiveDefault();
        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        try {
            $templateMail = Shopware()->TemplateMail()->createMail($mailarray_merge($this->getDefaultMailContext($shop)$mail->getContext())$shop);
            $templateMail->addTo($recipient);
            $templateMail->setAssociation(AdministrativeMailFilter::ADMINISTRATIVE_MAIL, true);
            $templateMail->send();
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);

            return;
        }

        
/** * Clean up seo links. remove links of non-existing categories, articles... */
    public function initSeoAction()
    {
        $shopId = (int) $this->Request()->getParam('shopId', 1);

        @set_time_limit(1200);

        // Create shop         $this->SeoIndex()->registerShop($shopId);

        $this->RewriteTable()->baseSetup();
        $this->RewriteTable()->sCreateRewriteTableCleanup();

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

    /** * Assigns the amount of the seo links which to build for this shop * Bind for: Shopware_Controllers_Seo_filterCounts */

        $io = new SymfonyStyle($input$output);

        if ($this->container->getParameter('shopware.session.save_handler') === 'file') {
            $io->error('Session save handler "file" is not supported');

            return 1;
        }

        /** @var Shop $shop */
        $shop = $this->container->get('models')->getRepository(Shop::class)->getDefault();
        $this->container->get('shopware.components.shop_registration_service')->registerShop($shop);

        $count = session_gc();
        session_destroy();

        $io->success(sprintf('Successfully removed %d expired sessions', $count));

        return 0;
    }
}
$repository = $this->get('models')->getRepository(Shop::class);
        $shop = $repository->getActiveById($mailing['languageID']);
        if ($shop === null) {
            throw new ModelNotFoundException(Shop::class$mailing['languageID']);
        }

        $this->Request()
            ->setHttpHost((string) $shop->getHost())
            ->setBasePath($shop->getBasePath())
            ->setBaseUrl($shop->getBasePath());

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

        Shopware()->Session()->set('sUserGroup', $mailing['customergroup']);
        $sql = 'SELECT * FROM s_core_customergroups WHERE groupkey=?';
        Shopware()->Session()->set('sUserGroupData', Shopware()->Db()->fetchRow($sql[$mailing['customergroup']]));

        Shopware()->Container()->get(RouterInterface::class)->setGlobalParam('module', 'frontend');
        Shopware()->Config()->offsetSet('DontAttachSession', true);
        Shopware()->Container()->get(ContextServiceInterface::class)->initializeShopContext();

        return $mailing;
    }

    
$this->sCustomergroup = $this->sGetCustomergroup($this->sSettings['customergroupID']);

        $this->articleMediaAlbum = $this->getMediaRepository()
            ->getAlbumWithSettingsQuery(-1)
            ->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);

        if ($this->sCurrency === false) {
            throw new RuntimeException('Currency could not be fetched correctly.');
        }
        $currency = Shopware()->Models()->getRepository(Currency::class)->find($this->sCurrency['id']);
        $shop->setCurrency($currency);
        Shopware()->Container()->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        if ($this->sCustomergroup !== false) {
            Shopware()->Container()->get('session')->offsetSet('sUserGroup', $this->sCustomergroup['groupkey']);
        }

        $this->contextService->initializeContext();

        $this->shop = $shop;

        $this->sSYSTEM->sCONFIG = $this->config;
    }

    

    private function checkPrice(array $data, Order $order, ShopContextInterface $shopContext): array
    {
        $orderListProductService = $this->container->get(OrderListProductServiceInterface::class);

        if (!$orderListProductService instanceof OrderListProductServiceInterface) {
            return $data;
        }

        $shopRegistrationService = $this->container->get(ShopRegistrationServiceInterface::class);
        $shop = $order->getShop();
        $shopRegistrationService->registerShop($shop);

        $listProduct = $orderListProductService->getList([$data['articleNumber']]$shopContext);
        if (empty($listProduct)) {
            return $data;
        }

        $prices = $listProduct[$data['articleNumber']]['prices'];
        if (\is_array($prices)) {
            foreach ($prices as $graduatedPrice) {
                if ($data['quantity'] >= $graduatedPrice['valFrom'] && ($data['quantity'] <= $graduatedPrice['valTo'] || $graduatedPrice['valTo'] === null)) {
                    $data['price'] = $graduatedPrice['price_numeric'];
                    
            if ($shop->getBasePath() === null) {
                $shop->setBasePath('');
            }

            $request->setSecure($shop->getSecure());
            $request->setBasePath($shop->getBasePath());
            $request->setBaseUrl($shop->getBaseUrl());
            $request->setHttpHost($shop->getHost());
        }

        $this->validateShop($shop);
        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);
    }

    /** * @return void */
    public function onRouteShutdown(Enlight_Controller_EventArgs $args)
    {
        $request = $args->getRequest();
        $response = $args->getResponse();

        if (!Shopware()->Container()->initialized('shop')) {
            
if (empty($user['email'])) {
            return;
        }

        $shop = $this->getShopRepository()->getActiveById($user['language']);
        if ($shop === null) {
            return;
        }

        session_write_close();

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

        $session = $this->get('session');
        $session->clear();
        $session->migrate(true);

        Shopware()->Session()->offsetSet('sessionId', $session->getId());
        Shopware()->Container()->set('sessionid', $session->getId());

        Shopware()->Session()->set('Admin', true);
        Shopware()->System()->_POST = [
            'email' => $user['email'],
            

        $strategy = Shopware()->Config()->get('seoRefreshStrategy', self::STRATEGY_LIVE);

        if ($strategy !== self::STRATEGY_CRON_JOB) {
            return true;
        }

        $shops = Shopware()->Db()->fetchCol('SELECT id FROM s_core_shops WHERE active = 1');

        $currentTime = new DateTime();

        $this->SeoIndex()->registerShop($shops[0]);
        $this->RewriteTable()->sCreateRewriteTableCleanup();

        foreach ($shops as $shopId) {
            $repository = Shopware()->Models()->getRepository(Shop::class);
            $shop = $repository->getActiveById($shopId);
            if ($shop === null) {
                throw new Exception('No valid shop id passed');
            }

            $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);
            Shopware()->Modules()->Categories()->baseId = $shop->getCategory()->getId();

            [,

    private function setupContext(int $shopId): void
    {
        $shopRepository = $this->getContainer()->get(ModelManager::class)->getRepository(ShopModel::class);

        $shop = $shopRepository->getActiveById($shopId);
        if (!$shop instanceof ShopModel) {
            throw new ModelNotFoundException(ShopModel::class$shopId);
        }

        $this->getContainer()->get(ShopRegistrationServiceInterface::class)->registerShop($shop);
    }

    /** * Resolves ids to models * * @throws CustomValidationException when attempting to change a customer id on an address * @throws NotFoundException if the given customer id in the data array is invalid */
    private function prepareAddressData(array $data, ?int $customerId = null, bool $filter = false): array
    {
        /* * Check if the API user tries to set an address to a *different* customer * if the customer is the same as the owner of the address, then no exception will be thrown * if it is different, depending on the case, an \InvalidArgumentException or a \LogicException will be thrown */
$attributeLoader = $this->get(DataLoaderInterface::class);
            $notify['attribute'] = $attributeLoader->load('s_articles_notification_attributes', $notify['id']);

            $shop = $modelManager->getRepository(Shop::class)->getActiveById($notify['language']);

            // Continue if shop is inactive or deleted             if ($shop === null) {
                continue;
            }

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

            $shopContext = Context::createFromShop($shop$this->get(Shopware_Components_Config::class));
            $this->get(RouterInterface::class)->setContext($shopContext);
            $sContext = $this->get(ContextServiceInterface::class)->createShopContext($notify['language']);

            $productInformation = $this->get(ListProductServiceInterface::class)->get($notify['ordernumber']$sContext);

            if (empty($productInformation)) {
                continue;
            }

            
$module = Shopware()->Modules()->RewriteTable();
        $shops = $emotion->getShops();
        $emotionData = [
            'id' => $emotion->getId(),
            'name' => $emotion->getName(),
        ];

        $translator = $this->getTranslation();
        $routerCampaignTemplate = Shopware()->Config()->get('routerCampaignTemplate');

        foreach ($shops as $shop) {
            $seoIndexer->registerShop($shop->getId());
            $fallbackShopId = null;
            $fallbackShop = $shop->getFallback();
            if (!empty($fallbackShop)) {
                $fallbackShopId = $fallbackShop->getId();
            }
            // Make sure a template is available             $module->baseSetup();
            $module->sCreateRewriteTableForSingleCampaign($translator$shop->getId()$fallbackShopId$emotionData$routerCampaignTemplate);
        }
    }

    
namespace Shopware\Controllers\Backend;

use Shopware\Bundle\StoreFrontBundle\Struct\Search\CustomSorting;
use Shopware\Models\Shop\Shop;
use Shopware_Controllers_Backend_ExtJs;

class ManualSorting extends Shopware_Controllers_Backend_ExtJs
{
    public function preDispatch()
    {
        parent::preDispatch();
        $this->get(\Shopware\Components\ShopRegistrationServiceInterface::class)->registerShop($this->getModelManager()->getRepository(Shop::class)->getActiveDefault());
    }

    public function listAction(int $start = 0, int $limit = 25, int $categoryId = 3, int $sortingId = 1): void
    {
        $sorting = $this->getSorting($categoryId$sortingId);

        $products = $this->get(\Shopware\Components\ManualSorting\ProductLoaderInterface::class)->load($categoryId$start$limit$sorting);

        $this->View()->assign($products);
    }

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