Pim-community-dev: Errors in product pdf export from enrichment page

Created on 16 Jun 2020  路  6Comments  路  Source: akeneo/pim-community-dev

: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.

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.

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pardahlman picture pardahlman  路  4Comments

gotgelf picture gotgelf  路  5Comments

Piotr-Borek picture Piotr-Borek  路  5Comments

ronthedrummer picture ronthedrummer  路  3Comments

peleq-smile picture peleq-smile  路  4Comments