Magento:To Show Product Navigation on Product view page

hello friend,
for showing product navigation on product view page.then Add following code in view.phtml file after messages_product_view div.
<!– start pagination nav –>

<div class=”product-navigation”>
<?php
//Determine the previous/next link and link to current category

if ($this->helper(‘catalog/data’)->getCategory()) {
$_ccat = $this->helper(‘catalog/data’)->getCategory();
$_ccatname= $this->helper(‘catalog/data’)->getCategory()->getName();
} else {
$_ccats = $this->helper(‘catalog/data’)->getProduct()->getCategoryIds();
$_ccat = Mage::getModel(‘catalog/category’)->load($_ccats[0]);
$_ccatname = Mage::getModel(‘catalog/category’)->getName($_ccats);
}; //missing “;” causes 503 error for validation service

$ppos         = $_ccat->getProductsPosition();
$current_pid  = $this->helper(‘catalog/data’)->getProduct()->getId();
// build array from products positions
$plist = array();
foreach ($ppos as $pid => $pos) {
$plist[] = $pid;
}
$total=sizeof($plist);
$curpos   = array_search($current_pid, $plist);
// get link for prev product
$previd   = isset($plist[$curpos+1])? $plist[$curpos+1] : $current_pid;
$product  = Mage::getModel(‘catalog/product’)->load($previd);
$prevpos  = $curpos;
while (!$product->isVisibleInCatalog()) {
$prevpos += 1;
$nextid   = isset($plist[$prevpos])? $plist[$prevpos] : $current_pid;
$product  = Mage::getModel(‘catalog/product’)->load($nextid);
}
$prev_url = $product->getProductUrl();
// get link for next product
$nextid   = isset($plist[$curpos-1])? $plist[$curpos-1] : $current_pid;
$product  = Mage::getModel(‘catalog/product’)->load($nextid);
$nextpos  = $curpos;
while (!$product->isVisibleInCatalog()) {
$nextpos -= 1;
$nextid   = isset($plist[$nextpos])? $plist[$nextpos] : $current_pid;
$product  = Mage::getModel(‘catalog/product’)->load($nextid);
}
$next_url = $product->getProductUrl();
// get link for current category
$more_url = $_ccat->getUrl();
?>

<?php
$url = ‘http://&#8217; . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];
?>
<p><?php if( $url <> $next_url ) { echo ‘<a href=”‘ . $next_url . ‘”>’ . $this->__(‘Previous’) . ‘</a>’; } ?><?php echo “Product “;  ?><?php echo $curpos +1;  ?><?php echo ” of “;  ?><?php echo ” $total “;  ?><?php echo ” of   Categary “;  ?><?php echo ”     $_ccatname “;  ?><?php if( $url <> $prev_url ) { echo ‘<a href=”‘ . $prev_url . ‘”>’ . $this->__(‘Next’) . ‘</a>’; } ?></p>
</div><!– end pagination nav –>

Posted in Magento. 1 Comment »

One Response to “Magento:To Show Product Navigation on Product view page”

  1. akshay jain (@akshay_1988) Says:

    my product page shows blank when i put the code in the mentioned place. I believe its because product-navigation css class does not exist


Speak Your Mind

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: