0

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

0

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
0

Try this code:

<?php 
$maxPosition = Mage::getSingleton('catalog/layer')
    ->setCurrentCategory(Mage::registry('current_category'))
    ->getProductCollection()
    ->getMaxPosition(); 
?>
1
  • I am getting this error : Call to undefined method Mage_Catalog_Model_Resource_Product_Collection::getMaxPosition() . It's not working
    – BornCoder
    Commented 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.