madpugger Posted September 18, 2021 Share Posted September 18, 2021 Is there a way to delete product discounts added by CSV to 10000+ products? I can change them by CSV again, but how do we delete them to use group / category discounts instead? I am on 1.7.7.8 but I guess the question is valid for many versions! TIA Link to comment Share on other sites More sharing options...
ps8modules Posted September 18, 2021 Share Posted September 18, 2021 Too general question. We do not know how you imported discounts from CSV, according to which you matched (product id, references ...). If there are discounts in percentages, if there are discounts as a rule for a basket, or a sale, etc. What do you expect from us? That someone will write you an extra code? Link to comment Share on other sites More sharing options...
madpugger Posted September 18, 2021 Author Share Posted September 18, 2021 Sorry, the answer is sort of in my question though! they were imported in csv as part of the product import, as percentage, and some as a price discount per product. they are all per product. we want to delete them as a product discount so we can use a group / category discount instead. so the question is, how do “we” (prestashop users) bulk delete product discounts (amount or percent) thanks Link to comment Share on other sites More sharing options...
ps8modules Posted September 18, 2021 Share Posted September 18, 2021 Prestashop basically has no possibility of mass editing. Options are to edit the CSV file with the removal of discounts and new import (it is necessary to have a unique identifier (product id, reference number, ean 13), according to which it will be possible to identify the product for editing. Another option is to create and run an SQL query in the database in bulk for all products, and another option is to have the module programmed. Link to comment Share on other sites More sharing options...
madpugger Posted September 18, 2021 Author Share Posted September 18, 2021 29 minutes ago, WebSoft said: Prestashop basically has no possibility of mass editing. Options are to edit the CSV file with the removal of discounts and new import (it is necessary to have a unique identifier (product id, reference number, ean 13), according to which it will be possible to identify the product for editing. Another option is to create and run an SQL query in the database in bulk for all products, and another option is to have the module programmed. Yes but my point is, just leaving the discount blank on the csv doesn’t delete it. It just doesn’t change the existing one. I.e. it does not change it to NULL. I’m just looking to see if others have managed this with php or sql or similar as there must be others who’ve been here. Link to comment Share on other sites More sharing options...
ps8modules Posted September 18, 2021 Share Posted September 18, 2021 (edited) Discounts are in the database in the ps_specific_price table. DELETE FROM `ps_specific_price`; DELETE FROM `ps_specific_price_priority`; ALTER TABLE `ps_specific_price` AUTO_INCREMENT = 1; ALTER TABLE `ps_specific_price_priority` AUTO_INCREMENT = 1; This SQL query removes all discounts and sets the index to 1. There are other tables you need to look at. The prefix ps_ is according to your settings. If it's different, you have to change it. If you have filled in columns for discounts in the CSV file, it is clear that they will not edit them. If you leave the columns in the CSV file blank, Prestashop will remove the discounts. CSV with discount: "ID","ACTIVE","NAME","CATEGORIES","PRICE_TAX_EXCLUDE","TAX_RULE_ID","ON_SALE","DISCOUNT_AMOUNT","DISCOUNT_PERCENT","DISCOUNT_FROM","QUANTITY","MINIMAL_QUANTITY","SHORT_DESCRIPTION","DESCRIPTION","URL_REWRITTEN" 1,1,"product one","Home",2400,1,1,10,,5,120,1,"product one","product one description","product-one" CSV without discount: "ID","ACTIVE","NAME","CATEGORIES","PRICE_TAX_EXCLUDE","TAX_RULE_ID","ON_SALE","DISCOUNT_AMOUNT","DISCOUNT_PERCENT","DISCOUNT_FROM","QUANTITY","MINIMAL_QUANTITY","SHORT_DESCRIPTION","DESCRIPTION","URL_REWRITTEN" 1,1,"product one","Home",2400,1,0,0,,,120,1,"product one","product one description","product-one" Edited September 18, 2021 by WebSoft (see edit history) Link to comment Share on other sites More sharing options...
madpugger Posted September 18, 2021 Author Share Posted September 18, 2021 Thanks for that ref the SQL query. im not sure you understand about the csv though. if a csv has been used to set a discount amount, or discount percent (or if a discount has been added to a product manually -or even multiple discounts) then simply using the csv again with the discounts empty does not then remove the discount previously set. It simply makes no changes to the existing discounts. further, even if we set the discount to 0 for example, it would only do this to the first instance of a discount of that type (amount or percent) Images for example, has a column in the import system for “delete existing images”. It would be handy if discounts had this too, as well as the ability to add multiple discounts per product by csv but that is another matter. Link to comment Share on other sites More sharing options...
ps8modules Posted September 19, 2021 Share Posted September 19, 2021 When you have so many events, you can edit the file: ./controllers/admin/AdminImportController.php find: if ((isset($info['reduction_price']) && $info['reduction_price'] > 0) || (isset($info['reduction_percent']) && $info['reduction_percent'] > 0)) and adjust as you need. If you want to add your own import field to remove discounts, you can add it: ./src/Core/Import/EntityField/Provider/ProductFieldsProvider.php and ./controllers/admin/AdminImportController.php Good luck. Link to comment Share on other sites More sharing options...
madpugger Posted November 16, 2022 Author Share Posted November 16, 2022 I am just now coming back to this issue after being busy with other stuff! I've still not figured this out.. In this file, I see the if statement is looking for a valid reduction or percentage discount, but it does nothing if the discount is 0. What would we need to change to remove all specific discounts for that product (£ or %) if the figure in the CSV is 0? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now