alexander-pick / MKMTool

MKMTool ist a helper application I wrote for tinkering around with optimization of sale processes on magiccardmarket.eu and the idea of automisation of some tasks most people wouldn’t be able to get done by pure manpower.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delete stock or cards based on csv import?

yorii opened this issue · comments

commented

Hello, first of all I must say I really love this program, I have tried my hands at manually scripting against the cardmarket API before but never to this level of achievement.

I was just wondering if there is possibly a function to quickly delete your inventory, either in full or based on certain parameters? Or if it would be possible to code such a feature?

Hello,

I don't think you can delete the entire stock in a single request, but you can do it the same way we do price update, using the "STOCK" command, specifically the DELETE option. You can look in the MKMInteract.cs file, almost all the necessary code is there, you would just use the SendStockUpdate method using the string DELETE as the method argument and to set the sRequestXML you would create a method similar to changeStockArticleBody (also in the same file), but according to the specification in the documentation linked above (the body for DELETE is at the bottom of the doc page). Note that you can get/update/delete at most 100 items per one STOCK request.

So it would go:

  1. Fetch all your stock by GET stock (keeping in mind you are getting at most 100 items per one request, so you have to do it several times; the code can be found for example in updatePrices() of MKMBot.cs)
  2. For each fetched item, create a DELETE body
  3. Once you have 100 delete requests, send them using the DELETE stock request
  4. Repeat from 2 until you're done

The benefit is that this way you could do all kinds of filtering as you have to fetch all the item first anyway (like "delete all rares", "delete all non-english cards" etc.).

commented

Hi, thank you for the reply!
I take it then that you have not added a gui for this feature to MKMTool itself?

I will go and learn C# now :D

no, I haven't, but that is honestly the most complicated part of it :) mainly from the design point of view, like if it was to be supposed to be a permanent function of MKMTool, where to put that button so that it makes sense? I could see the "view inventory" having a checkbox for each item and then a button "delete all checked items", but it would be a bit of work. But adding a "delete all" button there should be easy, the module already stores all stock (it fetches it when you open the window, can take a few seconds), so sending a DELETE STOCK for all of them is straightforward (just one note, I see we are currently deleting the "idArticle" column from the table inside the View Inventory module (line 99 in StockView.cs), that would have to be changed as the id is needed to send any kind of STOCK request).

commented

Thanks for all your in-depth explanation, it is greatly appreciated :)