Config example

static::assertImportExportSucceeded($progress$this->getInvalidLogContent($progress->getInvalidRecordsLogId()));

        $filesystem = $this->getContainer()->get('shopware.filesystem.private');
        $logfile = $this->getLogEntity($progress->getLogId())->getFile();
        static::assertInstanceOf(ImportExportFileEntity::class$logfile);
        $csv = $filesystem->read($logfile->getPath());
        static::assertIsString($csv);
        $resource = fopen('data://text/plain;base64,' . base64_encode($csv), 'rb');
        static::assertIsResource($resource);
        $reader = new CsvReader();
        $record = null;
        foreach ($reader->read(new Config([][][])$resource, 0) as $row) {
            $record = $row;

            break;
        }

        static::assertNotNull($record);
        static::assertEquals('foo', $record['custom_field_1']);
        static::assertEquals('23', $record['custom_field_2']);
        static::assertEquals('1', $record['custom_field_3']);
        static::assertEquals('2021-12-12T12:00:00+00:00', $record['custom_field_4']);
        static::assertEquals('["abc8b8f701034e8dbea72ac0fc32521e","c5c8b8f701034e8dbea72ac0fc32521e"]', $record['custom_field_5']);
        

    public function checkIsBot($userAgent)
    {
        $userAgent = preg_replace('/[^a-z]/', '', strtolower($userAgent));
        if (empty($userAgent)) {
            return false;
        }
        $result = false;
        $bots = (string) preg_replace('/[^a-z;]/', '', strtolower($this->Config()->get('botBlackList')));
        $bots = explode(';', $bots);
        if (str_replace($bots, '', $userAgent) !== $userAgent) {
            $result = true;
        }

        return $result;
    }

    /** * @param Enlight_Controller_Request_Request $request * @param Enlight_Controller_Response_ResponseHttp $response * * @return void */


    public function get(string $key): mixed
    {
        return $this->parameters[$key] ?? null;
    }

    public static function fromLog(ImportExportLogEntity $log): self
    {
        $config = $log->getConfig();

        return new Config(
            $config['mapping'] ?? [],
            $config['parameters'] ?? [],
            $config['updateBy'] ?? []
        );
    }
}
'mediaFolderId' => Uuid::randomHex(),
            'url' => 'https://shopware.test/foo/bar/media.png',
            'private' => false,
            'mediaType' => 'image/png',
            'translations' => [
                'DEFAULT' => $mediaTranslations,
            ],
        ];

        $mapping = $this->getDefaultMapping(MediaDefinition::ENTITY_NAME);

        $config = new Config($mapping[][]);
        $mappingPipe = new KeyMappingPipe($mapping, true);
        $pipeInResult = $mappingPipe->in($config$media);
        static::assertInstanceOf(\Traversable::class$pipeInResult);
        $mappedMedia = iterator_to_array($pipeInResult);

        static::assertSame($media['id']$mappedMedia['id']);
        static::assertSame($media['mediaFolderId']$mappedMedia['folder_id']);
        static::assertSame($media['url']$mappedMedia['url']);
        static::assertSame($media['private']$mappedMedia['private']);
        static::assertSame($media['mediaType']$mappedMedia['type']);

        
if ($shopId !== null) {
            $builder->andWhere('(blog.shopIds LIKE :shopId OR blog.shopIds IS NULL)')
                ->setParameter('shopId', '%|' . $shopId . '|%');
        }

        if (!empty($blogCategoryIds)) {
            $builder->andWhere('blog.categoryId IN (:categoryIds)')
                ->setParameter('categoryIds', $blogCategoryIds, Connection::PARAM_INT_ARRAY);
        }

        if ($shopId && Shopware()->Config()->get('displayOnlySubShopBlogComments')) {
            $builder
                ->leftJoin('blog.comments', 'comments', Join::WITH, 'comments.active = 1 AND (comments.shopId IS NULL OR comments.shopId = :commentShopId)')
                ->setParameter('commentShopId', $shopId);
        } else {
            $builder->leftJoin('blog.comments', 'comments', Join::WITH, 'comments.active = 1');
        }

        if (!empty($filter)) {
            $builder->addFilter($filter);
        }

        
