Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stephen Girdler 1 post 71 karma points
    May 14, 2021 @ 15:58
    Stephen Girdler
    0

    Vouchers: changing values by importing files ?

    Hi all,

    My first post and I joined this community to make it! I am hoping some good natured souls will help me out 😊

    Context

    I am not technical but have just joined a client’s team as a PM. We’re using Umbraco as a web front end to allow customers to access a bookings system. I am new to Umbraco. We issue customers vouchers (i.e. stored value gift cards) for cancelled bookings. My Umbraco developer has had to take some time out and I have no-one else to cover (it’s the run over by a bus scenario!).

    We’re uploading lists of vouchers (.csv input file) from an external source so that they can be used on Umbraco.

    Version of Umbraco is 8.10.1

    Technical question

    Does Umbraco allow you to change the values (e.g. balance) of an existing voucher through a file import? In other words, our csv import has a row with an existing voucher code but other fields have new values.

    My dev had told me Umbraco would accept edits to values before he had to take time off, but that’s not the behaviour we are seeing. It only seems to accept entirely new vouchers.

    Any thoughts warmly appreciated!

    Thanks,

    Steve

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    May 16, 2021 @ 15:58
    Marc Goodson
    0

    Hi Steve

    It will depend a bit on how you have implemented the import of the CSV and where these values are stored as to whether they could be updated or edited via Umbraco. Are you using a particular shopping cart package like Vendr?

    If this is all custom built by the developer, the way to start unpicking this in your crisis scenario is to find the page where the CSV is uploaded.

    If it's on the front end of the site, the url will map to an item published in the Umbraco content section and this content item will have associated wit it a page template - the page template will correspond to a file in the /views folder, open up this file and find the form embedded in it, there might be a Html.Partial, or Html.Action in the html where the form appears, this means the form is in a different file in the /views/partials folder

    once you've located the form, it's likely to specify where the form is posted to in it's definition you are looking for something in the style of:

    Html.BeginUmbracoForm<MyController>("HandleSubmit"))
    

    This means when the form is posted on the site, it's sent to another file, that might only be availble in your source control for the site, in a /controllers folder - here it would be called MyController.cs and have within it an action called 'handleSubmit'.

    This is where the code will live to process the uploaded CSV file, and you'll see at some point a foreach loop that, will loop through each 'row' of the CSV and do the import - it might add each row to a custom database table or it might create a row inside Umbraco, as another content item.

    You might see it try to 'find' the voucher first, and update it if it already exists - in which case - updating the CSV and reimporting it should update voucher values... if not then you might find it's only importing 'new items'

    If it's using something called the ContentService.Create then that means the imported items, are being created somewhere in Umbraco - and if they are not being updated from the CSV, you'd be able to find those items and update them manually from the backoffice.

    But if there is code that looks like INSERT INTO, then this means it's going in to a custom database table somewhere, and that's where values could be manually updated - the developer may have installed a package called UI Oh Matic or Fluidity - in which case there might be a 'whole section' of Umbraco (different from the content section) that allows you a view over this data, and the possibility to update it from the backoffice.

    But I'm just guessing, this could have been implemented in tons of different ways!

    If you upload the CSV in the backoffice to the Media section, then it might be a MediaService.Saving event that triggers the import code, and is the place to start your investigations, your are looking for a file, probably in a folder called Composition, that would register for the saving event MediaService.Saving += is the kind of code you are looking for.

    Finally if you upload the CSV from inside the Umbraco backoffice on a custom 'dashboard' - then you are looking this time in the App_Plugins folder for a folder that matches the name of the dashboard, eg VoucherImport... this will contain a .js file which will likely post the csv file to an APIController, (again in the Controllers folder) and this is where the journey begins!

    Ha!, now I've typed all that you'll say... we're using the 'Voucher Import' Package or something!

    Anyway if any of that makes sense, and you can locate where the implementation is happening when the CSV is uploaded, you can always post the code on here, and people would get a better idea of the logic involved to advise you where you can update!

    regards

    marc

Please Sign in or register to post replies

Write your reply to:

Draft