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