Skip to content

Instantly share code, notes, and snippets.

@jasontipton
Created November 17, 2014 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasontipton/fb62e1771280d197389d to your computer and use it in GitHub Desktop.
Save jasontipton/fb62e1771280d197389d to your computer and use it in GitHub Desktop.
rel="prev/next" - Magento 1.9 Community Edition
<?xml version="1.0"?>
<layout version="0.1.0">
<!-- add rel="prev" and rel="next" for Google SEO -->
<catalog_category_default>
<reference name="head">
<block type="page/html_pager" name="relprev.next" as="rel_prev_next" template="page/html/rel_prev_next.phtml"/>
</reference>
</catalog_category_default>
<catalog_category_layered>
<reference name="head">
<block type="page/html_pager" name="relprev.next" as="rel_prev_next" template="page/html/rel_prev_next.phtml"/>
</reference>
</catalog_category_layered>
</layout>
<?php
/*
code originally posted by Inchoo.net
http://inchoo.net/magento/how-to-implement-relprev-and-relnext-to-magentos-pagination/
*/
?>
<?php
$actionName = $this->getAction()->getFullActionName();
if ($actionName == 'catalog_category_view') // Category Page
{
$category = Mage::registry('current_category');
$prodCol = $category->getProductCollection()->addAttributeToFilter('status', 1)->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
$tool = Mage::app()->getLayout()->createBlock('page/html_pager')->setLimit(Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar')->getLimit())->setCollection($prodCol);
$linkPrev = false;
$linkNext = false;
if ($tool->getCollection()->getSelectCountSql()) {
if ($tool->getLastPageNum() > 1) {
if (!$tool->isFirstPage()) {
$linkPrev = true;
if ($tool->getCurrentPage() == 2) {
$url = explode('?', $tool->getPreviousPageUrl());
$prevUrl = @$url[0];
}
else {
$prevUrl = $tool->getPreviousPageUrl();
}
}
if (!$tool->isLastPage()) {
$linkNext = true;
$nextUrl = $tool->getNextPageUrl();
}
}
}
if ($linkPrev) echo '<link rel="prev" href="' . $prevUrl . '" />';
if ($linkNext) echo '<link rel="next" href="' . $nextUrl . '" />';
}
?>
@ansarul
Copy link

ansarul commented Aug 19, 2017

Hi I am facing pagination please check attachment my source code , if anyone know about how to solve it please help i am really appreciate
Website URL is http://komal.com.au/scarves.html
screenshot_5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment