Fix product schema image and price validity - #1091
Conversation
|
Hello @mihailovs2000! This is your first pull request on hummingbird repository of the PrestaShop project. Thank you, and welcome to this Open Source community! |
|
Hello @mihailovs2000, starting with 9.2, structured data are now sent from the core directly. The images are made differently. priceValidUntil is still there, but you can easily override it via a module. See the example module I made - https://github.com/PrestaShop/example-modules/tree/master/demoseo. But, maybe we can remove it indeed. Or maybe improve it so that it reflects the validity of specific price, if the product is discounted? |
|
Hi @mihailovs2000, thanks for the PR! As @Hlavtox mentioned above, the images are built differently since 9.2 the core now does it in And on the second point @Hlavtox raised, rather than removing So this to test and format the data: {assign var=priceValidUntil value=false}
{if !empty($product.specific_prices.to) && $product.specific_prices.to != '0000-00-00 00:00:00'}
{assign var=priceValidUntil value=$product.specific_prices.to|date_format:'%Y-%m-%d'}
{/if}and this to output it in the structure should be enough: {if $priceValidUntil}"priceValidUntil": {$priceValidUntil|json_encode nofilter},{/if}What do you think, @mihailovs2000, @Hlavtox? |
Summary
Product.imageinstead of the 250 x 250home_defaultthumbnailOffer.priceValidUntilwhen the catalog has no actual price-expiry dateWhy
priceValidUntilmeans the date after which the displayed price is no longer available. Generating an arbitrary date 15 days in the future publishes data that is not backed by catalog state and changes on every render. Omitting it is accurate when no validity date exists.The full product cover is also a better structured-data image than the small listing thumbnail and is already exposed by the product presenter.
Reference: https://developers.google.com/search/docs/appearance/structured-data/product-snippet#offer-properties
Test
priceValidUntilremoved