update example

$sqlParams['content_html'] = $contentHtml;
        }

        if ($contentPlain !== null) {
            $sqlParams['content_plain'] = $contentPlain;
        }

        if ($senderName !== null) {
            $sqlParams['sender_name'] = $senderName;
        }

        $connection->update('mail_template_translation', $sqlParams[
            'mail_template_id' => $mailTemplateId,
            'language_id' => $langId,
            'updated_at' => null,
        ]);
    }

    private function getOrderConfirmationHtmlTemplateEn(): string
    {
        return '<div style="font-family:arial; font-size:12px;"> {% set currencyIsoCode = order.currency.isoCode %} {{order.orderCustomer.salutation.letterName }} {{order.orderCustomer.firstName}} {{order.orderCustomer.lastName}},<br> <br> Thank you for your order at {{ salesChannel.name }} (Number: {{order.orderNumber}}) on {{ order.orderDateTime|date }}.<br> <br> <strong>Information on your order:</strong><br> <br> <table width="80%" border="0" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;"> <tr> <td bgcolor="#F7F7F2" style="border-bottom:1px solid #cccccc;"><strong>Pos.</strong></td> <td bgcolor="#F7F7F2" style="border-bottom:1px solid #cccccc;"><strong>Description</strong></td> <td bgcolor="#F7F7F2" style="border-bottom:1px solid #cccccc;"><strong>Quantities</strong></td> <td bgcolor="#F7F7F2" style="border-bottom:1px solid #cccccc;"><strong>Price</strong></td> <td bgcolor="#F7F7F2" style="border-bottom:1px solid #cccccc;"><strong>Total</strong></td> </tr> {% for lineItem in order.lineItems %} <tr> <td style="border-bottom:1px solid #cccccc;">{{ loop.index }} </td> <td style="border-bottom:1px solid #cccccc;"> {{ lineItem.label|u.wordwrap(80) }}<br/> {% if lineItem.payload.options|length >= 1 %} {% for option in lineItem.payload.options %} {{ option.group }}: {{ option.option }} {% if lineItem.payload.options|last != option %} {{ " | " }} {% endif %} {% endfor %} <br/> {% endif %} {% if lineItem.payload.productNumber is defined %}Art. No.: {{ lineItem.payload.productNumber|u.wordwrap(80) }}{% endif %} </td> <td style="border-bottom:1px solid #cccccc;">{{ lineItem.quantity }}</td> <td style="border-bottom:1px solid #cccccc;">{{ lineItem.unitPrice|currency(currencyIsoCode) }}</td> <td style="border-bottom:1px solid #cccccc;">{{ lineItem.totalPrice|currency(currencyIsoCode) }}</td> </tr> {% endfor %} </table> {% set delivery = order.deliveries.first %} <p> <br> <br> Shipping costs: {{order.deliveries.first.shippingCosts.totalPrice|currency(currencyIsoCode) }}<br> Net total: {{ order.amountNet|currency(currencyIsoCode) }}<br> {% for calculatedTax in order.price.calculatedTaxes %} {% if order.taxStatus is same as(\'net\') %}plus{% else %}including{% endif %} {{ calculatedTax.taxRate }}% VAT. {{ calculatedTax.tax|currency(currencyIsoCode) }}<br> {% endfor %} <strong>Total gross: {{ order.amountTotal|currency(currencyIsoCode) }}</strong><br> <br> <strong>Selected payment type:</strong> {{ order.transactions.first.paymentMethod.name }}<br> {{ order.transactions.first.paymentMethod.description }}<br> <br> <strong>Selected shipping type:</strong> {{ delivery.shippingMethod.name }}<br> {{ delivery.shippingMethod.description }}<br> <br> {% set billingAddress = order.addresses.get(order.billingAddressId) %} <strong>Billing address:</strong><br> {{ billingAddress.company }}<br> {{ billingAddress.firstName }} {{ billingAddress.lastName }}<br> {{ billingAddress.street }} <br> {{ billingAddress.zipcode }} {{ billingAddress.city }}<br> {{ billingAddress.country.name }}<br> <br> <strong>Shipping address:</strong><br> {{ delivery.shippingOrderAddress.company }}<br> {{ delivery.shippingOrderAddress.firstName }} {{ delivery.shippingOrderAddress.lastName }}<br> {{ delivery.shippingOrderAddress.street }} <br> {{ delivery.shippingOrderAddress.zipcode}} {{ delivery.shippingOrderAddress.city }}<br> {{ delivery.shippingOrderAddress.country.name }}<br> <br> {% if billingAddress.vatId %} Your VAT-ID: {{ billingAddress.vatId }} In case of a successful order and if you are based in one of the EU countries, you will receive your goods exempt from turnover tax.<br> {% endif %} <br/> You can check the current status of your order on our website under "My account" - "My orders" anytime: {{ path(\'frontend.account.edit-order.page\', { \'orderId\': order.id}) }} </br> If you have any questions, do not hesitate to contact us. </p> <br> </div> ';
->execute();

// Update core.extension. $extensions = $connection->select('config')
  ->fields('config', ['data'])
  ->condition('collection', '')
  ->condition('name', 'core.extension')
  ->execute()
  ->fetchField();
$extensions = unserialize($extensions);
$extensions['module']['update_test_semver_update_n'] = 8000;
$connection->update('config')
  ->fields([
    'data' => serialize($extensions),
  ])
  ->condition('collection', '')
  ->condition('name', 'core.extension')
  ->execute();
$number = (int) str_replace('config_test_', '', $config_entity->id());
      // Only update even numbered entities.       if ($number % 2 == 0) {
        $config_entity->set('label', $config_entity->label . ' (updated)');
        return TRUE;
      }
      return FALSE;
    };

    // This should run against the first 10 entities. The even numbered labels     // will have been updated.     $updater->update($sandbox, 'config_test', $callback);
    $entities = $storage->loadMultiple();
    $this->assertEquals('config_test_8 (updated)', $entities['config_test_8']->label());
    $this->assertEquals('config_test_9', $entities['config_test_9']->label());
    $this->assertEquals('config_test_10', $entities['config_test_10']->label());
    $this->assertEquals('config_test_14', $entities['config_test_14']->label());
    $this->assertEquals(15, $sandbox['config_entity_updater']['count']);
    $this->assertEquals('config_test', $sandbox['config_entity_updater']['entity_type']);
    $this->assertCount(5, $sandbox['config_entity_updater']['entities']);
    $this->assertEquals(10 / 15, $sandbox['#finished']);

    // Update the rest.