/** @var \DOMElement $action */
        $action = $actions->getElementsByTagName('flow-action')->item(0);
        /** @var \DOMElement $meta */
        $meta = $action->getElementsByTagName('meta')->item(0);

        $meta = Metadata::fromXml($meta);

        $parameter = new Parameter(['id' => 'key']);
        $this->parameters = new Parameters([$parameter]);
        $this->headers = new Headers([$parameter]);
        $inputFiled = new InputField(['id' => 'key']);
        $this->config = new Config([$inputFiled]);

        $this->action = new Action([
            'meta' => $meta,
            'headers' => $this->headers,
            'parameters' => $this->parameters,
            'config' => $this->config,
        ]);
    }

    public function testToArray(): void
    {
        
$this->get('session')->invalidate();
        }
    }

    /** * Event listener method * * @return \sSystem */
    public function onInitResourceSystem(Enlight_Event_EventArgs $args)
    {
        $config = Shopware()->Config();

        $request = Shopware()->Front()->Request();
        $system = new sSystem($request);

        Shopware()->Container()->set('system', $system);

        $system->sMODULES = Shopware()->Modules();
        $system->sSMARTY = Shopware()->Template();
        $system->sCONFIG = $config;
        $system->sMailer = Shopware()->Container()->get('mail');

        
$productDefinition = $this->getContainer()->get(ProductDefinition::class);

        $serializer = new ProductSerializer(
            $this->visibilityRepository,
            $this->salesChannelRepository,
            $this->productMediaRepository,
            $this->productConfiguratorSettingRepository
        );
        $serializer->setRegistry($this->getContainer()->get(SerializerRegistry::class));

        $serialized = iterator_to_array($serializer->serialize(new Config([][][])$productDefinition$product));

        static::assertNotEmpty($serialized);

        static::assertSame($product->getId()$serialized['id']);
        static::assertSame($product->getTranslations()->first()->getName()$serialized['translations']['DEFAULT']['name']);
        static::assertSame((string) $product->getStock()$serialized['stock']);
        static::assertSame($product->getProductNumber()$serialized['productNumber']);
        static::assertSame('1', $serialized['active']);
        static::assertStringContainsString('shopware-logo.png', $serialized['cover']['media']['url']);
        static::assertStringContainsString('shopware-icon.png', $serialized['media']);
        static::assertStringContainsString('shopware-background.png', $serialized['media']);
        
Shopware_Components_Config $config = null,
        ?Enlight_Components_Session_Namespace $session = null,
        ?Enlight_Controller_Front $front = null,
        ?Shopware_Components_Modules $moduleManager = null,
        ?sSystem $systemModule = null,
        ?ContextServiceInterface $contextService = null,
        ?AdditionalTextServiceInterface $additionalTextService = null
    ) {
        $this->db = $db ?: Shopware()->Db();
        $this->eventManager = $eventManager ?: Shopware()->Events();
        $this->snippetManager = $snippetManager ?: Shopware()->Snippets();
        $this->config = $config ?: Shopware()->Config();
        $this->session = $session ?: Shopware()->Session();
        $this->front = $front ?: Shopware()->Front();
        $this->moduleManager = $moduleManager ?: Shopware()->Modules();
        $this->sSYSTEM = $systemModule ?: Shopware()->System();

        $this->contextService = $contextService;
        $this->additionalTextService = $additionalTextService;
        $this->connection = Shopware()->Container()->get(Connection::class);

        if ($this->contextService === null) {
            $this->contextService = Shopware()->Container()->get(ContextServiceInterface::class);
        }

    public function preDispatch()
    {
        $this->Response()->setHeader('x-robots-tag', 'noindex');
    }

    /** * @return void */
    public function init()
    {
        $this->config = Shopware()->Config();
        $this->articleModule = Shopware()->Modules()->Articles();
        $this->marketingModule = Shopware()->Modules()->Marketing();
    }

    /** * Show similar viewed articles */
    public function viewedAction()
    {
        $productId = (int) $this->Request()->getParam('articleId');
        $maxPages = (int) $this->config->get('similarViewedMaxPages', 10);
        
->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;
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Init template method * * Initializes the template using the mailing data. * * @param array $mailing * * @return Enlight_Template_Manager */
return $data;
    }

    /** * Returns a list of all product detail templates as array. * * @return array */
    protected function getTemplates()
    {
        $config = Shopware()->Config()->get('detailTemplates');
        $data = [];
        foreach (explode(';', $config) as $path) {
            list($id$name) = explode(':', $path);
            $data[] = ['id' => $id, 'name' => $name];
        }

        return $data;
    }

    /** * Internal helper function which returns default data for a new product. * * @return array */
        if (!$this->logEntity->getInvalidRecordsLogId() && $file instanceof ImportExportFileEntity) {
            $pathInfo = pathinfo($file->getOriginalName());
            $newName = $pathInfo['filename'] . '_failed.' . ($pathInfo['extension'] ?? '');

            $newPath = $file->getPath() . '_invalid';

            $config = $this->logEntity->getConfig();
            $config['mapping'][] = [
                'key' => '_error',
                'mappedKey' => '_error',
            ];
            $config = new Config($config['mapping']$config['parameters'] ?? []$config['updateBy'] ?? []);

            if ($this->logEntity->getProfileId() !== null) {
                $failedImportLogEntity = $this->importExportService->prepareExport(
                    $context,
                    $this->logEntity->getProfileId(),
                    $file->getExpireDate(),
                    $newName,
                    $config->jsonSerialize(),
                    $newPath,
                    ImportExportLogEntity::ACTIVITY_INVALID_RECORDS_EXPORT
                );

                
        if ($customer->getActive() && (!$customer->getFirstLogin() || $customer->getFirstLogin()->getTimestamp() === 0)) {
            $customer->setFirstLogin(new DateTime());
        }

        $password = $this->Request()->getParam('newPassword');

        // Encode the password with md5         if (!empty($password)) {
            $customer->setPassword($password);
        }

        if (!$customer->getNumber() && Shopware()->Config()->get('shopwareManagedCustomerNumbers')) {
            /** @var NumberRangeIncrementerInterface $incrementer */
            $incrementer = Shopware()->Container()->get(NumberRangeIncrementerInterface::class);
            $customer->setNumber((string) $incrementer->increment('user'));
        }

        $this->getManager()->persist($customer);
        $this->getManager()->flush();

        $this->View()->assign([
            'success' => true,
            'data' => $this->getCustomer($customer->getId()),
        ]);


    /** * @dataProvider provideCategoryPaths */
    public function testCategoryPathToAssignment(array $categoriesToWrite, array $record, array $row, array $assertion): void
    {
        $context = Context::createDefaultContext();

        $this->categoryRepository->upsert($categoriesToWrite$context);

        $event = new ImportExportBeforeImportRecordEvent($record$rownew Config([]['sourceEntity' => ProductDefinition::ENTITY_NAME][])$context);

        $subscriber = new ProductCategoryPathsSubscriber($this->categoryRepository, $this->getContainer()->get(SyncService::class));

        $subscriber->categoryPathsToAssignment($event);

        static::assertSame($assertion$event->getRecord()['categories']);
    }
}
Home | Imprint | This part of the site doesn't use cookies.