问题标签 [shopware6]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1060 浏览

symfony - Shopware 6 计划任务未运行

我没有在我的模块中运行计划任务。我遵循了文档:

https://docs.shopware.com/en/shopware-platform-dev-en/how-to/scheduled-tasks

和:

https://docs.shopware.com/en/shopware-platform-dev-en/references-internals/core/module/tasks

但似乎任务永远不会运行(我添加了日志记录以确保)。该任务显示在“scheduled_task”数据库表中,状态为“queued”,last_execution_time 为“NULL”。然而,看起来其他计划任务(如 delete_newsletter_recipient_task、requeue_dead_messages、product_export_generate_task、shopware.sitemap_generate 和 shopware.elasticsearch.create.alias)正在运行。此外,如果我手动运行“DownloadFeedTaskHandler”“运行”方法,代码将按预期工作。

我发现这个(德语)论坛帖子或多或少有相同的问题,但没有解决方案:

https://forum.shopware.com/discussion/67988/scheduled-task-hat-den-queued-status

我检查了 dead_messages 表,但它没有任何记录。

知道如何从这里出发吗?

我的相关文件如下所示:

自定义/插件/AWSamplePlugin/src/Resources/config/services.xml:

自定义/插件/AWSamplePlugin/src/ScheduledTask/DownloadFeedTask.php:

自定义/插件/AWSamplePlugin/src/ScheduledTask/DownloadFeedTaskHandler.php:

0 投票
1 回答
399 浏览

shopware - Shopware6:缺少插件配置

我正在编写我的第一个 Shopware 6 插件并遵循此操作指南

