Created
November 17, 2014 02:32
-
-
Save jasontipton/fb62e1771280d197389d to your computer and use it in GitHub Desktop.
rel="prev/next" - Magento 1.9 Community Edition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 . '" />'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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