Guest User

Untitled

a guest
Dec 10th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. $Collection=Mage::getResourceModel('catalog/product_collection')
  2. ->addFinalPrice()
  3. ->getSelect()
  4. ->where('price_index.final_price < price_index.price');
  5. // Get product ids
  6. $productIds=$Collection->getAllIds();
  7. $categoryId = 'Your Category_Ids'; /
  8. $category = Mage::getModel('catalog/category')->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)->load($categoryId);
  9. //get the current products
  10. $products = $category->getProductsPosition();
  11.  
  12. foreach ($productIds as $id){
  13. $products[$id] = 1;//you can put any other position number instead of 1.
  14. }
  15. //attach all the products to the category
  16. $category->setPostedProducts($products);
  17. //save the category.
  18. $category->save();
Add Comment
Please, Sign In to add comment