Check if a category exists Shopware 6

Advertisements Check if a category existsyour text I have such code $categoryService = $this->container->get(‘category.repository’); $newCategory = [ ‘name’ => ‘Profi-Shop’, ‘parentId’ => null, ‘customFields’ => [ ], ]; $categoryService->create([$newCategory], $context->getContext()); It is executed every time. How to execute it only if there is no such category >Solution : You need to check if your category… Read More Check if a category exists Shopware 6

How to recreate the orders context in order to send out emails in Shopware 6

Advertisements I am creating a console task to ship orders based on XML files (How to add a shipment (tracking code + change status to shipped) programmatically? ) which I import. Currently I am using $context = Context::createDefaultContext(); And create a shipment: $this->deliveryRepository->update([ [ ‘id’ => $deliveryId, ‘trackingCodes’ => [$trackingCode] ] ], $context); $context->addExtension( MailSendSubscriber::MAIL_CONFIG_EXTENSION,… Read More How to recreate the orders context in order to send out emails in Shopware 6

Override many to many association instead of adding new entries

Advertisements is it possible to override the entries in a many-to-many association via the admin API? I tried it with a basic update (PATCH) request and instead of overriding the association it just adds the new ones. Before Update: [GET] {apiBasePath}/product/91d7e5d1e77b48ae957d90f9a5210465 { "data": { "id": "91d7e5d1e77b48ae957d90f9a5210465", "properties": [ { "id": "4a893ae509cc42ce9084a2ac55753bd6" } ] } }… Read More Override many to many association instead of adding new entries

How do i update a nested value via. the API?

Advertisements How do i update a nested value via. the API? i want to update my custom field custom_product_fields_magento_product_id Request path: /api/product/f9529c4f40e94fa6ae7439f97090cc9e Request type: PATCH Body: { "translated.customFields.custom_product_fields_magento_product_id" : "123" } Where am i going wrong? i can easily update product values that arent nested, like "productNumber" : "value" >Solution : You can use {… Read More How do i update a nested value via. the API?