optimisation of the frontoffice. Product list is ten times faster. But only the default product sale element can be added to cart.

This commit is contained in:
Julien Chanséaume
2014-07-23 17:20:45 +02:00
committed by Julien Chanseaume
parent 00baae6da0
commit b4d0d085fe
7 changed files with 13592 additions and 111 deletions

File diff suppressed because one or more lines are too long

View File

@@ -330,17 +330,18 @@ td.product,
.special-price {
.price {
display: block;
font-size: 20px; line-height: 25px;
font-style: italic;
font-size: 14px; line-height: 25px;
font-style: normal;
font-weight: 400;
}
}
.old-price {
.price {
display: block;
font-size: 18px; line-height: 25px;
font-size: 14px; line-height: 25px;
font-style: italic;
font-weight: 600;
font-weight: 400;
text-decoration: line-through;
}
}

View File

@@ -25,9 +25,14 @@
{* Breadcrumb *}
{block name='no-return-functions' append}
{$breadcrumbs = []}
{loop type="brand" name="brand-breadcrumb" id="{brand attr="id"}"}
{$breadcrumbs[] = ['title' => {$TITLE}, 'url'=> {$URL}]}
{/loop}
{$brand_id={brand attr="id"}}
{if $brand_id}
{loop type="brand" name="brand-breadcrumb" id="{brand attr="id"}"}
{$breadcrumbs[] = ['title' => {$TITLE}, 'url'=> {$URL}]}
{/loop}
{else}
{$breadcrumbs[] = ['title' => {intl l="All brands"}, 'url'=> '']}
{/if}
{/block}
{block name="main-content"}

View File

