Home Communication board WiKi Get Quote

Magento Previous-Next module problem

The Previous-Next module problem in Magento has got the small problem: the next (or previous) product is not right. So, for example, you are expecting to see the “some product” as the next one, but actually you see “another product”.

This problem is related with the products sort order when the products are selecting by previous-next module. By default it's selecting the products by its id, instead of the category “sort by”.

To fix this problem you should edit app/code/local/AW/Previousnext/Block/Previousnext.php

Find the following row here:

$products = Mage::getModel('catalog/layer')->getProductCollection();

If you like to sort it constantly by some field, you should change it in the following way:

$products = Mage::getModel('catalog/layer')->getProductCollection()->addAttributeToSort('name', 'asc');

But if you like to reproduce the category sorting here (so, when the customer change the sort field/direction on the category page - the next/previous products are changing too),we should extract these params from the session:

$products = Mage::getModel('catalog/layer')->getProductCollection()->addAttributeToSort(Mage::getSingleton('catalog/session')->getData('sort_order'), Mage::getSingleton('catalog/session')->getData('sort_direction'));
Home About us Privacy statement Terms & Conditions Refund policy © 2007–2022 ArsCommunity