2

How can i display the products position (of the current category) in the products view.phtml?

I try

$_category->getProductsPosition()
and
$_product->getProductsPosition()

Both still won't work :(

1 Answer 1

2

Try this!

$catId = end($_product->getCategoryIds());

// Returns all product ids with its position
$productPositions = Mage::getModel('catalog/category')->load($catId)->getProductsPosition();
echo $productPositions[$_product->getId()];
1
  • Ah thank you for this awesome tip. I got it now. I only have to edit the code a bit to get the right Category and for load the position: $catId = Mage::registry('current_product')->getCategoryId(); // Returns all product ids with its position $category = Mage::getModel('catalog/category')->load($catId); $productPositions = Mage::getResourceModel('catalog/category')->getProductsPosition($category); echo $productPositions[$_product->getId()];
    – Lars
    Commented Nov 13, 2014 at 2:32

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.