Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
Created June 24, 2015 20:05
Show Gist options
  • Select an option

  • Save ryaan-anthony/c2d64e1b1435c9c01ec3 to your computer and use it in GitHub Desktop.

Select an option

Save ryaan-anthony/c2d64e1b1435c9c01ec3 to your computer and use it in GitHub Desktop.
<?php
// Set product positions within a selected category
$cat_id = CATEGORY_ID;
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_api = new Mage_Catalog_Model_Category_Api;
$products = $category->getProductCollection();
foreach ($products as $product){
$new_order = NEW_POSITION;
$cat_api->assignProduct($category->getId(), $product->getId(), $new_order);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment