Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Collection=Mage::getResourceModel('catalog/product_collection')
- ->addFinalPrice()
- ->getSelect()
- ->where('price_index.final_price < price_index.price');
- // Get product ids
- $productIds=$Collection->getAllIds();
- $categoryId = 'Your Category_Ids'; /
- $category = Mage::getModel('catalog/category')->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)->load($categoryId);
- //get the current products
- $products = $category->getProductsPosition();
- foreach ($productIds as $id){
- $products[$id] = 1;//you can put any other position number instead of 1.
- }
- //attach all the products to the category
- $category->setPostedProducts($products);
- //save the category.
- $category->save();
Add Comment
Please, Sign In to add comment