Jump to content
rocky

[MODULE] Next and previous links on the product page

Recommended Posts

This module adds Next and Previous links on the product page that go to the next and previous product in the last visited category. It displays in the product footer by default, but it can also be repositioned to the "Product actions", "Extra Left" or "Extra Right" hooks.

UPDATE v1.1

* Friendly URLs are now used when enabled

UPDATE v1.2

* Changed so that it uses the last visited category instead of the product's default category
* Added code so that visiting the homepage is counted as the last visited category

UPDATE v1.3

* Added product name tooltip over links
* Made links translatable
* Made compatible with Prestashop v1.1

UPDATE v1.3.1

* Removed 1 from homepage

UPDATE v1.4

* Improved breadcrumb bar when navigating products
* Added option to choose whether to navigate featured products or the product's default category on the homepage
* Module can now be hooked in the Extra Left and Extra Right hooks.

UPDATE v1.4.1

* Made separate module that is compatible with Prestashop v1.1
* Improved breadcrumb bar when navigating products

UPDATE v1.4.2

* Remove compatibility code that was unnecessary now that the modules are separate

UPDATE v1.5

* Added option to loop next and previous links
* Fixed bug in PrestaShop v1.1 version of the module

Download this module from my website here.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for letting me know. I thought a simple $link->getProductLink($id_product) would get the friendly URL, but it turned out to be more complicated than that. I've updated my module.

Share this post


Link to post
Share on other sites

Links are ok now, great ! :cheese:

I noticed another problem: when I have a product in a category from another category (a product can be displayed on several category), the next link go to the other category, not staying in the curent category.
(tested on 1.1)

Share this post


Link to post
Share on other sites

I've updated my module to use the last visited category in the cookie instead of the product's default category. You'll need to uninstall and reinstall the module, since I added a hook to the homepage so visiting it is counted as the last visited category. For some reason, Prestashop doesn't do that by default.

Share this post


Link to post
Share on other sites

There is a "1" displayed on home

It's not working on PS 1.1

Fatal error: Call to undefined method Product::idIsOnCategoryId() in /homez.34/myshop/www/boutique/modules/productnextprevnc/productnextprevnc.php on line 29


I suggest:
What do you think about adding "name of next or previous product" in title links previous and next?
(as it's done in blockpnav module http://www.prestashop.com/forums/viewthread/31247/#141414, this previous/next module doesn't work well)

Share this post


Link to post
Share on other sites

Good idea. I've added product name tooltips to the buttons. The reason you were getting that error was because the method was changed between Prestashop v1.1 and Prestashop v1.2. In Prestashop v1.1, the function was a non-static function called isOnCategoryId(). In Prestashop v1.2, this was changed to a static function called idIsOnCategoryId(). I've written code to check which method exists and then call the right method. Let me know if it works for you.

Share this post


Link to post
Share on other sites

Thank you. I didn't even notice the 1 on the homepage. I've removed it.

Share this post


Link to post
Share on other sites

It works with PS 1.1, great job

but I noticed:

featured products:

When a product is displayed as a featured product, if you go to the product using product listing, the previous and next links go to other featured products but not the current category, the products belonging to the category should be linked, not the featured products

about breadcrumb :
When a product is from another category than current category, if you go to the product page from product listing, the breadcrumb is right, it shows the current category, but if you use the previous/next links, the name of category shown in breadcrumb is the default category of the product but not the current category. So when visiting the category, the category breadcrumb change, but should stay the same for all products displayed in the category.

Not simple ;-)

Another suggestion

I display the links using extra left hook
So perhaps you could add ability to hook on extra left and why not extra right

    function hookExtraLeft($params)
   {
       return $this->hookProductFooter($params);
   }


   function hookExtraRight($params)
   {
       return $this->hookProductFooter($params);
   }

  • Like 1

Share this post


Link to post
Share on other sites

Thanks rocky i will try your module, seems to be a nice add-on.

Best regards,


ysco..

Share this post


Link to post
Share on other sites

I've fixed the breadcrumb bar issue and added the hooks. I personally think it is better to navigate the featured products when clicking on a featured product rather than navigate the product's default category, since it is consistent with the behaviour when clicking from a category. It may be confusing to jump to the product's default category. I added it as an option you can choose which behaviour you want.

Share this post


Link to post
Share on other sites

Unfortunatly I've got this message using PS1.1 with 1.4 version

Fatal error: Call to undefined method Tools::getFullPath() in /homez.34/myshop/www/boutique/modules/productnextprevnc/productnextprevnc.php on line 125


