Using a CSV file to populate a website?
Results 1 to 10 of 10

Thread: Using a CSV file to populate a website?

  1. #1
    Member n4ows's Avatar
    Join Date
    Nov 2007
    Posts
    35

    Using a CSV file to populate a website?

    Hi all,

    I need a little advice on how to use a csv file to extract data and use on my website. My website has been under construction for way to long, so I need to finish it asap.

    I have a wholesaler who has a csv file for their client's use. It is my understanding that this file is dynamically created so is up-to-date any time it's accessed. The file contains all the information I need for my website, SKU, catagory, long and short product description, weight, wholesale and suggested retail prices, inventory, and image link.

    I'm trying to figure out the best way to use this information for my website. Mainly to keep the inventory up-to-date, so I'm not offering items for sale that either may not be restocked or my not be restocked until the start of a particular season, like scarves that I are sold out now (January) and will not be back in stock until September.

    I have been working on this at localhost, and not on my live site. Currently, at localhost, I have been able to read the csv file and with that data, populate a website and also, create a MySQL database table.

    The way the ordering process works is that I get an order either on my website or in person, then taking that information, go to the wholesaler's website and place the order. Because of this delay, I am concerned about selling items with a low or 0 inventory and then having to issue a refund. The wholesaler also supplies me with a retail catalog and selling items that were out of stock happened to me twice during the Christmas rush. I want to avoid this problem if at all possible in the future.

    I guess my biggest question is, should I just work from the csv file, load everything into a MySQL table everytime my site is accessed, or a combo of the two (updating inventory when my site is accessed), OR something entirely different. Going from the csv file seems a little slow to me. There are 245 items on that site and it just seems like a db table would be a lot quicker and more efficient.

    I was an intermediate level PHP/MySQL developer until 2008 when I got totally burned out and quit my job to open this and another small business. I play at programming some, but have not kept up with the latest technology.

    Thanks,
    Alisa
    Dancing Bay Embroidery

  2. #2
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Working "from the csv" does not mean loading it into your own DB: just load it in memory and use it. Why would you store it if you're not going to retrieve it later?

    If you want to store the product info in your DB (assuming the wholesaler's use policy allows this), then you might check if they provide a csv with *only* stocking information: that way, you can display product info from your DB, and check current stock when a customer actually starts an order.

    edit
    Of course, this would not help if the item was sold out in the time between your customer placing the order with you and your placing the order with the wholesaler.
    Last edited by traq; 01-13-2013 at 05:17 PM.

  3. #3
    Member n4ows's Avatar
    Join Date
    Nov 2007
    Posts
    35
    Thanks for the advice. I'm thinking about doing one or two things.

    1. would be to pull the csv file into an array and then putting the array into a session to use on any page.

    OR

    2. would be to pull the csv file in and use the information to update the already existing the db table.

    I plan on only showing inventory items that have at least 10 in stock. I will probably up that to number a little, the further I get into December to avoid listing items in danger of selling out.

    I wish I could integrate all this into Wordpress, which is what I'm using right now, along with Cart66 and Gravity Forms, but I just don't see a way. If I can find a good stand alone shopping cart to use, instead of having to write one from scratch, that would be great. Any recommendations on that?

    Thanks,
    Alisa
    Dancing Bay Embroidery

  4. #4
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    The session idea is probably how I'd approach it. Updating your DB each time seems wasteful, since it will simply be a "backup" copy of info that you just retrieved from somewhere else.

    I'm sure you could hire someone to turn this into a WP plugin. WP has several choices for shopping carts, too. Not my specialty, though.

  5. #5
    Member n4ows's Avatar
    Join Date
    Nov 2007
    Posts
    35
    WP has proven to be heavy and slow. Since it's designed for the masses, mainly those who don't know much about programming, it's pretty generic and getting custom options to work is always an issue without paying someone to write a plugin. I'm basically working on short funds (thanks to the economy), unless I can find someone who will do it at a very reasonable prices, I'm stuck doing the work myself.

    Thanks,
    Alisa
    Dancing Bay Embroidery

  6. #6
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Yeah, I understand your concerns about WP.

    post your code if you need any help.

  7. #7
    Member n4ows's Avatar
    Join Date
    Nov 2007
    Posts
    35
    so far, so good writing the code. I'd really like to find a reliable open source shopping cart, but it may be the same issues as with WP, bloated and written for the masses and more work to customize that writing from scratch. There are some out there. Every time I come across a store template I like, it's through a service that charges by the month and by number of products. I'm already at HostGator and like it there.

  8. #8
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,850
    Personally I would use a real E-Commerce suite to handle all of this. Something like Magento or osCommerce which you can modify to do what you want.

    The way I would handle it is to have a cron that runs every 15 minutes to update a local MySQL database of inventory. Then when the CSV inventory reaches a threshold (say 3 or fewer) you either (a) display a notice on your site that there is limited inventory or (b) remove the item from sale on the site.

    The problem here is that there is no two-way communication between your system and the wholesaler (unless there is an API you neglected to mention). So while you may sell 4 items and there are 10 available, you can't be certain that someone else didn't sell 8 of the same product. So what you would need is an API where you can quickly call up the current inventory at the time the order is being processed (but before payment is complete) to check to see if there is enough there for your order. This will increase the checkout time but reduce the number of refunds you have to issue.

    This all still hinges upon the wholesaler participating and being the central point of all info and all third-party sellers reporting back in real-time the number they have sold. Otherwise, there is no real way to solve the problem.

    Downloading the CSV and parsing it every time your site loads will cost you in your load time, plus if you do load it into the database, that too will add time (and so too will the retrieval of the same data). This is all not to mention that loading the CSV into memory and operating on it may exhaust your memory limit in PHP more-often than you really want.

  9. #9
    Senior Member
    Join Date
    Mar 2009
    Posts
    802
    Quote Originally Posted by n4ows View Post
    WP has proven to be heavy and slow. Since it's designed for the masses, mainly those who don't know much about programming, it's pretty generic and getting custom options to work is always an issue without paying someone to write a plugin. I'm basically working on short funds (thanks to the economy), unless I can find someone who will do it at a very reasonable prices, I'm stuck doing the work myself.

    Thanks,
    Alisa
    Dancing Bay Embroidery
    WordPress may not be your first choice, but have you looked at the WP eCommerce plugin? Admittedly, it's very bloated and the code kinda sucks, but we have used it many times at our web company for our eCommerce projects and it seems to do its job well enough, and it has quite a nice set of features (and allows you to import all your products via CSV, I'm pretty sure). It's free, though there are some useful add-ons that cost money (such as the Gold Cart plugin). Depending where your moral compass lies, you can go into the code and find the check for the licence and just set it to true.
    Declare variables, not war.

  10. #10
    Member n4ows's Avatar
    Join Date
    Nov 2007
    Posts
    35
    After trying several other options, came back to Wordpress, Cart66, and Gravity Forms. I could not find any other WP shopping cart that allowed for the number of product variations that I needed. I'm still working on my initial form, but am very close to having it completed. As far as reading the csv file is concerned, the wholesale company that provides about half my products no longer has the csv file on their website. I have tried to get them to add it back, but so far no luck. Since the inventory on most items is in the hundreds and not the thousands, it does make me nervous to offer something for order and not no for sure if it will be in stock. I have most of these items dropshipped, so would like to know they're in stock before I take a customer's money.

    Thanks,
    Alisa
    Dancing Bay Embroidery

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •