How To Add Promotions Through Databasae?

I want to add more than 3000 products into one promotion,but its difficult to add all of them through manually in admin panel.

So i plan to add all those products through database script.Is it possible to add all the products through scripts.

Please help me to resolve the issue

Thanks & Regards

Anil Kumar

Yes, it's possible. What are the properties of your promotion? Is this a cart or catalog promotion?

It can get complicated if you're doing multiple conditions or groups of conditions. But if you just wanted to say create a promotion for 25% off products in set X, and you set it up with 1 X then you could run something fairly straightforward that will replace set X with the 3000 products you want.

Do note that using promotions like this will have a performance implact at each cart recalculate or in the case of a catalog promotion, each add to cart. Maybe if you described in more detail what you really want to do, there's an easier or more performant way.

I found the following serialize data in database(cscart_promotion table) for my promotion


In that i need to add few more products

I think those values are generated through random right




if not how can i generate those values for 3000 products?

please help me

No, they are certainly NOT random.

I believe they are a product key which is created from the product_id and product options using fn_generate_cart_id() or similar function. It is used so you can have a product with different options in the promotion. It will use that key to determine if that product (and options) is in the cart.

I would think you could experiment a bit with one of your products to verify that doing an fn_generate_cart_id($product_id, array('product_options'=>array()) comes up with the keys above.

You should look through app/functions/fn.promotions.php. However, I will caution you that the code is somewhat obtuse and difficult to read/understand without using a debugger to step through some of the functions.