$context = Context::createDefaultContext();
        $criteria = new Criteria();
        $criteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_OR, [
            new EqualsFilter('filters.type', 'until'),
            new EqualsFilter('filters.type', 'since'),
        ]));

        /** @var array<string> $streamIds */
        $streamIds = $this->productStreamRepository->searchIds($criteria$context)->getIds();
        $data = array_map(fn (string $id) => ['id' => $id]$streamIds);

        $this->productStreamRepository->update($data$context);
    }
}
foreach ($roles as $role) {
            $currentPrivileges = \json_decode((string) $role['privileges'], true, 512, \JSON_THROW_ON_ERROR);
            $newPrivileges = array_values($this->fixRolePrivileges($currentPrivileges));

            if ($currentPrivileges === $newPrivileges) {
                continue;
            }

            $role['privileges'] = json_encode($newPrivileges, \JSON_THROW_ON_ERROR);
            $role['updated_at'] = (new \DateTimeImmutable())->format(Defaults::STORAGE_DATE_FORMAT);

            $connection->update('acl_role', $role['id' => $role['id']]);
        }
    }

    public function updateDestructive(Connection $connection): void
    {
        // implement update destructive     }

    /** * @param list<string> $rolePrivileges * * @return list<string> */
$data['data'] = serialize($job->getData());
        $data['active'] = $job->getActive() ? '1' : '0';
        $data['next'] = $job->getNext() ? $job->getNext()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['start'] = $job->getStart() ? $job->getStart()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['end'] = $job->getEnd() ? $job->getEnd()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['disable_on_error'] = $job->getDisableOnError() ? '1' : '0';
        $data['name'] = $job->getName();

        if ($job->getId() === null) {
            $this->connection->insert($this->tableName, $data);
        } else {
            $this->connection->update(
                $this->tableName,
                $data,
                ['id' => $job->getId()]
            );
        }
    }

    /** * {@inheritdoc} */
    public function startJob(Enlight_Components_Cron_Job $job)
    {
static::assertIsString($png->getFileName());
        $this->fileSaver->renameMedia($png->getId()$png->getFileName()$context);
        static::assertTrue($this->getPublicFilesystem()->has($mediaPath));
    }

    public function testRenameMediaRenamesOldFileAndThumbnails(): void
    {
        $context = Context::createDefaultContext();
        $this->setFixtureContext($context);

        $png = $this->getPng();
        $this->mediaRepository->update([[
            'id' => $png->getId(),
            'thumbnails' => [
                [
                    'width' => 100,
                    'height' => 100,
                    'highDpi' => false,
                ],
            ],
        ]]$context);
        $oldMediaPath = $this->urlGenerator->getRelativeMediaUrl($png);
        $oldThumbnailPath = $this->urlGenerator->getRelativeThumbnailUrl($png(new MediaThumbnailEntity())->assign(['width' => 100, 'height' => 100]));

        
'id' => $ids->get('filters'),
                    'type' => 'equals',
                    'field' => $customField,
                    'value' => '1',
                ],
            ],
        ];

        $writtenEvent = $this->productStreamRepository->create([$stream], Context::createDefaultContext());

        $productStreamIndexer = $this->getContainer()->get(ProductStreamIndexer::class);
        $message = $productStreamIndexer->update($writtenEvent);
        static::assertInstanceOf(EntityIndexingMessage::class$message);
        $productStreamIndexer->handle($message);

        $migration = new Migration1620374229UpdateCustomFieldNameInProductStreamTable();
        $migration->update($this->getContainer()->get(Connection::class));

        $criteria = new Criteria([$ids->get('stream')]);
        $criteria->addAssociation('filters');
        /** @var ProductStreamEntity $stream */
        $stream = $this->productStreamRepository->search($criteria, Context::createDefaultContext())->first();

        