I've changed Tools::getFullPath with Tools::getlPath, no more error message but links with Featured products in categories show other featured products, not current category. configuration in BO do nothing, breadcrumb is not good too ( perhaps shouldn't be default category of product $product->id_category_default).


I personally think it is better to navigate the featured products when clicking on a featured product rather than navigate the product’s default category


Yes of course, but in my case, when I visit the category I navigate in featured products if the first product is featured, so it's better to see products of the category than featured products when navigate in a category.

Share this post


Link to post
Share on other sites

Since the getPath() function was changed in Prestashop v1.2, I had to copy the v1.2 getPath() instead of using the v1.1 one to get things working. This means I had to create two separate modules for each of the versions.

I think I've got the breadcrumb bar sorted out now. Let me know whether it works. I thought this was going to be a simple module, but it has turned out to be quite complicated.

Share this post


Link to post
Share on other sites

Hello and thank you for this module.

I installed "productnextprevnc v1.4.1 for PrestaShop v1.2 .zip".
I do not see the difference between "Featured" and "Default Category".

In the 2 cases I do not surf to the default category (I wish only products of the same category)

Is it possible and which is the solution?

Thank you !

___________
EDIT

I think to know where is the trouble : all the articles of my shop are in 2 categories: home and their category… So :-S

Share this post


Link to post
Share on other sites

It's OK for me ! breadcrumb is good,

featured products : if a customer just coming from home open a featured product wich is the first product in a category, other products linked are featured products, if he visits first other category and go to this product, it'ok, other category products are linked


because you made 2 modules for 1.1 and 1.2 (thanks a lot) perhaps, the test
// For compatibility with both Prestashop v1.1 and Prestashop v1.2, check which method exists and call it
can be removed



Something strange when I open and save the php file:
'.$this->l('Featured products').'
when I save the file using dreamweaver ')') is added:
'.$this->l('Featured products').'

so it makes error, i must use another way to save

Share this post


Link to post
Share on other sites

other question:
how to take off name in breadcrumb, I tried to remove in code but I had an error, thank you :-)

Share this post


Link to post
Share on other sites

@capclem

Make sure that the default category of your products is not "Home", but another category. Obviously, if the default category is "Home", then that is what will be displayed when the "Default category" option is selected, which happens to be the same result as when "Featured products" is selected, making it look like my module isn't working, when in fact it is.

@jolvil

To remove the product name from the breadcrumb, change line 107 of productnextprevnc.php from:

return self::getPath($id_category, Category::hideCategoryPosition($category->name), true).' '.$pipe.' '.htmlentities($end, ENT_NOQUOTES, 'UTF-8');



to:

return self::getPath($id_category, Category::hideCategoryPosition($category->name), true)/*.' '.$pipe.' '.htmlentities($end, ENT_NOQUOTES, 'UTF-8')*/;



I can't reproduce the issue you are having in Dreamweaver. I changed the line anyway to remove the == part in case it helps.

Share this post


Link to post
Share on other sites
To remove the product name from the breadcrumb, change line 107 of productnextprevnc.php from:

return self::getPath($id_category, Category::hideCategoryPosition($category->name), true).' '.$pipe.' '.htmlentities($end, ENT_NOQUOTES, 'UTF-8');



to:

return self::getPath($id_category, Category::hideCategoryPosition($category->name), true)/*.' '.$pipe.' '.htmlentities($end, ENT_NOQUOTES, 'UTF-8')*/;



I can't reproduce the issue you are having in Dreamweaver. I changed the line anyway to remove the == part in case it helps.



Thank you :-)

Share this post


Link to post
Share on other sites

This module is quite perfect but I've still featured products linked instead of current category products with a featured product in category. (PS 1.1)
I don't see differences when I change configuration: default or featured :smirk:

Share this post


Link to post
Share on other sites

Hi, thanks for the module. I like to see the next and previous link as pictures how do I do that? and also I want to have them positioned at the beggining and end of the product page. Is it possible?

Share this post


Link to post
Share on other sites

@jolvil

I'm currently testing my module on Prestashop v1.2.5 and Prestashop v1.3 RC3 and it is working fine on both of them. I don't have a test site for Prestashop v1.1 at the moment. I'll install Prestashop v1.1 on my test site when I have time and see whether I encounter the same problem as you.

@viztec

To change the links to images, edit modules/productnextprevnc/productnextprevnc.tpl and replace the Previous and Next text with an <img> tag to your previous and next images. You can also edit modules/productnextprevnc/css/productnextprevnc.css if you want to add CSS images.