@@ -32,13 +32,55 @@
{* Content *}
{block name="main-content"}
{$category_id={category attr="id"}}
{$limit={$smarty.get.limit|default:8}}
{$product_page={$smarty.get.page|default:1}}
{$product_order={$smarty.get.order|default:'alpha'}}
<div class="main layout-col-2-left">
{$limit={$smarty.get.limit|default:8}}
{$product_page={$smarty.get.page|default:1}}
{$product_order={$smarty.get.order|default:'alpha'}}
<article class="col-main {$smarty.get.mode|default:"grid"}" role="main">
{if #category_display_detail# && $category_id}
<section class="category-description">
{loop name="category.description" type="category" id={$category_id} }
<h1 id="main-label" class="page-header">{category attr="title"}</h1>
{loop name="category.image" type="image" source="category" id={$ID} width=218 height=146 resize_mode="borders"}
<p><img itemprop="image" src="{$IMAGE_URL}" alt="{$TITLE}"></p>
{/loop}
{if $DESCRIPTION}
<div class="description">
{$DESCRIPTION nofilter}
</div>
{/if}
{if $POSTSCRIPTUM}
<small class="postscriptum">
{$POSTSCRIPTUM}
</small>
{/if}
{/loop}
</section>
<hr/>
{/if}
{if #category_display_subcategories#}
{ifloop rel="subcategories"}
<div class="block-links">
<div class="block-content">
<ul>
{loop name="subcategories" type="category" parent=$category_id}
<li>
<a href="{url path={navigate to="current"} category_id=$ID }">{$TITLE}</a>
</li>
{/loop}
</ul>
</div>
</div>
{/ifloop}
{/if}
{ifloop rel="product_list"}
{assign var="amount" value="{count type="product" category="{category attr="id"}"}"}
{assign var="amount" value="{count type="product" category="$category_id"}"}
<div class="toolbar toolbar-top" role="toolbar">
<div class="sorter-container">
<span class="amount">{if ($amount > 1)}{intl l="%nb Items" nb="{$amount}"}{else}{intl l="%nb Item" nb="{$amount}"}{/if}</span>
@@ -79,7 +121,7 @@
<div id="category-products">
<div class="products-content">
<ul class="product-col-4">
{loop type="product" name="product_list" category={category attr="id"} limit=$limit page=$product_page order=$product_order}
{loop type="product" name="product_list" category=$category_id limit=$limit page=$product_page order=$product_order}
{include file="includes/single-product.html" product_id=$ID hasBtn=true hasDescription=true hasQuickView=true width="218" height="146"}
{/loop}
</ul>

View File

@@ -1,3 +1,11 @@
# Display
category_display_detail = true
category_display_subcategories = true
folder_display_detail = true
folder_display_subfolders = true
# Maximum number of lines in lists
# --------------------------------
max_displayed_orders = 20

View File

@@ -18,7 +18,7 @@
{/if}
{/if}
{loop name="cat-parent-$level" type="category" parent=$parent need_count_child=1}
{loop name="cat-parent-$level" type="category" parent=$parent need_count_child=1 not_empty="1"}
{if $CHILD_COUNT> 0}
<li><a href="{$URL}#collapse{$ID}" class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#collapse{$ID}">{$TITLE}</a>

View File

@@ -5,15 +5,6 @@
{assign var="product_id" value=$ID}
{/if}
<article itemscope itemtype="http://schema.org/Product">
<!-- Use the meta tag to specify content that is not visible on the page in any way -->
{loop name="brand" type="brand" product=$product_id }
<meta itemprop="brand" content="{$TITLE}">
{/loop}
{loop name="isbn.feature" type="feature" product=$product_id title="isbn"}
{loop name="isbn.value" type="feature_value" feature=$ID product=$product_id}
<meta itemprop="productID" content="isbn:{$TITLE}">
{/loop}
{/loop}
<a href="{$URL}" itemprop="url" tabindex="-1" class="product-image{if $hasQuickView == true} product-quickview{/if}">
{loop name="product_thumbnail" type="image" product=$product_id width="{$width}" height="{$height}" resize_mode="borders" limit="1"}
@@ -26,7 +17,7 @@
</a>
<div class="product-info">
<h3 class="name"><a href="{$URL}"><span itemprop="name">{$productTitle}</span></a></h3>
<h2 class="name"><a href="{$URL}"><span itemprop="name">{$productTitle}</span></a></h2>
{if $hasDescription}
<div class="description" itemprop="description">
<p>{$DESCRIPTION nofilter}</p>
@@ -34,20 +25,15 @@
{/if}
</div>
{* Default value *}
{* Stock *}
{assign var="current_stock_content" value = "in_stock"}
{assign var="current_stock_href" value = "http://schema.org/InStock"}
{loop name="stock_meta" type="product_sale_elements" product=$product_id}
{loop name="combi_meta" type="attribute_combination" product_sale_elements="$ID"}
{if $LOOP_COUNT == 0}
{if $QUANTITY == 0}
{assign var="current_stock_content" value = "out_stock"}
{assign var="current_stock_href" value = "http://schema.org/OutOfStock"}
{/if}
{/if}
{/loop}
{/loop}
{if {config key="check-available-stock"} != 0}
{if $QUANTITY == 0}
{assign var="current_stock_content" value = "out_stock"}
{assign var="current_stock_href" value = "http://schema.org/OutOfStock"}
{/if}
{/if}
<div class="product-price">
<div class="price-container" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
@@ -55,96 +41,65 @@
<meta itemprop="itemCondition" itemscope itemtype="http://schema.org/NewCondition"> <!-- List of condition : NewCondition, DamagedCondition, UsedCondition, RefurbishedCondition -->
<meta itemprop="priceCurrency" content="{currency attr="symbol"}"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
<link itemprop="availability" href="{$current_stock_href}" content="{$current_stock_content}" />
<!-- List of availibility :
out_of_stock : http://schema.org/OutOfStock
in_stock : http://schema.org/InStock
instore_only : http://schema.org/InStoreOnly
preorder : http://schema.org/PreOrder
online_only : http://schema.org/OnlineOnly
-->
{if $IS_PROMO }
{loop name="productSaleElements_promo" type="product_sale_elements" product=$product_id limit="1" order="min_price"}
{assign var="default_product_sale_elements" value=$ID}
<span class="special-price"><span itemprop="price" class="price-label">{intl l="Special Price:"} </span><span class="price">{format_number number=$TAXED_PROMO_PRICE} {currency attr="symbol"}</span></span>
<span class="old-price"><span class="price-label">{intl l="Regular Price:"} </span><span class="price">{format_number number=$TAXED_PRICE} {currency attr="symbol"}</span></span>
{/loop}
<span class="special-price"><span itemprop="price" class="price-label">{intl l="Special Price:"} </span><span class="price">{format_number number=$TAXED_PROMO_PRICE} {currency attr="symbol"}</span></span>
<span class="old-price"><span class="price-label">{intl l="Regular Price:"} </span><span class="price">{format_number number=$TAXED_PRICE} {currency attr="symbol"}</span></span>
{else}
<span class="regular-price"><span itemprop="price" class="price">{format_number number=$BEST_TAXED_PRICE} {currency attr="symbol"}</span></span>
{/if}
</div>
{if $hasBtn == true}
{form name="thelia.cart.add" }
<form id="form-product-details{$product_id}" action="{url path="/cart/add" }" method="post" class="form-product">
{form_hidden_fields form=$form}
<input type="hidden" name="view" value="product">
<input type="hidden" name="product_id" value="{$product_id}">
{if $hasSubmit == true}
{form name="thelia.cart.add" }
<form id="form-product-details{$product_id}" action="{url path="/cart/add" }" method="post" class="form-product">
{form_hidden_fields form=$form}
<input type="hidden" name="view" value="product">
<input type="hidden" name="product_id" value="{$product_id}">
{if $form_error}<div class="alert alert-error">{$form_error_message}</div>{/if}
{if $form_error}<div class="alert alert-error">{$form_error_message}</div>{/if}
{form_field form=$form field='product_sale_elements_id'}
{if $default_product_sale_elements }
<input type="hidden" name="{$name}" value="{$default_product_sale_elements}" {$attr}>
{else}
{loop name="productSaleElements_promo" type="product_sale_elements" product="{$product_id}" limit="1"}
<input type="hidden" name="{$name}" value="{$ID}" {$attr}>
{/loop}
{/if}
{/form_field}
{form_field form=$form field="product"}
<input id="{$label_attr.for}" type="hidden" name="{$name}" value="{$product_id}" {$attr} >
{/form_field}
{form_field form=$form field='product_sale_elements_id'}
<input type="hidden" name="{$name}" value="{$PRODUCT_SALE_ELEMENT}" {$attr}>
{/form_field}
{form_field form=$form field="product"}
<input id="{$label_attr.for}" type="hidden" name="{$name}" value="{$product_id}" {$attr} >
{/form_field}
<fieldset class="product-options hide">
{ifloop rel="stock"}
<div class="option">
<label for="options" class="option-heading">Options</label>
<div class="option-content">
<select name="options" class="form-control">
{loop name="stock" type="product_sale_elements" product="$product_id" order="min_price"}
{if $LOOP_TOTAL == 1}
{assign var="hasSubmit" value = true}
<fieldset class="product-cart form-inline">
{form_field form=$form field='quantity'}
<div class="form-group group-qty hide {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
<label for="{$label_attr.for}">{$label}</label>
<input type="number" name="{$name}" id="{$label_attr.for}" class="form-control" value="{$value|default:1}" min="0" required>
{if $error }
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
{elseif $value != "" && !$error}
<span class="help-block"><i class="icon-ok"></i></span>
{/if}
{loop name="combi" type="attribute_combination" product_sale_elements="$product_id" order="alpha"}
<option value="{$ID}" data-quantity="{$QUANTITY}" data-price="{format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"}" data-old-price="{format_number number="{$TAXED_PRICE}"} {currency attr="symbol"}">{$ATTRIBUTE_AVAILABILITY_TITLE}</small></option>
{/loop}
{/loop}
</select>
</div>
{/form_field}
<div class="form-group group-btn">
</div>
<div>
<div class="product-btn">
<button type="submit" class="btn btn-cart">{intl l="Add to cart"}</button>
</div>
</div>
</div>
{/ifloop}
</fieldset>
<fieldset class="product-cart form-inline">
{form_field form=$form field='quantity'}
<div class="form-group group-qty hide {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
<label for="{$label_attr.for}">{$label}</label>
<input type="number" name="{$name}" id="{$label_attr.for}" class="form-control" value="{$value|default:1}" min="0" required>
{if $error }
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
{elseif $value != "" && !$error}
<span class="help-block"><i class="icon-ok"></i></span>
{/if}
</div>
{/form_field}
<div class="form-group group-btn">
</div>
</fieldset>
</form>
{/form}
{else}
<div>
<div class="product-btn">
{if $hasSubmit == true}
<button type="submit" class="btn btn-cart">{intl l="Add to cart"}</button>
{else}
<a href="{$URL}" class="btn btn-cart">{intl l="View product"}</a>
{/if}
<a href="{$URL}" class="btn btn-cart">{intl l="View product"}</a>
</div>
</div>
</fieldset>
</form>
{/form}
{/if}
{/if}
</div>
</article><!-- /product -->