public function testLandingPageUpdate(): void
    {
        $salesChannelId = Uuid::randomHex();
        $salesChannelContext = $this->createStorefrontSalesChannelContext($salesChannelId, 'test');

        $id = $this->createTestLandingPage(['salesChannels' => [
            [
                'id' => $salesChannelContext->getSalesChannelId(),
            ],
        ]]);

        $this->landingPageRepository->update(
            [
                [
                    'id' => $id,
                    'url' => 'newUrl',
                ],
            ],
            $salesChannelContext->getContext()
        );

        $criteria = new Criteria([$id]);
        $criteria->addAssociation('seoUrls');

        
return new Response('', Response::HTTP_NO_CONTENT);
    }

    #[Route('/update/_run', name: 'update_run', methods: ['POST'])]     public function run(Request $request): Response
    {
        $version = $request->query->get('shopwareVersion', '');

        $shopwarePath = $this->recoveryManager->getShopwareLocation();

        ProjectComposerJsonUpdater::update(
            $shopwarePath . '/composer.json',
            $version
        );

        return $this->streamedCommandResponseGenerator->runJSON([
            $this->recoveryManager->getPhpBinary($request),
            '-dmemory_limit=1G',
            $this->recoveryManager->getBinary(),
            'update',
            '-d',
            $shopwarePath,
            

    public function __construct(
        private readonly FilesystemOperator $filesystem,
        private readonly EntityRepository $fileRepository
    ) {
    }

    public function regenerateToken(Context $context, string $fileId): string
    {
        $token = ImportExportFileEntity::generateAccessToken();

        $this->fileRepository->update(
            [['id' => $fileId, 'accessToken' => $token]],
            $context
        );

        return $token;
    }

    public function createFileResponse(Context $context, string $fileId, string $accessToken): Response
    {
        $entity = $this->findFile($context$fileId);

        
$admin = TestUser::createNewTestUser($connection['product:read']);

        $admin->authorizeBrowser($browser);

        $browser->request('POST', '/api/search/product', []);
        $response = $browser->getResponse();
        static::assertSame(Response::HTTP_OK, $response->getStatusCode()(string) $response->getContent());

        $userRepository = $this->getContainer()->get('user.repository');

        // Change user password         $userRepository->update([[
            'id' => $admin->getUserId(),
            'password' => Uuid::randomHex(),
        ]], Context::createDefaultContext());

        $browser->request('POST', '/api/search/product', []);
        $response = $browser->getResponse();

        static::assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode()(string) $response->getContent());
        $jsonResponse = json_decode((string) $response->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals('Access token is expired', $jsonResponse['errors'][0]['detail']);
    }

    
    \Drupal::service('update.update_hook_registry')->setInstalledVersion('post_update_test_failing', 8000);

    // Update core.extension.     $extensions = $connection->select('config')
      ->fields('config', ['data'])
      ->condition('collection', '')
      ->condition('name', 'core.extension')
      ->execute()
      ->fetchField();
    $extensions = unserialize($extensions);
    $extensions['module']['post_update_test_failing'] = 8000;
    $connection->update('config')
      ->fields([
        'data' => serialize($extensions),
      ])
      ->condition('collection', '')
      ->condition('name', 'core.extension')
      ->execute();
  }

  /** * Tests hook_post_update_NAME(). */
  
