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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Schema ItemList for products listing & Fix Schema Product #14558

Merged
merged 4 commits into from Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/Selenium/helpers/checkout.js
Expand Up @@ -5,7 +5,7 @@ import fixtures from '../fixtures';
export function addSomeProductToCart () {
return browser
.url(fixtures.urls.aCategoryWithProducts)
.click('.product-miniature:nth-of-type(2) a.product-thumbnail')
.click('.products :nth-of-type(2) a.product-thumbnail')
Progi1984 marked this conversation as resolved.
Show resolved Hide resolved
.click('[data-button-action="add-to-cart"]')
.waitForVisible('#blockcart-modal')
;
Expand Down
Expand Up @@ -26,11 +26,7 @@
<h2 class="h2 products-section-title text-uppercase">
{l s='Best Sellers' d='Shop.Theme.Catalog'}
</h2>
<div class="products">
{foreach from=$products item="product"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$products}
<a class="all-product-link float-xs-left float-md-right h4" href="{$allBestSellers}">
{l s='All best sellers' d='Shop.Theme.Catalog'}<i class="material-icons">&#xE315;</i>
</a>
Expand Down
Expand Up @@ -30,9 +30,5 @@
{l s='%s other products in the same category:' sprintf=[$products|@count] d='Shop.Theme.Catalog'}
{/if}
</h2>
<div class="products">
{foreach from=$products item="product"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$products}
</section>
Expand Up @@ -25,9 +25,5 @@

<section class="featured-products clearfix mt-3">
<h2>{l s='Customers who bought this product also bought:' d='Shop.Theme.Catalog'}</h2>
<div class="products">
{foreach from=$products item="product"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$products}
</section>
Expand Up @@ -26,11 +26,7 @@
<h2 class="h2 products-section-title text-uppercase">
{l s='Popular Products' d='Shop.Theme.Catalog'}
</h2>
<div class="products">
{foreach from=$products item="product"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$products}
<a class="all-product-link float-xs-left float-md-right h4" href="{$allProductsLink}">
{l s='All products' d='Shop.Theme.Catalog'}<i class="material-icons">&#xE315;</i>
</a>
Expand Down
Expand Up @@ -27,11 +27,7 @@
<h2 class="h2 products-section-title text-uppercase">
{l s='New products' d='Shop.Theme.Catalog'}
</h2>
<div class="products">
{foreach from=$products item="product"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$products}
<a class="all-product-link float-xs-left float-md-right h4" href="{$allNewProductsLink}">
{l s='All new products' d='Shop.Theme.Catalog'}<i class="material-icons">&#xE315;</i>
</a>
Expand Down
Expand Up @@ -27,11 +27,7 @@
<h2 class="h2 products-section-title text-uppercase">
{l s='On sale' d='Shop.Theme.Catalog'}
</h2>
<div class="products">
{foreach from=$products item="product"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$products}
<a class="all-product-link float-xs-left float-md-right h4" href="{$allSpecialProductsLink}">
{l s='All sale products' d='Shop.Theme.Catalog'}<i class="material-icons">&#xE315;</i>
</a>
Expand Down
Expand Up @@ -24,9 +24,5 @@
*}
<section class="featured-products clearfix mt-3">
<h2>{l s='Viewed products' d='Shop.Theme.Catalog'}</h2>
<div class="products">
{foreach from=$products item="product"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$products}
</section>
Expand Up @@ -23,7 +23,9 @@
* International Registered Trademark & Property of PrestaShop SA
*}
{block name='product_miniature_item'}
<article class="product-miniature js-product-miniature" data-id-product="{$product.id_product}" data-id-product-attribute="{$product.id_product_attribute}" itemscope itemtype="http://schema.org/Product">
<div itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<meta itemprop="position" content="{$position}" />
<article class="product-miniature js-product-miniature" data-id-product="{$product.id_product}" data-id-product-attribute="{$product.id_product_attribute}" itemprop="item" itemscope itemtype="http://schema.org/Product">
Progi1984 marked this conversation as resolved.
Show resolved Hide resolved
<div class="thumbnail-container">
{block name='product_thumbnail'}
{if $product.cover}
Expand All @@ -44,9 +46,9 @@
<div class="product-description">
{block name='product_name'}
{if $page.page_name == 'index'}
<h3 class="h3 product-title" itemprop="name"><a href="{$product.canonical_url}">{$product.name|truncate:30:'...'}</a></h3>
<h3 class="h3 product-title" itemprop="name"><a href="{$product.canonical_url}" itemprop="url" content="{$product.canonical_url}">{$product.name|truncate:30:'...'}</a></h3>
{else}
<h2 class="h3 product-title" itemprop="name"><a href="{$product.canonical_url}">{$product.name|truncate:30:'...'}</a></h2>
<h2 class="h3 product-title" itemprop="name"><a href="{$product.canonical_url}" itemprop="url" content="{$product.canonical_url}">{$product.name|truncate:30:'...'}</a></h2>
{/if}
{/block}

Expand All @@ -68,7 +70,11 @@
{hook h='displayProductPriceBlock' product=$product type="before_price"}

<span class="sr-only">{l s='Price' d='Shop.Theme.Catalog'}</span>
<span itemprop="price" class="price">{$product.price}</span>
<span class="price">{$product.price}</span>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="invisible">
<meta itemprop="priceCurrency" content="{$currency.iso_code}" />
<meta itemprop="price" content="{$product.price_amount}" />
</div>

{hook h='displayProductPriceBlock' product=$product type='unit_price'}

Expand Down Expand Up @@ -99,4 +105,5 @@
</div>
</div>
</article>
</div>
{/block}
29 changes: 29 additions & 0 deletions themes/classic/templates/catalog/_partials/productlist.tpl
@@ -0,0 +1,29 @@
{**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="products{if !empty($cssClass)} {$cssClass}{/if}" itemscope itemtype="http://schema.org/ItemList">
{foreach from=$products item="product" key="position"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product position=$position}
{/foreach}
</div>
8 changes: 1 addition & 7 deletions themes/classic/templates/catalog/_partials/products.tpl
Expand Up @@ -23,13 +23,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<div id="js-product-list">
<div class="products row">
{foreach from=$listing.products item="product"}
{block name='product_miniature'}
{include file='catalog/_partials/miniatures/product.tpl' product=$product}
{/block}
{/foreach}
</div>
{include file="catalog/_partials/productlist.tpl" products=$listing.products cssClass="row"}

{block name='pagination'}
{include file='_partials/pagination.tpl' pagination=$listing.pagination}
Expand Down
6 changes: 3 additions & 3 deletions themes/classic/templates/catalog/product.tpl
Expand Up @@ -230,10 +230,10 @@
{if $accessories}
<section class="product-accessories clearfix">
<p class="h5 text-uppercase">{l s='You might also like' d='Shop.Theme.Catalog'}</p>
<div class="products">
{foreach from=$accessories item="product_accessory"}
<div class="products" itemscope itemtype="http://schema.org/ItemList">
{foreach from=$accessories item="product_accessory" key="position"}
{block name='product_miniature'}
{include file='catalog/_partials/miniatures/product.tpl' product=$product_accessory}
{include file='catalog/_partials/miniatures/product.tpl' product=$product_accessory position=$position}
{/block}
{/foreach}
</div>
Expand Down