I would like to set position-numbers of category products in one specific category according to sku instead of 0 (default).
Magento version 1.9
I have a csv including position with sku. EX : "42-140107", "43-140108",
42 : Position,
140107 : Sku
I Tried smething Like below
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$categoryId = 156; //replace with your category id
$newPosition = ""; //To Be set according to sku
$category = Mage::getModel('catalog/category')->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)->load($categoryId);
$products = $category->getProductsPosition();
//I Want to get the sku like above we getting the position
$all_products = $category->getProducts();
foreach ($products as $id=>$value){
$products[$id] = $newPosition;//This $newPosition will change according to sku
}
$category->setPostedProducts($products);
$category->save();
My question is how to get the product sku & position from a relevant category and update the new position for category products?