I want to get the maximal position assigned to a product in the category , so that whenever I create a new product then I can assign ($max+1) position to the product and it will be displayed in the end of the page in frontend.

Can anyone help me how to get maximal product position for a single category in Magento1?

2 Answers 2


For get the maximum position of product in a category :

$categoryId = '175';
$model = Mage::getModel('catalog/category')->load($categoryId)->getProductsPosition(); //get the positions of all product in magento for a category

echo max($test); // check for maximum value in array

Try this code:

$maxPosition = Mage::getSingleton('catalog/layer')
  • I am getting this error : Call to undefined method Mage_Catalog_Model_Resource_Product_Collection::getMaxPosition() . It's not working
    – BornCoder
    Sep 22, 2017 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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