Pim-community-dev: Erros na exportação de pdf do produto da página de enriquecimento

Criado em 16 jun. 2020  ·  6Comentários  ·  Fonte: akeneo/pim-community-dev

:bug: Estou reportando um Bug :bug:

Versão Akeneo: CE 4.0.31

Ao baixar o pdf da página de enriquecimento do produto, ele vai para a url abaixo e mostra o erro: 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)

Isso acontece porque para pim_catalog_simpleselect e pim_catalog_multiselect tipo content já está convertido para string nesta linha 114 :
{% set content = optionLabels[attribute.code] %}

Outro problema relacionado na mesma página está na linha 110 :
Para o tipo pim_catalog_image o content é uma instância de Akeneo\Pim\Enrichment\Component\Product\Value\MediaValue que tem a propriedade data mas não a propriedade media . Mas essa linha usa content.media causando erro.

Comentários muito úteis

Desculpe por não responder antes.

Eu olhei para isso e abri um PR sobre isso: https://github.com/akeneo/pim-community-dev/pull/12496
Deve ser mesclado em breve em 4.0.x.

Todos 6 comentários

O seguinte diff pode corrigir o problema por enquanto

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

Olá @adhocore ,
Obrigado por abrir este problema com uma descrição tão precisa.

em relação ao seu primeiro problema com __toString , uma correção rápida deve ser mesclada em breve no 4.0.x : https://github.com/akeneo/pim-community-dev/pull/12430

Para a segunda edição, tentarei reservar um tempo para analisá-la o mais rápido possível.

Olá,

você tem alguma notícia sobre a segunda edição?

Muito obrigado 🙏

A correção pode ser usar a função de galho definida no atributo de mídia assim:

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

Desculpe por não responder antes.

Eu olhei para isso e abri um PR sobre isso: https://github.com/akeneo/pim-community-dev/pull/12496
Deve ser mesclado em breve em 4.0.x.

Muito obrigado 👍 💪

pls fique à vontade para fechar este problema se tivermos uma nova versão do akeneo com as correções, obrigado

Esta página foi útil?
0 / 5 - 0 avaliações

Questões relacionadas

a2xchip picture a2xchip  ·  5Comentários

wakqasahmed picture wakqasahmed  ·  4Comentários

Piotr-Borek picture Piotr-Borek  ·  5Comentários

henryktews picture henryktews  ·  4Comentários

ronthedrummer picture ronthedrummer  ·  3Comentários