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?

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
| improve this answer | |
0

Try this code:

<?php 
$maxPosition = Mage::getSingleton('catalog/layer')
    ->setCurrentCategory(Mage::registry('current_category'))
    ->getProductCollection()
    ->getMaxPosition(); 
?>
| improve this answer | |
  • I am getting this error : Call to undefined method Mage_Catalog_Model_Resource_Product_Collection::getMaxPosition() . It's not working – BornCoder Sep 22 '17 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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