daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top