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!
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!
Try this:
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$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;
}
$category->setPostedProducts($products);
$category->save();
store_id
in the catalog/category
table.
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
Commented
May 27, 2016 at 12:20