: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_simpleselect
和pim_catalog_multiselect
类型content
已在此行114中转换为字符串:
{% set content = optionLabels[attribute.code] %}
同一页面上的另一个相关问题在第110行:
对于pim_catalog_image
类型, content
是Akeneo\Pim\Enrichment\Component\Product\Value\MediaValue
的实例,它具有data
属性但没有media
属性。 但是该行使用content.media
导致错误。
以下差异可能会暂时解决此问题
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,请随时关闭此问题,谢谢
最有用的评论
很抱歉没有早点回复。
我调查了它并打开了一个关于它的 PR: https :
应该很快在 4.0.x 中合并。