Pim-community-dev: 从浓缩页面导出产品 pdf 时出错

创建于 2020-06-16  ·  6评论  ·  资料来源: akeneo/pim-community-dev

:bug:我正在报告一个错误:bug:

Akeneo 版本:CE 4.0.31

从产品丰富页面下载 pdf 时,它会转到以下 url 并显示错误: http://<pimhost>/enrich/product/1018/download-pdf?dataLocale=en_US&dataScope=ecommerce

Impossible to invoke a method ("__toString") on a string variable ("Some value")
in vendor/akeneo/pim-community-dev/src/Akeneo/Pim/Enrichment/Bundle/Resources/views/Product/renderPdf.html.twig (line 118)

发生这种情况是因为对于pim_catalog_simpleselectpim_catalog_multiselect类型content已在此行114中转换为字符串:
{% set content = optionLabels[attribute.code] %}

同一页面上的另一个相关问题在第110行:
对于pim_catalog_image类型, contentAkeneo\Pim\Enrichment\Component\Product\Value\MediaValue的实例,它具有data属性但没有media属性。 但是该行使用content.media导致错误。

最有用的评论

很抱歉没有早点回复。

我调查了它并打开了一个关于它的 PR: https :
应该很快在 4.0.x 中合并。

所有6条评论

以下差异可能会暂时解决此问题

diff --git a/src/Akeneo/Pim/Enrichment/Bundle/Resources/views/Product/renderPdf.html.twig b/src/Akeneo/Pim/Enrichment/Bundle/Resources/views/Product/renderPdf.html.twig
index 3730bea3c2b..7576ad0ef82 100644
--- a/src/Akeneo/Pim/Enrichment/Bundle/Resources/views/Product/renderPdf.html.twig
+++ b/src/Akeneo/Pim/Enrichment/Bundle/Resources/views/Product/renderPdf.html.twig
@@ -107,11 +107,12 @@
                                 {% set content = product.getValue(attribute.code, locale_attribute, channel_attribute) %}
                                 {% set manualHeight = true %}

-                                {% if 'pim_catalog_image' == attribute.type and content.media is not null %}
-                                    {% set content = content.media.originalFilename %}
+                                {% if 'pim_catalog_image' == attribute.type and content.data is not null %}
+                                    {% set content = content.data.originalFilename %}
                                     {% set manualHeight = false %}
                                 {% elseif ('pim_catalog_simpleselect' == attribute.type or 'pim_catalog_multiselect' == attribute.type) and attribute.code in optionLabels|keys %}
                                     {% set content = optionLabels[attribute.code] %}
+                                    {% set manualHeight = false %}
                                 {% endif %}

                                 {% if content != null and manualHeight == true %}

你好@adhocore
感谢您以如此精确的描述打开此问题。

关于__toString的第一个问题,应尽快在 4.0.x 中合并快速修复: https ://github.com/akeneo/pim-community-dev/pull/12430

对于第二个问题,我会尽快花时间研究它。

你好,

你有关于第二期的消息吗?

非常感谢🙏

修复可能是使用在 media 属性上定义的 twig 函数,如下所示:

{% if 'pim_catalog_image' == attribute.type and content.media is defined and content.media is not null %}

很抱歉没有早点回复。

我调查了它并打开了一个关于它的 PR: https :
应该很快在 4.0.x 中合并。

非常感谢👍💪

如果我们有带有修复的新版本的akeneo,请随时关闭此问题,谢谢

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

kanduvisla picture kanduvisla  ·  3评论

a2xchip picture a2xchip  ·  5评论

pardahlman picture pardahlman  ·  4评论

lpxavi picture lpxavi  ·  4评论

oliverde8 picture oliverde8  ·  3评论