В \components\shop\model.php было так (предыдущий и следующий выбирались по последовательности в категории):
public function getItemNav($item_id, $cat_id) { $ordering = $this->inDB->get_field('cms_shop_items_cats', "item_id={$item_id} AND category_id={$cat_id}", 'ordering'); $sql = "SELECT i.id as id, i.seolink as seolink, ic.ordering as ordering, i.title as title FROM cms_shop_items i, cms_shop_items_cats ic WHERE ic.item_id = i.id AND i.published = 1 AND ic.category_id = {$cat_id} AND (ic.ordering < {$ordering} OR ic.ordering > {$ordering}) LIMIT 2"; $result = $this->inDB->query($sql); if (!$this->inDB->num_rows($result)){ return false; } while($item = $this->inDB->fetch_assoc($result)){ if($item['ordering'] == $ordering-1){ $nav['prev'] = $item; } else { $nav['next']= $item; } } return $nav; }
public function getItemNav($id, $price) { $ordering = $this->inDB->get_field('cms_shop_items', "id={$id} AND price={$price}", 'price'); $sql = "SELECT id, seolink, title, price FROM cms_shop_items WHERE published = 1 AND (price < {$ordering} OR price > {$ordering}) LIMIT 2"; $result = $this->inDB->query($sql); if (!$this->inDB->num_rows($result)){ return false; } while($item = $this->inDB->fetch_assoc($result)){ if($item['price'] == $ordering-1){ $nav['prev'] = $item; } else { $nav['next']= $item; } } return $nav; }