Apply discount via SQL don't works

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
I've created a discount that I need apply to most all products in our store. 15% to all.

I created the discount in the Discount Admin.
Then I added this discount via a SQL Insert in the table: [Discount_AppliedToProducts]

The problem: The products don't appear in the store with the discount.

The situation:
If I edit a product in the Admin page, the discount appears and checked.
If I saved the product, the Discount is applied.
But I did via the SQL Insert because there are a lot of products to go to every one to Click in every one.

I already Restart the store and cleared cache too.

Any ideas of what I need to do so Nop apply the discount to all products immediately?

Thanks
8 years ago
Please share the SQL insert query, because it may be missing some conditions required to apply a discount
8 years ago
The problem is not the INSERT because if I edit any of the products in the admin area, the Discount appears and appears Checked.

INSERT INTO [Discount_AppliedToProducts]
SELECT 12 AS [Discount_Id], [Id] AS [Product_Id]
  FROM [dbo].[Product]
WHERE [Published] = 1  AND [Deleted] = 0  AND [Price] > 0


Look the images for an example:

1. Discount in Table:
http://tienda.frutafrescavirtual.com/01.png

2. Discount in Admin:
http://tienda.frutafrescavirtual.com/02.png

3. Product without discount:
http://tienda.frutafrescavirtual.com/03.png

4. Product with discount after save. Just click in SAVE button. But is a hard work to go to click in Save in every product:
http://tienda.frutafrescavirtual.com/04.png

Am I clear?
8 years ago
Make sure the [DiscountTypeId] is set to 2, that it doesn't require CouponCode, the start and end dates apply (or are null) and customer fits in the limitations.
Also you need to be sure that [HasDiscountsApplied] is set to 1 on these products in the [Product] table
8 years ago
Thankssss... I miss the "Discount_AppliedToProducts" to 1 in Products Table.


With this UPDATE the discount now is applied to all:

UPDATE [dbo].[Product]
   SET [HasDiscountsApplied] = 1
WHERE id IN (SELECT [Product_Id] FROM [Discount_AppliedToProducts] WHERE [Discount_id] = myDiscountOd )


; )
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.