1

I would create a dynamic category "special offers" that contains all discounted products:

  • discounts of single products;
  • global discounts (menu "promotions" / "catalog price rules").

How I can copy, automatically, discounted products to "special offers" category?

I thought to crontab process.. or plugin (ok, but which event for global discounts?)

1 Answer 1

0

You can achieve this thing by cron job:s

First,you need to get list of products which have discounts,then assign those products in special category

So.first to fetch product collection and filter those products which have final_price is less that price field.

  $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();

Code is not tested.but concept is right

1
  • Ok.. I tested this snippet and I see that it works also with global promo. Then, it means that magento update "final_price" field also with this type of promo, not only with discount on single item. Thanks!
    – Infocurci
    Jan 4, 2016 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.