To put the next and previous links at the top of bottom of the product page, you'll need to move {$HOOK_PRODUCT_FOOTER} from line 324 of product.tpl in your theme's directory to before or after the breadcrumb bar on line 86. Then copy it to the bottom of the file too. If you are using the product footer hook for other modules and don't want them moved, you should transplant my module into the Extra Left or Extra Right hook instead.

Share this post


Link to post
Share on other sites

hello all,
Simple question:
On the last or first product there is only one link pointing to nearest product, but
how to make next and previous links to cycle all products and on the last product I want to add aditional link to the first product and vice versa.

ps
good module :)

Share this post


Link to post
Share on other sites

That's a good idea. I'll add that as an option in the Back Office in the next version of the module.

Share this post


Link to post
Share on other sites

This looks great and installed well but I it doesn't appear in order. I have one product category with 6 products their id's are 69,70,71, 73, 74,75 and the are displayed in that order. However using the navigation buttons it takes me in this order 69,71, 70, 73,74,75.

Any idea why that might be? I can't figure it out. Any help is appreciated.

Share this post


Link to post
Share on other sites

Thanks for pointing this out. It appears the products are currently being sorted by position in category, not by product ID. To change this to sort by product ID, change line 101 of modules/productnextprev.php from:

$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000);



to:

$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000, 'id_product');



I'm not exactly sure how the products should be sorted. The customer may expect the products to be sorted the same way they were on the product listings page, which is complicated since they can change the sort order using the dropdown. I'll have to think about a possible solution.

Share this post


Link to post
Share on other sites

I made the change and the site went blank until I undid that change.


I am using 1.2.5 if it helps

Share this post


Link to post
Share on other sites

I just tested the change on my Prestashop v1.2.5 site and it worked fine. Are you sure you copied it right?

Share this post


Link to post
Share on other sites

I am very inpatient and cant wait new version :) so I made this feature (link to first product on last product page and vice versa) myself :)
I tonally unfamiliar with php so maybe it can be done more intelligent way or maybe you can optimize this code, but it works :) and here it is...
1) New productnextprevnc.tpl:

{if $prevLink != NULL OR $nextLink != NULL}

{if $prevLink != NULL}« {l s='Previous' mod='productnextprevnc'}{else}« {l s='Previous' mod='productnextprevnc'}{/if} {if $nextLink != NULL}{l s='Next' mod='productnextprevnc'} »{else}{l s='Next' mod='productnextprevnc'} »{/if}
{/if}



2) Modified and new lines in productnextprevnc.php:
Found this:

$prevLink = NULL;
$prevName = NULL;
$nextLink = NULL;
$nextName = NULL;


and added 4 new variables:

$prevLink = NULL;
$prevName = NULL;
$nextLink = NULL;
$nextName = NULL;
/**New variables*/
$firstLink = NULL;
$firstName = NULL;
$lastLink = NULL;
$lastName = NULL;


Then after:

