Jump to content

Переход к следующиму или предыдущиму товару (решено)


Recommended Posts

Для начала добавим некий код в файл Storefront.class.php

// Соседние товары
$query = sql_placeholder("SELECT products.model as model, products.url as url, brands.name as brand, categories.single_name as category FROM categories, products LEFT JOIN brands ON products.brand_id = brands.brand_id WHERE categories.category_id = products.category_id AND categories.category_id=? AND products.enabled=1 AND categories.enabled=1 AND products.order_num<? ORDER BY products.order_num DESC LIMIT 1", $product->category_id, $product->order_num);
$this->db->query($query);
$next_product = $this->db->result();
$this->smarty->assign('next_product', $next_product);
$query = sql_placeholder("SELECT products.model as model, products.url as url, brands.name as brand, categories.single_name as category FROM categories, products LEFT JOIN brands ON products.brand_id = brands.brand_id WHERE categories.category_id = products.category_id AND categories.category_id=? AND products.enabled=1 AND categories.enabled=1 AND products.order_num>? ORDER BY products.order_num LIMIT 1", $product->category_id, $product->order_num);
$this->db->query($query);
$prev_product = $this->db->result();
$this->smarty->assign('prev_product', $prev_product);
///

Это примерно после 274 строки.

Далее в шаблон (product.tpl) добавим следующий код:

<!-- Соседние товары /-->
{if $prev_product}
<div>
<a href='products/{$prev_product->url}'>? {$prev_product->category|escape} {$prev_product->brand|escape} {$prev_product->model|escape}</a></nobr>
{/if}
{if $next_product}
   
<a href='products/{$next_product->url}'>{$next_product->category|escape} {$next_product->brand|escape} {$next_product->model|escape} ?</a>
</div>
{/if}
<!-- Соседние товары #End/-->

Все готово!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...