In Magento you can set the position of the products in a category from Magento admin by following the path Admin >> Catalog >> Categories >> Manage Categories >> Edit a category >> Set the position of the products in the “Category Products” tab.
Let see how we can find the position of a product on the product detail page:
$catId = Mage::registry('current_product')->getCategoryId(); $category = Mage::getModel('catalog/category')->load($catId); $productPositions = Mage::getResourceModel('catalog/category')->getProductsPosition($category); // This returns all product ids with their position echo $productPositions[$_product->getId()]; //Print the product postion
If you know the category id and the product id then you can find the position of a product in a category on any page.
Leave a Comment