:bug: I'm reporting a Bug :bug:
Akeneo version: CE 4.0.31
When downloading pdf from product enrich page it goes to the below url and shows error: 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)
It happens because for pim_catalog_simpleselect
and pim_catalog_multiselect
type content
is already converted to string in this line 114:
{% set content = optionLabels[attribute.code] %}
Another related issue on same page is in line 110:
For type pim_catalog_image
the content
is instance of Akeneo\Pim\Enrichment\Component\Product\Value\MediaValue
which has data
property but not media
property. But that line uses content.media
causing error.
The following diff might fix the issue for now
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 %}
Hello @adhocore,
Thanks for opening this issue with such a precise description.
regarding your first issue with __toString
, a quick fix should be merged soon in 4.0.x : https://github.com/akeneo/pim-community-dev/pull/12430
For the second issue, I will try to take the time to look into it asap.
Hello,
have you some news about the second issue ?
Thank you very much 🙏
The fix could be to use the twig function defined on the media attribute like that :
{% if 'pim_catalog_image' == attribute.type and content.media is defined and content.media is not null %}
Sorry for not responding earlier.
I've looked into it and opened a PR about it: https://github.com/akeneo/pim-community-dev/pull/12496
Should be merged soon in 4.0.x.
Thank you very much 👍 💪
pls feel free to close this issue if we have new version release of akeneo with the fixes, thanks
Most helpful comment
Sorry for not responding earlier.
I've looked into it and opened a PR about it: https://github.com/akeneo/pim-community-dev/pull/12496
Should be merged soon in 4.0.x.