0

i know that question have been asked here before but i have no solution. im trying to implement pagination rel="next" and rel="prev" and after a lot of research i found this code:

<?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 = $this->getLayout()->createBlock('page/html_pager')->setLimit($this->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 . '" />';
}
?>

i added this code to my head.phtml and it dosent show in the page source as rel="next" and rel="prev".

please help me with this.

0

Your code might not get full Action name, that's why its not going in to IF condition.

Try this code:

$actionName = Mage::app()->getFrontController()->getAction()->getFullActionName();
  • i tried this but still not working. – Almog Lahav Nov 24 '17 at 20:46
  • what you are getting in that variable? – Abhishek Panchal Nov 24 '17 at 20:46
  • please can you help? – Almog Lahav Nov 24 '17 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.