但是插件的导航条目不会显示。(URL:admin#/sw/settings/index),菜单看起来像这样: 在此处输入图像描述但它应该看起来像这样:在此处输入图像描述

我的插件处于活动状态(在后端签入),表已创建,所以我猜它已加载。

我将教程中的 config.xml 文件复制到我的插件中并对其进行了验证(只是为了确定)。

那么显示Plugin导航入口的前提是什么呢?

0 投票
1 回答
1217 浏览

custom-fields - Shopware 6 具有自定义字段类型的产品

在后端我定义了几个自定义字段,它们都是选择类型,这些都连接到产品。现在我想在详细信息页面中显示 product.customFields 的选定选项的值。

我可以转储 product.customFields 并获得如下数组:

现在如何获取存储在 custom_field 中的值作为 json 对象,用 name = Technical_name_select_field_1 和 config = {{"type": "select", "label": {"de-DE": "Wert für option xxx", "en-US": "value for option xxx", "nl-NL": "Waarde optie xxx" ), "value": "option_xxx" } 等等。

当我在模板中写 {{ attribute(product.translated.customFields,'technical_name_select_field_1')|sw_sanitize }} 时,我得到了 option_xxx 打印。但我想查看标签值“选项 xxx 的值”等。

0 投票
2 回答
1162 浏览

symfony - Shopware 6 后端控制器路径

在 Shopware 6 中,我想/admin使用 JavaScript 从后端/管理页面调用后端 () API 控制器。使用相对路径的正确方法是什么,可能带有内置的 getter 函数?

/api/v1当商店在时才有效/,但在子文件夹中时无效。

0 投票
1 回答
70 浏览

shopware - 在 Shopware6 框架/上下文中运行代码的最简单方法

在开发 shopware6 模块时,我有时想测试几行代码,看看我是否朝着正确的方向前进。假设我想运行以下代码(忽略我将使用 xDebug)

我如何/在哪里可以合并它而不产生太多开销,并且不改变 /vendor 中的任何内容?我在 index.php 中尝试过,但是一旦我们加载了框架,就已经有几个可以采用的路径了。

谢谢

0 投票
1 回答
2937 浏览

php - How to extend Shopware 6 controller action

I am building a plugin for Shopware 6 and cannot seem to find any documentation as to how to extend an existing controller action. I found this How to add an Action to Account Controller in Shopware but it seems to refer to Shopware 5 and I am not sure I can use it that way in Shopware 6.

The controller action I want to extend is \Shopware\Storefront\Controller\AddressController::saveAddress - in my case I want to add custom address validation that would use a service in my plugin where a request to 3rd party API would be made, if the address is correct then allow the address, if not then return an error. Perhaps it is better to instead extend \Shopware\Core\Checkout\Customer\SalesChannel\AddressService::save but I have no clue for now (I am new to Shopware in general). Extending the service would mean I do not have to override the whole action logic so that it contains my check in the middle. Or perhaps there is an event I can use for address saving (same thing, can't find a good source/list of events for Shopware6).

There seem to be guides here: https://docs.shopware.com/en/shopware-platform-dev-en/developer-guide/controller and here: https://docs.shopware.com/en/shopware-platform-dev-en/how-to/custom-storefront-controller but these only describe how to make a new controller and it is not very useful to me since I do not want to add any new routes but use the existing one /account/address/create.

I would be very grateful for a code example of how to register the override in the plugin (config, xml) and how would the extending class look like. If it is not too much to ask the ideal answer would contain an example of:

  1. How to extend an action for existing controller.
  2. How to extend an existing service.
  3. Where to find which event is firing in a controller/service, subscribe to it and make it override default behaviour (like throw Shopware\Core\Framework\Validation\Exception\ConstraintViolationException).
0 投票
1 回答
754 浏览

plugins - 通过 composer 需要 shopware 6 插件

我正在为 Shopware 6 开发一个自定义插件。它不会位于 Shopware 商店,而是我们自己公司在 github 上的存储库。

我怎样才能让它安装到custom/plugins而不是vendor在我运行时composer require plugin/name

我尝试在插件的作曲家中进行设置"type": "shopware-plugin""type": "shopware-platform-plugin"但它仍然将其放入vendor.

有这个:https ://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-path-for-my-framework.md - 我宁愿指定一个正确的键入而不是使用手动设置安装路径installer-paths

您知道每种商店用品类型的含义吗?

我的作曲家版本是 1.10.8

0 投票
1 回答
140 浏览

shopware - 未知列_id on Shopware 6 翻译

完全按照官方教程创建带有翻译的 Shopware6 实体后,出现Unknown column "<tablename>_id"错误;表名似乎被解释为列名的一部分。

0 投票
1 回答
1035 浏览

shopware - 在运行时从外部 URL 加载 Shopware 6 店面中的任何地方的产品图像,而不将其保存在文件系统中

我在 saleschannel.product.load 事件的运行时从外部 URL 更改产品的图像。这一切都很好,但是在下订单时,它给出了关于的错误

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`sv3_dev`.`order_line_item`, CONSTRAINT `fk.order_line_item.cover_id` FOREIGN KEY (`cover_id`) REFERENCES `media` (`id`) ON UPDATE CASCADE)

我猜这是因为我用这样的自定义实现覆盖了产品的媒体实体,所以在插入订单行项目时它找不到媒体封面 ID:

有没有办法在店面各处的运行时动态更改图像?

由于某些版权条款不允许在商店中下载图像,我无法将图像/媒体保存在文件系统中。我们只能在运行时加载它。

0 投票
1 回答
105 浏览

vuejs2 - 在 Shopware 6 中的循环中使用内部组件不会为每个循环组件唯一地保留值

我正在使用v-for自定义组件并将项目作为道具传递。但问题是循环中的每个组件实例都采用相同的 item 属性。例如,在第一个循环中,组件字段具有文本“abc”,那么第二个循环组件也将具有相同的“abc”文本。如果我更改第二个中的文本,它也会在第一个组件中更改。有没有办法让每个循环的道具都独一无二?

例如,这是调用内部组件的代码:

在这个组件里面我有一个基本的形式

如果我不这样做,:valuev-model一旦元素失去焦点,输入的值就会消失。

如果我使用v-model,数据会保留在那里,但是两个(或循环中存在的多个)组件实例之间都有数据绑定,因此它违背了为多个组件设置循环的目的。如屏幕截图所示,我正在输入第二个组件,但它也更改了第一个组件的文本。

数据绑定问题

在上面的示例中,我将整个数组作为道具发送,但我也尝试使用单个field元素而不是fields