for ($i = 0; $i < sizeof($cat_products); $i++)
           {
               if ($cat_products[$i]['id_product'] == $id_product)
               {
                   if ($i > 0)
                   {
                       $cat_product = new Product($cat_products[$i - 1]['id_product'], false, intval($cookie->id_lang));
                       $prevLink = $link->getProductLink($cat_products[$i - 1]['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
                       $prevName = $cat_products[$i - 1]['name'];
                   }

                   if ($i < sizeof($cat_products) - 1)
                   {
                       $cat_product = new Product($cat_products[$i + 1]['id_product'], false, intval($cookie->id_lang));
                       $nextLink = $link->getProductLink($cat_products[$i + 1]['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
                       $nextName = $cat_products[$i + 1]['name'];
                   }
               }
           }


added new lines to asign values to those variables:

            for ($i = 0; $i < sizeof($cat_products); $i++)
           {
               if ($cat_products[$i]['id_product'] == $id_product)
               {
                   if ($i > 0)
                   {
                       $cat_product = new Product($cat_products[$i - 1]['id_product'], false, intval($cookie->id_lang));
                       $prevLink = $link->getProductLink($cat_products[$i - 1]['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
                       $prevName = $cat_products[$i - 1]['name'];
                   }

                   if ($i < sizeof($cat_products) - 1)
                   {
                       $cat_product = new Product($cat_products[$i + 1]['id_product'], false, intval($cookie->id_lang));
                       $nextLink = $link->getProductLink($cat_products[$i + 1]['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
                       $nextName = $cat_products[$i + 1]['name'];
                   }
               }
           }
/**New lines. My be I need to add condition here: if (sizeof($cat_products)>1) then i think next previous links wont display if its only one product in cat.????*/
$cat_product = new Product($cat_products[0]['id_product'], false, intval($cookie->id_lang));
$firstLink = $link->getProductLink($cat_products[0]['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
$firstName = $cat_products[0]['name'];
$cat_product = new Product($cat_products[sizeof($cat_products) - 1]['id_product'], false, intval($cookie->id_lang));
$lastLink = $link->getProductLink($cat_products[sizeof($cat_products) - 1]['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
$lastName = $cat_products[sizeof($cat_products) - 1]['name'];



And the last thing in:

$smarty->assign(array('prevLink' => $prevLink, 'prevName' => $prevName, 'nextLink' => $nextLink, 'nextName' => $nextName));


Added my new variables:

$smarty->assign(array('prevLink' => $prevLink, 'prevName' => $prevName, 'nextLink' => $nextLink, 'nextName' => $nextName, 'firstLink' => $firstLink, 'firstName' => $firstName, 'lastLink' => $lastLink, 'lastName' => $lastName));

Share this post


Link to post
Share on other sites

I've now released v1.5 of this module, which adds the option to loop next and previous links and fixes a bug in the PrestaShop v1.1 version of the module.

Share this post


Link to post
Share on other sites

I found that if there is too many products in category, then it takes too mach time to load all products in category.
I have for about 40 products in category. And only loading them took 0,2 sec on my home computer (Core 2 duo).
(If there only 10 products it takes 0,02 sec.) Time consumation increase quickly!

This code part:

$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000);



But we don't need all this products. We need only 2 products: previous and next :)

So, find them using sql.

Hear is my solution

public function hookProductFooter($params)
{
   global $smarty, $cookie, $link;

   $id_product = intval(Tools::getValue('id_product'));

   if (!$id_product)
       return true;

   $product = new Product($id_product, false, intval($cookie->id_lang));
   $productInLastVisitedCategory = $product->isOnCategoryId(intval($cookie->last_visited_category));

   if ((!isset($cookie->last_visited_category) OR !$productInLastVisitedCategory) AND Validate::isLoadedObject($product))
       $cookie->last_visited_category = intval($product->id_category_default);

   $category = new Category(intval($cookie->last_visited_category), intval($cookie->id_lang));

   //$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000);
   $category_product = _DB_PREFIX_.'category_product';

   $sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND id_product=$id_product";

   $cur_product_row = Db::getInstance()->getRow($sql);
   $cur_pos = 0;
   if ($cur_product_row){
       $cur_pos = $cur_product_row['position'];
   }

   $sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND position IN
       (SELECT min(position) mpos FROM $category_product p
           WHERE id_category=$cookie->last_visited_category and position>$cur_pos)";

   $pred_result = DB::getInstance()->getRow($sql);

   $sql = "SELECT 1 as ord, id_category,id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND position IN (SELECT max(position) mpos FROM $category_product p
    WHERE id_category=$cookie->last_visited_category and position<$cur_pos)";

   $next_result = DB::getInstance()->getRow($sql);

   $prevLink = NULL;
   $prevName = NULL;
   $nextLink = NULL;
   $nextName = NULL;

   if ($pred_result) {
       $cat_product = new Product($pred_result['id_product'], false, intval($cookie->id_lang));
       $prevLink = $link->getProductLink($pred_result['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
       $prevName = $cat_product->name;
   } 

   if ($next_result) {
       $cat_product = new Product($next_result['id_product'], false, intval($cookie->id_lang));
       $nextLink = $link->getProductLink($next_result['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
       $nextName = $cat_product->name;
   }

   $homepage = intval(Configuration::get('PRODUCT_LINKS_NC_HOMEPAGE'));

   $smarty->assign(array('prevLink' => $prevLink, 'prevName' => $prevName, 'nextLink' => $nextLink, 'nextName' => $nextName));
   $smarty->assign('path', self::getFullPath($homepage ? $category->id : ($category->id == 1 ? $product->id_category_default : $category->id), $product->name));

   if (!$homepage AND $category->id == 1)
       $cookie->last_visited_category = intval($product->id_category_default);

   return $this->display(__FILE__, 'productlinksnc.tpl');
}



Yeh, there may be compatibility problems in future versions, but it load only max 2 products (prev and next). This queries take only 0,01 sec. And execution time is not grow, when grow quantity of products in category. (We can create index in DB for position column, if need)

PS: I do not need looping, that's why I do not realize it. Of course if you need, you can.

Share this post


Link to post
Share on other sites

Thank you for raising this issue. I always appreciate feedback on my modules. I'll fix this in the next version of the module.

Share this post


Link to post
Share on other sites

Rocky, thankyou for your contributions in prestashop. It realy helps me. :)

And we can simplify my code a little.

This constructions

SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND position IN
       (SELECT min(position) mpos FROM $category_product p
           WHERE id_category=$cookie->last_visited_category and position>$cur_pos)


SELECT 1 as ord, id_category,id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND position IN (SELECT max(position) mpos FROM $category_product p
    WHERE id_category=$cookie->last_visited_category and position<$cur_pos)



Replace with

SELECT id_category, id_product, position FROM ps_category_product WHERE id_category=$cookie->last_visited_category AND position >$cur_pos order by position ASC

SELECT id_category, id_product, position FROM ps_category_product WHERE id_category=$cookie->last_visited_category AND position <$cur_pos order by position DESC



And 'LIMIT 1' will be added by MySQL->getRow function.

We have:

//$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 2);//1000000);
$category_product = _DB_PREFIX_.'category_product';

$sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND id_product=$id_product";

$cur_product_row = Db::getInstance()->getRow($sql);
$cur_pos = 0;
if ($cur_product_row){
   $cur_pos = $cur_product_row['position'];
} else {
   return true;
}

$sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND position >$cur_pos order by position ASC";

$pred_result = DB::getInstance()->getRow($sql);

$sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cookie->last_visited_category AND position <$cur_pos order by position DESC";

$next_result = DB::getInstance()->getRow($sql);

$prevLink = NULL;
$prevName = NULL;
$nextLink = NULL;
$nextName = NULL;

$loop = Configuration::get('PRODUCT_LINKS_NC_LOOP');

if ($pred_result) {
   $cat_product = new Product($pred_result['id_product'], false, intval($cookie->id_lang));
   $prevLink = $link->getProductLink($pred_result['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
   $prevName = $cat_product->name;
} elseif ($loop) {
   // Load last Product in category: 
   // SELECT ... FROM $category_product WHERE id_category=$cookie->last_visited_category AND position>$cur_pos 
   //   ORDER BY position DESC
   // getRow
   // if (it exists) { $prevLink ... }
}

if ($next_result) {
   $cat_product = new Product($next_result['id_product'], false, intval($cookie->id_lang));
   $nextLink = $link->getProductLink($next_result['id_product'], $cat_product->link_rewrite, $category->link_rewrite, $cat_product->ean13);
   $nextName = $cat_product->name;
} elseif ($loop) {
   // Load first Product in category: 
   // SELECT ... FROM $category_product WHERE id_category=$cookie->last_visited_category AND position<$cur_pos 
   //   ORDER BY position ASC
   // getRow
   // if (it exists) { $nextLink ... }
}



Maybe some microseconds, I think:)
But it more elegant solution.

PS: As You noticed, I reverse order of Next and Prev products.

Share this post


Link to post
Share on other sites

Its to protect our code from hackers :)

$cat_id = intval($cookie->last_visited_category);

$sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cat_id AND id_product=$id_product";

$cur_product_row = Db::getInstance()->getRow($sql);
$cur_pos = 0;
if ($cur_product_row){
   $cur_pos = $cur_product_row['position'];
} else {
   return true;
}

$sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cat_id AND position >$cur_pos order by position ASC";

$pred_result = DB::getInstance()->getRow($sql);

$sql = "SELECT id_category, id_product, position FROM $category_product WHERE id_category=$cat_id AND position <$cur_pos order by position DESC";

Share this post


Link to post
Share on other sites

I've found a slight bug I think.....any products that are featured on the homepage when viewed with this module activated the breadcrumb navigation loses the category name. Fine for products not on the homepage.

Share this post


Link to post
Share on other sites

Do you have the "Homepage navigation" option on the configuration page set to "Default category" or "Featured Product"? When it is set on "Featured product", the category is supposed to be hidden, so that you can navigate through the featured products. If you have "Default category" selected and the default category isn't being shown, check that the product isn't in the "Home" category. If the default category isn't "Home", but it is displaying as in the "Home" category, then it is a bug.

Share this post


Link to post
Share on other sites

Ahh ok, didn't realize it hid the category in the breadcrumb, all working as you described.

The correct sorting would be a great addition. Working on 1.3 for me.

Share this post


Link to post
Share on other sites

Yes, I thought of that too. I'm currently working on sorting by whatever is selected in the "sort by" dropdown instead of always sorting by product ID.

Share this post


Link to post
Share on other sites

There is a bug though somewhere, all my products default categories are not home, I have your module set to "default category" but when a product is clicked from the featured products table on the homepage the next/prev links on that product target products in different categories, this does not seem right.

Share this post


Link to post
Share on other sites

Can you provide a link to your site so I can see the problem?

Share this post


Link to post
Share on other sites

Also just noticed the alt/title shown on the link is not formatting the " character when used in a product name.

Share this post


Link to post
Share on other sites

I'll add these to my list of things to fix in this module.

Share this post


Link to post
Share on other sites

@Nabeel Aejaz

You can add the following code to productlinksnc.php so you can display the links at the top of the page:

function hookTop($params)
{
      return $this->hookProductFooter($params);
}



Then go to Modules > Positions and transplant the "Product Links" module into the "Top of pages" hook, and remove it from the "Product footer" hook.

Share this post


Link to post
Share on other sites
@Nabeel Aejaz

You can add the following code to productlinksnc.php so you can display the links at the top of the page:

function hookTop($params)
{
      return $this->hookProductFooter($params);
}



Then go to Modules > Positions and transplant the "Product Links" module into the "Top of pages" hook, and remove it from the "Product footer" hook.



Great, thanks a lot. Right now the link are appearing above the catrgories and cart block. How do I get it to come below the product titles. for e.g. http://www.sanaullastore.com/34-blue-shades-color-2.html - Thanks in advance.

Share this post


Link to post
Share on other sites

There is no hook in that position, so you can't position my module there by default. You'll need to move a hook into that position, then transplant my module into the position. For example, you could move the {if $HOOK_EXTRA_LEFT}{$HOOK_EXTRA_LEFT}{/if} on line 131 of product.tpl in your theme's directory up to just after <h2>{$product->name|escape:'htmlall':'UTF-8'}</h2> on line 91, then transplant my module into the "Extra actions on the product page (left column)" hook, and remove it from the "Top of pages" hook.

Share this post


Link to post
Share on other sites

Hi, Rocky

I couldn't find your web, can you upload this modul here?

Thanks

Share this post


Link to post
Share on other sites

I just tested my website and it is working fine. I can't post the module here for legal reasons. The module can be available only from my website. I'll PM the module to you.

Share this post


Link to post
Share on other sites
There is no hook in that position, so you can't position my module there by default. You'll need to move a hook into that position, then transplant my module into the position. For example, you could move the {if $HOOK_EXTRA_LEFT}{$HOOK_EXTRA_LEFT}{/if} on line 131 of product.tpl in your theme's directory up to just after <h2>{$product->name|escape:'htmlall':'UTF-8'}</h2> on line 91, then transplant my module into the "Extra actions on the product page (left column)" hook, and remove it from the "Top of pages" hook.


Thank you so much Rocky. May God Bless You!!!

Share this post


Link to post
Share on other sites

When are you going to post new version of this module? I would really appriciate to get this module to be faster... I cannot use it now because I have thousands of products and it is very very slow to show product page... I have tried the code that Sergey put here but I cannot get it to work.
Thank you for your help.

Share this post


Link to post
Share on other sites

@abroucek

I'm currently working on three modules including this one in between moderating and answering questions on the forums, which is time-consuming. I'm also trying to spend some time writing PrestaShop documentation. You may have to wait a while until I get around to doing v2.0 of this module.

@Ensign

You'll need to copy one of the hooks in product.tpl that you the module supports that you aren't using up just after the breadcrumb line, then modify the CSS so that both the next and previous buttons are floated right, then add some padding between them.

Share this post


Link to post
Share on other sites

2Ensign,

I am not using this module, but I wish I did. Using Rocky's module is better as he is a pro.

Share this post


Link to post
Share on other sites

No, it does not add "Next" and "Previous" links on news entries. I'll add it to my list of things to do for this module.

Share this post


Link to post
Share on other sites

How do i install this module - when I download from your website or from this topic I receive only one file. When I open it is is scrambled and unreadable..

Share this post


Link to post
Share on other sites

Rename downloaded file by adding .zip at the end.
Then unzip file and copy folder productlinksnc to your modules folder.

Share this post


Link to post
Share on other sites

Hi thanks for this.

Now I feel really blond - should have tried that myself :)

Share this post


Link to post
Share on other sites

Hello everybody, I've used this module on the book catalog i'm developing and made one modification that my client wanted so I want to share it with you all.

Go visit here and look for the "" just right below share icons.

The "catalog" link sends you directly to the category view again, in this case it would be "photograpy books". It obviously changes from one cat to another...

I modify both productlinksnc.tpl and productlinksnc.php that are inside my .zip attachment.

Hope this is usefull for you.

S.

modifiedProducLinks.zip

Share this post


Link to post
Share on other sites

Hello,

I am trying to make this module look like this sample:

http://www.blossomcart.com/Rose/1008-12-white-long-stem-roses.html ? I want to hook it at the end of breadcrumb?

What I did:

1) I have added a hook ProductHeader to the DB
2) I put

 {if $HOOK_PRODUCT_HEADER}{$HOOK_PRODUCT_HEADER}{/if} 



after

{include file=$tpl_dir./breadcrumb.tpl} in the product.tpl



3) I put

 public function hookProductHeader($params) 
   {
       return $this->hookProductFooter($params);
   }



before

public function hookProductActions($params)
   {
       return $this->hookProductFooter($params);
   }



But when I tried to transplant the module to the ProductHeader, I got hack attempt. Can someone please tell me what is wrong with my code? And how should I go next? Thanks.

Share this post


Link to post
Share on other sites

Hi Rocky

Great module, thanks so much! I've got one suggestion for the next version:

The product should be ordered according to the preferences set in the back office so that the order of the products is the same as in the product listing.

Around line 114 in productlinksnc.php you can change the code from this:

$category = new Category(intval($cookie->last_visited_category), intval($cookie->id_lang));
$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000);



as follows to get that behaviour:

$category = new Category(intval($cookie->last_visited_category), intval($cookie->id_lang));
include(_PS_ROOT_DIR_.'/product-sort.php');
$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000, $orderBy, $orderWay);



Hope that helps.

Share this post


Link to post
Share on other sites

Hello to all,

I installed the version modified by the module (modifiedProducLinks.zip page 4) and made the modification so above.

The module works perfectly but I do not manage to transform the links into button or to create a background, to change size of text...

How to create a css for this module?

Thank you.

Share this post


Link to post
Share on other sites

Hello,

I modified the productlinksnc.tpl file of the module (Susi with link catalogs) for a compatibility with url rewriting for link catalogs.

I replaced

{l s='Catalogue' mod='productlinksnc'} 

by

{l s='Catalogue' mod='productlinksnc'}



In mode url rewriting activated the link is redirected well towards the category on the other hand the address is not written again.

Somebody would have an idea of the code so that the récriture is made.

Share this post


Link to post
Share on other sites

Hi Rocky,

Great module. Quick question: I can't seem to find how to translate the next and previous text in the BO. Is that not possible?

Regards,

Steven

Share this post


Link to post
Share on other sites

Hi,

For the translations you go to tools / translations then to Modify translations you select modulate translations and kept silent valid by clicking the flag of the language to be translated.

He stays in you more than has to find the fieldset productlinksnc

Share this post


Link to post
Share on other sites

@ Enduro

Thanks man! I was looking in the front office translations.....



Cheers,

Steven

Share this post


Link to post
Share on other sites

Has there not of what ;). To me it is in modulate translations

Share this post


Link to post
Share on other sites

This module is now compatible with PrestaShop v1.4.x.

  • Like 1

Share this post


Link to post
Share on other sites
This module is now compatible with PrestaShop v1.4.x.


hello,

Or you one can download the module compatible PrestaShop v1.4.x.

Share this post


Link to post
Share on other sites

Click the link in my first post to go to the module's page, then click the download button below the price, then save the archive to your computer. Extract "For PrestaShop v1.4.x.zip" for the version compatible with PrestaShop v1.4.x.

Share this post


Link to post
Share on other sites

Hi, man, thnx for this module.

 

I got this problem in ps 1.3.2:

 

If I set a hook to product footer I get two instances of the module (one at header and one at product footer), but I only want the second one. I don't know where or how to deactivate it.

 

Also the product footer version gets the width of the default hook, not the product footer, how can I fix this?

 

 

Ty again,

Jose

Share this post


Link to post
Share on other sites

Hi Rocky

Great module, thanks so much! I've got one suggestion for the next version:

The product should be ordered according to the preferences set in the back office so that the order of the products is the same as in the product listing.

Around line 114 in productlinksnc.php you can change the code from this:

$category = new Category(intval($cookie->last_visited_category), intval($cookie->id_lang));
$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000);

as follows to get that behaviour:

$category = new Category(intval($cookie->last_visited_category), intval($cookie->id_lang));
include(_PS_ROOT_DIR_.'/product-sort.php');
$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000, $orderBy, $orderWay);

Hope that helps.

 

Tell me how to change the sort order for this module. I sort anyhow I can not understand the laws, as you wrote above I did not work.

Share this post


Link to post
Share on other sites

Thanks for pointing this out. It appears the products are currently being sorted by position in category, not by product ID. To change this to sort by product ID, change line 101 of modules/productnextprev.php from:

$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000);

to:

$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000, 'id_product');

I'm not exactly sure how the products should be sorted. The customer may expect the products to be sorted the same way they were on the product listings page, which is complicated since they can change the sort order using the dropdown. I'll have to think about a possible solution.

 

 

Thank you very much already figured out myself. Missed this one post.

Share this post


Link to post
Share on other sites

Hello,

 

i have installed this product in PS 1.3.1.1 and it is OK, now i have upgrade in 1.4.5.1 and it is not ok. i have a blank page.

i change for the new verson of your module, and it is the same.

have you an idea ?

Thanks

Patrick

Share this post


Link to post
Share on other sites

Ty for the module. How could i replace the next and previuos word links with a custom button ?

  • Like 1

Share this post


Link to post
Share on other sites

Hi

 

I have installed this modual on ps 1.3.1

 

I uploaded the modual to the back office . But when i press install i just get a blank screen

 

Can someone tell me were im going wrong .

 

Could ready do with this modual

 

Many Thanks

 

Gary

Share this post


Link to post
Share on other sites

Hello

Good module I have use it. My question is it possible to make buttons that navigate through all categories instead products. I have specific project with fixed number of product in category only on one page (grid 4x4) and I'm desperate for button next prev for category on both sides of grid.

 

Thanks

Share this post


Link to post
Share on other sites

Hello,

 

I use this module and it run. But i have a problem when my category have many products (300 our more), because the module load all products category in a SQL cache. Is it possible to change productlinksnc.php to load only 2 products (before/next) ?

 

Thank you

Edited by laccardi (see edit history)

Share this post


Link to post
Share on other sites

Hi, I need this module, how can I download it for prestashop 1.5?

 

Thanks in advance

 

Hi all, I need this module, where can I download it for prestashop 1.5?

 

Thanks in advance.

Share this post


Link to post
Share on other sites

Its not on your site anymore any way i can get this rocky? or can anyone that dl it post it back in this tread.

Share this post


Link to post
Share on other sites

can you put images instead of the text "next and previous"? does anyone know how to do this? :)

Share this post


Link to post
Share on other sites

Don't know if only for me, but:

 

Prestashop: 1.4.7

productlinksnc: 1.5

public function hookProductFooter($params): ~ 2.78666806221 seconds

 

Took me days to find what slows my website this much.

 

 

Edit: Ok, I narrowed it down to this:

 

$cat_products = $category->getProducts(intval($cookie->id_lang), 1, 1000000);

 

Why would you need everything, when you only need product id's to create links through Link class and product name for title attribute?

 

 

 

P.S. Created function for it to only take product id's and product names, also deleted other silly stuff - it dropped script working time from around 3 seconds to 0.00347 second.

Edited by Aleksandras (see edit history)

Share this post


Link to post
Share on other sites

Its still available here

 

And this is the page

 

Gonna test it now on my local prestashop v1.5.3.1 and will tell you is it workin...

 

Edit: Its working ye, just with one problem, breadcrumbs appear doubling the category name, as gsv1982 said a few posts back, but in my case, If you disable the module, the double category names are gone too, so you can keep using the store the old way... Gonna try to figure it out why this is happening, will post again if have something.

 

Edit 2: its something here:

$smarty->assign('path', Tools::getFullPath($homepage ? $category->id : ($category->id == 1 ? $product->id_category_default : $category->id), $product->name));

in productlinksnc.php file, but dont know how to change the code :/

 

Edit 3: I manage to do it :)

 

In file classes/Tools.php on line 947 replace:

 

return Tools::getPath($id_category, $category->name, true, $type_cat).'<span class="navigation-pipe">'.$pipe.'</span> <span class="navigation_product">'.htmlentities($end, ENT_NOQUOTES, 'UTF-8').'</span>';

 

with:

 

return Tools::getPath($homepage ? $category->id : ($category->id == 1 ? $product->id_category_default : $category->id), $product->name, true, $type_cat).'<span class="navigation-pipe">'.$pipe.'</span> <span class="navigation_product">'.htmlentities($end, ENT_NOQUOTES, 'UTF-8').'</span>';

 

This is not affecting the website at all, with or without the module activated, BUT, test it in localhost before apply the changes online!

Edited by e_anastassov (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites