I would like to set all position-numbers in one specific category to 100 instead of 0 (default). Id like to do this once - not for future products in that category.

Thx in forward!


1 Answer 1


Try this:

$categoryId = 22; //replace with your category id
$newPosition = 100; //replace with your new position
$category = Mage::getModel('catalog/category')->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)->load($categoryId);
$products = $category->getProductsPosition();
foreach ($products as $id=>$value){
    $products[$id] = $newPosition;
  • I know I shouldnt, but from time to time I have to tell I LOVE YOU MARIUS :D You are the best of the best of the best! Nov 25, 2013 at 13:45
  • 4
    Glad to help, but if my wife sees your comment...well... I cannot guarantee your safety :)
    – Marius
    Nov 25, 2013 at 13:52
  • Old question, but is there a reason to set store ID on this operation? I don't see store_id in the catalog/category table.
    – laketuna
    Sep 5, 2014 at 22:28
  • @laketuna. It shouldn't even be a store_id field in the category table. That one is used only for loading the correct attribute values. Check the eav models for more info.
    – Marius
    Sep 8, 2014 at 11:05
  • 1
    Also you can use direct SQL query, for all cats UPDATE catalog_category_product AS ccp SET ccp.position = 10000 WHERE cp.position = 1 or for specific category UPDATE catalog_category_product AS ccp SET ccp.position = 10000 WHERE ccp.position = 1 AND ccp.category_id = 23 May 27, 2016 at 12:20

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