yield 'Cache invalidated if review updated' => [
            $ids,
            function DIdsCollection $ids, ContainerInterface $container): void {
                $data = self::review($ids->get('review-update')$ids->get('product'), 'Title', 'Content');

                $container->get('product_review.repository')->create([$data], Context::createDefaultContext());
            },
            function DIdsCollection $ids, ContainerInterface $container): void {
                $data = ['id' => $ids->get('review-update'), 'title' => 'updated'];

                $container->get('product_review.repository')->update([$data], Context::createDefaultContext());
            },
            2,
        ];

        yield 'Cache invalidated if review deleted' => [
            $ids,
            function DIdsCollection $ids, ContainerInterface $container): void {
                $data = self::review($ids->get('to-delete')$ids->get('product'), 'Title', 'Content');

                $container->get('product_review.repository')->create([$data], Context::createDefaultContext());
            },
            

        ];

        $migration = new Migration1691662140MigrateAvailableStock();

        $this->createProduct($this->ids->getBytes('p1'), 5, 7, true);
        $this->createProduct($this->ids->getBytes('p2'), 6, 6, true);
        $this->createProduct($this->ids->getBytes('p3'), 8, 8, false);
        $this->createProduct($this->ids->getBytes('p4'), 8, 10, false);
        $this->createProduct($this->ids->getBytes('p5'), 8, -6, true);

        $migration->update($this->connection);

        static::assertSame(
            $expected,
            $this->connection->fetchAllAssociative('SELECT LOWER(HEX(id)) as id, stock, available_stock FROM product ORDER BY created_at ASC')
        );

        $migration->update($this->connection);

        static::assertSame(
            $expected,
            $this->connection->fetchAllAssociative('SELECT LOWER(HEX(id)) as id, stock, available_stock FROM product ORDER BY created_at ASC')
        );
Home | Imprint | This part of the site doesn't use cookies.