Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in product pdf export from enrichment page #12298

Closed
adhocore opened this issue Jun 16, 2020 · 6 comments
Closed

Errors in product pdf export from enrichment page #12298

adhocore opened this issue Jun 16, 2020 · 6 comments

Comments

@adhocore
Copy link

adhocore commented Jun 16, 2020

馃悰 I'm reporting a 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.

@adhocore
Copy link
Author

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 %}

@tseho
Copy link
Contributor

tseho commented Jul 8, 2020

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 : #12430

For the second issue, I will try to take the time to look into it asap.

@lasdou
Copy link
Contributor

lasdou commented Jul 22, 2020

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 %}

@tseho
Copy link
Contributor

tseho commented Jul 22, 2020

Sorry for not responding earlier.

I've looked into it and opened a PR about it: #12496
Should be merged soon in 4.0.x.

@lasdou
Copy link
Contributor

lasdou commented Jul 22, 2020

Thank you very much 馃憤 馃挭

@adhocore
Copy link
Author

pls feel free to close this issue if we have new version release of akeneo with the fixes, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants